function Promise::cancel
Same name in this branch
- 11.1.x vendor/react/promise/src/Promise.php \React\Promise\Promise::cancel()
Overrides PromiseInterface::cancel
File
-
vendor/
guzzlehttp/ promises/ src/ Promise.php, line 88
Class
- Promise
- Promises/A+ implementation that avoids recursion when possible.
Namespace
GuzzleHttp\PromiseCode
public function cancel() : void {
if ($this->state !== self::PENDING) {
return;
}
$this->waitFn = $this->waitList = null;
if ($this->cancelFn) {
$fn = $this->cancelFn;
$this->cancelFn = null;
try {
$fn();
} catch (\Throwable $e) {
$this->reject($e);
}
}
// Reject the promise only if it wasn't rejected in a then callback.
/** @psalm-suppress RedundantCondition */
if ($this->state === self::PENDING) {
$this->reject(new CancellationException('Promise has been cancelled'));
}
}