@@ -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); |
@@ -63,16 +63,16 @@ discard block |
||
63 | 63 | $info['user_data'] = $options['user_data']; |
64 | 64 | ++$multi->responseCount; |
65 | 65 | |
66 | - $this->initializer = static function (self $response) { |
|
66 | + $this->initializer = static function(self $response) { |
|
67 | 67 | return null === $response->remaining; |
68 | 68 | }; |
69 | 69 | |
70 | 70 | $pauseExpiry = &$this->pauseExpiry; |
71 | - $info['pause_handler'] = static function (float $duration) use (&$pauseExpiry) { |
|
71 | + $info['pause_handler'] = static function(float $duration) use (&$pauseExpiry) { |
|
72 | 72 | $pauseExpiry = 0 < $duration ? micro\time(true) + $duration : 0; |
73 | 73 | }; |
74 | 74 | |
75 | - $this->canary = new Canary(static function () use ($multi, $id) { |
|
75 | + $this->canary = new Canary(static function() use ($multi, $id) { |
|
76 | 76 | if (null !== ($host = $multi->openHandles[$id][6] ?? null) && 0 >= --$multi->hosts[$host]) { |
77 | 77 | unset($multi->hosts[$host]); |
78 | 78 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | { |
116 | 116 | $url = $this->url; |
117 | 117 | |
118 | - set_error_handler(function ($type, $msg) use (&$url) { |
|
118 | + set_error_handler(function($type, $msg) use (&$url) { |
|
119 | 119 | if (\E_NOTICE !== $type || 'fopen(): Content-type not specified assuming application/x-www-form-urlencoded' !== $msg) { |
120 | 120 | throw new TransportException($msg); |
121 | 121 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | \curl_setopt($ch, \CURLOPT_PRIVATE, \in_array($method, ['GET', 'HEAD', 'OPTIONS', 'TRACE'], true) && 1.0 < (float) ($options['http_version'] ?? 1.1) ? 'H2' : 'H0'); // H = headers + retry counter |
76 | 76 | } |
77 | 77 | |
78 | - \curl_setopt($ch, \CURLOPT_HEADERFUNCTION, static function ($ch, string $data) use (&$info, &$headers, $options, $multi, $id, &$location, $resolveRedirect, $logger): int { |
|
78 | + \curl_setopt($ch, \CURLOPT_HEADERFUNCTION, static function($ch, string $data) use (&$info, &$headers, $options, $multi, $id, &$location, $resolveRedirect, $logger): int { |
|
79 | 79 | if (0 !== substr_compare($data, "\r\n", -2)) { |
80 | 80 | return 0; |
81 | 81 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | if (null === $options) { |
93 | 93 | // Pushed response: buffer until requested |
94 | - \curl_setopt($ch, \CURLOPT_WRITEFUNCTION, static function ($ch, string $data) use ($multi, $id): int { |
|
94 | + \curl_setopt($ch, \CURLOPT_WRITEFUNCTION, static function($ch, string $data) use ($multi, $id): int { |
|
95 | 95 | $multi->handlesActivity[$id][] = $data; |
96 | 96 | curl_pause($ch, \CURLPAUSE_RECV); |
97 | 97 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | } |
103 | 103 | |
104 | 104 | $execCounter = $multi->execCounter; |
105 | - $this->info['pause_handler'] = static function (float $duration) use ($ch, $multi, $execCounter) { |
|
105 | + $this->info['pause_handler'] = static function(float $duration) use ($ch, $multi, $execCounter) { |
|
106 | 106 | if (0 < $duration) { |
107 | 107 | if ($execCounter === $multi->execCounter) { |
108 | 108 | $multi->execCounter = !\is_float($execCounter) ? 1 + $execCounter : \PHP_INT_MIN; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | if ($onProgress = $options['on_progress']) { |
129 | 129 | $url = isset($info['url']) ? ['url' => $info['url']] : []; |
130 | 130 | \curl_setopt($ch, \CURLOPT_NOPROGRESS, false); |
131 | - \curl_setopt($ch, \CURLOPT_PROGRESSFUNCTION, static function ($ch, $dlSize, $dlNow) use ($onProgress, &$info, $url, $multi, $debugBuffer) { |
|
131 | + \curl_setopt($ch, \CURLOPT_PROGRESSFUNCTION, static function($ch, $dlSize, $dlNow) use ($onProgress, &$info, $url, $multi, $debugBuffer) { |
|
132 | 132 | try { |
133 | 133 | rewind($debugBuffer); |
134 | 134 | $debug = ['debug' => stream_get_contents($debugBuffer)]; |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | }); |
145 | 145 | } |
146 | 146 | |
147 | - \curl_setopt($ch, \CURLOPT_WRITEFUNCTION, static function ($ch, string $data) use ($multi, $id): int { |
|
147 | + \curl_setopt($ch, \CURLOPT_WRITEFUNCTION, static function($ch, string $data) use ($multi, $id): int { |
|
148 | 148 | if ('H' === (\curl_getinfo($ch, \CURLINFO_PRIVATE)[0] ?? null)) { |
149 | 149 | $multi->handlesActivity[$id][] = null; |
150 | 150 | $multi->handlesActivity[$id][] = new TransportException(\sprintf('Unsupported protocol for "%s"', \curl_getinfo($ch, \CURLINFO_EFFECTIVE_URL))); |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | return 0; |
153 | 153 | } |
154 | 154 | |
155 | - \curl_setopt($ch, \CURLOPT_WRITEFUNCTION, static function ($ch, string $data) use ($multi, $id): int { |
|
155 | + \curl_setopt($ch, \CURLOPT_WRITEFUNCTION, static function($ch, string $data) use ($multi, $id): int { |
|
156 | 156 | $multi->handlesActivity[$id][] = $data; |
157 | 157 | |
158 | 158 | return \strlen($data); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | return \strlen($data); |
164 | 164 | }); |
165 | 165 | |
166 | - $this->initializer = static function (self $response) { |
|
166 | + $this->initializer = static function(self $response) { |
|
167 | 167 | $waitFor = \curl_getinfo($ch = $response->handle, \CURLINFO_PRIVATE); |
168 | 168 | |
169 | 169 | return 'H' === $waitFor[0]; |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | $multi->openHandles[$id] = [$ch, $options]; |
174 | 174 | curl_multi_add_handle($multi->handle, $ch); |
175 | 175 | |
176 | - $this->canary = new Canary(static function () use ($ch, $multi, $id) { |
|
176 | + $this->canary = new Canary(static function() use ($ch, $multi, $id) { |
|
177 | 177 | unset($multi->pauseExpiries[$id], $multi->openHandles[$id], $multi->handlesActivity[$id]); |
178 | 178 | \curl_setopt($ch, \CURLOPT_PRIVATE, '_0'); |
179 | 179 |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | $response->requestOptions = $options; |
127 | 127 | $response->id = ++self::$idSequence; |
128 | 128 | $response->shouldBuffer = $options['buffer'] ?? true; |
129 | - $response->initializer = static function (self $response) { |
|
129 | + $response->initializer = static function(self $response) { |
|
130 | 130 | return \is_array($response->body[0] ?? null); |
131 | 131 | }; |
132 | 132 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | */ |
225 | 225 | private static function writeRequest(self $response, array $options, ResponseInterface $mock) |
226 | 226 | { |
227 | - $onProgress = $options['on_progress'] ?? static function () {}; |
|
227 | + $onProgress = $options['on_progress'] ?? static function() {}; |
|
228 | 228 | $response->info += $mock->getInfo() ?: []; |
229 | 229 | |
230 | 230 | // simulate "size_upload" if it is set |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | */ |
268 | 268 | private static function readResponse(self $response, array $options, ResponseInterface $mock, int &$offset) |
269 | 269 | { |
270 | - $onProgress = $options['on_progress'] ?? static function () {}; |
|
270 | + $onProgress = $options['on_progress'] ?? static function() {}; |
|
271 | 271 | |
272 | 272 | // populate info related to headers |
273 | 273 | $info = $mock->getInfo() ?: []; |