Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
|
Classes | |
class | AggregateException |
class | CancellationException |
class | Coroutine |
class | Create |
class | Each |
class | EachPromise |
class | FulfilledPromise |
class | Is |
class | Promise |
interface | PromiseInterface |
interface | PromisorInterface |
class | RejectedPromise |
class | RejectionException |
class | TaskQueue |
interface | TaskQueueInterface |
class | Utils |
Functions | |
all ($promises, $recursive=false) | |
Given an array of promises, return a promise that is fulfilled when all the items in the array are fulfilled. | |
any ($promises) | |
Like some(), with 1 as count. | |
coroutine (callable $generatorFn) | |
Create a new coroutine. | |
each ( $iterable, callable $onFulfilled=null, callable $onRejected=null) | |
Given an iterator that yields promises or values, returns a promise that is fulfilled with a null value when the iterator has been consumed or the aggregate promise has been fulfilled or rejected. | |
each_limit ( $iterable, $concurrency, callable $onFulfilled=null, callable $onRejected=null) | |
Like each, but only allows a certain number of outstanding promises at any given time. | |
each_limit_all ( $iterable, $concurrency, callable $onFulfilled=null) | |
Like each_limit, but ensures that no promise in the given $iterable argument is rejected. | |
exception_for ($reason) | |
Create an exception for a rejected promise value. | |
inspect (PromiseInterface $promise) | |
Synchronously waits on a promise to resolve and returns an inspection state array. | |
inspect_all ($promises) | |
Waits on all of the provided promises, but does not unwrap rejected promises as thrown exception. | |
is_fulfilled (PromiseInterface $promise) | |
Returns true if a promise is fulfilled. | |
is_rejected (PromiseInterface $promise) | |
Returns true if a promise is rejected. | |
is_settled (PromiseInterface $promise) | |
Returns true if a promise is fulfilled or rejected. | |
iter_for ($value) | |
Returns an iterator for the given value. | |
promise_for ($value) | |
Creates a promise for a value if the value is not a promise. | |
queue (TaskQueueInterface $assign=null) | |
rejection_for ($reason) | |
Creates a rejected promise for a reason if the reason is not a promise. | |
settle ($promises) | |
Returns a promise that is fulfilled when all of the provided promises have been fulfilled or rejected. | |
some ($count, $promises) | |
Initiate a competitive race between multiple promises or values (values will become immediately fulfilled promises). | |
task (callable $task) | |
Adds a function to run in the task queue when it is next run() and returns a promise that is fulfilled or rejected with the result. | |
unwrap ($promises) | |
Waits on all of the provided promises and returns the fulfilled values. | |
GuzzleHttp\Promise\all | ( | $promises, | |
$recursive = false ) |
Given an array of promises, return a promise that is fulfilled when all the items in the array are fulfilled.
The promise's fulfillment value is an array with fulfillment values at respective positions to the original array. If any promise in the array rejects, the returned promise is rejected with the rejection reason.
mixed | $promises | Promises or values. |
bool | $recursive | If true, resolves new promises that might have been added to the stack during its own resolution. |
PromiseInterface |
GuzzleHttp\Promise\any | ( | $promises | ) |
Like some(), with 1 as count.
However, if the promise fulfills, the fulfillment value is not an array of 1 but the value directly.
mixed | $promises | Promises or values. |
PromiseInterface |
GuzzleHttp\Promise\coroutine | ( | callable | $generatorFn | ) |
Create a new coroutine.
PromiseInterface |
GuzzleHttp\Promise\each | ( | $iterable, | |
callable | $onFulfilled = null, | ||
callable | $onRejected = null ) |
Given an iterator that yields promises or values, returns a promise that is fulfilled with a null value when the iterator has been consumed or the aggregate promise has been fulfilled or rejected.
$onFulfilled is a function that accepts the fulfilled value, iterator index, and the aggregate promise. The callback can invoke any necessary side effects and choose to resolve or reject the aggregate if needed.
$onRejected is a function that accepts the rejection reason, iterator index, and the aggregate promise. The callback can invoke any necessary side effects and choose to resolve or reject the aggregate if needed.
mixed | $iterable | Iterator or array to iterate over. |
callable | $onFulfilled | |
callable | $onRejected |
PromiseInterface |
GuzzleHttp\Promise\each_limit | ( | $iterable, | |
$concurrency, | |||
callable | $onFulfilled = null, | ||
callable | $onRejected = null ) |
Like each, but only allows a certain number of outstanding promises at any given time.
$concurrency may be an integer or a function that accepts the number of pending promises and returns a numeric concurrency limit value to allow for dynamic a concurrency size.
mixed | $iterable | |
int | callable | $concurrency | |
callable | $onFulfilled | |
callable | $onRejected |
PromiseInterface |
GuzzleHttp\Promise\each_limit_all | ( | $iterable, | |
$concurrency, | |||
callable | $onFulfilled = null ) |
Like each_limit, but ensures that no promise in the given $iterable argument is rejected.
If any promise is rejected, then the aggregate promise is rejected with the encountered rejection.
mixed | $iterable | |
int | callable | $concurrency | |
callable | $onFulfilled |
PromiseInterface |
GuzzleHttp\Promise\exception_for | ( | $reason | ) |
Create an exception for a rejected promise value.
mixed | $reason |
Exception|Throwable |
GuzzleHttp\Promise\inspect | ( | PromiseInterface | $promise | ) |
Synchronously waits on a promise to resolve and returns an inspection state array.
Returns a state associative array containing a "state" key mapping to a valid promise state. If the state of the promise is "fulfilled", the array will contain a "value" key mapping to the fulfilled value of the promise. If the promise is rejected, the array will contain a "reason" key mapping to the rejection reason of the promise.
PromiseInterface | $promise | Promise or value. |
array |
GuzzleHttp\Promise\inspect_all | ( | $promises | ) |
Waits on all of the provided promises, but does not unwrap rejected promises as thrown exception.
Returns an array of inspection state arrays.
PromiseInterface[] | $promises | Traversable of promises to wait upon. |
array |
GuzzleHttp\Promise\is_fulfilled | ( | PromiseInterface | $promise | ) |
Returns true if a promise is fulfilled.
bool |
GuzzleHttp\Promise\is_rejected | ( | PromiseInterface | $promise | ) |
Returns true if a promise is rejected.
bool |
GuzzleHttp\Promise\is_settled | ( | PromiseInterface | $promise | ) |
Returns true if a promise is fulfilled or rejected.
bool |
GuzzleHttp\Promise\iter_for | ( | $value | ) |
Returns an iterator for the given value.
mixed | $value |
Iterator |
GuzzleHttp\Promise\promise_for | ( | $value | ) |
Creates a promise for a value if the value is not a promise.
mixed | $value | Promise or value. |
PromiseInterface |
GuzzleHttp\Promise\rejection_for | ( | $reason | ) |
Creates a rejected promise for a reason if the reason is not a promise.
If the provided reason is a promise, then it is returned as-is.
mixed | $reason | Promise or reason. |
PromiseInterface |
GuzzleHttp\Promise\settle | ( | $promises | ) |
Returns a promise that is fulfilled when all of the provided promises have been fulfilled or rejected.
The returned promise is fulfilled with an array of inspection state arrays.
mixed | $promises | Promises or values. |
PromiseInterface |
GuzzleHttp\Promise\some | ( | $count, | |
$promises ) |
Initiate a competitive race between multiple promises or values (values will become immediately fulfilled promises).
When count amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of the winners in order of resolution.
This promise is rejected with a {
int | $count | Total number of promises. |
mixed | $promises | Promises or values. |
PromiseInterface |
GuzzleHttp\Promise\task | ( | callable | $task | ) |
Adds a function to run in the task queue when it is next run()
and returns a promise that is fulfilled or rejected with the result.
callable | $task | Task function to run. |
PromiseInterface |
GuzzleHttp\Promise\unwrap | ( | $promises | ) |
Waits on all of the provided promises and returns the fulfilled values.
Returns an array that contains the value of each promise (in the same order the promises were provided). An exception is thrown if any of the promises are rejected.
iterable<PromiseInterface> | $promises Iterable of PromiseInterface objects to wait on. |
array |
Exception | on error |
Throwable | on error in PHP >=7 |