← All changes
|
vendor_prefixed/guzzlehttp/promises/src/EachPromise.php
+16
-0
27.6
→
trunk
View file →
| @@ -47,8 +47,12 @@ | ||
| 47 | 47 | * @param array $config Configuration options |
| 48 | 48 | */ |
| 49 | 49 | public function __construct($iterable, array $config = []) |
| 50 | 50 | { |
| 51 | + if (!\is_iterable($iterable)) { | |
| 52 | + \YoastSEO_Vendor\trigger_deprecation('guzzlehttp/promises', '2.5', 'Passing a non-iterable to %s::%s() is deprecated; guzzlehttp/promises 3.0 will require an iterable.', __CLASS__, __FUNCTION__); | |
| 53 | + $iterable = [$iterable]; | |
| 54 | + } | |
| 51 | 55 | $this->iterable = \YoastSEO_Vendor\GuzzleHttp\Promise\Create::iterFor($iterable); |
| 52 | 56 | if (isset($config['concurrency'])) { |
| 53 | 57 | $this->concurrency = $config['concurrency']; |
| 54 | 58 | } |
| @@ -69,8 +73,20 @@ | ||
| 69 | 73 | $this->createPromise(); |
| 70 | 74 | /** @psalm-assert Promise $this->aggregate */ |
| 71 | 75 | $this->iterable->rewind(); |
| 72 | 76 | $this->refillPending(); |
| 77 | + if (!$this->pending) { | |
| 78 | + \YoastSEO_Vendor\GuzzleHttp\Promise\Utils::queue()->add(function () : void { | |
| 79 | + if (!$this->aggregate || \YoastSEO_Vendor\GuzzleHttp\Promise\Is::settled($this->aggregate)) { | |
| 80 | + return; | |
| 81 | + } | |
| 82 | + try { | |
| 83 | + $this->checkIfFinished(); | |
| 84 | + } catch (\Throwable $e) { | |
| 85 | + $this->aggregate->reject($e); | |
| 86 | + } | |
| 87 | + }); | |
| 88 | + } | |
| 73 | 89 | } catch (\Throwable $e) { |
| 74 | 90 | $this->aggregate->reject($e); |
| 75 | 91 | } |
| 76 | 92 | /** |