diff --git a/src/Deferred.php b/src/Deferred.php index eaf7cdf..effabb2 100644 --- a/src/Deferred.php +++ b/src/Deferred.php @@ -51,7 +51,7 @@ public function __construct(callable $waitCallback) $this->onRejectedCallbacks = []; } - public function then(callable $onFulfilled = null, callable $onRejected = null): Promise + public function then(?callable $onFulfilled = null, ?callable $onRejected = null): Promise { $deferred = new self($this->waitCallback); diff --git a/src/Exception/HttpClientNoMatchException.php b/src/Exception/HttpClientNoMatchException.php index 682c5dd..83037d3 100644 --- a/src/Exception/HttpClientNoMatchException.php +++ b/src/Exception/HttpClientNoMatchException.php @@ -19,7 +19,7 @@ final class HttpClientNoMatchException extends TransferException */ private $request; - public function __construct(string $message, RequestInterface $request, \Exception $previous = null) + public function __construct(string $message, RequestInterface $request, ?\Exception $previous = null) { $this->request = $request; diff --git a/src/HttpClientPool/HttpClientPoolItem.php b/src/HttpClientPool/HttpClientPoolItem.php index 2496dda..1bf4381 100644 --- a/src/HttpClientPool/HttpClientPoolItem.php +++ b/src/HttpClientPool/HttpClientPoolItem.php @@ -57,7 +57,7 @@ class HttpClientPoolItem implements HttpClient, HttpAsyncClient * @param ClientInterface|HttpAsyncClient $client * @param int|null $reenableAfter Number of seconds until this client is enabled again after an error */ - public function __construct($client, int $reenableAfter = null) + public function __construct($client, ?int $reenableAfter = null) { if (!$client instanceof ClientInterface && !$client instanceof HttpAsyncClient) { throw new \TypeError( diff --git a/src/HttpMethodsClient.php b/src/HttpMethodsClient.php index 497921b..95fee3b 100644 --- a/src/HttpMethodsClient.php +++ b/src/HttpMethodsClient.php @@ -33,7 +33,7 @@ final class HttpMethodsClient implements HttpMethodsClientInterface /** * @param RequestFactory|RequestFactoryInterface $requestFactory */ - public function __construct(ClientInterface $httpClient, $requestFactory, StreamFactoryInterface $streamFactory = null) + public function __construct(ClientInterface $httpClient, $requestFactory, ?StreamFactoryInterface $streamFactory = null) { if (!$requestFactory instanceof RequestFactory && !$requestFactory instanceof RequestFactoryInterface) { throw new \TypeError( diff --git a/src/Plugin/RedirectPlugin.php b/src/Plugin/RedirectPlugin.php index 3ba71d6..8aebcbf 100644 --- a/src/Plugin/RedirectPlugin.php +++ b/src/Plugin/RedirectPlugin.php @@ -218,7 +218,7 @@ public function guessStreamFactory(): ?StreamFactoryInterface return new Psr17Factory(); } if (class_exists(Utils::class)) { - return new class() implements StreamFactoryInterface { + return new class implements StreamFactoryInterface { public function createStream(string $content = ''): StreamInterface { return Utils::streamFor($content); diff --git a/src/Plugin/RequestMatcherPlugin.php b/src/Plugin/RequestMatcherPlugin.php index 8373409..eb97d92 100644 --- a/src/Plugin/RequestMatcherPlugin.php +++ b/src/Plugin/RequestMatcherPlugin.php @@ -31,7 +31,7 @@ final class RequestMatcherPlugin implements Plugin */ private $failurePlugin; - public function __construct(RequestMatcher $requestMatcher, ?Plugin $delegateOnMatch, Plugin $delegateOnNoMatch = null) + public function __construct(RequestMatcher $requestMatcher, ?Plugin $delegateOnMatch, ?Plugin $delegateOnNoMatch = null) { $this->requestMatcher = $requestMatcher; $this->successPlugin = $delegateOnMatch; diff --git a/tests/HttpMethodsClientTest.php b/tests/HttpMethodsClientTest.php index 4ec9f69..d93a2a8 100644 --- a/tests/HttpMethodsClientTest.php +++ b/tests/HttpMethodsClientTest.php @@ -78,7 +78,7 @@ public function testOptions(): void * * As there is no data provider in phpspec, we keep separate methods to get new mocks for each test. */ - private function expectSendRequest(string $method, string $body = null): void + private function expectSendRequest(string $method, ?string $body = null): void { $response = new Response(); $this->httpClient->expects($this->once()) diff --git a/tests/Plugin/RedirectPluginTest.php b/tests/Plugin/RedirectPluginTest.php index 7fbf6f0..92072ad 100644 --- a/tests/Plugin/RedirectPluginTest.php +++ b/tests/Plugin/RedirectPluginTest.php @@ -93,7 +93,7 @@ public function provideRedirections(): array 'relative-path with ./' => ['https://example.com:8000/path/', './other?query=value', 'https://example.com:8000/path/other?query=value'], 'relative-path with //' => ['https://example.com:8000/path/', 'other//sub?query=value', 'https://example.com:8000/path/other//sub?query=value'], 'relative-path redirect with only query' => ['https://example.com:8000/path', '?query=value', 'https://example.com:8000/path?query=value'], - ]; + ]; } /** diff --git a/tests/PluginClientTest.php b/tests/PluginClientTest.php index 6c29569..26547bd 100644 --- a/tests/PluginClientTest.php +++ b/tests/PluginClientTest.php @@ -33,14 +33,14 @@ public function testRestartChain(PluginClient $client, string $method, string $r public function clientAndMethodProvider() { - $syncClient = new class() implements ClientInterface { + $syncClient = new class implements ClientInterface { public function sendRequest(RequestInterface $request): ResponseInterface { return new Response(); } }; - $asyncClient = new class() implements HttpAsyncClient { + $asyncClient = new class implements HttpAsyncClient { public function sendAsyncRequest(RequestInterface $request) { return new HttpFulfilledPromise(new Response()); @@ -49,7 +49,7 @@ public function sendAsyncRequest(RequestInterface $request) $headerAppendPlugin = new HeaderAppendPlugin(['Content-Type' => 'text/html']); $redirectPlugin = new RedirectPlugin(); - $restartOncePlugin = new class() implements Plugin { + $restartOncePlugin = new class implements Plugin { private $firstRun = true; public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise