class FulfilledPromise
Same name in this branch
- 11.1.x vendor/php-http/promise/src/FulfilledPromise.php \Http\Promise\FulfilledPromise
- 11.1.x vendor/guzzlehttp/promises/src/FulfilledPromise.php \GuzzleHttp\Promise\FulfilledPromise
@internal
@template T @template-implements PromiseInterface<T>
Hierarchy
- class \React\Promise\Internal\FulfilledPromise implements \React\Promise\PromiseInterface
Expanded class hierarchy of FulfilledPromise
1 file declares its use of FulfilledPromise
- functions.php in vendor/
react/ promise/ src/ functions.php
File
-
vendor/
react/ promise/ src/ Internal/ FulfilledPromise.php, line 14
Namespace
React\Promise\InternalView source
final class FulfilledPromise implements PromiseInterface {
/** @var T */
private $value;
/**
* @param T $value
* @throws \InvalidArgumentException
*/
public function __construct($value = null) {
if ($value instanceof PromiseInterface) {
throw new \InvalidArgumentException('You cannot create React\\Promise\\FulfilledPromise with a promise. Use React\\Promise\\resolve($promiseOrValue) instead.');
}
$this->value = $value;
}
/**
* @template TFulfilled
* @param ?(callable((T is void ? null : T)): (PromiseInterface<TFulfilled>|TFulfilled)) $onFulfilled
* @return PromiseInterface<($onFulfilled is null ? T : TFulfilled)>
*/
public function then(?callable $onFulfilled = null, ?callable $onRejected = null) : PromiseInterface {
if (null === $onFulfilled) {
return $this;
}
try {
/**
* @var PromiseInterface<T>|T $result
*/
$result = $onFulfilled($this->value);
return resolve($result);
} catch (\Throwable $exception) {
return new RejectedPromise($exception);
}
}
public function catch(callable $onRejected) : PromiseInterface {
return $this;
}
public function finally(callable $onFulfilledOrRejected) : PromiseInterface {
return $this->then(function ($value) use ($onFulfilledOrRejected) : PromiseInterface {
return resolve($onFulfilledOrRejected())->then(function () use ($value) {
return $value;
});
});
}
public function cancel() : void {
}
/**
* @deprecated 3.0.0 Use `catch()` instead
* @see self::catch()
*/
public function otherwise(callable $onRejected) : PromiseInterface {
return $this->catch($onRejected);
}
/**
* @deprecated 3.0.0 Use `finally()` instead
* @see self::finally()
*/
public function always(callable $onFulfilledOrRejected) : PromiseInterface {
return $this->finally($onFulfilledOrRejected);
}
}
Members
Title Sort descending | Deprecated | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|---|
FulfilledPromise::$value | private | property | @var T | ||
FulfilledPromise::always | Deprecated | public | function | Overrides PromiseInterface::always | |
FulfilledPromise::cancel | public | function | The `cancel()` method notifies the creator of the promise that there is no further interest in the results of the operation. |
Overrides PromiseInterface::cancel | |
FulfilledPromise::catch | public | function | Registers a rejection handler for promise. It is a shortcut for: | Overrides PromiseInterface::catch | |
FulfilledPromise::finally | public | function | Allows you to execute "cleanup" type tasks in a promise chain. | Overrides PromiseInterface::finally | |
FulfilledPromise::otherwise | Deprecated | public | function | Overrides PromiseInterface::otherwise | |
FulfilledPromise::then | public | function | @template TFulfilled | Overrides PromiseInterface::then | |
FulfilledPromise::__construct | public | function |