function FulfilledPromise::then
Same name in this branch
- 11.1.x vendor/react/promise/src/Internal/FulfilledPromise.php \React\Promise\Internal\FulfilledPromise::then()
- 11.1.x vendor/php-http/promise/src/FulfilledPromise.php \Http\Promise\FulfilledPromise::then()
Overrides PromiseInterface::then
1 call to FulfilledPromise::then()
- FulfilledPromise::otherwise in vendor/
guzzlehttp/ promises/ src/ FulfilledPromise.php - Appends a rejection handler callback to the promise, and returns a new promise resolving to the return value of the callback if it is called, or to its original fulfillment value if the promise is instead fulfilled.
File
-
vendor/
guzzlehttp/ promises/ src/ FulfilledPromise.php, line 33
Class
- FulfilledPromise
- A promise that has been fulfilled.
Namespace
GuzzleHttp\PromiseCode
public function then(?callable $onFulfilled = null, ?callable $onRejected = null) : PromiseInterface {
// Return itself if there is no onFulfilled function.
if (!$onFulfilled) {
return $this;
}
$queue = Utils::queue();
$p = new Promise([
$queue,
'run',
]);
$value = $this->value;
$queue->add(static function () use ($p, $value, $onFulfilled) : void {
if (Is::pending($p)) {
try {
$p->resolve($onFulfilled($value));
} catch (\Throwable $e) {
$p->reject($e);
}
}
});
return $p;
}