@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | public function __construct(callable $generatorFn) |
63 | 63 | { |
64 | 64 | $this->generator = $generatorFn(); |
65 | - $this->result = new Promise(function () { |
|
65 | + $this->result = new Promise(function() { |
|
66 | 66 | while (isset($this->currentPromise)) { |
67 | 67 | $this->currentPromise->wait(); |
68 | 68 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $next = $this->generator->send($value); |
141 | 141 | if ($this->generator->valid()) { |
142 | 142 | $this->nextCoroutine($next); |
143 | - } else { |
|
143 | + }else { |
|
144 | 144 | $this->result->resolve($value); |
145 | 145 | } |
146 | 146 | } catch (Exception $exception) { |
@@ -35,7 +35,7 @@ |
||
35 | 35 | $queue = Utils::queue(); |
36 | 36 | $reason = $this->reason; |
37 | 37 | $p = new Promise([$queue, 'run']); |
38 | - $queue->add(static function () use ($p, $reason, $onRejected) { |
|
38 | + $queue->add(static function() use ($p, $reason, $onRejected) { |
|
39 | 39 | if (Is::pending($p)) { |
40 | 40 | try { |
41 | 41 | // Return a resolved promise if onRejected does not throw. |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | if (!is_object($value) || !method_exists($value, 'then')) { |
149 | 149 | $id = $state === self::FULFILLED ? 1 : 2; |
150 | 150 | // It's a success, so resolve the handlers in the queue. |
151 | - Utils::queue()->add(static function () use ($id, $value, $handlers) { |
|
151 | + Utils::queue()->add(static function() use ($id, $value, $handlers) { |
|
152 | 152 | foreach ($handlers as $handler) { |
153 | 153 | self::callHandler($id, $value, $handler); |
154 | 154 | } |
@@ -156,15 +156,15 @@ discard block |
||
156 | 156 | } elseif ($value instanceof Promise && Is::pending($value)) { |
157 | 157 | // We can just merge our handlers onto the next promise. |
158 | 158 | $value->handlers = array_merge($value->handlers, $handlers); |
159 | - } else { |
|
159 | + }else { |
|
160 | 160 | // Resolve the handlers when the forwarded promise is resolved. |
161 | 161 | $value->then( |
162 | - static function ($value) use ($handlers) { |
|
162 | + static function($value) use ($handlers) { |
|
163 | 163 | foreach ($handlers as $handler) { |
164 | 164 | self::callHandler(1, $value, $handler); |
165 | 165 | } |
166 | 166 | }, |
167 | - static function ($reason) use ($handlers) { |
|
167 | + static function($reason) use ($handlers) { |
|
168 | 168 | foreach ($handlers as $handler) { |
169 | 169 | self::callHandler(2, $reason, $handler); |
170 | 170 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | } elseif ($index === 1) { |
206 | 206 | // Forward resolution values as-is. |
207 | 207 | $promise->resolve($value); |
208 | - } else { |
|
208 | + }else { |
|
209 | 209 | // Forward rejections down the chain. |
210 | 210 | $promise->reject($value); |
211 | 211 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | $this->invokeWaitFn(); |
225 | 225 | } elseif ($this->waitList) { |
226 | 226 | $this->invokeWaitList(); |
227 | - } else { |
|
227 | + }else { |
|
228 | 228 | // If there's no wait function, then reject the promise. |
229 | 229 | $this->reject('Cannot wait on a promise that has ' |
230 | 230 | . 'no internal wait function. You must provide a wait ' |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | // The promise has not been resolved yet, so reject the promise |
252 | 252 | // with the exception. |
253 | 253 | $this->reject($reason); |
254 | - } else { |
|
254 | + }else { |
|
255 | 255 | // The promise was already resolved, so there's a problem in |
256 | 256 | // the application. |
257 | 257 | throw $reason; |
@@ -82,7 +82,7 @@ |
||
82 | 82 | $iterable, |
83 | 83 | $concurrency, |
84 | 84 | $onFulfilled, |
85 | - function ($reason, $idx, PromiseInterface $aggregate) { |
|
85 | + function($reason, $idx, PromiseInterface $aggregate) { |
|
86 | 86 | $aggregate->reject($reason); |
87 | 87 | } |
88 | 88 | ); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | { |
47 | 47 | $queue = self::queue(); |
48 | 48 | $promise = new Promise([$queue, 'run']); |
49 | - $queue->add(function () use ($task, $promise) { |
|
49 | + $queue->add(function() use ($task, $promise) { |
|
50 | 50 | try { |
51 | 51 | if (Is::pending($promise)) { |
52 | 52 | $promise->resolve($task()); |
@@ -155,19 +155,19 @@ discard block |
||
155 | 155 | $results = []; |
156 | 156 | $promise = Each::of( |
157 | 157 | $promises, |
158 | - function ($value, $idx) use (&$results) { |
|
158 | + function($value, $idx) use (&$results) { |
|
159 | 159 | $results[$idx] = $value; |
160 | 160 | }, |
161 | - function ($reason, $idx, Promise $aggregate) { |
|
161 | + function($reason, $idx, Promise $aggregate) { |
|
162 | 162 | $aggregate->reject($reason); |
163 | 163 | } |
164 | - )->then(function () use (&$results) { |
|
164 | + )->then(function() use (&$results) { |
|
165 | 165 | ksort($results); |
166 | 166 | return $results; |
167 | 167 | }); |
168 | 168 | |
169 | 169 | if (true === $recursive) { |
170 | - $promise = $promise->then(function ($results) use ($recursive, &$promises) { |
|
170 | + $promise = $promise->then(function($results) use ($recursive, &$promises) { |
|
171 | 171 | foreach ($promises as $promise) { |
172 | 172 | if (Is::pending($promise)) { |
173 | 173 | return self::all($promises, $recursive); |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | |
204 | 204 | return Each::of( |
205 | 205 | $promises, |
206 | - function ($value, $idx, PromiseInterface $p) use (&$results, $count) { |
|
206 | + function($value, $idx, PromiseInterface $p) use (&$results, $count) { |
|
207 | 207 | if (Is::settled($p)) { |
208 | 208 | return; |
209 | 209 | } |
@@ -212,11 +212,11 @@ discard block |
||
212 | 212 | $p->resolve(null); |
213 | 213 | } |
214 | 214 | }, |
215 | - function ($reason) use (&$rejections) { |
|
215 | + function($reason) use (&$rejections) { |
|
216 | 216 | $rejections[] = $reason; |
217 | 217 | } |
218 | 218 | )->then( |
219 | - function () use (&$results, &$rejections, $count) { |
|
219 | + function() use (&$results, &$rejections, $count) { |
|
220 | 220 | if (count($results) !== $count) { |
221 | 221 | throw new AggregateException( |
222 | 222 | 'Not enough promises to fulfill count', |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | */ |
240 | 240 | public static function any($promises) |
241 | 241 | { |
242 | - return self::some(1, $promises)->then(function ($values) { |
|
242 | + return self::some(1, $promises)->then(function($values) { |
|
243 | 243 | return $values[0]; |
244 | 244 | }); |
245 | 245 | } |
@@ -262,13 +262,13 @@ discard block |
||
262 | 262 | |
263 | 263 | return Each::of( |
264 | 264 | $promises, |
265 | - function ($value, $idx) use (&$results) { |
|
265 | + function($value, $idx) use (&$results) { |
|
266 | 266 | $results[$idx] = ['state' => PromiseInterface::FULFILLED, 'value' => $value]; |
267 | 267 | }, |
268 | - function ($reason, $idx) use (&$results) { |
|
268 | + function($reason, $idx) use (&$results) { |
|
269 | 269 | $results[$idx] = ['state' => PromiseInterface::REJECTED, 'reason' => $reason]; |
270 | 270 | } |
271 | - )->then(function () use (&$results) { |
|
271 | + )->then(function() use (&$results) { |
|
272 | 272 | ksort($results); |
273 | 273 | return $results; |
274 | 274 | }); |
@@ -27,7 +27,7 @@ |
||
27 | 27 | $m = $matches[0]; |
28 | 28 | if (isset($m[1])) { |
29 | 29 | $part[trim($m[0], $trimmed)] = trim($m[1], $trimmed); |
30 | - } else { |
|
30 | + }else { |
|
31 | 31 | $part[] = trim($m[0], $trimmed); |
32 | 32 | } |
33 | 33 | } |
@@ -75,7 +75,7 @@ |
||
75 | 75 | if (empty($method)) { |
76 | 76 | if (!empty($serverParams['REQUEST_METHOD'])) { |
77 | 77 | $method = $serverParams['REQUEST_METHOD']; |
78 | - } else { |
|
78 | + }else { |
|
79 | 79 | throw new \InvalidArgumentException('Cannot determine HTTP method'); |
80 | 80 | } |
81 | 81 | } |
@@ -60,7 +60,7 @@ |
||
60 | 60 | $str .= "{$key}: {$value}\r\n"; |
61 | 61 | } |
62 | 62 | |
63 | - return "--{$this->boundary}\r\n" . trim($str) . "\r\n\r\n"; |
|
63 | + return "--{$this->boundary}\r\n".trim($str)."\r\n\r\n"; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -33,7 +33,7 @@ |
||
33 | 33 | |
34 | 34 | // Create the functions on the class |
35 | 35 | foreach ($methods as $name => $fn) { |
36 | - $this->{'_fn_' . $name} = $fn; |
|
36 | + $this->{'_fn_'.$name} = $fn; |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 |