PHP CS Fixer: enable @PHP8x1Migration:risky

This commit is contained in:
Dariusz Ruminski
2026-01-26 16:17:45 +01:00
committed by Nicolas Grekas
parent f4b49a07f2
commit b0433ba61b
3 changed files with 16 additions and 24 deletions

View File

@@ -101,9 +101,7 @@ final class NoPrivateNetworkHttpClient implements HttpClientInterface, ResetInte
$redirectHeaders['with_auth'] = $redirectHeaders['no_auth'] = $options['headers'];
if (isset($options['normalized_headers']['host']) || isset($options['normalized_headers']['authorization']) || isset($options['normalized_headers']['cookie'])) {
$redirectHeaders['no_auth'] = array_filter($redirectHeaders['no_auth'], static function ($h) {
return 0 !== stripos($h, 'Host:') && 0 !== stripos($h, 'Authorization:') && 0 !== stripos($h, 'Cookie:');
});
$redirectHeaders['no_auth'] = array_filter($redirectHeaders['no_auth'], static fn ($h) => 0 !== stripos($h, 'Host:') && 0 !== stripos($h, 'Authorization:') && 0 !== stripos($h, 'Cookie:'));
}
return new AsyncResponse($this->client, $method, $url, $options, static function (ChunkInterface $chunk, AsyncContext $context) use (&$method, &$options, $maxRedirects, &$redirectHeaders, $subnets, $ipFlags, $dnsCache): \Generator {
@@ -133,9 +131,7 @@ final class NoPrivateNetworkHttpClient implements HttpClientInterface, ResetInte
unset($options['body'], $options['json']);
if (isset($options['normalized_headers']['content-length']) || isset($options['normalized_headers']['content-type']) || isset($options['normalized_headers']['transfer-encoding'])) {
$filterContentHeaders = static function ($h) {
return 0 !== stripos($h, 'Content-Length:') && 0 !== stripos($h, 'Content-Type:') && 0 !== stripos($h, 'Transfer-Encoding:');
};
$filterContentHeaders = static fn ($h) => 0 !== stripos($h, 'Content-Length:') && 0 !== stripos($h, 'Content-Type:') && 0 !== stripos($h, 'Transfer-Encoding:');
$options['headers'] = array_filter($options['headers'], $filterContentHeaders);
$redirectHeaders['no_auth'] = array_filter($redirectHeaders['no_auth'], $filterContentHeaders);
$redirectHeaders['with_auth'] = array_filter($redirectHeaders['with_auth'], $filterContentHeaders);

View File

@@ -302,15 +302,13 @@ class HttplugClientTest extends TestCase
public function testAutoUpgradeHttpVersion()
{
$clientWithoutOption = new HttplugClient(new MockHttpClient(static function (string $method, string $url, array $options) {
return new MockResponse(json_encode([
'SERVER_PROTOCOL' => 'HTTP/'.$options['http_version'] ?? '',
]), [
'response_headers' => [
'Content-Type' => 'application/json',
],
]);
}));
$clientWithoutOption = new HttplugClient(new MockHttpClient(static fn (string $method, string $url, array $options) => new MockResponse(json_encode([
'SERVER_PROTOCOL' => 'HTTP/'.$options['http_version'] ?? '',
]), [
'response_headers' => [
'Content-Type' => 'application/json',
],
])));
$clientWithOptionFalse = $clientWithoutOption->withOptions(['auto_upgrade_http_version' => false]);
foreach (['1.0', '1.1', '2.0', '3.0'] as $httpVersion) {

View File

@@ -121,15 +121,13 @@ class Psr18ClientTest extends TestCase
public function testAutoUpgradeHttpVersion()
{
$clientWithoutOption = new Psr18Client(new MockHttpClient(static function (string $method, string $url, array $options) {
return new MockResponse(json_encode([
'SERVER_PROTOCOL' => 'HTTP/'.$options['http_version'] ?? '',
]), [
'response_headers' => [
'Content-Type' => 'application/json',
],
]);
}));
$clientWithoutOption = new Psr18Client(new MockHttpClient(static fn (string $method, string $url, array $options) => new MockResponse(json_encode([
'SERVER_PROTOCOL' => 'HTTP/'.$options['http_version'] ?? '',
]), [
'response_headers' => [
'Content-Type' => 'application/json',
],
])));
$clientWithOptionFalse = $clientWithoutOption->withOptions(['auto_upgrade_http_version' => false]);
foreach (['1.0', '1.1', '2.0', '3.0'] as $httpVersion) {