Skip to content

Commit 25e9bfa

Browse files
committed
Make When::any more error prone against not being a callable
1 parent d6de8ca commit 25e9bfa

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

src/React/Promise/When.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,11 @@ public static function all($promisesOrValues, $fulfilledHandler = null, $errorHa
3030

3131
public static function any($promisesOrValues, $fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
3232
{
33-
$unwrapSingleResult = function ($val) use ($fulfilledHandler) {
34-
$val = array_shift($val);
35-
36-
return $fulfilledHandler ? $fulfilledHandler($val) : $val;
37-
};
33+
$promise = static::some($promisesOrValues, 1)->then(function($val) {
34+
return array_shift($val);
35+
});
3836

39-
return static::some($promisesOrValues, 1, $unwrapSingleResult, $errorHandler, $progressHandler);
37+
return $promise->then($fulfilledHandler, $errorHandler, $progressHandler);
4038
}
4139

4240
public static function some($promisesOrValues, $howMany, $fulfilledHandler = null, $errorHandler = null, $progressHandler = null)

0 commit comments

Comments
 (0)