From 8453398c13fe7d560063812f1a83290c683a84de Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Fri, 3 Nov 2023 16:42:32 +0100 Subject: [PATCH 1/3] update with latest cs fixer --- src/Deferred.php | 9 --------- src/HttpAsyncClientDecorator.php | 2 -- src/HttpAsyncClientEmulator.php | 4 ---- src/HttpClientDecorator.php | 2 -- src/HttpClientEmulator.php | 4 ---- src/HttpClientPool/HttpClientPool.php | 6 ------ src/HttpClientPool/HttpClientPoolItem.php | 6 ------ src/HttpClientPool/LeastUsedClientPool.php | 3 --- src/HttpClientPool/RandomClientPool.php | 3 --- src/HttpClientPool/RoundRobinClientPool.php | 3 --- src/HttpClientRouter.php | 8 -------- src/Plugin/AddHostPlugin.php | 3 --- src/Plugin/AuthenticationPlugin.php | 3 --- src/Plugin/BaseUriPlugin.php | 5 +---- src/Plugin/ContentLengthPlugin.php | 3 --- src/Plugin/ContentTypePlugin.php | 3 --- src/Plugin/CookiePlugin.php | 3 --- src/Plugin/DecoderPlugin.php | 3 --- src/Plugin/ErrorPlugin.php | 3 --- src/Plugin/HeaderAppendPlugin.php | 3 --- src/Plugin/HeaderDefaultsPlugin.php | 3 --- src/Plugin/HeaderRemovePlugin.php | 3 --- src/Plugin/HeaderSetPlugin.php | 3 --- src/Plugin/HistoryPlugin.php | 3 --- src/Plugin/QueryDefaultsPlugin.php | 3 --- src/Plugin/RedirectPlugin.php | 3 --- src/Plugin/RequestMatcherPlugin.php | 3 --- src/Plugin/RequestSeekableBodyPlugin.php | 3 --- src/Plugin/ResponseSeekableBodyPlugin.php | 3 --- src/Plugin/RetryPlugin.php | 3 --- src/PluginClient.php | 6 ------ src/PluginClientBuilder.php | 3 --- 32 files changed, 1 insertion(+), 117 deletions(-) diff --git a/src/Deferred.php b/src/Deferred.php index 646f3755..eaf7cdf7 100644 --- a/src/Deferred.php +++ b/src/Deferred.php @@ -51,9 +51,6 @@ public function __construct(callable $waitCallback) $this->onRejectedCallbacks = []; } - /** - * {@inheritdoc} - */ public function then(callable $onFulfilled = null, callable $onRejected = null): Promise { $deferred = new self($this->waitCallback); @@ -86,9 +83,6 @@ public function then(callable $onFulfilled = null, callable $onRejected = null): return $deferred; } - /** - * {@inheritdoc} - */ public function getState(): string { return $this->state; @@ -128,9 +122,6 @@ public function reject(ClientExceptionInterface $exception): void } } - /** - * {@inheritdoc} - */ public function wait($unwrap = true) { if (Promise::PENDING === $this->state) { diff --git a/src/HttpAsyncClientDecorator.php b/src/HttpAsyncClientDecorator.php index 2714b4ac..91ff5af2 100644 --- a/src/HttpAsyncClientDecorator.php +++ b/src/HttpAsyncClientDecorator.php @@ -20,8 +20,6 @@ trait HttpAsyncClientDecorator protected $httpAsyncClient; /** - * {@inheritdoc} - * * @see HttpAsyncClient::sendAsyncRequest */ public function sendAsyncRequest(RequestInterface $request) diff --git a/src/HttpAsyncClientEmulator.php b/src/HttpAsyncClientEmulator.php index 53c2535f..ffc0d5a4 100644 --- a/src/HttpAsyncClientEmulator.php +++ b/src/HttpAsyncClientEmulator.php @@ -17,15 +17,11 @@ trait HttpAsyncClientEmulator { /** - * {@inheritdoc} - * * @see HttpClient::sendRequest */ abstract public function sendRequest(RequestInterface $request): ResponseInterface; /** - * {@inheritdoc} - * * @see HttpAsyncClient::sendAsyncRequest */ public function sendAsyncRequest(RequestInterface $request) diff --git a/src/HttpClientDecorator.php b/src/HttpClientDecorator.php index c00ba6f3..d236ad58 100644 --- a/src/HttpClientDecorator.php +++ b/src/HttpClientDecorator.php @@ -21,8 +21,6 @@ trait HttpClientDecorator protected $httpClient; /** - * {@inheritdoc} - * * @see ClientInterface::sendRequest */ public function sendRequest(RequestInterface $request): ResponseInterface diff --git a/src/HttpClientEmulator.php b/src/HttpClientEmulator.php index 51e2c058..7c40b504 100644 --- a/src/HttpClientEmulator.php +++ b/src/HttpClientEmulator.php @@ -15,8 +15,6 @@ trait HttpClientEmulator { /** - * {@inheritdoc} - * * @see HttpClient::sendRequest */ public function sendRequest(RequestInterface $request): ResponseInterface @@ -27,8 +25,6 @@ public function sendRequest(RequestInterface $request): ResponseInterface } /** - * {@inheritdoc} - * * @see HttpAsyncClient::sendAsyncRequest */ abstract public function sendAsyncRequest(RequestInterface $request); diff --git a/src/HttpClientPool/HttpClientPool.php b/src/HttpClientPool/HttpClientPool.php index a30bdb05..d7c2dbd0 100644 --- a/src/HttpClientPool/HttpClientPool.php +++ b/src/HttpClientPool/HttpClientPool.php @@ -52,17 +52,11 @@ public function addHttpClient($client): void */ abstract protected function chooseHttpClient(): HttpClientPoolItem; - /** - * {@inheritdoc} - */ public function sendAsyncRequest(RequestInterface $request) { return $this->chooseHttpClient()->sendAsyncRequest($request); } - /** - * {@inheritdoc} - */ public function sendRequest(RequestInterface $request): ResponseInterface { return $this->chooseHttpClient()->sendRequest($request); diff --git a/src/HttpClientPool/HttpClientPoolItem.php b/src/HttpClientPool/HttpClientPoolItem.php index f29d0655..2496ddae 100644 --- a/src/HttpClientPool/HttpClientPoolItem.php +++ b/src/HttpClientPool/HttpClientPoolItem.php @@ -69,9 +69,6 @@ public function __construct($client, int $reenableAfter = null) $this->reenableAfter = $reenableAfter; } - /** - * {@inheritdoc} - */ public function sendRequest(RequestInterface $request): ResponseInterface { if ($this->isDisabled()) { @@ -92,9 +89,6 @@ public function sendRequest(RequestInterface $request): ResponseInterface return $response; } - /** - * {@inheritdoc} - */ public function sendAsyncRequest(RequestInterface $request) { if ($this->isDisabled()) { diff --git a/src/HttpClientPool/LeastUsedClientPool.php b/src/HttpClientPool/LeastUsedClientPool.php index 789c3579..bfa1cd00 100644 --- a/src/HttpClientPool/LeastUsedClientPool.php +++ b/src/HttpClientPool/LeastUsedClientPool.php @@ -15,9 +15,6 @@ */ final class LeastUsedClientPool extends HttpClientPool { - /** - * {@inheritdoc} - */ protected function chooseHttpClient(): HttpClientPoolItem { $clientPool = array_filter($this->clientPool, function (HttpClientPoolItem $clientPoolItem) { diff --git a/src/HttpClientPool/RandomClientPool.php b/src/HttpClientPool/RandomClientPool.php index 789ba42f..8fda587e 100644 --- a/src/HttpClientPool/RandomClientPool.php +++ b/src/HttpClientPool/RandomClientPool.php @@ -13,9 +13,6 @@ */ final class RandomClientPool extends HttpClientPool { - /** - * {@inheritdoc} - */ protected function chooseHttpClient(): HttpClientPoolItem { $clientPool = array_filter($this->clientPool, function (HttpClientPoolItem $clientPoolItem) { diff --git a/src/HttpClientPool/RoundRobinClientPool.php b/src/HttpClientPool/RoundRobinClientPool.php index 7c7b1910..a9086539 100644 --- a/src/HttpClientPool/RoundRobinClientPool.php +++ b/src/HttpClientPool/RoundRobinClientPool.php @@ -13,9 +13,6 @@ */ final class RoundRobinClientPool extends HttpClientPool { - /** - * {@inheritdoc} - */ protected function chooseHttpClient(): HttpClientPoolItem { $last = current($this->clientPool); diff --git a/src/HttpClientRouter.php b/src/HttpClientRouter.php index 040d893a..42c69073 100644 --- a/src/HttpClientRouter.php +++ b/src/HttpClientRouter.php @@ -12,8 +12,6 @@ use Psr\Http\Message\ResponseInterface; /** - * {@inheritdoc} - * * @author Joel Wurtz */ final class HttpClientRouter implements HttpClientRouterInterface @@ -23,17 +21,11 @@ final class HttpClientRouter implements HttpClientRouterInterface */ private $clients = []; - /** - * {@inheritdoc} - */ public function sendRequest(RequestInterface $request): ResponseInterface { return $this->chooseHttpClient($request)->sendRequest($request); } - /** - * {@inheritdoc} - */ public function sendAsyncRequest(RequestInterface $request) { return $this->chooseHttpClient($request)->sendAsyncRequest($request); diff --git a/src/Plugin/AddHostPlugin.php b/src/Plugin/AddHostPlugin.php index 2a866ee6..ca811b78 100644 --- a/src/Plugin/AddHostPlugin.php +++ b/src/Plugin/AddHostPlugin.php @@ -48,9 +48,6 @@ public function __construct(UriInterface $host, array $config = []) $this->replace = $options['replace']; } - /** - * {@inheritdoc} - */ public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise { if ($this->replace || '' === $request->getUri()->getHost()) { diff --git a/src/Plugin/AuthenticationPlugin.php b/src/Plugin/AuthenticationPlugin.php index ce9d4bd1..2336062f 100644 --- a/src/Plugin/AuthenticationPlugin.php +++ b/src/Plugin/AuthenticationPlugin.php @@ -26,9 +26,6 @@ public function __construct(Authentication $authentication) $this->authentication = $authentication; } - /** - * {@inheritdoc} - */ public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise { $request = $this->authentication->authenticate($request); diff --git a/src/Plugin/BaseUriPlugin.php b/src/Plugin/BaseUriPlugin.php index 34c3b641..c361683c 100644 --- a/src/Plugin/BaseUriPlugin.php +++ b/src/Plugin/BaseUriPlugin.php @@ -24,7 +24,7 @@ final class BaseUriPlugin implements Plugin /** * @var AddPathPlugin|null */ - private $addPathPlugin = null; + private $addPathPlugin; /** * @param UriInterface $uri Has to contain a host name and can have a path @@ -39,9 +39,6 @@ public function __construct(UriInterface $uri, array $hostConfig = []) } } - /** - * {@inheritdoc} - */ public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise { $addHostNext = function (RequestInterface $request) use ($next, $first) { diff --git a/src/Plugin/ContentLengthPlugin.php b/src/Plugin/ContentLengthPlugin.php index f313c330..ad69ff33 100644 --- a/src/Plugin/ContentLengthPlugin.php +++ b/src/Plugin/ContentLengthPlugin.php @@ -16,9 +16,6 @@ */ final class ContentLengthPlugin implements Plugin { - /** - * {@inheritdoc} - */ public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise { if (!$request->hasHeader('Content-Length')) { diff --git a/src/Plugin/ContentTypePlugin.php b/src/Plugin/ContentTypePlugin.php index da3758eb..e4844c48 100644 --- a/src/Plugin/ContentTypePlugin.php +++ b/src/Plugin/ContentTypePlugin.php @@ -57,9 +57,6 @@ public function __construct(array $config = []) $this->sizeLimit = $options['size_limit']; } - /** - * {@inheritdoc} - */ public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise { if (!$request->hasHeader('Content-Type')) { diff --git a/src/Plugin/CookiePlugin.php b/src/Plugin/CookiePlugin.php index aa4d5d7e..6a8942ab 100644 --- a/src/Plugin/CookiePlugin.php +++ b/src/Plugin/CookiePlugin.php @@ -33,9 +33,6 @@ public function __construct(CookieJar $cookieJar) $this->cookieJar = $cookieJar; } - /** - * {@inheritdoc} - */ public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise { $cookies = []; diff --git a/src/Plugin/DecoderPlugin.php b/src/Plugin/DecoderPlugin.php index 41c1a589..3e781aa9 100644 --- a/src/Plugin/DecoderPlugin.php +++ b/src/Plugin/DecoderPlugin.php @@ -48,9 +48,6 @@ public function __construct(array $config = []) $this->useContentEncoding = $options['use_content_encoding']; } - /** - * {@inheritdoc} - */ public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise { $encodings = extension_loaded('zlib') ? ['gzip', 'deflate'] : ['identity']; diff --git a/src/Plugin/ErrorPlugin.php b/src/Plugin/ErrorPlugin.php index 678977f5..712e28a4 100644 --- a/src/Plugin/ErrorPlugin.php +++ b/src/Plugin/ErrorPlugin.php @@ -54,9 +54,6 @@ public function __construct(array $config = []) $this->onlyServerException = $options['only_server_exception']; } - /** - * {@inheritdoc} - */ public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise { $promise = $next($request); diff --git a/src/Plugin/HeaderAppendPlugin.php b/src/Plugin/HeaderAppendPlugin.php index 95ea673c..e6d6235f 100644 --- a/src/Plugin/HeaderAppendPlugin.php +++ b/src/Plugin/HeaderAppendPlugin.php @@ -34,9 +34,6 @@ public function __construct(array $headers) $this->headers = $headers; } - /** - * {@inheritdoc} - */ public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise { foreach ($this->headers as $header => $headerValue) { diff --git a/src/Plugin/HeaderDefaultsPlugin.php b/src/Plugin/HeaderDefaultsPlugin.php index bf580700..baf8f9d4 100644 --- a/src/Plugin/HeaderDefaultsPlugin.php +++ b/src/Plugin/HeaderDefaultsPlugin.php @@ -30,9 +30,6 @@ public function __construct(array $headers) $this->headers = $headers; } - /** - * {@inheritdoc} - */ public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise { foreach ($this->headers as $header => $headerValue) { diff --git a/src/Plugin/HeaderRemovePlugin.php b/src/Plugin/HeaderRemovePlugin.php index 9f4ca44e..abfb922e 100644 --- a/src/Plugin/HeaderRemovePlugin.php +++ b/src/Plugin/HeaderRemovePlugin.php @@ -28,9 +28,6 @@ public function __construct(array $headers) $this->headers = $headers; } - /** - * {@inheritdoc} - */ public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise { foreach ($this->headers as $header) { diff --git a/src/Plugin/HeaderSetPlugin.php b/src/Plugin/HeaderSetPlugin.php index 06f00eb8..1ca9fb35 100644 --- a/src/Plugin/HeaderSetPlugin.php +++ b/src/Plugin/HeaderSetPlugin.php @@ -30,9 +30,6 @@ public function __construct(array $headers) $this->headers = $headers; } - /** - * {@inheritdoc} - */ public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise { foreach ($this->headers as $header => $headerValue) { diff --git a/src/Plugin/HistoryPlugin.php b/src/Plugin/HistoryPlugin.php index a1796a6f..15597ee1 100644 --- a/src/Plugin/HistoryPlugin.php +++ b/src/Plugin/HistoryPlugin.php @@ -29,9 +29,6 @@ public function __construct(Journal $journal) $this->journal = $journal; } - /** - * {@inheritdoc} - */ public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise { $journal = $this->journal; diff --git a/src/Plugin/QueryDefaultsPlugin.php b/src/Plugin/QueryDefaultsPlugin.php index 4c8087c4..fc11ba1f 100644 --- a/src/Plugin/QueryDefaultsPlugin.php +++ b/src/Plugin/QueryDefaultsPlugin.php @@ -31,9 +31,6 @@ public function __construct(array $queryParams) $this->queryParams = $queryParams; } - /** - * {@inheritdoc} - */ public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise { $uri = $request->getUri(); diff --git a/src/Plugin/RedirectPlugin.php b/src/Plugin/RedirectPlugin.php index ee5c232f..beb633e1 100644 --- a/src/Plugin/RedirectPlugin.php +++ b/src/Plugin/RedirectPlugin.php @@ -158,9 +158,6 @@ public function __construct(array $config = []) $this->streamFactory = $options['stream_factory']; } - /** - * {@inheritdoc} - */ public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise { // Check in storage diff --git a/src/Plugin/RequestMatcherPlugin.php b/src/Plugin/RequestMatcherPlugin.php index 45d4375d..83734094 100644 --- a/src/Plugin/RequestMatcherPlugin.php +++ b/src/Plugin/RequestMatcherPlugin.php @@ -38,9 +38,6 @@ public function __construct(RequestMatcher $requestMatcher, ?Plugin $delegateOnM $this->failurePlugin = $delegateOnNoMatch; } - /** - * {@inheritdoc} - */ public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise { if ($this->requestMatcher->matches($request)) { diff --git a/src/Plugin/RequestSeekableBodyPlugin.php b/src/Plugin/RequestSeekableBodyPlugin.php index 1b6c5289..f39c88d3 100644 --- a/src/Plugin/RequestSeekableBodyPlugin.php +++ b/src/Plugin/RequestSeekableBodyPlugin.php @@ -15,9 +15,6 @@ */ final class RequestSeekableBodyPlugin extends SeekableBodyPlugin { - /** - * {@inheritdoc} - */ public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise { if (!$request->getBody()->isSeekable()) { diff --git a/src/Plugin/ResponseSeekableBodyPlugin.php b/src/Plugin/ResponseSeekableBodyPlugin.php index 6f941b65..ef8bee45 100644 --- a/src/Plugin/ResponseSeekableBodyPlugin.php +++ b/src/Plugin/ResponseSeekableBodyPlugin.php @@ -16,9 +16,6 @@ */ final class ResponseSeekableBodyPlugin extends SeekableBodyPlugin { - /** - * {@inheritdoc} - */ public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise { return $next($request)->then(function (ResponseInterface $response) { diff --git a/src/Plugin/RetryPlugin.php b/src/Plugin/RetryPlugin.php index 144679ea..992bb214 100644 --- a/src/Plugin/RetryPlugin.php +++ b/src/Plugin/RetryPlugin.php @@ -96,9 +96,6 @@ public function __construct(array $config = []) $this->exceptionDelay = $options['exception_delay']; } - /** - * {@inheritdoc} - */ public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise { $chainIdentifier = spl_object_hash((object) $first); diff --git a/src/PluginClient.php b/src/PluginClient.php index db81243c..d728c78a 100644 --- a/src/PluginClient.php +++ b/src/PluginClient.php @@ -64,9 +64,6 @@ public function __construct($client, array $plugins = [], array $options = []) $this->options = $this->configure($options); } - /** - * {@inheritdoc} - */ public function sendRequest(RequestInterface $request): ResponseInterface { // If the client doesn't support sync calls, call async @@ -87,9 +84,6 @@ public function sendRequest(RequestInterface $request): ResponseInterface return $pluginChain($request)->wait(); } - /** - * {@inheritdoc} - */ public function sendAsyncRequest(RequestInterface $request) { $pluginChain = $this->createPluginChain($this->plugins, function (RequestInterface $request) { diff --git a/src/PluginClientBuilder.php b/src/PluginClientBuilder.php index 87464982..87ee280e 100644 --- a/src/PluginClientBuilder.php +++ b/src/PluginClientBuilder.php @@ -30,9 +30,6 @@ public function addPlugin(Plugin $plugin, int $priority = 0): self return $this; } - /** - * @param mixed $value - */ public function setOption(string $name, $value): self { $this->options[$name] = $value; From 8a0f30c1e0fa9f714d1319afe0ad3d56b9b314d4 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Fri, 3 Nov 2023 16:57:47 +0100 Subject: [PATCH 2/3] fix phpstan errors --- phpstan.neon.dist | 12 ------------ src/PluginClientBuilder.php | 3 +++ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 8886dea1..60571ca7 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -57,18 +57,6 @@ parameters: count: 1 path: src/Plugin/RedirectPlugin.php - # phpstan is confused by the optional dependencies. we check for existence first - - - message: "#^Method Http\\\\Client\\\\Common\\\\Plugin\\\\RedirectPlugin::guessStreamFactory\\(\\) should return Psr\\\\Http\\\\Message\\\\StreamFactoryInterface\\|null but returns Nyholm\\\\Psr7\\\\Factory\\\\Psr17Factory\\.$#" - count: 1 - path: src/Plugin/RedirectPlugin.php - - # phpstan is confused by the optional dependencies. we check for existence first - - - message: "#^Call to static method streamFor\\(\\) on an unknown class GuzzleHttp\\\\Psr7\\\\Utils\\.$#" - count: 1 - path: src/Plugin/RedirectPlugin.php - - message: "#^Method Http\\\\Client\\\\Common\\\\Plugin\\\\RetryPlugin\\:\\:retry\\(\\) should return Psr\\\\Http\\\\Message\\\\ResponseInterface but returns mixed\\.$#" count: 1 diff --git a/src/PluginClientBuilder.php b/src/PluginClientBuilder.php index 87ee280e..45fd787c 100644 --- a/src/PluginClientBuilder.php +++ b/src/PluginClientBuilder.php @@ -30,6 +30,9 @@ public function addPlugin(Plugin $plugin, int $priority = 0): self return $this; } + /** + * @param string|int|float|bool|string[] $value + */ public function setOption(string $name, $value): self { $this->options[$name] = $value; From bfce8a6eb227ea200cdd72af9819de278abe8143 Mon Sep 17 00:00:00 2001 From: Philip Gichuhi Date: Sat, 4 Nov 2023 01:56:48 +0300 Subject: [PATCH 3/3] fix pending PHPStan errors --- phpstan.neon.dist | 20 -------------------- src/Deferred.php | 11 +++++++++++ src/HttpAsyncClientDecorator.php | 3 +++ src/HttpAsyncClientEmulator.php | 1 + src/HttpClientPool/HttpClientPool.php | 4 ++++ src/HttpClientPool/HttpClientPoolItem.php | 4 ++++ src/HttpClientRouter.php | 4 ++++ src/Plugin.php | 7 ++++--- src/PluginChain.php | 8 ++++++-- src/PluginClient.php | 5 ++++- 10 files changed, 41 insertions(+), 26 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 60571ca7..082f78f0 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -26,11 +26,6 @@ parameters: count: 1 path: src/PluginClient.php - - - message: "#^Method Http\\\\Client\\\\Common\\\\EmulatedHttpClient\\:\\:sendRequest\\(\\) should return Psr\\\\Http\\\\Message\\\\ResponseInterface but returns mixed\\.$#" - count: 1 - path: src/EmulatedHttpClient.php - # we still support the obsolete RequestFactory for BC but do not require the package anymore - message: "#^Call to method createRequest\\(\\) on an unknown class Http\\\\Message\\\\RequestFactory\\.$#" @@ -51,18 +46,3 @@ parameters: message: "#^Property Http\\\\Client\\\\Common\\\\HttpMethodsClient\\:\\:\\$requestFactory has unknown class Http\\\\Message\\\\RequestFactory as its type\\.$#" count: 1 path: src/HttpMethodsClient.php - - - - message: "#^Anonymous function should return Psr\\\\Http\\\\Message\\\\ResponseInterface but returns mixed\\.$#" - count: 1 - path: src/Plugin/RedirectPlugin.php - - - - message: "#^Method Http\\\\Client\\\\Common\\\\Plugin\\\\RetryPlugin\\:\\:retry\\(\\) should return Psr\\\\Http\\\\Message\\\\ResponseInterface but returns mixed\\.$#" - count: 1 - path: src/Plugin/RetryPlugin.php - - - - message: "#^Method Http\\\\Client\\\\Common\\\\PluginClient\\:\\:sendRequest\\(\\) should return Psr\\\\Http\\\\Message\\\\ResponseInterface but returns mixed\\.$#" - count: 2 - path: src/PluginClient.php diff --git a/src/Deferred.php b/src/Deferred.php index eaf7cdf7..cee9b696 100644 --- a/src/Deferred.php +++ b/src/Deferred.php @@ -10,6 +10,8 @@ /** * A deferred allow to return a promise which has not been resolved yet. + * + * @implements Promise */ final class Deferred implements Promise { @@ -51,6 +53,11 @@ public function __construct(callable $waitCallback) $this->onRejectedCallbacks = []; } + /** + * @param callable(ResponseInterface): ResponseInterface|null $onFulfilled + * @param callable(\Throwable): ResponseInterface|null $onRejected + * @return Promise + */ public function then(callable $onFulfilled = null, callable $onRejected = null): Promise { $deferred = new self($this->waitCallback); @@ -90,6 +97,7 @@ public function getState(): string /** * Resolve this deferred with a Response. + * @param ResponseInterface $response */ public function resolve(ResponseInterface $response): void { @@ -122,6 +130,9 @@ public function reject(ClientExceptionInterface $exception): void } } + /** + * {@inheritDoc} + */ public function wait($unwrap = true) { if (Promise::PENDING === $this->state) { diff --git a/src/HttpAsyncClientDecorator.php b/src/HttpAsyncClientDecorator.php index 91ff5af2..92cf2c97 100644 --- a/src/HttpAsyncClientDecorator.php +++ b/src/HttpAsyncClientDecorator.php @@ -5,6 +5,8 @@ namespace Http\Client\Common; use Http\Client\HttpAsyncClient; +use Http\Promise\Promise; +use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\RequestInterface; /** @@ -21,6 +23,7 @@ trait HttpAsyncClientDecorator /** * @see HttpAsyncClient::sendAsyncRequest + * @return Promise */ public function sendAsyncRequest(RequestInterface $request) { diff --git a/src/HttpAsyncClientEmulator.php b/src/HttpAsyncClientEmulator.php index ffc0d5a4..9667e3ce 100644 --- a/src/HttpAsyncClientEmulator.php +++ b/src/HttpAsyncClientEmulator.php @@ -23,6 +23,7 @@ abstract public function sendRequest(RequestInterface $request): ResponseInterfa /** * @see HttpAsyncClient::sendAsyncRequest + * @return \Http\Promise\Promise */ public function sendAsyncRequest(RequestInterface $request) { diff --git a/src/HttpClientPool/HttpClientPool.php b/src/HttpClientPool/HttpClientPool.php index d7c2dbd0..5166e6e0 100644 --- a/src/HttpClientPool/HttpClientPool.php +++ b/src/HttpClientPool/HttpClientPool.php @@ -7,6 +7,7 @@ use Http\Client\Common\Exception\HttpClientNotFoundException; use Http\Client\Common\HttpClientPool as HttpClientPoolInterface; use Http\Client\HttpAsyncClient; +use Http\Promise\Promise; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -52,6 +53,9 @@ public function addHttpClient($client): void */ abstract protected function chooseHttpClient(): HttpClientPoolItem; + /** + * @return Promise + */ public function sendAsyncRequest(RequestInterface $request) { return $this->chooseHttpClient()->sendAsyncRequest($request); diff --git a/src/HttpClientPool/HttpClientPoolItem.php b/src/HttpClientPool/HttpClientPoolItem.php index 2496ddae..0f2b03de 100644 --- a/src/HttpClientPool/HttpClientPoolItem.php +++ b/src/HttpClientPool/HttpClientPoolItem.php @@ -8,6 +8,7 @@ use Http\Client\Exception; use Http\Client\HttpAsyncClient; use Http\Client\HttpClient; +use Http\Promise\Promise; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -89,6 +90,9 @@ public function sendRequest(RequestInterface $request): ResponseInterface return $response; } + /** + * @return Promise + */ public function sendAsyncRequest(RequestInterface $request) { if ($this->isDisabled()) { diff --git a/src/HttpClientRouter.php b/src/HttpClientRouter.php index 42c69073..83fe9dfe 100644 --- a/src/HttpClientRouter.php +++ b/src/HttpClientRouter.php @@ -7,6 +7,7 @@ use Http\Client\Common\Exception\HttpClientNoMatchException; use Http\Client\HttpAsyncClient; use Http\Message\RequestMatcher; +use Http\Promise\Promise; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -26,6 +27,9 @@ public function sendRequest(RequestInterface $request): ResponseInterface return $this->chooseHttpClient($request)->sendRequest($request); } + /** + * @return Promise + */ public function sendAsyncRequest(RequestInterface $request) { return $this->chooseHttpClient($request)->sendAsyncRequest($request); diff --git a/src/Plugin.php b/src/Plugin.php index 99898b92..82b30abb 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -5,6 +5,7 @@ namespace Http\Client\Common; use Http\Promise\Promise; +use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\RequestInterface; /** @@ -24,10 +25,10 @@ interface Plugin * * @see http://docs.php-http.org/en/latest/plugins/build-your-own.html * - * @param callable(RequestInterface): Promise $next Next middleware in the chain, the request is passed as the first argument - * @param callable(RequestInterface): Promise $first First middleware in the chain, used to to restart a request + * @param callable(RequestInterface): Promise $next Next middleware in the chain, the request is passed as the first argument + * @param callable(RequestInterface): Promise $first First middleware in the chain, used to to restart a request * - * @return Promise Resolves a PSR-7 Response or fails with an Http\Client\Exception (The same as HttpAsyncClient) + * @return Promise Resolves a PSR-7 Response or fails with an Http\Client\Exception (The same as HttpAsyncClient) */ public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise; } diff --git a/src/PluginChain.php b/src/PluginChain.php index 2bfbfbc9..ddf85cb1 100644 --- a/src/PluginChain.php +++ b/src/PluginChain.php @@ -7,13 +7,14 @@ use Http\Client\Common\Exception\LoopException; use Http\Promise\Promise; use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; final class PluginChain { /** @var Plugin[] */ private $plugins; - /** @var callable(RequestInterface): Promise */ + /** @var callable(RequestInterface): Promise */ private $clientCallable; /** @var int */ @@ -24,7 +25,7 @@ final class PluginChain /** * @param Plugin[] $plugins A plugin chain - * @param callable(RequestInterface): Promise $clientCallable Callable making the HTTP call + * @param callable(RequestInterface): Promise $clientCallable Callable making the HTTP call * @param array{'max_restarts'?: int} $options */ public function __construct(array $plugins, callable $clientCallable, array $options = []) @@ -48,6 +49,9 @@ private function createChain(): callable return $lastCallable; } + /** + * @return Promise + */ public function __invoke(RequestInterface $request): Promise { if ($this->restarts > $this->maxRestarts) { diff --git a/src/PluginClient.php b/src/PluginClient.php index d728c78a..7f7a58e1 100644 --- a/src/PluginClient.php +++ b/src/PluginClient.php @@ -84,6 +84,9 @@ public function sendRequest(RequestInterface $request): ResponseInterface return $pluginChain($request)->wait(); } + /** + * @return Promise + */ public function sendAsyncRequest(RequestInterface $request) { $pluginChain = $this->createPluginChain($this->plugins, function (RequestInterface $request) { @@ -114,7 +117,7 @@ private function configure(array $options = []): array * @param Plugin[] $plugins A plugin chain * @param callable $clientCallable Callable making the HTTP call * - * @return callable(RequestInterface): Promise + * @return callable(RequestInterface): Promise */ private function createPluginChain(array $plugins, callable $clientCallable): callable {