@@ -103,11 +103,11 @@ |
||
| 103 | 103 | |
| 104 | 104 | $this->incrementRequestCount(); |
| 105 | 105 | |
| 106 | - return $this->client->sendAsyncRequest($request)->then(function ($response) { |
|
| 106 | + return $this->client->sendAsyncRequest($request)->then(function($response) { |
|
| 107 | 107 | $this->decrementRequestCount(); |
| 108 | 108 | |
| 109 | 109 | return $response; |
| 110 | - }, function ($exception) { |
|
| 110 | + }, function($exception) { |
|
| 111 | 111 | $this->disable(); |
| 112 | 112 | $this->decrementRequestCount(); |
| 113 | 113 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | protected function chooseHttpClient(): HttpClientPoolItem |
| 22 | 22 | { |
| 23 | - $clientPool = \array_filter($this->clientPool, function (HttpClientPoolItem $clientPoolItem) { |
|
| 23 | + $clientPool = \array_filter($this->clientPool, function(HttpClientPoolItem $clientPoolItem) { |
|
| 24 | 24 | return !$clientPoolItem->isDisabled(); |
| 25 | 25 | }); |
| 26 | 26 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | throw new HttpClientNotFoundException('Cannot choose a http client as there is no one present in the pool'); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - usort($clientPool, function (HttpClientPoolItem $clientA, HttpClientPoolItem $clientB) { |
|
| 31 | + usort($clientPool, function(HttpClientPoolItem $clientA, HttpClientPoolItem $clientB) { |
|
| 32 | 32 | if ($clientA->getSendingRequestCount() === $clientB->getSendingRequestCount()) { |
| 33 | 33 | return 0; |
| 34 | 34 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | // Memoize the last progress to ease calling the callback periodically when no network transfer happens |
| 118 | 118 | $lastProgress = [0, 0]; |
| 119 | 119 | $maxDuration = 0 < $options['max_duration'] ? $options['max_duration'] : \INF; |
| 120 | - $onProgress = static function (...$progress) use ($onProgress, &$lastProgress, &$info, $maxDuration) { |
|
| 120 | + $onProgress = static function(...$progress) use ($onProgress, &$lastProgress, &$info, $maxDuration) { |
|
| 121 | 121 | if ($info['total_time'] >= $maxDuration) { |
| 122 | 122 | throw new TransportException(\sprintf('Max duration was reached for "%s".', \implode('', $info['url']))); |
| 123 | 123 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | }; |
| 138 | 138 | } elseif (0 < $options['max_duration']) { |
| 139 | 139 | $maxDuration = $options['max_duration']; |
| 140 | - $onProgress = static function () use (&$info, $maxDuration): void { |
|
| 140 | + $onProgress = static function() use (&$info, $maxDuration): void { |
|
| 141 | 141 | if ($info['total_time'] >= $maxDuration) { |
| 142 | 142 | throw new TransportException(\sprintf('Max duration was reached for "%s".', \implode('', $info['url']))); |
| 143 | 143 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | // Always register a notification callback to compute live stats about the response |
| 148 | - $notification = static function (int $code, int $severity, ?string $msg, int $msgCode, int $dlNow, int $dlSize) use ($onProgress, &$info) { |
|
| 148 | + $notification = static function(int $code, int $severity, ?string $msg, int $msgCode, int $dlNow, int $dlSize) use ($onProgress, &$info) { |
|
| 149 | 149 | $info['total_time'] = micro\time(true) - $info['start_time']; |
| 150 | 150 | |
| 151 | 151 | if (\STREAM_NOTIFY_PROGRESS === $code) { |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | 'allow_self_signed' => (bool) $options['peer_fingerprint'], |
| 206 | 206 | 'SNI_enabled' => true, |
| 207 | 207 | 'disable_compression' => true, |
| 208 | - ], static function ($v) { return null !== $v; }), |
|
| 208 | + ], static function($v) { return null !== $v; }), |
|
| 209 | 209 | 'socket' => [ |
| 210 | 210 | 'bindto' => $options['bindto'] ?: '0:0', |
| 211 | 211 | 'tcp_nodelay' => true, |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | |
| 215 | 215 | $context = stream_context_create($context, ['notification' => $notification]); |
| 216 | 216 | |
| 217 | - $resolver = static function ($multi) use ($context, $options, $url, &$info, $onProgress) { |
|
| 217 | + $resolver = static function($multi) use ($context, $options, $url, &$info, $onProgress) { |
|
| 218 | 218 | [$host, $port] = self::parseHostPort($url, $info); |
| 219 | 219 | |
| 220 | 220 | if (!isset($options['normalized_headers']['host'])) { |
@@ -324,18 +324,18 @@ discard block |
||
| 324 | 324 | $redirectHeaders = []; |
| 325 | 325 | if (0 < $maxRedirects = $options['max_redirects']) { |
| 326 | 326 | $redirectHeaders = ['host' => $host]; |
| 327 | - $redirectHeaders['with_auth'] = $redirectHeaders['no_auth'] = \array_filter($options['headers'], static function ($h) { |
|
| 327 | + $redirectHeaders['with_auth'] = $redirectHeaders['no_auth'] = \array_filter($options['headers'], static function($h) { |
|
| 328 | 328 | return 0 !== stripos($h, 'Host:'); |
| 329 | 329 | }); |
| 330 | 330 | |
| 331 | 331 | if (isset($options['normalized_headers']['authorization']) || isset($options['normalized_headers']['cookie'])) { |
| 332 | - $redirectHeaders['no_auth'] = \array_filter($redirectHeaders['no_auth'], static function ($h) { |
|
| 332 | + $redirectHeaders['no_auth'] = \array_filter($redirectHeaders['no_auth'], static function($h) { |
|
| 333 | 333 | return 0 !== stripos($h, 'Authorization:') && 0 !== stripos($h, 'Cookie:'); |
| 334 | 334 | }); |
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - return static function (NativeClientState $multi, ?string $location, $context) use ($redirectHeaders, $proxy, &$info, $maxRedirects, $onProgress): ?string { |
|
| 338 | + return static function(NativeClientState $multi, ?string $location, $context) use ($redirectHeaders, $proxy, &$info, $maxRedirects, $onProgress) : ?string { |
|
| 339 | 339 | if (null === $location || $info['http_code'] < 300 || 400 <= $info['http_code']) { |
| 340 | 340 | $info['redirect_url'] = null; |
| 341 | 341 | |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | if ('POST' === $options['method'] || 303 === $info['http_code']) { |
| 369 | 369 | $info['http_method'] = $options['method'] = 'HEAD' === $options['method'] ? 'HEAD' : 'GET'; |
| 370 | 370 | $options['content'] = ''; |
| 371 | - $options['header'] = \array_filter($options['header'], static function ($h) { |
|
| 371 | + $options['header'] = \array_filter($options['header'], static function($h) { |
|
| 372 | 372 | return 0 !== stripos($h, 'Content-Length:') && 0 !== stripos($h, 'Content-Type:'); |
| 373 | 373 | }); |
| 374 | 374 | |
@@ -66,7 +66,7 @@ |
||
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - return new AsyncResponse($this->client, $method, $url, $options, static function (ChunkInterface $chunk, AsyncContext $context) use ($state, $method, $url, $options) { |
|
| 69 | + return new AsyncResponse($this->client, $method, $url, $options, static function(ChunkInterface $chunk, AsyncContext $context) use ($state, $method, $url, $options) { |
|
| 70 | 70 | if (null !== $state->buffer) { |
| 71 | 71 | $context->setInfo('reconnection_time', $state->reconnectionTime); |
| 72 | 72 | $isTimeout = false; |
@@ -119,9 +119,9 @@ |
||
| 119 | 119 | |
| 120 | 120 | $waitLoop = $this->waitLoop; |
| 121 | 121 | |
| 122 | - $promise = new GuzzlePromise(static function () use ($response, $waitLoop) { |
|
| 122 | + $promise = new GuzzlePromise(static function() use ($response, $waitLoop) { |
|
| 123 | 123 | $waitLoop->wait($response); |
| 124 | - }, static function () use ($response, $promisePool) { |
|
| 124 | + }, static function() use ($response, $promisePool) { |
|
| 125 | 125 | $response->cancel(); |
| 126 | 126 | unset($promisePool[$response]); |
| 127 | 127 | }); |
@@ -78,7 +78,7 @@ |
||
| 78 | 78 | $subnets = $this->subnets; |
| 79 | 79 | $lastPrimaryIp = ''; |
| 80 | 80 | |
| 81 | - $options['on_progress'] = function (int $dlNow, int $dlSize, array $info) use ($onProgress, $subnets, &$lastPrimaryIp): void { |
|
| 81 | + $options['on_progress'] = function(int $dlNow, int $dlSize, array $info) use ($onProgress, $subnets, &$lastPrimaryIp): void { |
|
| 82 | 82 | if ($info['primary_ip'] !== $lastPrimaryIp) { |
| 83 | 83 | if (IpUtils::checkIp($info['primary_ip'], $subnets ?? self::PRIVATE_SUBNETS)) { |
| 84 | 84 | throw new TransportException(\sprintf('IP "%s" is blocked for "%s".', $info['primary_ip'], $info['url'])); |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | if (!$responseFactory instanceof \Iterator && null !== $responseFactory && !\is_callable($responseFactory)) { |
| 44 | - $responseFactory = (static function () use ($responseFactory) { |
|
| 44 | + $responseFactory = (static function() use ($responseFactory) { |
|
| 45 | 45 | yield from $responseFactory; |
| 46 | 46 | })(); |
| 47 | 47 | } |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | $content = false; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $options['on_progress'] = function (int $dlNow, int $dlSize, array $info) use (&$traceInfo, $onProgress) { |
|
| 60 | + $options['on_progress'] = function(int $dlNow, int $dlSize, array $info) use (&$traceInfo, $onProgress) { |
|
| 61 | 61 | $traceInfo = $info; |
| 62 | 62 | |
| 63 | 63 | if (null !== $onProgress) { |
@@ -46,13 +46,13 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | if (null !== $onProgress = $options['on_progress'] ?? null) { |
| 48 | 48 | $thisInfo = &$this->info; |
| 49 | - $options['on_progress'] = static function (int $dlNow, int $dlSize, array $info) use (&$thisInfo, $onProgress) { |
|
| 49 | + $options['on_progress'] = static function(int $dlNow, int $dlSize, array $info) use (&$thisInfo, $onProgress) { |
|
| 50 | 50 | $onProgress($dlNow, $dlSize, $thisInfo + $info); |
| 51 | 51 | }; |
| 52 | 52 | } |
| 53 | 53 | $this->response = $client->request($method, $url, ['buffer' => false] + $options); |
| 54 | 54 | $this->passthru = $passthru; |
| 55 | - $this->initializer = static function (self $response) { |
|
| 55 | + $this->initializer = static function(self $response) { |
|
| 56 | 56 | if (null === $response->shouldBuffer) { |
| 57 | 57 | return false; |
| 58 | 58 | } |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | $this->getHeaders(true); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - $handle = function () { |
|
| 128 | + $handle = function() { |
|
| 129 | 129 | $stream = $this->response instanceof StreamableInterface ? $this->response->toStream(false) : StreamWrapper::createResource($this->response); |
| 130 | 130 | |
| 131 | 131 | return stream_get_meta_data($stream)['wrapper_data']->stream_cast(\STREAM_CAST_FOR_SELECT); |