Skip to content

Commit d243c1d

Browse files
committed
Require PromiseInterface[] as first argument in awaitAll / awaitAny
1 parent ba35f85 commit d243c1d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/functions.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ function ($error) use (&$exception, &$rejected, &$wait, $loop) {
196196
* value, it will still start a timer and will thus trigger at the earliest
197197
* possible time in the future.
198198
*
199-
* @param array $promises
200-
* @param ?LoopInterface $loop
201-
* @param ?float $timeout [deprecated] (optional) maximum timeout in seconds or null=wait forever
199+
* @param PromiseInterface[] $promises
200+
* @param ?LoopInterface $loop
201+
* @param ?float $timeout [deprecated] (optional) maximum timeout in seconds or null=wait forever
202202
* @return mixed returns whatever the first promise resolves to
203203
* @throws Exception if ALL promises are rejected
204204
* @throws TimeoutException if the $timeout is given and triggers
@@ -287,9 +287,9 @@ function awaitAny(array $promises, LoopInterface $loop = null, $timeout = null)
287287
* value, it will still start a timer and will thus trigger at the earliest
288288
* possible time in the future.
289289
*
290-
* @param array $promises
291-
* @param ?LoopInterface $loop
292-
* @param ?float $timeout [deprecated] (optional) maximum timeout in seconds or null=wait forever
290+
* @param PromiseInterface[] $promises
291+
* @param ?LoopInterface $loop
292+
* @param ?float $timeout [deprecated] (optional) maximum timeout in seconds or null=wait forever
293293
* @return array returns an array with whatever each promise resolves to
294294
* @throws Exception when ANY promise is rejected
295295
* @throws TimeoutException if the $timeout is given and triggers
@@ -322,7 +322,7 @@ function awaitAll(array $promises, LoopInterface $loop = null, $timeout = null)
322322
function _cancelAllPromises(array $promises)
323323
{
324324
foreach ($promises as $promise) {
325-
if ($promise instanceof CancellablePromiseInterface || (! \interface_exists('React\Promise\CancellablePromiseInterface') && \method_exists($promise, 'cancel'))) {
325+
if ($promise instanceof PromiseInterface && ($promise instanceof CancellablePromiseInterface || !\interface_exists('React\Promise\CancellablePromiseInterface'))) {
326326
$promise->cancel();
327327
}
328328
}

0 commit comments

Comments
 (0)