Skip to content

Commit

Permalink
chore: adjust for php-cs-fixer 3.54.0 (6.0 branch)
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed Apr 19, 2024
1 parent 0b7f0f2 commit 9094768
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 52 deletions.
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"sabre/uri" : "^2.3"
},
"require-dev" : {
"friendsofphp/php-cs-fixer": "^3.38",
"friendsofphp/php-cs-fixer": "^3.54",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit" : "^9.6"
},
Expand Down Expand Up @@ -60,5 +60,10 @@
"composer cs-fixer",
"composer phpunit"
]
},
"config": {
"allow-plugins": {
"phpstan/extension-installer": true
}
}
}
4 changes: 2 additions & 2 deletions examples/stringify.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
$request->setHeaders([
'Host' => 'example.org',
'Content-Type' => 'application/json',
]);
]);

$request->setBody(json_encode(['foo' => 'bar']));

Expand All @@ -41,7 +41,7 @@
$response->setHeaders([
'Content-Type' => 'text/plain',
'Connection' => 'close',
]);
]);

$response->setBody('ABORT! ABORT!');

Expand Down
2 changes: 1 addition & 1 deletion lib/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function send(RequestInterface $request): ResponseInterface
* After calling sendAsync, you must therefore occasionally call the poll()
* method, or wait().
*/
public function sendAsync(RequestInterface $request, callable $success = null, callable $error = null): void
public function sendAsync(RequestInterface $request, ?callable $success = null, ?callable $error = null): void
{
$this->emit('beforeRequest', [$request]);
$this->sendAsyncInternal($request, $success, $error);
Expand Down
2 changes: 1 addition & 1 deletion lib/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class Response extends Message implements ResponseInterface
* @param array<string, mixed>|null $headers
* @param resource|string|callable|null $body
*/
public function __construct($status = 500, array $headers = null, $body = null)
public function __construct($status = 500, ?array $headers = null, $body = null)
{
if (null !== $status) {
$this->setStatus($status);
Expand Down
90 changes: 45 additions & 45 deletions tests/HTTP/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ public function testCreateCurlSettingsArrayGET(): void
$request = new Request('GET', 'http://example.org/', ['X-Foo' => 'bar']);

$settings = [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
CURLOPT_POSTREDIR => 0,
CURLOPT_HTTPHEADER => ['X-Foo: bar'],
CURLOPT_NOBODY => false,
CURLOPT_URL => 'http://example.org/',
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_USERAGENT => 'sabre-http/'.Version::VERSION.' (http://sabre.io/)',
];
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
CURLOPT_POSTREDIR => 0,
CURLOPT_HTTPHEADER => ['X-Foo: bar'],
CURLOPT_NOBODY => false,
CURLOPT_URL => 'http://example.org/',
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_USERAGENT => 'sabre-http/'.Version::VERSION.' (http://sabre.io/)',
];

// FIXME: CURLOPT_PROTOCOLS and CURLOPT_REDIR_PROTOCOLS are currently unsupported by HHVM
// at least if this unit test fails in the future we know it is :)
Expand Down Expand Up @@ -67,14 +67,14 @@ public function testCreateCurlSettingsArrayHEAD(): void
$request = new Request('HEAD', 'http://example.org/', ['X-Foo' => 'bar']);

$settings = [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
CURLOPT_NOBODY => true,
CURLOPT_CUSTOMREQUEST => 'HEAD',
CURLOPT_HTTPHEADER => ['X-Foo: bar'],
CURLOPT_URL => 'http://example.org/',
CURLOPT_USERAGENT => 'sabre-http/'.Version::VERSION.' (http://sabre.io/)',
];
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
CURLOPT_NOBODY => true,
CURLOPT_CUSTOMREQUEST => 'HEAD',
CURLOPT_HTTPHEADER => ['X-Foo: bar'],
CURLOPT_URL => 'http://example.org/',
CURLOPT_USERAGENT => 'sabre-http/'.Version::VERSION.' (http://sabre.io/)',
];

// FIXME: CURLOPT_PROTOCOLS and CURLOPT_REDIR_PROTOCOLS are currently unsupported by HHVM
// at least if this unit test fails in the future we know it is :)
Expand All @@ -100,14 +100,14 @@ public function testCreateCurlSettingsArrayGETAfterHEAD(): void
$request = new Request('GET', 'http://example.org/', ['X-Foo' => 'bar']);

$settings = [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
CURLOPT_HTTPHEADER => ['X-Foo: bar'],
CURLOPT_NOBODY => false,
CURLOPT_URL => 'http://example.org/',
CURLOPT_USERAGENT => 'sabre-http/'.Version::VERSION.' (http://sabre.io/)',
];
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
CURLOPT_HTTPHEADER => ['X-Foo: bar'],
CURLOPT_NOBODY => false,
CURLOPT_URL => 'http://example.org/',
CURLOPT_USERAGENT => 'sabre-http/'.Version::VERSION.' (http://sabre.io/)',
];

