Skip to content

Commit 5bd058b

Browse files
authored
Merge pull request #248 from php-http/cs-fix
adjust to latest cs fixer
2 parents d930a40 + b25792f commit 5bd058b

9 files changed

+11
-11
lines changed

src/Deferred.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct(callable $waitCallback)
5151
$this->onRejectedCallbacks = [];
5252
}
5353

54-
public function then(callable $onFulfilled = null, callable $onRejected = null): Promise
54+
public function then(?callable $onFulfilled = null, ?callable $onRejected = null): Promise
5555
{
5656
$deferred = new self($this->waitCallback);
5757

src/Exception/HttpClientNoMatchException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ final class HttpClientNoMatchException extends TransferException
1919
*/
2020
private $request;
2121

22-
public function __construct(string $message, RequestInterface $request, \Exception $previous = null)
22+
public function __construct(string $message, RequestInterface $request, ?\Exception $previous = null)
2323
{
2424
$this->request = $request;
2525

src/HttpClientPool/HttpClientPoolItem.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class HttpClientPoolItem implements HttpClient, HttpAsyncClient
5757
* @param ClientInterface|HttpAsyncClient $client
5858
* @param int|null $reenableAfter Number of seconds until this client is enabled again after an error
5959
*/
60-
public function __construct($client, int $reenableAfter = null)
60+
public function __construct($client, ?int $reenableAfter = null)
6161
{
6262
if (!$client instanceof ClientInterface && !$client instanceof HttpAsyncClient) {
6363
throw new \TypeError(

src/HttpMethodsClient.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ final class HttpMethodsClient implements HttpMethodsClientInterface
3333
/**
3434
* @param RequestFactory|RequestFactoryInterface $requestFactory
3535
*/
36-
public function __construct(ClientInterface $httpClient, $requestFactory, StreamFactoryInterface $streamFactory = null)
36+
public function __construct(ClientInterface $httpClient, $requestFactory, ?StreamFactoryInterface $streamFactory = null)
3737
{
3838
if (!$requestFactory instanceof RequestFactory && !$requestFactory instanceof RequestFactoryInterface) {
3939
throw new \TypeError(

src/Plugin/RedirectPlugin.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public function guessStreamFactory(): ?StreamFactoryInterface
218218
return new Psr17Factory();
219219
}
220220
if (class_exists(Utils::class)) {
221-
return new class() implements StreamFactoryInterface {
221+
return new class implements StreamFactoryInterface {
222222
public function createStream(string $content = ''): StreamInterface
223223
{
224224
return Utils::streamFor($content);

src/Plugin/RequestMatcherPlugin.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ final class RequestMatcherPlugin implements Plugin
3131
*/
3232
private $failurePlugin;
3333

34-
public function __construct(RequestMatcher $requestMatcher, ?Plugin $delegateOnMatch, Plugin $delegateOnNoMatch = null)
34+
public function __construct(RequestMatcher $requestMatcher, ?Plugin $delegateOnMatch, ?Plugin $delegateOnNoMatch = null)
3535
{
3636
$this->requestMatcher = $requestMatcher;
3737
$this->successPlugin = $delegateOnMatch;

tests/HttpMethodsClientTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function testOptions(): void
7878
*
7979
* As there is no data provider in phpspec, we keep separate methods to get new mocks for each test.
8080
*/
81-
private function expectSendRequest(string $method, string $body = null): void
81+
private function expectSendRequest(string $method, ?string $body = null): void
8282
{
8383
$response = new Response();
8484
$this->httpClient->expects($this->once())

tests/Plugin/RedirectPluginTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function provideRedirections(): array
9393
'relative-path with ./' => ['https://example.com:8000/path/', './other?query=value', 'https://example.com:8000/path/other?query=value'],
9494
'relative-path with //' => ['https://example.com:8000/path/', 'other//sub?query=value', 'https://example.com:8000/path/other//sub?query=value'],
9595
'relative-path redirect with only query' => ['https://example.com:8000/path', '?query=value', 'https://example.com:8000/path?query=value'],
96-
];
96+
];
9797
}
9898

9999
/**

tests/PluginClientTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ public function testRestartChain(PluginClient $client, string $method, string $r
3333

3434
public function clientAndMethodProvider()
3535
{
36-
$syncClient = new class() implements ClientInterface {
36+
$syncClient = new class implements ClientInterface {
3737
public function sendRequest(RequestInterface $request): ResponseInterface
3838
{
3939
return new Response();
4040
}
4141
};
4242

43-
$asyncClient = new class() implements HttpAsyncClient {
43+
$asyncClient = new class implements HttpAsyncClient {
4444
public function sendAsyncRequest(RequestInterface $request)
4545
{
4646
return new HttpFulfilledPromise(new Response());
@@ -49,7 +49,7 @@ public function sendAsyncRequest(RequestInterface $request)
4949

5050
$headerAppendPlugin = new HeaderAppendPlugin(['Content-Type' => 'text/html']);
5151
$redirectPlugin = new RedirectPlugin();
52-
$restartOncePlugin = new class() implements Plugin {
52+
$restartOncePlugin = new class implements Plugin {
5353
private $firstRun = true;
5454

5555
public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise

0 commit comments

Comments
 (0)