@@ -68,7 +68,7 @@ function reject(\Throwable $reason): PromiseInterface
6868 * will be an array containing the resolution values of each of the items in
6969 * `$promisesOrValues`.
7070 *
71- * @param iterable $promisesOrValues
71+ * @param iterable<mixed> $promisesOrValues
7272 * @return PromiseInterface
7373 */
7474function all (iterable $ promisesOrValues ): PromiseInterface
@@ -77,6 +77,7 @@ function all(iterable $promisesOrValues): PromiseInterface
7777
7878 return new Promise (function ($ resolve , $ reject ) use ($ promisesOrValues , $ cancellationQueue ): void {
7979 $ toResolve = 0 ;
80+ /** @var bool */
8081 $ continue = true ;
8182 $ values = [];
8283
@@ -118,7 +119,7 @@ function (\Throwable $reason) use (&$continue, $reject): void {
118119 * The returned promise will become **infinitely pending** if `$promisesOrValues`
119120 * contains 0 items.
120121 *
121- * @param iterable $promisesOrValues
122+ * @param iterable<mixed> $promisesOrValues
122123 * @return PromiseInterface
123124 */
124125function race (iterable $ promisesOrValues ): PromiseInterface
@@ -153,7 +154,7 @@ function race(iterable $promisesOrValues): PromiseInterface
153154 * The returned promise will also reject with a `React\Promise\Exception\LengthException`
154155 * if `$promisesOrValues` contains 0 items.
155156 *
156- * @param iterable $promisesOrValues
157+ * @param iterable<mixed> $promisesOrValues
157158 * @return PromiseInterface
158159 */
159160function any (iterable $ promisesOrValues ): PromiseInterface
@@ -215,6 +216,7 @@ function _checkTypehint(callable $callback, \Throwable $reason): bool
215216 } elseif (\is_object ($ callback ) && !$ callback instanceof \Closure) {
216217 $ callbackReflection = new \ReflectionMethod ($ callback , '__invoke ' );
217218 } else {
219+ assert ($ callback instanceof \Closure || \is_string ($ callback ));
218220 $ callbackReflection = new \ReflectionFunction ($ callback );
219221 }
220222
@@ -257,16 +259,16 @@ function _checkTypehint(callable $callback, \Throwable $reason): bool
257259 if ($ type instanceof \ReflectionIntersectionType) {
258260 foreach ($ type ->getTypes () as $ typeToMatch ) {
259261 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 ))) {
262264 break ;
263265 }
264266 }
265267 assert (isset ($ matches ));
266268 } else {
267269 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 ;
270272 }
271273
272274 // If we look for a single match (union), we can return early on match
0 commit comments