Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Utils.php

function Utils::inspect

Synchronously waits on a promise to resolve and returns an inspection state array.

Returns a state associative array containing a "state" key mapping to a valid promise state. If the state of the promise is "fulfilled", the array will contain a "value" key mapping to the fulfilled value of the promise. If the promise is rejected, the array will contain a "reason" key mapping to the rejection reason of the promise.

Parameters

PromiseInterface $promise Promise or value.:

1 call to Utils::inspect()
Utils::inspectAll in vendor/guzzlehttp/promises/src/Utils.php
Waits on all of the provided promises, but does not unwrap rejected promises as thrown exception.

File

vendor/guzzlehttp/promises/src/Utils.php, line 72

Class

Utils

Namespace

GuzzleHttp\Promise

Code

public static function inspect(PromiseInterface $promise) : array {
    try {
        return [
            'state' => PromiseInterface::FULFILLED,
            'value' => $promise->wait(),
        ];
    } catch (RejectionException $e) {
        return [
            'state' => PromiseInterface::REJECTED,
            'reason' => $e->getReason(),
        ];
    } catch (\Throwable $e) {
        return [
            'state' => PromiseInterface::REJECTED,
            'reason' => $e,
        ];
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal