A promise represents the eventual result of an asynchronous operation.

The primary way of interacting with a promise is through its then method,
which registers callbacks to receive either a promise’s eventual value or
the reason why the promise cannot be fulfilled.

AbstractInterface
Constants
public GuzzleHttp\Promise\PromiseInterface::FULFILLED = 'fulfilled'
public GuzzleHttp\Promise\PromiseInterface::PENDING = 'pending'
public GuzzleHttp\Promise\PromiseInterface::REJECTED = 'rejected'
Methods
public abstract cancel()
 
public abstract getState()
 

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.

  • return string
public abstract otherwise(callable $onRejected)
 

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.

public abstract reject( $reason)
 

Reject the promise with the given reason.

  • throws RuntimeException if the promise is already resolved.
public abstract resolve( $value)
 

Resolve the promise with the given value.

  • throws RuntimeException if the promise is already resolved.
public abstract then(?callable $onFulfilled = NULL, ?callable $onRejected = NULL)
 

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

public abstract wait( $unwrap = true)
 

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.

  • return mixed
  • throws LogicException if the promise has no wait function or if the promise does not settle after waiting.
© 2020 Bruce Wells
Search Namespaces \ Classes
ConfigurationNumbers (0-9.) only