\GuzzleHttp\PromisePromise

Promises/A+ implementation that avoids recursion when possible.

Summary

Methods
Properties
Constants
__construct()
then()
otherwise()
wait()
getState()
cancel()
resolve()
reject()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
settle()
callHandler()
waitIfPending()
invokeWaitFn()
invokeWaitList()
$state
$result
$cancelFn
$waitFn
$waitList
$handlers
N/A

Properties

$state

$state : 

Type

$result

$result : 

Type

$cancelFn

$cancelFn : 

Type

$waitFn

$waitFn : 

Type

$waitList

$waitList : 

Type

$handlers

$handlers : 

Type

Methods

__construct()

__construct(callable  $waitFn = null, callable  $cancelFn = null) 

Parameters

callable $waitFn

Fn that when invoked resolves the promise.

callable $cancelFn

Fn that when invoked cancels the promise.

then()

then(callable  $onFulfilled = null, callable  $onRejected = null) : \GuzzleHttp\Promise\PromiseInterface

Appends fulfillment and rejection handlers to the promise, and returns a new promise resolving to the return value of the called handler.

Parameters

callable $onFulfilled

Invoked when the promise fulfills.

callable $onRejected

Invoked when the promise is rejected.

Returns

\GuzzleHttp\Promise\PromiseInterface

otherwise()

otherwise(callable  $onRejected) : \GuzzleHttp\Promise\PromiseInterface

Appends a rejection handler callback to the promise, and returns a new promise resolving to the return value of the callback if it is called, or to its original fulfillment value if the promise is instead fulfilled.

Parameters

callable $onRejected

Invoked when the promise is rejected.

Returns

\GuzzleHttp\Promise\PromiseInterface

wait()

wait(boolean  $unwrap = true) : mixed

Waits until the promise completes if possible.

Pass $unwrap as true to unwrap the result of the promise, either returning the resolved value or throwing the rejected exception.

If the promise cannot be waited on, then the promise will be rejected.

Parameters

boolean $unwrap

Returns

mixed

getState()

getState() : string

Get the state of the promise ("pending", "rejected", or "fulfilled").

The three states can be checked against the constants defined on PromiseInterface: PENDING, FULFILLED, and REJECTED.

Returns

string

cancel()

cancel() 

Cancels the promise if possible.

resolve()

resolve(mixed  $value) 

Resolve the promise with the given value.

Parameters

mixed $value

reject()

reject(mixed  $reason) 

Reject the promise with the given reason.

Parameters

mixed $reason

settle()

settle(  $state,   $value) 

Parameters

$state
$value

callHandler()

callHandler(integer  $index, mixed  $value, array  $handler) : array

Call a stack of handlers using a specific callback index and value.

Parameters

integer $index

1 (resolve) or 2 (reject).

mixed $value

Value to pass to the callback.

array $handler

Array of handler data (promise and callbacks).

Returns

array —

Returns the next group to resolve.

waitIfPending()

waitIfPending() 

invokeWaitFn()

invokeWaitFn() 

invokeWaitList()

invokeWaitList()