@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param callable(TThrowable): (PromiseInterface<TRejected>|TRejected) $onRejected |
83 | 83 | * @return PromiseInterface<TRejected> |
84 | 84 | */ |
85 | - public function catch(callable $onRejected): PromiseInterface |
|
85 | + public function catch (callable $onRejected): PromiseInterface |
|
86 | 86 | { |
87 | 87 | if (!_checkTypehint($onRejected, $this->reason)) { |
88 | 88 | return $this; |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | |
97 | 97 | public function finally(callable $onFulfilledOrRejected): PromiseInterface |
98 | 98 | { |
99 | - return $this->then(null, function (\Throwable $reason) use ($onFulfilledOrRejected): PromiseInterface { |
|
100 | - return resolve($onFulfilledOrRejected())->then(function () use ($reason): PromiseInterface { |
|
99 | + return $this->then(null, function(\Throwable $reason) use ($onFulfilledOrRejected): PromiseInterface { |
|
100 | + return resolve($onFulfilledOrRejected())->then(function() use ($reason): PromiseInterface { |
|
101 | 101 | return new RejectedPromise($reason); |
102 | 102 | }); |
103 | 103 | }); |
@@ -54,7 +54,7 @@ |
||
54 | 54 | * @param callable(TThrowable): (PromiseInterface<TRejected>|TRejected) $onRejected |
55 | 55 | * @return PromiseInterface<T|TRejected> |
56 | 56 | */ |
57 | - public function catch(callable $onRejected): PromiseInterface; |
|
57 | + public function catch (callable $onRejected): PromiseInterface; |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Allows you to execute "cleanup" type tasks in a promise chain. |
@@ -23,7 +23,7 @@ |
||
23 | 23 | */ |
24 | 24 | public function __construct(?callable $canceller = null) |
25 | 25 | { |
26 | - $this->promise = new Promise(function ($resolve, $reject): void { |
|
26 | + $this->promise = new Promise(function($resolve, $reject): void { |
|
27 | 27 | $this->resolveCallback = $resolve; |
28 | 28 | $this->rejectCallback = $reject; |
29 | 29 | }, $canceller); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | } |
37 | 37 | |
38 | 38 | /** @var Promise<T> */ |
39 | - return new Promise(function (callable $resolve, callable $reject) use ($promiseOrValue): void { |
|
39 | + return new Promise(function(callable $resolve, callable $reject) use ($promiseOrValue): void { |
|
40 | 40 | $promiseOrValue->then($resolve, $reject); |
41 | 41 | }, $canceller); |
42 | 42 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $cancellationQueue = new Internal\CancellationQueue(); |
80 | 80 | |
81 | 81 | /** @var Promise<array<T>> */ |
82 | - return new Promise(function (callable $resolve, callable $reject) use ($promisesOrValues, $cancellationQueue): void { |
|
82 | + return new Promise(function(callable $resolve, callable $reject) use ($promisesOrValues, $cancellationQueue): void { |
|
83 | 83 | $toResolve = 0; |
84 | 84 | /** @var bool */ |
85 | 85 | $continue = true; |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | ++$toResolve; |
92 | 92 | |
93 | 93 | resolve($promiseOrValue)->then( |
94 | - function ($value) use ($i, &$values, &$toResolve, &$continue, $resolve): void { |
|
94 | + function($value) use ($i, &$values, &$toResolve, &$continue, $resolve): void { |
|
95 | 95 | $values[$i] = $value; |
96 | 96 | |
97 | 97 | if (0 === --$toResolve && !$continue) { |
98 | 98 | $resolve($values); |
99 | 99 | } |
100 | 100 | }, |
101 | - function (\Throwable $reason) use (&$continue, $reject): void { |
|
101 | + function(\Throwable $reason) use (&$continue, $reject): void { |
|
102 | 102 | $continue = false; |
103 | 103 | $reject($reason); |
104 | 104 | } |
@@ -132,13 +132,13 @@ discard block |
||
132 | 132 | $cancellationQueue = new Internal\CancellationQueue(); |
133 | 133 | |
134 | 134 | /** @var Promise<T> */ |
135 | - return new Promise(function (callable $resolve, callable $reject) use ($promisesOrValues, $cancellationQueue): void { |
|
135 | + return new Promise(function(callable $resolve, callable $reject) use ($promisesOrValues, $cancellationQueue): void { |
|
136 | 136 | $continue = true; |
137 | 137 | |
138 | 138 | foreach ($promisesOrValues as $promiseOrValue) { |
139 | 139 | $cancellationQueue->enqueue($promiseOrValue); |
140 | 140 | |
141 | - resolve($promiseOrValue)->then($resolve, $reject)->finally(function () use (&$continue): void { |
|
141 | + resolve($promiseOrValue)->then($resolve, $reject)->finally(function() use (&$continue): void { |
|
142 | 142 | $continue = false; |
143 | 143 | }); |
144 | 144 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | $cancellationQueue = new Internal\CancellationQueue(); |
170 | 170 | |
171 | 171 | /** @var Promise<T> */ |
172 | - return new Promise(function (callable $resolve, callable $reject) use ($promisesOrValues, $cancellationQueue): void { |
|
172 | + return new Promise(function(callable $resolve, callable $reject) use ($promisesOrValues, $cancellationQueue): void { |
|
173 | 173 | $toReject = 0; |
174 | 174 | $continue = true; |
175 | 175 | $reasons = []; |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | ++$toReject; |
180 | 180 | |
181 | 181 | resolve($promiseOrValue)->then( |
182 | - function ($value) use ($resolve, &$continue): void { |
|
182 | + function($value) use ($resolve, &$continue): void { |
|
183 | 183 | $continue = false; |
184 | 184 | $resolve($value); |
185 | 185 | }, |
186 | - function (\Throwable $reason) use ($i, &$reasons, &$toReject, $reject, &$continue): void { |
|
186 | + function(\Throwable $reason) use ($i, &$reasons, &$toReject, $reject, &$continue): void { |
|
187 | 187 | $reasons[$i] = $reason; |
188 | 188 | |
189 | 189 | if (0 === --$toReject && !$continue) { |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | return new static( |
63 | 63 | $this->resolver($onFulfilled, $onRejected), |
64 | - static function () use (&$parent): void { |
|
64 | + static function() use (&$parent): void { |
|
65 | 65 | assert($parent instanceof self); |
66 | 66 | --$parent->requiredCancelRequests; |
67 | 67 | |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | * @param callable(TThrowable): (PromiseInterface<TRejected>|TRejected) $onRejected |
81 | 81 | * @return PromiseInterface<T|TRejected> |
82 | 82 | */ |
83 | - public function catch(callable $onRejected): PromiseInterface |
|
83 | + public function catch (callable $onRejected): PromiseInterface |
|
84 | 84 | { |
85 | - return $this->then(null, static function (\Throwable $reason) use ($onRejected) { |
|
85 | + return $this->then(null, static function(\Throwable $reason) use ($onRejected) { |
|
86 | 86 | if (!_checkTypehint($onRejected, $reason)) { |
87 | 87 | return new RejectedPromise($reason); |
88 | 88 | } |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | |
97 | 97 | public function finally(callable $onFulfilledOrRejected): PromiseInterface |
98 | 98 | { |
99 | - return $this->then(static function ($value) use ($onFulfilledOrRejected): PromiseInterface { |
|
100 | - return resolve($onFulfilledOrRejected())->then(function () use ($value) { |
|
99 | + return $this->then(static function($value) use ($onFulfilledOrRejected): PromiseInterface { |
|
100 | + return resolve($onFulfilledOrRejected())->then(function() use ($value) { |
|
101 | 101 | return $value; |
102 | 102 | }); |
103 | - }, static function (\Throwable $reason) use ($onFulfilledOrRejected): PromiseInterface { |
|
104 | - return resolve($onFulfilledOrRejected())->then(function () use ($reason): RejectedPromise { |
|
103 | + }, static function(\Throwable $reason) use ($onFulfilledOrRejected): PromiseInterface { |
|
104 | + return resolve($onFulfilledOrRejected())->then(function() use ($reason): RejectedPromise { |
|
105 | 105 | return new RejectedPromise($reason); |
106 | 106 | }); |
107 | 107 | }); |
@@ -168,12 +168,12 @@ discard block |
||
168 | 168 | |
169 | 169 | private function resolver(?callable $onFulfilled = null, ?callable $onRejected = null): callable |
170 | 170 | { |
171 | - return function (callable $resolve, callable $reject) use ($onFulfilled, $onRejected): void { |
|
172 | - $this->handlers[] = static function (PromiseInterface $promise) use ($onFulfilled, $onRejected, $resolve, $reject): void { |
|
171 | + return function(callable $resolve, callable $reject) use ($onFulfilled, $onRejected) : void { |
|
172 | + $this->handlers[] = static function(PromiseInterface $promise) use ($onFulfilled, $onRejected, $resolve, $reject) : void { |
|
173 | 173 | $promise = $promise->then($onFulfilled, $onRejected); |
174 | 174 | |
175 | 175 | if ($promise instanceof self && $promise->result === null) { |
176 | - $promise->handlers[] = static function (PromiseInterface $promise) use ($resolve, $reject): void { |
|
176 | + $promise->handlers[] = static function(PromiseInterface $promise) use ($resolve, $reject): void { |
|
177 | 177 | $promise->then($resolve, $reject); |
178 | 178 | }; |
179 | 179 | } else { |
@@ -278,16 +278,16 @@ discard block |
||
278 | 278 | // garbage cycles if any callback creates an Exception. |
279 | 279 | // These assumptions are covered by the test suite, so if you ever feel like |
280 | 280 | // refactoring this, go ahead, any alternative suggestions are welcome! |
281 | - $target =& $this; |
|
281 | + $target = & $this; |
|
282 | 282 | |
283 | 283 | $callback( |
284 | - static function ($value) use (&$target): void { |
|
284 | + static function($value) use (&$target): void { |
|
285 | 285 | if ($target !== null) { |
286 | 286 | $target->settle(resolve($value)); |
287 | 287 | $target = null; |
288 | 288 | } |
289 | 289 | }, |
290 | - static function (\Throwable $reason) use (&$target): void { |
|
290 | + static function(\Throwable $reason) use (&$target): void { |
|
291 | 291 | if ($target !== null) { |
292 | 292 | $target->reject($reason); |
293 | 293 | $target = null; |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if (!\function_exists('React\Promise\resolve')) { |
4 | - require __DIR__.'/functions.php'; |
|
4 | + require __DIR__ . '/functions.php'; |
|
5 | 5 | } |
@@ -22,6 +22,6 @@ |
||
22 | 22 | */ |
23 | 23 | function trigger_deprecation(string $package, string $version, string $message, mixed ...$args): void |
24 | 24 | { |
25 | - @trigger_error(($package || $version ? "Since $package $version: " : '').($args ? vsprintf($message, $args) : $message), \E_USER_DEPRECATED); |
|
25 | + @trigger_error(($package || $version ? "Since $package $version: " : '') . ($args ? vsprintf($message, $args) : $message), \E_USER_DEPRECATED); |
|
26 | 26 | } |
27 | 27 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | use Symfony\Polyfill\Ctype as p; |
13 | 13 | |
14 | 14 | if (\PHP_VERSION_ID >= 80000) { |
15 | - return require __DIR__.'/bootstrap80.php'; |
|
15 | + return require __DIR__ . '/bootstrap80.php'; |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | if (!function_exists('ctype_alnum')) { |
@@ -220,7 +220,7 @@ |
||
220 | 220 | } |
221 | 221 | |
222 | 222 | if (\PHP_VERSION_ID >= 80100) { |
223 | - @trigger_error($function.'(): Argument of type int will be interpreted as string in the future', \E_USER_DEPRECATED); |
|
223 | + @trigger_error($function . '(): Argument of type int will be interpreted as string in the future', \E_USER_DEPRECATED); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | if ($int < 0) { |