Skip to content

Commit

Permalink
Require PromiseInterface[] as first argument in awaitAll / awaitAny
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonFrings committed Oct 18, 2021
1 parent ba35f85 commit d243c1d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ function ($error) use (&$exception, &$rejected, &$wait, $loop) {
* value, it will still start a timer and will thus trigger at the earliest
* possible time in the future.
*
* @param array $promises
* @param ?LoopInterface $loop
* @param ?float $timeout [deprecated] (optional) maximum timeout in seconds or null=wait forever
* @param PromiseInterface[] $promises
* @param ?LoopInterface $loop
* @param ?float $timeout [deprecated] (optional) maximum timeout in seconds or null=wait forever
* @return mixed returns whatever the first promise resolves to
* @throws Exception if ALL promises are rejected
* @throws TimeoutException if the $timeout is given and triggers
Expand Down Expand Up @@ -287,9 +287,9 @@ function awaitAny(array $promises, LoopInterface $loop = null, $timeout = null)
* value, it will still start a timer and will thus trigger at the earliest
* possible time in the future.
*
* @param array $promises
* @param ?LoopInterface $loop
* @param ?float $timeout [deprecated] (optional) maximum timeout in seconds or null=wait forever
* @param PromiseInterface[] $promises
* @param ?LoopInterface $loop
* @param ?float $timeout [deprecated] (optional) maximum timeout in seconds or null=wait forever
* @return array returns an array with whatever each promise resolves to
* @throws Exception when ANY promise is rejected
* @throws TimeoutException if the $timeout is given and triggers
Expand Down Expand Up @@ -322,7 +322,7 @@ function awaitAll(array $promises, LoopInterface $loop = null, $timeout = null)
function _cancelAllPromises(array $promises)
{
foreach ($promises as $promise) {
if ($promise instanceof CancellablePromiseInterface || (! \interface_exists('React\Promise\CancellablePromiseInterface') && \method_exists($promise, 'cancel'))) {
if ($promise instanceof PromiseInterface && ($promise instanceof CancellablePromiseInterface || !\interface_exists('React\Promise\CancellablePromiseInterface'))) {
$promise->cancel();
}
}
Expand Down

0 comments on commit d243c1d

Please sign in to comment.