@@ -68,7 +68,7 @@ function reject(\Throwable $reason): PromiseInterface
68
68
* will be an array containing the resolution values of each of the items in
69
69
* `$promisesOrValues`.
70
70
*
71
- * @param iterable $promisesOrValues
71
+ * @param iterable<mixed> $promisesOrValues
72
72
* @return PromiseInterface
73
73
*/
74
74
function all (iterable $ promisesOrValues ): PromiseInterface
@@ -77,6 +77,7 @@ function all(iterable $promisesOrValues): PromiseInterface
77
77
78
78
return new Promise (function ($ resolve , $ reject ) use ($ promisesOrValues , $ cancellationQueue ): void {
79
79
$ toResolve = 0 ;
80
+ /** @var bool */
80
81
$ continue = true ;
81
82
$ values = [];
82
83
@@ -118,7 +119,7 @@ function (\Throwable $reason) use (&$continue, $reject): void {
118
119
* The returned promise will become **infinitely pending** if `$promisesOrValues`
119
120
* contains 0 items.
120
121
*
121
- * @param iterable $promisesOrValues
122
+ * @param iterable<mixed> $promisesOrValues
122
123
* @return PromiseInterface
123
124
*/
124
125
function race (iterable $ promisesOrValues ): PromiseInterface
@@ -153,7 +154,7 @@ function race(iterable $promisesOrValues): PromiseInterface
153
154
* The returned promise will also reject with a `React\Promise\Exception\LengthException`
154
155
* if `$promisesOrValues` contains 0 items.
155
156
*
156
- * @param iterable $promisesOrValues
157
+ * @param iterable<mixed> $promisesOrValues
157
158
* @return PromiseInterface
158
159
*/
159
160
function any (iterable $ promisesOrValues ): PromiseInterface
@@ -215,6 +216,7 @@ function _checkTypehint(callable $callback, \Throwable $reason): bool
215
216
} elseif (\is_object ($ callback ) && !$ callback instanceof \Closure) {
216
217
$ callbackReflection = new \ReflectionMethod ($ callback , '__invoke ' );
217
218
} else {
219
+ assert ($ callback instanceof \Closure || \is_string ($ callback ));
218
220
$ callbackReflection = new \ReflectionFunction ($ callback );
219
221
}
220
222
@@ -257,16 +259,16 @@ function _checkTypehint(callable $callback, \Throwable $reason): bool
257
259
if ($ type instanceof \ReflectionIntersectionType) {
258
260
foreach ($ type ->getTypes () as $ typeToMatch ) {
259
261
assert ($ typeToMatch instanceof \ReflectionNamedType);
260
- if (!( $ matches = ( $ typeToMatch ->isBuiltin () && \gettype ( $ reason ) === $ typeToMatch -> getName ())
261
- || ( new \ ReflectionClass ( $ typeToMatch ->getName ()))-> isInstance ( $ reason ))) {
262
+ $ name = $ typeToMatch ->getName ();
263
+ if (!( $ matches = (! $ typeToMatch ->isBuiltin () && $ reason instanceof $ name ))) {
262
264
break ;
263
265
}
264
266
}
265
267
assert (isset ($ matches ));
266
268
} else {
267
269
assert ($ type instanceof \ReflectionNamedType);
268
- $ matches = ( $ type ->isBuiltin () && \gettype ( $ reason ) === $ type -> getName ())
269
- || ( new \ ReflectionClass ( $ type ->getName ()))-> isInstance ( $ reason) ;
270
+ $ name = $ type ->getName ();
271
+ $ matches = ! $ type ->isBuiltin () && $ reason instanceof $ name ;
270
272
}
271
273
272
274
// If we look for a single match (union), we can return early on match
0 commit comments