This commit is contained in:
Javier Casares 2026-06-02 18:49:45 +00:00
commit 1dd5809016

View file

@ -57,6 +57,18 @@ class EachPromise implements PromisorInterface
*/
public function __construct($iterable, array $config = [])
{
if (!is_iterable($iterable)) {
\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__
);
$iterable = [$iterable];
}
$this->iterable = Create::iterFor($iterable);
if (isset($config['concurrency'])) {
@ -84,6 +96,19 @@ class EachPromise implements PromisorInterface
/** @psalm-assert Promise $this->aggregate */
$this->iterable->rewind();
$this->refillPending();
if (!$this->pending) {
Utils::queue()->add(function (): void {
if (!$this->aggregate || Is::settled($this->aggregate)) {
return;
}
try {
$this->checkIfFinished();
} catch (\Throwable $e) {
$this->aggregate->reject($e);
}
});
}
} catch (\Throwable $e) {
$this->aggregate->reject($e);
}