Skip to content

Commit 39bb616

Browse files
Merge branch '4.4' into 5.1
* 4.4: Enable "native_constant_invocation" CS rule Make AbstractPhpFileCacheWarmer public
2 parents 21c4372 + d4fcb57 commit 39bb616

11 files changed

+154
-154
lines changed

CurlHttpClient.php

Lines changed: 66 additions & 66 deletions
Large diffs are not rendered by default.

HttpClient.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static function create(array $defaultOptions = [], int $maxHostConnection
4444
$curlVersion = $curlVersion ?? curl_version();
4545

4646
// HTTP/2 push crashes before curl 7.61
47-
if (0x073d00 > $curlVersion['version_number'] || !(CURL_VERSION_HTTP2 & $curlVersion['features'])) {
47+
if (0x073d00 > $curlVersion['version_number'] || !(\CURL_VERSION_HTTP2 & $curlVersion['features'])) {
4848
return new AmpHttpClient($defaultOptions, null, $maxHostConnections, $maxPendingPushes);
4949
}
5050
}
@@ -54,14 +54,14 @@ public static function create(array $defaultOptions = [], int $maxHostConnection
5454
return new CurlHttpClient($defaultOptions, $maxHostConnections, $maxPendingPushes);
5555
}
5656

57-
@trigger_error('Configure the "curl.cainfo", "openssl.cafile" or "openssl.capath" php.ini setting to enable the CurlHttpClient', E_USER_WARNING);
57+
@trigger_error('Configure the "curl.cainfo", "openssl.cafile" or "openssl.capath" php.ini setting to enable the CurlHttpClient', \E_USER_WARNING);
5858
}
5959

6060
if ($amp) {
6161
return new AmpHttpClient($defaultOptions, null, $maxHostConnections, $maxPendingPushes);
6262
}
6363

64-
@trigger_error((\extension_loaded('curl') ? 'Upgrade' : 'Install').' the curl extension or run "composer require amphp/http-client" to perform async HTTP operations, including full HTTP/2 support', E_USER_NOTICE);
64+
@trigger_error((\extension_loaded('curl') ? 'Upgrade' : 'Install').' the curl extension or run "composer require amphp/http-client" to perform async HTTP operations, including full HTTP/2 support', \E_USER_NOTICE);
6565

6666
return new NativeHttpClient($defaultOptions, $maxHostConnections);
6767
}

HttpClientTrait.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ private static function normalizeHeaders(array $headers): array
269269
private static function normalizeBody($body)
270270
{
271271
if (\is_array($body)) {
272-
return http_build_query($body, '', '&', PHP_QUERY_RFC1738);
272+
return http_build_query($body, '', '&', \PHP_QUERY_RFC1738);
273273
}
274274

275275
if (\is_string($body)) {
@@ -352,15 +352,15 @@ private static function normalizePeerFingerprint($fingerprint): array
352352
*/
353353
private static function jsonEncode($value, int $flags = null, int $maxDepth = 512): string
354354
{
355-
$flags = $flags ?? (JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_PRESERVE_ZERO_FRACTION);
355+
$flags = $flags ?? (\JSON_HEX_TAG | \JSON_HEX_APOS | \JSON_HEX_AMP | \JSON_HEX_QUOT | \JSON_PRESERVE_ZERO_FRACTION);
356356

357357
try {
358-
$value = json_encode($value, $flags | (\PHP_VERSION_ID >= 70300 ? JSON_THROW_ON_ERROR : 0), $maxDepth);
358+
$value = json_encode($value, $flags | (\PHP_VERSION_ID >= 70300 ? \JSON_THROW_ON_ERROR : 0), $maxDepth);
359359
} catch (\JsonException $e) {
360360
throw new InvalidArgumentException('Invalid value for "json" option: '.$e->getMessage());
361361
}
362362

363-
if (\PHP_VERSION_ID < 70300 && JSON_ERROR_NONE !== json_last_error() && (false === $value || !($flags & JSON_PARTIAL_OUTPUT_ON_ERROR))) {
363+
if (\PHP_VERSION_ID < 70300 && \JSON_ERROR_NONE !== json_last_error() && (false === $value || !($flags & \JSON_PARTIAL_OUTPUT_ON_ERROR))) {
364364
throw new InvalidArgumentException('Invalid value for "json" option: '.json_last_error_msg());
365365
}
366366

@@ -455,7 +455,7 @@ private static function parseUrl(string $url, array $query = [], array $allowedS
455455
throw new InvalidArgumentException(sprintf('Unsupported IDN "%s", try enabling the "intl" PHP extension or running "composer require symfony/polyfill-intl-idn".', $host));
456456
}
457457

458-
$host = \defined('INTL_IDNA_VARIANT_UTS46') ? idn_to_ascii($host, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46) ?: strtolower($host) : strtolower($host);
458+
$host = \defined('INTL_IDNA_VARIANT_UTS46') ? idn_to_ascii($host, \IDNA_DEFAULT, \INTL_IDNA_VARIANT_UTS46) ?: strtolower($host) : strtolower($host);
459459
$host .= $port ? ':'.$port : '';
460460
}
461461

@@ -540,7 +540,7 @@ private static function mergeQueryString(?string $queryString, array $queryArray
540540
}
541541
}
542542

543-
$queryString = http_build_query($queryArray, '', '&', PHP_QUERY_RFC3986);
543+
$queryString = http_build_query($queryArray, '', '&', \PHP_QUERY_RFC3986);
544544
$queryArray = [];
545545

546546
if ($queryString) {

Internal/AmpClientState.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public function connect(string $uri, ?ConnectContext $context = null, ?Cancellat
185185
}
186186
}
187187

188-
$maxHostConnections = 0 < $this->maxHostConnections ? $this->maxHostConnections : PHP_INT_MAX;
188+
$maxHostConnections = 0 < $this->maxHostConnections ? $this->maxHostConnections : \PHP_INT_MAX;
189189
$pool = new DefaultConnectionFactory($connector, $context);
190190
$pool = ConnectionLimitingPool::byAuthority($maxHostConnections, $pool);
191191

Internal/NativeClientState.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class NativeClientState extends ClientState
2323
/** @var int */
2424
public $id;
2525
/** @var int */
26-
public $maxHostConnections = PHP_INT_MAX;
26+
public $maxHostConnections = \PHP_INT_MAX;
2727
/** @var int */
2828
public $responseCount = 0;
2929
/** @var string[] */
@@ -33,6 +33,6 @@ final class NativeClientState extends ClientState
3333

3434
public function __construct()
3535
{
36-
$this->id = random_int(PHP_INT_MIN, PHP_INT_MAX);
36+
$this->id = random_int(\PHP_INT_MIN, \PHP_INT_MAX);
3737
}
3838
}

NativeHttpClient.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function __construct(array $defaultOptions = [], int $maxHostConnections
5555
}
5656

5757
$this->multi = new NativeClientState();
58-
$this->multi->maxHostConnections = 0 < $maxHostConnections ? $maxHostConnections : PHP_INT_MAX;
58+
$this->multi->maxHostConnections = 0 < $maxHostConnections ? $maxHostConnections : \PHP_INT_MAX;
5959
}
6060

