Lines Matching defs:promiseOrValue

6  * Creates a promise for the supplied `$promiseOrValue`.
8 * If `$promiseOrValue` is a value, it will be the resolution value of the
11 * If `$promiseOrValue` is a thenable (any object that provides a `then()` method),
14 * If `$promiseOrValue` is a promise, it will be returned as is.
16 * @param mixed $promiseOrValue
19 function resolve($promiseOrValue = null)
21 if ($promiseOrValue instanceof ExtendedPromiseInterface) {
22 return $promiseOrValue;
26 // class autoloaders if $promiseOrValue is a string.
27 if (\is_object($promiseOrValue) && \method_exists($promiseOrValue, 'then')) {
30 if (\method_exists($promiseOrValue, 'cancel')) {
31 $canceller = [$promiseOrValue, 'cancel'];
34 return new Promise(function ($resolve, $reject, $notify) use ($promiseOrValue) {
35 $promiseOrValue->then($resolve, $reject, $notify);
39 return new FulfilledPromise($promiseOrValue);
43 * Creates a rejected promise for the supplied `$promiseOrValue`.
45 * If `$promiseOrValue` is a value, it will be the rejection value of the
48 * If `$promiseOrValue` is a promise, its completion value will be the rejected
55 * @param mixed $promiseOrValue
58 function reject($promiseOrValue = null)
60 if ($promiseOrValue instanceof PromiseInterface) {
61 return resolve($promiseOrValue)->then(function ($value) {
66 return new RejectedPromise($promiseOrValue);
108 foreach ($array as $promiseOrValue) {
109 $cancellationQueue->enqueue($promiseOrValue);
111 resolve($promiseOrValue)
190 foreach ($array as $i => $promiseOrValue) {
215 $cancellationQueue->enqueue($promiseOrValue);
217 resolve($promiseOrValue)
251 foreach ($array as $i => $promiseOrValue) {
252 $cancellationQueue->enqueue($promiseOrValue);
255 resolve($promiseOrValue)