Open Journal Systems  3.3.0
GuzzleHttp\Promise\PromiseInterface Interface Reference
Inheritance diagram for GuzzleHttp\Promise\PromiseInterface:
GuzzleHttp\Promise\Coroutine GuzzleHttp\Promise\FulfilledPromise GuzzleHttp\Promise\Promise GuzzleHttp\Promise\RejectedPromise

Public Member Functions

 cancel ()
 
 getState ()
 
 otherwise (callable $onRejected)
 
 reject ($reason)
 
 resolve ($value)
 
 then (callable $onFulfilled=null, callable $onRejected=null)
 
 wait ($unwrap=true)
 

Data Fields

const FULFILLED = 'fulfilled'
 
const PENDING = 'pending'
 
const REJECTED = 'rejected'
 

Detailed Description

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.

https://promisesaplus.com/

Definition at line 13 of file PromiseInterface.php.

Member Function Documentation

◆ cancel()

◆ getState()

GuzzleHttp\Promise\PromiseInterface::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.

Returns
string

Implemented in GuzzleHttp\Promise\Coroutine, GuzzleHttp\Promise\Promise, GuzzleHttp\Promise\RejectedPromise, and GuzzleHttp\Promise\FulfilledPromise.

Referenced by GuzzleHttp\Promise\is_fulfilled(), GuzzleHttp\Promise\is_rejected(), GuzzleHttp\Promise\is_settled(), and GuzzleHttp\Promise\some().

◆ otherwise()

GuzzleHttp\Promise\PromiseInterface::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.

Parameters
callable$onRejectedInvoked when the promise is rejected.
Returns
PromiseInterface

Implemented in GuzzleHttp\Promise\Coroutine, GuzzleHttp\Promise\Promise, GuzzleHttp\Promise\RejectedPromise, and GuzzleHttp\Promise\FulfilledPromise.

◆ reject()

GuzzleHttp\Promise\PromiseInterface::reject (   $reason)

Reject the promise with the given reason.

Parameters
mixed$reason
Exceptions

Implemented in GuzzleHttp\Promise\Promise, GuzzleHttp\Promise\Coroutine, GuzzleHttp\Promise\RejectedPromise, and GuzzleHttp\Promise\FulfilledPromise.

Referenced by GuzzleHttp\Promise\each_limit_all().

◆ resolve()

GuzzleHttp\Promise\PromiseInterface::resolve (   $value)

Resolve the promise with the given value.

Parameters
mixed$value
Exceptions

Implemented in GuzzleHttp\Promise\Promise, GuzzleHttp\Promise\Coroutine, GuzzleHttp\Promise\RejectedPromise, and GuzzleHttp\Promise\FulfilledPromise.

Referenced by GuzzleHttp\Promise\some().

◆ then()

GuzzleHttp\Promise\PromiseInterface::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.

Parameters
callable$onFulfilledInvoked when the promise fulfills.
callable$onRejectedInvoked when the promise is rejected.
Returns
PromiseInterface

Implemented in GuzzleHttp\Promise\Coroutine, GuzzleHttp\Promise\Promise, GuzzleHttp\Promise\FulfilledPromise, and GuzzleHttp\Promise\RejectedPromise.

Referenced by Http\Adapter\Guzzle6\Promise\__construct().

◆ wait()

GuzzleHttp\Promise\PromiseInterface::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.

Parameters
bool$unwrap
Returns
mixed
Exceptions

Implemented in GuzzleHttp\Promise\Coroutine, and GuzzleHttp\Promise\Promise.

Referenced by GuzzleHttp\Promise\inspect(), and GuzzleHttp\Promise\Promise\wait().

Field Documentation

◆ FULFILLED

const GuzzleHttp\Promise\PromiseInterface::FULFILLED = 'fulfilled'

◆ PENDING

const GuzzleHttp\Promise\PromiseInterface::PENDING = 'pending'

Definition at line 15 of file PromiseInterface.php.

Referenced by GuzzleHttp\Promise\is_settled(), and GuzzleHttp\Promise\some().

◆ REJECTED

const GuzzleHttp\Promise\PromiseInterface::REJECTED = 'rejected'

The documentation for this interface was generated from the following file: