class FulfilledPromise in Auth0 Single Sign On 8.2
A promise that has been fulfilled.
Thenning off of this promise will invoke the onFulfilled callback immediately and ignore other callbacks.
Hierarchy
- class \GuzzleHttp\Promise\FulfilledPromise implements PromiseInterface
Expanded class hierarchy of FulfilledPromise
2 files declare their use of FulfilledPromise
- CurlFactory.php in vendor/
guzzlehttp/ guzzle/ src/ Handler/ CurlFactory.php - StreamHandler.php in vendor/
guzzlehttp/ guzzle/ src/ Handler/ StreamHandler.php
File
- vendor/
guzzlehttp/ promises/ src/ FulfilledPromise.php, line 10
Namespace
GuzzleHttp\PromiseView source
class FulfilledPromise implements PromiseInterface {
private $value;
public function __construct($value) {
if (method_exists($value, 'then')) {
throw new \InvalidArgumentException('You cannot create a FulfilledPromise with a promise.');
}
$this->value = $value;
}
public function then(callable $onFulfilled = null, callable $onRejected = null) {
// Return itself if there is no onFulfilled function.
if (!$onFulfilled) {
return $this;
}
$queue = queue();
$p = new Promise([
$queue,
'run',
]);
$value = $this->value;
$queue
->add(static function () use ($p, $value, $onFulfilled) {
if ($p
->getState() === self::PENDING) {
try {
$p
->resolve($onFulfilled($value));
} catch (\Throwable $e) {
$p
->reject($e);
} catch (\Exception $e) {
$p
->reject($e);
}
}
});
return $p;
}
public function otherwise(callable $onRejected) {
return $this
->then(null, $onRejected);
}
public function wait($unwrap = true, $defaultDelivery = null) {
return $unwrap ? $this->value : null;
}
public function getState() {
return self::FULFILLED;
}
public function resolve($value) {
if ($value !== $this->value) {
throw new \LogicException("Cannot resolve a fulfilled promise");
}
}
public function reject($reason) {
throw new \LogicException("Cannot reject a fulfilled promise");
}
public function cancel() {
// pass
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FulfilledPromise:: |
private | property | ||
FulfilledPromise:: |
public | function |
Cancels the promise if possible. Overrides PromiseInterface:: |
|
FulfilledPromise:: |
public | function |
Get the state of the promise ("pending", "rejected", or "fulfilled"). Overrides PromiseInterface:: |
|
FulfilledPromise:: |
public | function |
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. Overrides PromiseInterface:: |
|
FulfilledPromise:: |
public | function |
Reject the promise with the given reason. Overrides PromiseInterface:: |
|
FulfilledPromise:: |
public | function |
Resolve the promise with the given value. Overrides PromiseInterface:: |
|
FulfilledPromise:: |
public | function |
Appends fulfillment and rejection handlers to the promise, and returns
a new promise resolving to the return value of the called handler. Overrides PromiseInterface:: |
|
FulfilledPromise:: |
public | function |
Waits until the promise completes if possible. Overrides PromiseInterface:: |
|
FulfilledPromise:: |
public | function | ||
PromiseInterface:: |
constant | |||
PromiseInterface:: |
constant | |||
PromiseInterface:: |
constant |