// FIXME: CURLOPT_PROTOCOLS and CURLOPT_REDIR_PROTOCOLS are currently unsupported by HHVM
// at least if this unit test fails in the future we know it is :)
Expand All @@ -129,17 +129,17 @@ public function testCreateCurlSettingsArrayPUTStream(): void
$request = new Request('PUT', 'http://example.org/', ['X-Foo' => 'bar'], $h);

$settings = [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
CURLOPT_PUT => true,
CURLOPT_INFILE => $h,
CURLOPT_INFILESIZE => strlen($fileContent),
CURLOPT_NOBODY => false,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => ['X-Foo: bar'],
CURLOPT_URL => 'http://example.org/',
CURLOPT_USERAGENT => 'sabre-http/'.Version::VERSION.' (http://sabre.io/)',
];
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
CURLOPT_PUT => true,
CURLOPT_INFILE => $h,
CURLOPT_INFILESIZE => strlen($fileContent),
CURLOPT_NOBODY => false,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => ['X-Foo: bar'],
CURLOPT_URL => 'http://example.org/',
CURLOPT_USERAGENT => 'sabre-http/'.Version::VERSION.' (http://sabre.io/)',
];

// FIXME: CURLOPT_PROTOCOLS and CURLOPT_REDIR_PROTOCOLS are currently unsupported by HHVM
// at least if this unit test fails in the future we know it is :)
Expand All @@ -157,15 +157,15 @@ public function testCreateCurlSettingsArrayPUTString(): void
$request = new Request('PUT', 'http://example.org/', ['X-Foo' => 'bar'], 'boo');

$settings = [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
CURLOPT_NOBODY => false,
CURLOPT_POSTFIELDS => 'boo',
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => ['X-Foo: bar'],
CURLOPT_URL => 'http://example.org/',
CURLOPT_USERAGENT => 'sabre-http/'.Version::VERSION.' (http://sabre.io/)',
];
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
CURLOPT_NOBODY => false,
CURLOPT_POSTFIELDS => 'boo',
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => ['X-Foo: bar'],
CURLOPT_URL => 'http://example.org/',
CURLOPT_USERAGENT => 'sabre-http/'.Version::VERSION.' (http://sabre.io/)',
];

// FIXME: CURLOPT_PROTOCOLS and CURLOPT_REDIR_PROTOCOLS are currently unsupported by HHVM
// at least if this unit test fails in the future we know it is :)
Expand Down
4 changes: 2 additions & 2 deletions tests/HTTP/MessageDecoratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testHeaders(): void
{
$this->outer->setHeaders([
'a' => 'b',
]);
]);

$this->assertEquals(['a' => ['b']], $this->inner->getHeaders());
$this->assertEquals(['a' => ['b']], $this->outer->getHeaders());
Expand All @@ -44,7 +44,7 @@ public function testHeaders(): void

$this->outer->addHeaders([
'e' => 'f',
]);
]);

$this->assertEquals(['a' => ['b'], 'c' => ['d'], 'e' => ['f']], $this->inner->getHeaders());
$this->assertEquals(['a' => ['b'], 'c' => ['d'], 'e' => ['f']], $this->outer->getHeaders());
Expand Down

0 comments on commit 9094768

Please sign in to comment.