You are here

private static function Promise::callHandler in Auth0 Single Sign On 8.2

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

Parameters

int $index 1 (resolve) or 2 (reject).:

mixed $value Value to pass to the callback.:

array $handler Array of handler data (promise and callbacks).:

Return value

array Returns the next group to resolve.

1 call to Promise::callHandler()
Promise::settle in vendor/guzzlehttp/promises/src/Promise.php

File

vendor/guzzlehttp/promises/src/Promise.php, line 190

Class

Promise
Promises/A+ implementation that avoids recursion when possible.

Namespace

GuzzleHttp\Promise

Code

private static function callHandler($index, $value, array $handler) {

  /** @var PromiseInterface $promise */
  $promise = $handler[0];

  // The promise may have been cancelled or resolved before placing
  // this thunk in the queue.
  if ($promise
    ->getState() !== self::PENDING) {
    return;
  }
  try {
    if (isset($handler[$index])) {
      $promise
        ->resolve($handler[$index]($value));
    }
    elseif ($index === 1) {

      // Forward resolution values as-is.
      $promise
        ->resolve($value);
    }
    else {

      // Forward rejections down the chain.
      $promise
        ->reject($value);
    }
  } catch (\Throwable $reason) {
    $promise
      ->reject($reason);
  } catch (\Exception $reason) {
    $promise
      ->reject($reason);
  }
}