You are here

function rejection_for in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/promises/src/functions.php \GuzzleHttp\Promise\rejection_for()

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 $reason Promise or reason.:

Return value

PromiseInterface

1 call to rejection_for()
Promise::then in vendor/guzzlehttp/promises/src/Promise.php
Appends fulfillment and rejection handlers to the promise, and returns a new promise resolving to the return value of the called handler.

File

vendor/guzzlehttp/promises/src/functions.php, line 86

Namespace

GuzzleHttp\Promise

Code

function rejection_for($reason) {
  if ($reason instanceof PromiseInterface) {
    return $reason;
  }
  return new RejectedPromise($reason);
}