function EachPromise::addPending
1 call to EachPromise::addPending()
- EachPromise::refillPending in vendor/
guzzlehttp/ promises/ src/ EachPromise.php
File
-
vendor/
guzzlehttp/ promises/ src/ EachPromise.php, line 157
Class
- EachPromise
- Represents a promise that iterates over many promises and invokes side-effect functions in the process.
Namespace
GuzzleHttp\PromiseCode
private function addPending() : bool {
if (!$this->iterable || !$this->iterable
->valid()) {
return false;
}
$promise = Create::promiseFor($this->iterable
->current());
$key = $this->iterable
->key();
// Iterable keys may not be unique, so we use a counter to
// guarantee uniqueness
$idx = $this->nextPendingIndex++;
$this->pending[$idx] = $promise->then(function ($value) use ($idx, $key) : void {
if ($this->onFulfilled) {
($this->onFulfilled)($value, $key, $this->aggregate);
}
$this->step($idx);
}, function ($reason) use ($idx, $key) : void {
if ($this->onRejected) {
($this->onRejected)($reason, $key, $this->aggregate);
}
$this->step($idx);
});
return true;
}