class RejectedPromise
Same name in this branch
- 11.1.x vendor/react/promise/src/Internal/RejectedPromise.php \React\Promise\Internal\RejectedPromise
- 11.1.x vendor/guzzlehttp/promises/src/RejectedPromise.php \GuzzleHttp\Promise\RejectedPromise
A rejected promise.
@author Joel Wurtz <joel.wurtz@gmail.com>
Hierarchy
- class \Http\Promise\RejectedPromise implements \Http\Promise\Promise
Expanded class hierarchy of RejectedPromise
File
-
vendor/
php-http/ promise/ src/ RejectedPromise.php, line 10
Namespace
Http\PromiseView source
final class RejectedPromise implements Promise {
/**
* @var \Throwable
*/
private $exception;
public function __construct(\Throwable $exception) {
$this->exception = $exception;
}
public function then(?callable $onFulfilled = null, ?callable $onRejected = null) {
if (null === $onRejected) {
return $this;
}
try {
return new FulfilledPromise($onRejected($this->exception));
} catch (\Exception $e) {
return new self($e);
}
}
public function getState() {
return Promise::REJECTED;
}
public function wait($unwrap = true) {
if ($unwrap) {
throw $this->exception;
}
return null;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
Promise::FULFILLED | constant | Promise has been fulfilled. | ||
Promise::PENDING | constant | Promise has not been fulfilled or rejected. | ||
Promise::REJECTED | constant | Promise has been rejected. | ||
RejectedPromise::$exception | private | property | ||
RejectedPromise::getState | public | function | Returns the state of the promise, one of PENDING, FULFILLED or REJECTED. | Overrides Promise::getState |
RejectedPromise::then | public | function | Adds behavior for when the promise is resolved or rejected (response will be available, or error happens). | Overrides Promise::then |
RejectedPromise::wait | public | function | Wait for the promise to be fulfilled or rejected. | Overrides Promise::wait |
RejectedPromise::__construct | public | function |