Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
GuzzleHttp\Promise Namespace Reference

  More...

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.
 

Detailed Description

 

Function Documentation

◆ all()

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.

Parameters
mixed$promisesPromises or values.
bool$recursiveIf true, resolves new promises that might have been added to the stack during its own resolution.
Return values
PromiseInterface
Deprecated
all will be removed in guzzlehttp/promises:2.0. Use Utils\all instead.

◆ any()

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.

Parameters
mixed$promisesPromises or values.
Return values
PromiseInterface
Deprecated
any will be removed in guzzlehttp/promises:2.0. Use Utils\any instead.

◆ coroutine()

GuzzleHttp\Promise\coroutine ( callable $generatorFn)

Create a new coroutine.

See also
Coroutine
Return values
PromiseInterface
Deprecated
coroutine will be removed in guzzlehttp/promises:2.0. Use Coroutine\of instead.

◆ each()

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.

Parameters
mixed$iterableIterator or array to iterate over.
callable$onFulfilled
callable$onRejected
Return values
PromiseInterface
Deprecated
each will be removed in guzzlehttp/promises:2.0. Use Each\of instead.

◆ each_limit()

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.

Parameters
mixed$iterable
int | callable$concurrency
callable$onFulfilled
callable$onRejected
Return values
PromiseInterface
Deprecated
each_limit will be removed in guzzlehttp/promises:2.0. Use Each\ofLimit instead.

◆ each_limit_all()

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.

Parameters
mixed$iterable
int | callable$concurrency
callable$onFulfilled
Return values
PromiseInterface
Deprecated
each_limit_all will be removed in guzzlehttp/promises:2.0. Use Each\ofLimitAll instead.

◆ exception_for()

GuzzleHttp\Promise\exception_for ( $reason)

Create an exception for a rejected promise value.

Parameters
mixed$reason
Return values
Exception|Throwable
Deprecated
exception_for will be removed in guzzlehttp/promises:2.0. Use Create\exceptionFor instead.

◆ inspect()

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.

Parameters
PromiseInterface$promisePromise or value.
Return values
array
Deprecated
inspect will be removed in guzzlehttp/promises:2.0. Use Utils\inspect instead.

◆ inspect_all()

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.

See also
inspect for the inspection state array format.
Parameters
PromiseInterface[]$promisesTraversable of promises to wait upon.
Return values
array
Deprecated
inspect will be removed in guzzlehttp/promises:2.0. Use Utils\inspectAll instead.

◆ is_fulfilled()

GuzzleHttp\Promise\is_fulfilled ( PromiseInterface $promise)

Returns true if a promise is fulfilled.

Return values
bool
Deprecated
is_fulfilled will be removed in guzzlehttp/promises:2.0. Use Is\fulfilled instead.

◆ is_rejected()

GuzzleHttp\Promise\is_rejected ( PromiseInterface $promise)

Returns true if a promise is rejected.

Return values
bool
Deprecated
is_rejected will be removed in guzzlehttp/promises:2.0. Use Is\rejected instead.

◆ is_settled()

GuzzleHttp\Promise\is_settled ( PromiseInterface $promise)

Returns true if a promise is fulfilled or rejected.

Return values
bool
Deprecated
is_settled will be removed in guzzlehttp/promises:2.0. Use Is\settled instead.

◆ iter_for()

GuzzleHttp\Promise\iter_for ( $value)

Returns an iterator for the given value.

Parameters
mixed$value
Return values
Iterator
Deprecated
iter_for will be removed in guzzlehttp/promises:2.0. Use Create\iterFor instead.

◆ promise_for()

GuzzleHttp\Promise\promise_for ( $value)

Creates a promise for a value if the value is not a promise.

Parameters
mixed$valuePromise or value.
Return values
PromiseInterface
Deprecated
promise_for will be removed in guzzlehttp/promises:2.0. Use Create\promiseFor instead.

◆ rejection_for()

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.

Parameters
mixed$reasonPromise or reason.
Return values
PromiseInterface
Deprecated
rejection_for will be removed in guzzlehttp/promises:2.0. Use Create\rejectionFor instead.

◆ settle()

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.

See also
inspect for the inspection state array format.
Parameters
mixed$promisesPromises or values.
Return values
PromiseInterface
Deprecated
settle will be removed in guzzlehttp/promises:2.0. Use Utils\settle instead.

◆ some()

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 {

See also
AggregateException} if the number of fulfilled promises is less than the desired $count.
Parameters
int$countTotal number of promises.
mixed$promisesPromises or values.
Return values
PromiseInterface
Deprecated
some will be removed in guzzlehttp/promises:2.0. Use Utils\some instead.

◆ task()

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.

Parameters
callable$taskTask function to run.
Return values
PromiseInterface
Deprecated
task will be removed in guzzlehttp/promises:2.0. Use Utils\task instead.

◆ unwrap()

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.

Parameters
iterable<PromiseInterface>$promises Iterable of PromiseInterface objects to wait on.
Return values
array
Exceptions
Exceptionon error
Throwableon error in PHP >=7
Deprecated
unwrap will be removed in guzzlehttp/promises:2.0. Use Utils\unwrap instead.