Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
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 ()
 Cancels the promise if possible.
 
 getState ()
 Get the state of the promise ("pending", "rejected", or "fulfilled").
 
 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.
 
 reject ($reason)
 Reject the promise with the given reason.
 
 resolve ($value)
 Resolve the promise with the given value.
 
 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.
 
 wait (bool $unwrap=true)
 Waits until the promise completes if possible.
 

Public Attributes

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

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.

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

◆ 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.

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

◆ reject()

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

Reject the promise with the given reason.

Parameters
mixed$reason
Exceptions
RuntimeExceptionif the promise is already resolved.

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

◆ resolve()

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

Resolve the promise with the given value.

Parameters
mixed$value
Exceptions
RuntimeExceptionif the promise is already resolved.

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

◆ 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.

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

◆ wait()

GuzzleHttp\Promise\PromiseInterface::wait ( bool $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 values
mixed
Exceptions
LogicExceptionif the promise has no wait function or if the promise does not settle after waiting.

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


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