@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | $deferred = new self($this->waitCallback); |
| 60 | 60 | |
| 61 | - $this->onFulfilledCallbacks[] = function (ResponseInterface $response) use ($onFulfilled, $deferred) { |
|
| 61 | + $this->onFulfilledCallbacks[] = function(ResponseInterface $response) use ($onFulfilled, $deferred) { |
|
| 62 | 62 | try { |
| 63 | 63 | if (null !== $onFulfilled) { |
| 64 | 64 | $response = $onFulfilled($response); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | }; |
| 71 | 71 | |
| 72 | - $this->onRejectedCallbacks[] = function (ClientExceptionInterface $exception) use ($onRejected, $deferred) { |
|
| 72 | + $this->onRejectedCallbacks[] = function(ClientExceptionInterface $exception) use ($onRejected, $deferred) { |
|
| 73 | 73 | try { |
| 74 | 74 | if (null !== $onRejected) { |
| 75 | 75 | $response = $onRejected($exception); |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | $reversedPlugins = array_reverse($this->plugins); |
| 45 | 45 | |
| 46 | 46 | foreach ($reversedPlugins as $plugin) { |
| 47 | - $lastCallable = function (RequestInterface $request) use ($plugin, $lastCallable) { |
|
| 47 | + $lastCallable = function(RequestInterface $request) use ($plugin, $lastCallable) { |
|
| 48 | 48 | return $plugin->handleRequest($request, $lastCallable, $this); |
| 49 | 49 | }; |
| 50 | 50 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | // Else we want to use the synchronous call of the underlying client, |
| 81 | 81 | // and not the async one in the case we have both an async and sync call |
| 82 | - $pluginChain = $this->createPluginChain($this->plugins, function (RequestInterface $request) { |
|
| 82 | + $pluginChain = $this->createPluginChain($this->plugins, function(RequestInterface $request) { |
|
| 83 | 83 | try { |
| 84 | 84 | return new HttpFulfilledPromise($this->client->sendRequest($request)); |
| 85 | 85 | } catch (HttplugException $exception) { |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public function sendAsyncRequest(RequestInterface $request) |
| 97 | 97 | { |
| 98 | - $pluginChain = $this->createPluginChain($this->plugins, function (RequestInterface $request) { |
|
| 98 | + $pluginChain = $this->createPluginChain($this->plugins, function(RequestInterface $request) { |
|
| 99 | 99 | return $this->client->sendAsyncRequest($request); |
| 100 | 100 | }); |
| 101 | 101 | |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | protected function chooseHttpClient(): HttpClientPoolItem |
| 20 | 20 | { |
| 21 | - $clientPool = \array_filter($this->clientPool, function (HttpClientPoolItem $clientPoolItem) { |
|
| 21 | + $clientPool = \array_filter($this->clientPool, function(HttpClientPoolItem $clientPoolItem) { |
|
| 22 | 22 | return !$clientPoolItem->isDisabled(); |
| 23 | 23 | }); |
| 24 | 24 | |
@@ -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 | }); |