From c4278663b9244b5728e25dfeea64f02e4fa3409a Mon Sep 17 00:00:00 2001 From: Beno!t POLASZEK Date: Thu, 22 Dec 2016 13:59:52 +0100 Subject: [PATCH] Added a recursive option to all() function. Fixes #46 --- src/functions.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/functions.php b/src/functions.php index e63b715..db9e89a 100644 --- a/src/functions.php +++ b/src/functions.php @@ -231,6 +231,15 @@ function ($reason, $idx, Promise $aggregate) { )->then(function () use (&$results) { ksort($results); return $results; + })->then(function ($results) use ($recursive, &$promises) { + if (true === $recursive && !$promises instanceof \Generator) { + foreach ($promises AS $promise) { + if (\GuzzleHttp\Promise\PromiseInterface::PENDING === $promise->getState()) { + return all($promises, $recursive); + } + } + } + return $results; }); if (true === $recursive) {