@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | { |
182 | 182 | $regex = '/(?:%[A-Fa-f0-9]{2})++/'; |
183 | 183 | |
184 | - $callback = function (array $match) { |
|
184 | + $callback = function(array $match) { |
|
185 | 185 | return strtoupper($match[0]); |
186 | 186 | }; |
187 | 187 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | { |
198 | 198 | $regex = '/%(?:2D|2E|5F|7E|3[0-9]|[46][1-9A-F]|[57][0-9A])/i'; |
199 | 199 | |
200 | - $callback = function (array $match) { |
|
200 | + $callback = function(array $match) { |
|
201 | 201 | return rawurldecode($match[0]); |
202 | 202 | }; |
203 | 203 |
@@ -18,7 +18,7 @@ |
||
18 | 18 | public function __construct($withShutdown = true) |
19 | 19 | { |
20 | 20 | if ($withShutdown) { |
21 | - register_shutdown_function(function () { |
|
21 | + register_shutdown_function(function() { |
|
22 | 22 | if ($this->enableShutdown) { |
23 | 23 | // Only run the tasks if an E_ERROR didn't occur. |
24 | 24 | $err = error_get_last(); |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | if (!method_exists($value, 'then')) { |
152 | 152 | $id = $state === self::FULFILLED ? 1 : 2; |
153 | 153 | // It's a success, so resolve the handlers in the queue. |
154 | - queue()->add(static function () use ($id, $value, $handlers) { |
|
154 | + queue()->add(static function() use ($id, $value, $handlers) { |
|
155 | 155 | foreach ($handlers as $handler) { |
156 | 156 | self::callHandler($id, $value, $handler); |
157 | 157 | } |
@@ -164,12 +164,12 @@ discard block |
||
164 | 164 | } else { |
165 | 165 | // Resolve the handlers when the forwarded promise is resolved. |
166 | 166 | $value->then( |
167 | - static function ($value) use ($handlers) { |
|
167 | + static function($value) use ($handlers) { |
|
168 | 168 | foreach ($handlers as $handler) { |
169 | 169 | self::callHandler(1, $value, $handler); |
170 | 170 | } |
171 | 171 | }, |
172 | - static function ($reason) use ($handlers) { |
|
172 | + static function($reason) use ($handlers) { |
|
173 | 173 | foreach ($handlers as $handler) { |
174 | 174 | self::callHandler(2, $reason, $handler); |
175 | 175 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | $queue = queue(); |
34 | 34 | $reason = $this->reason; |
35 | 35 | $p = new Promise([$queue, 'run']); |
36 | - $queue->add(static function () use ($p, $reason, $onRejected) { |
|
36 | + $queue->add(static function() use ($p, $reason, $onRejected) { |
|
37 | 37 | if ($p->getState() === self::PENDING) { |
38 | 38 | try { |
39 | 39 | // Return a resolved promise if onRejected does not throw. |
@@ -60,7 +60,7 @@ |
||
60 | 60 | public function __construct(callable $generatorFn) |
61 | 61 | { |
62 | 62 | $this->generator = $generatorFn(); |
63 | - $this->result = new Promise(function () { |
|
63 | + $this->result = new Promise(function() { |
|
64 | 64 | while (isset($this->currentPromise)) { |
65 | 65 | $this->currentPromise->wait(); |
66 | 66 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | { |
44 | 44 | $queue = queue(); |
45 | 45 | $promise = new Promise([$queue, 'run']); |
46 | - $queue->add(function () use ($task, $promise) { |
|
46 | + $queue->add(function() use ($task, $promise) { |
|
47 | 47 | try { |
48 | 48 | $promise->resolve($task()); |
49 | 49 | } catch (\Throwable $e) { |
@@ -221,13 +221,13 @@ discard block |
||
221 | 221 | $results = []; |
222 | 222 | return each( |
223 | 223 | $promises, |
224 | - function ($value, $idx) use (&$results) { |
|
224 | + function($value, $idx) use (&$results) { |
|
225 | 225 | $results[$idx] = $value; |
226 | 226 | }, |
227 | - function ($reason, $idx, Promise $aggregate) { |
|
227 | + function($reason, $idx, Promise $aggregate) { |
|
228 | 228 | $aggregate->reject($reason); |
229 | 229 | } |
230 | - )->then(function () use (&$results) { |
|
230 | + )->then(function() use (&$results) { |
|
231 | 231 | ksort($results); |
232 | 232 | return $results; |
233 | 233 | }); |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | |
257 | 257 | return each( |
258 | 258 | $promises, |
259 | - function ($value, $idx, PromiseInterface $p) use (&$results, $count) { |
|
259 | + function($value, $idx, PromiseInterface $p) use (&$results, $count) { |
|
260 | 260 | if ($p->getState() !== PromiseInterface::PENDING) { |
261 | 261 | return; |
262 | 262 | } |
@@ -265,11 +265,11 @@ discard block |
||
265 | 265 | $p->resolve(null); |
266 | 266 | } |
267 | 267 | }, |
268 | - function ($reason) use (&$rejections) { |
|
268 | + function($reason) use (&$rejections) { |
|
269 | 269 | $rejections[] = $reason; |
270 | 270 | } |
271 | 271 | )->then( |
272 | - function () use (&$results, &$rejections, $count) { |
|
272 | + function() use (&$results, &$rejections, $count) { |
|
273 | 273 | if (count($results) !== $count) { |
274 | 274 | throw new AggregateException( |
275 | 275 | 'Not enough promises to fulfill count', |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | */ |
293 | 293 | function any($promises) |
294 | 294 | { |
295 | - return some(1, $promises)->then(function ($values) { return $values[0]; }); |
|
295 | + return some(1, $promises)->then(function($values) { return $values[0]; }); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | /** |
@@ -312,13 +312,13 @@ discard block |
||
312 | 312 | |
313 | 313 | return each( |
314 | 314 | $promises, |
315 | - function ($value, $idx) use (&$results) { |
|
315 | + function($value, $idx) use (&$results) { |
|
316 | 316 | $results[$idx] = ['state' => PromiseInterface::FULFILLED, 'value' => $value]; |
317 | 317 | }, |
318 | - function ($reason, $idx) use (&$results) { |
|
318 | + function($reason, $idx) use (&$results) { |
|
319 | 319 | $results[$idx] = ['state' => PromiseInterface::REJECTED, 'reason' => $reason]; |
320 | 320 | } |
321 | - )->then(function () use (&$results) { |
|
321 | + )->then(function() use (&$results) { |
|
322 | 322 | ksort($results); |
323 | 323 | return $results; |
324 | 324 | }); |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | $iterable, |
403 | 403 | $concurrency, |
404 | 404 | $onFulfilled, |
405 | - function ($reason, $idx, PromiseInterface $aggregate) { |
|
405 | + function($reason, $idx, PromiseInterface $aggregate) { |
|
406 | 406 | $aggregate->reject($reason); |
407 | 407 | } |
408 | 408 | ); |
@@ -33,7 +33,7 @@ |
||
33 | 33 | $queue = queue(); |
34 | 34 | $p = new Promise([$queue, 'run']); |
35 | 35 | $value = $this->value; |
36 | - $queue->add(static function () use ($p, $value, $onFulfilled) { |
|
36 | + $queue->add(static function() use ($p, $value, $onFulfilled) { |
|
37 | 37 | if ($p->getState() === self::PENDING) { |
38 | 38 | try { |
39 | 39 | $p->resolve($onFulfilled($value)); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | private function createPromise() |
88 | 88 | { |
89 | 89 | $this->mutex = false; |
90 | - $this->aggregate = new Promise(function () { |
|
90 | + $this->aggregate = new Promise(function() { |
|
91 | 91 | reset($this->pending); |
92 | 92 | if (empty($this->pending) && !$this->iterable->valid()) { |
93 | 93 | $this->aggregate->resolve(null); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | }); |
107 | 107 | |
108 | 108 | // Clear the references when the promise is resolved. |
109 | - $clearFn = function () { |
|
109 | + $clearFn = function() { |
|
110 | 110 | $this->iterable = $this->concurrency = $this->pending = null; |
111 | 111 | $this->onFulfilled = $this->onRejected = null; |
112 | 112 | }; |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $idx = $this->iterable->key(); |
153 | 153 | |
154 | 154 | $this->pending[$idx] = $promise->then( |
155 | - function ($value) use ($idx) { |
|
155 | + function($value) use ($idx) { |
|
156 | 156 | if ($this->onFulfilled) { |
157 | 157 | call_user_func( |
158 | 158 | $this->onFulfilled, $value, $idx, $this->aggregate |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | } |
161 | 161 | $this->step($idx); |
162 | 162 | }, |
163 | - function ($reason) use ($idx) { |
|
163 | + function($reason) use ($idx) { |
|
164 | 164 | if ($this->onRejected) { |
165 | 165 | call_user_func( |
166 | 166 | $this->onRejected, $reason, $idx, $this->aggregate |