6161
/**
@@ -116,7 +116,7 @@ public function request(string $method, string $url, array $options = []): Respo
116116
if ($onProgress = $options['on_progress']) {
117117
// Memoize the last progress to ease calling the callback periodically when no network transfer happens
118118
$lastProgress = [0, 0];
119-
$maxDuration = 0 < $options['max_duration'] ? $options['max_duration'] : INF;
119+
$maxDuration = 0 < $options['max_duration'] ? $options['max_duration'] : \INF;
120120
$onProgress = static function (...$progress) use ($onProgress, &$lastProgress, &$info, $maxDuration) {
121121
if ($info['total_time'] >= $maxDuration) {
122122
throw new TransportException(sprintf('Max duration was reached for "%s".', implode('', $info['url'])));
@@ -148,11 +148,11 @@ public function request(string $method, string $url, array $options = []): Respo
148148
$notification = static function (int $code, int $severity, ?string $msg, int $msgCode, int $dlNow, int $dlSize) use ($onProgress, &$info) {
149149
$info['total_time'] = microtime(true) - $info['start_time'];
150150

151-
if (STREAM_NOTIFY_PROGRESS === $code) {
151+
if (\STREAM_NOTIFY_PROGRESS === $code) {
152152
$info['starttransfer_time'] = $info['starttransfer_time'] ?: $info['total_time'];
153153
$info['size_upload'] += $dlNow ? 0 : $info['size_body'];
154154
$info['size_download'] = $dlNow;
155-
} elseif (STREAM_NOTIFY_CONNECT === $code) {
155+
} elseif (\STREAM_NOTIFY_CONNECT === $code) {
156156
$info['connect_time'] = $info['total_time'];
157157
$info['debug'] .= $info['request_header'];
158158
unset($info['request_header']);
@@ -269,14 +269,14 @@ private static function getBodyAsString($body): string
269269
*/
270270
private static function dnsResolve(array $url, NativeClientState $multi, array &$info, ?\Closure $onProgress): array
271271
{
272-
if ($port = parse_url($url['authority'], PHP_URL_PORT) ?: '') {
272+
if ($port = parse_url($url['authority'], \PHP_URL_PORT) ?: '') {
273273
$info['primary_port'] = $port;
274274
$port = ':'.$port;
275275
} else {
276276
$info['primary_port'] = 'http:' === $url['scheme'] ? 80 : 443;
277277
}
278278

279-
$host = parse_url($url['authority'], PHP_URL_HOST);
279+
$host = parse_url($url['authority'], \PHP_URL_HOST);
280280

281281
if (null === $ip = $multi->dnsCache[$host] ?? null) {
282282
$info['debug'] .= "* Hostname was NOT found in DNS cache\n";
@@ -366,7 +366,7 @@ private static function createRedirectResolver(array $options, string $host, ?ar
366366
[$host, $port, $url['authority']] = self::dnsResolve($url, $multi, $info, $onProgress);
367367
stream_context_set_option($context, 'ssl', 'peer_name', $host);
368368

369-
if (false !== (parse_url($location, PHP_URL_HOST) ?? false)) {
369+
if (false !== (parse_url($location, \PHP_URL_HOST) ?? false)) {
370370
// Authorization and Cookie headers MUST NOT follow except for the initial host name
371371
$requestHeaders = $redirectHeaders['host'] === $host ? $redirectHeaders['with_auth'] : $redirectHeaders['no_auth'];
372372
$requestHeaders[] = 'Host: '.$host.$port;

0 commit comments

Comments
 (0)