From 8154530b24039bd9675ab19f253a6126db515d68 Mon Sep 17 00:00:00 2001 From: knd Date: Fri, 23 Feb 2024 01:03:15 +0300 Subject: [PATCH 1/4] add PHPDoc and hints --- src/Facades/RequestForwarder.php | 5 ++++- src/Providers/DefaultProvider.php | 11 ++++++++++- src/Providers/Discord.php | 11 ++++++++++- src/Providers/ProviderInterface.php | 2 +- src/RequestForwarder.php | 13 +++++++++++-- src/RequestForwarderServiceProvider.php | 9 ++++++++- 6 files changed, 44 insertions(+), 7 deletions(-) diff --git a/src/Facades/RequestForwarder.php b/src/Facades/RequestForwarder.php index 0b23d66..ee2d5b2 100644 --- a/src/Facades/RequestForwarder.php +++ b/src/Facades/RequestForwarder.php @@ -9,7 +9,10 @@ */ class RequestForwarder extends Facade { - protected static function getFacadeAccessor() + /** + * @return string + */ + protected static function getFacadeAccessor(): string { return \Moneo\RequestForwarder\RequestForwarder::class; } diff --git a/src/Providers/DefaultProvider.php b/src/Providers/DefaultProvider.php index 7cedd65..1981e4f 100644 --- a/src/Providers/DefaultProvider.php +++ b/src/Providers/DefaultProvider.php @@ -2,7 +2,9 @@ namespace Moneo\RequestForwarder\Providers; +use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Http\Client\Factory; +use Illuminate\Http\Client\Response; class DefaultProvider implements ProviderInterface { @@ -11,7 +13,14 @@ public function __construct( ) { } - public function send($url, $params, $webhook) + /** + * @param $url + * @param $params + * @param $webhook + * @return PromiseInterface|Response + * @throws \Exception + */ + public function send($url, $params, $webhook): \GuzzleHttp\Promise\PromiseInterface|\Illuminate\Http\Client\Response { return $this->client ->send($webhook['method'] ?? 'POST', $webhook['url']); diff --git a/src/Providers/Discord.php b/src/Providers/Discord.php index 31be35f..e4a906b 100644 --- a/src/Providers/Discord.php +++ b/src/Providers/Discord.php @@ -2,7 +2,9 @@ namespace Moneo\RequestForwarder\Providers; +use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Http\Client\Factory; +use Illuminate\Http\Client\Response; class Discord implements ProviderInterface { @@ -11,7 +13,14 @@ public function __construct( ) { } - public function send($url, $params, $webhook) + /** + * @param $url + * @param $params + * @param $webhook + * @return PromiseInterface|Response + * @throws \Exception + */ + public function send($url, $params, $webhook): \GuzzleHttp\Promise\PromiseInterface|\Illuminate\Http\Client\Response { $content = $url.PHP_EOL; $content .= json_encode($params); diff --git a/src/Providers/ProviderInterface.php b/src/Providers/ProviderInterface.php index 11242b3..2be32a2 100644 --- a/src/Providers/ProviderInterface.php +++ b/src/Providers/ProviderInterface.php @@ -9,5 +9,5 @@ interface ProviderInterface public function __construct(Factory $client); /** @return \Illuminate\Http\Client\Response */ - public function send($url, $params, $webhook); + public function send($url, $params, $webhook): \Illuminate\Http\Client\Response; } diff --git a/src/RequestForwarder.php b/src/RequestForwarder.php index 1c85b68..2e597d1 100755 --- a/src/RequestForwarder.php +++ b/src/RequestForwarder.php @@ -15,12 +15,21 @@ public function __construct( ) { } - public function sendAsync(Request $request) + /** + * @param Request $request + * @return void + */ + public function sendAsync(Request $request): void { ProcessRequestForwarder::dispatch($request->url(), $request->toArray()); } - public function triggerHooks(string $url, array $params) + /** + * @param string $url + * @param array $params + * @return void + */ + public function triggerHooks(string $url, array $params): void { foreach ($this->webhooks as $webhook) { try { diff --git a/src/RequestForwarderServiceProvider.php b/src/RequestForwarderServiceProvider.php index 84c78e9..6872fcd 100644 --- a/src/RequestForwarderServiceProvider.php +++ b/src/RequestForwarderServiceProvider.php @@ -8,6 +8,10 @@ class RequestForwarderServiceProvider extends PackageServiceProvider { + /** + * @param Package $package + * @return void + */ public function configurePackage(Package $package): void { /* @@ -20,7 +24,10 @@ public function configurePackage(Package $package): void ->hasConfigFile(); } - public function registeringPackage() + /** + * @return void + */ + public function registeringPackage(): void { $this->app->bind('laravel_request_forwarder.client', function ($app): Factory { return $app[Factory::class]; From f809577b097e5f4ff304229c6fa1dca0c3e26bcc Mon Sep 17 00:00:00 2001 From: knd Date: Fri, 23 Feb 2024 15:27:07 +0300 Subject: [PATCH 2/4] fix from review --- src/Facades/RequestForwarder.php | 5 +---- src/Providers/DefaultProvider.php | 1 - src/Providers/Discord.php | 1 - src/Providers/ProviderInterface.php | 1 - src/RequestForwarder.php | 2 -- src/RequestForwarderServiceProvider.php | 4 ---- 6 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src/Facades/RequestForwarder.php b/src/Facades/RequestForwarder.php index ee2d5b2..0b23d66 100644 --- a/src/Facades/RequestForwarder.php +++ b/src/Facades/RequestForwarder.php @@ -9,10 +9,7 @@ */ class RequestForwarder extends Facade { - /** - * @return string - */ - protected static function getFacadeAccessor(): string + protected static function getFacadeAccessor() { return \Moneo\RequestForwarder\RequestForwarder::class; } diff --git a/src/Providers/DefaultProvider.php b/src/Providers/DefaultProvider.php index 1981e4f..03db108 100644 --- a/src/Providers/DefaultProvider.php +++ b/src/Providers/DefaultProvider.php @@ -17,7 +17,6 @@ public function __construct( * @param $url * @param $params * @param $webhook - * @return PromiseInterface|Response * @throws \Exception */ public function send($url, $params, $webhook): \GuzzleHttp\Promise\PromiseInterface|\Illuminate\Http\Client\Response diff --git a/src/Providers/Discord.php b/src/Providers/Discord.php index e4a906b..5df942d 100644 --- a/src/Providers/Discord.php +++ b/src/Providers/Discord.php @@ -17,7 +17,6 @@ public function __construct( * @param $url * @param $params * @param $webhook - * @return PromiseInterface|Response * @throws \Exception */ public function send($url, $params, $webhook): \GuzzleHttp\Promise\PromiseInterface|\Illuminate\Http\Client\Response diff --git a/src/Providers/ProviderInterface.php b/src/Providers/ProviderInterface.php index 2be32a2..94dcdd9 100644 --- a/src/Providers/ProviderInterface.php +++ b/src/Providers/ProviderInterface.php @@ -8,6 +8,5 @@ interface ProviderInterface { public function __construct(Factory $client); - /** @return \Illuminate\Http\Client\Response */ public function send($url, $params, $webhook): \Illuminate\Http\Client\Response; } diff --git a/src/RequestForwarder.php b/src/RequestForwarder.php index 2e597d1..7ce1e7a 100755 --- a/src/RequestForwarder.php +++ b/src/RequestForwarder.php @@ -17,7 +17,6 @@ public function __construct( /** * @param Request $request - * @return void */ public function sendAsync(Request $request): void { @@ -27,7 +26,6 @@ public function sendAsync(Request $request): void /** * @param string $url * @param array $params - * @return void */ public function triggerHooks(string $url, array $params): void { diff --git a/src/RequestForwarderServiceProvider.php b/src/RequestForwarderServiceProvider.php index 6872fcd..cba1216 100644 --- a/src/RequestForwarderServiceProvider.php +++ b/src/RequestForwarderServiceProvider.php @@ -10,7 +10,6 @@ class RequestForwarderServiceProvider extends PackageServiceProvider { /** * @param Package $package - * @return void */ public function configurePackage(Package $package): void { @@ -24,9 +23,6 @@ public function configurePackage(Package $package): void ->hasConfigFile(); } - /** - * @return void - */ public function registeringPackage(): void { $this->app->bind('laravel_request_forwarder.client', function ($app): Factory { From 712f5fb62f8c4a6860d2572dcd0780616b9c9d97 Mon Sep 17 00:00:00 2001 From: knd Date: Sat, 24 Feb 2024 21:06:46 +0300 Subject: [PATCH 3/4] fix from review --- src/Providers/Discord.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Providers/Discord.php b/src/Providers/Discord.php index 5df942d..79acfa9 100644 --- a/src/Providers/Discord.php +++ b/src/Providers/Discord.php @@ -19,7 +19,7 @@ public function __construct( * @param $webhook * @throws \Exception */ - public function send($url, $params, $webhook): \GuzzleHttp\Promise\PromiseInterface|\Illuminate\Http\Client\Response + public function send($url, $params, $webhook) { $content = $url.PHP_EOL; $content .= json_encode($params); From 1b23d8dbe0a8f104725619a6db0f6cdaae266706 Mon Sep 17 00:00:00 2001 From: knd Date: Sat, 24 Feb 2024 21:41:12 +0300 Subject: [PATCH 4/4] fix hint and return type on interface --- src/Providers/DefaultProvider.php | 5 +---- src/Providers/Discord.php | 6 +----- src/Providers/ProviderInterface.php | 3 ++- src/RequestForwarder.php | 7 ------- src/RequestForwarderServiceProvider.php | 3 --- 5 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/Providers/DefaultProvider.php b/src/Providers/DefaultProvider.php index 03db108..b7caea4 100644 --- a/src/Providers/DefaultProvider.php +++ b/src/Providers/DefaultProvider.php @@ -14,12 +14,9 @@ public function __construct( } /** - * @param $url - * @param $params - * @param $webhook * @throws \Exception */ - public function send($url, $params, $webhook): \GuzzleHttp\Promise\PromiseInterface|\Illuminate\Http\Client\Response + public function send(string $url, array $params, array $webhook): Response { return $this->client ->send($webhook['method'] ?? 'POST', $webhook['url']); diff --git a/src/Providers/Discord.php b/src/Providers/Discord.php index 79acfa9..869505a 100644 --- a/src/Providers/Discord.php +++ b/src/Providers/Discord.php @@ -2,7 +2,6 @@ namespace Moneo\RequestForwarder\Providers; -use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Http\Client\Factory; use Illuminate\Http\Client\Response; @@ -14,12 +13,9 @@ public function __construct( } /** - * @param $url - * @param $params - * @param $webhook * @throws \Exception */ - public function send($url, $params, $webhook) + public function send(string $url, array $params, array $webhook): Response { $content = $url.PHP_EOL; $content .= json_encode($params); diff --git a/src/Providers/ProviderInterface.php b/src/Providers/ProviderInterface.php index 94dcdd9..f42e133 100644 --- a/src/Providers/ProviderInterface.php +++ b/src/Providers/ProviderInterface.php @@ -3,10 +3,11 @@ namespace Moneo\RequestForwarder\Providers; use Illuminate\Http\Client\Factory; +use Illuminate\Http\Client\Response; interface ProviderInterface { public function __construct(Factory $client); - public function send($url, $params, $webhook): \Illuminate\Http\Client\Response; + public function send(string $url, array $params, array $webhook): Response; } diff --git a/src/RequestForwarder.php b/src/RequestForwarder.php index 7ce1e7a..c2d1750 100755 --- a/src/RequestForwarder.php +++ b/src/RequestForwarder.php @@ -15,18 +15,11 @@ public function __construct( ) { } - /** - * @param Request $request - */ public function sendAsync(Request $request): void { ProcessRequestForwarder::dispatch($request->url(), $request->toArray()); } - /** - * @param string $url - * @param array $params - */ public function triggerHooks(string $url, array $params): void { foreach ($this->webhooks as $webhook) { diff --git a/src/RequestForwarderServiceProvider.php b/src/RequestForwarderServiceProvider.php index cba1216..e59db01 100644 --- a/src/RequestForwarderServiceProvider.php +++ b/src/RequestForwarderServiceProvider.php @@ -8,9 +8,6 @@ class RequestForwarderServiceProvider extends PackageServiceProvider { - /** - * @param Package $package - */ public function configurePackage(Package $package): void { /*