function resolve
Creates a promise for the supplied `$promiseOrValue`.
If `$promiseOrValue` is a value, it will be the resolution value of the returned promise.
If `$promiseOrValue` is a thenable (any object that provides a `then()` method), a trusted promise that follows the state of the thenable is returned.
If `$promiseOrValue` is a promise, it will be returned as is.
@template T
Parameters
PromiseInterface<T>|T $promiseOrValue:
Return value
PromiseInterface<T>
3 calls to resolve()
- FulfilledPromise::then in vendor/
react/ promise/ src/ Internal/ FulfilledPromise.php - @template TFulfilled
- Promise::call in vendor/
react/ promise/ src/ Promise.php - RejectedPromise::then in vendor/
react/ promise/ src/ Internal/ RejectedPromise.php - @template TRejected
2 string references to 'resolve'
- Create::promiseFor in vendor/
guzzlehttp/ promises/ src/ Create.php - Creates a promise for a value if the value is not a promise.
- EnvVarProcessor::getEnv in vendor/
symfony/ dependency-injection/ EnvVarProcessor.php - Returns the value of the given variable as managed by the current instance.
File
-
vendor/
react/ promise/ src/ functions.php, line 24
Namespace
React\PromiseCode
function resolve($promiseOrValue) : PromiseInterface {
if ($promiseOrValue instanceof PromiseInterface) {
return $promiseOrValue;
}
if (\is_object($promiseOrValue) && \method_exists($promiseOrValue, 'then')) {
$canceller = null;
if (\method_exists($promiseOrValue, 'cancel')) {
$canceller = [
$promiseOrValue,
'cancel',
];
assert(\is_callable($canceller));
}
/** @var Promise<T> */
return new Promise(function (callable $resolve, callable $reject) use ($promiseOrValue) : void {
$promiseOrValue->then($resolve, $reject);
}, $canceller);
}
return new FulfilledPromise($promiseOrValue);
}