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

Breadcrumb

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

class FulfilledPromise

Same name in this branch
  1. 11.1.x vendor/react/promise/src/Internal/FulfilledPromise.php \React\Promise\Internal\FulfilledPromise
  2. 11.1.x vendor/guzzlehttp/promises/src/FulfilledPromise.php \GuzzleHttp\Promise\FulfilledPromise

A promise already fulfilled.

@author Joel Wurtz <joel.wurtz@gmail.com>

Hierarchy

  • class \Http\Promise\FulfilledPromise implements \Http\Promise\Promise

Expanded class hierarchy of FulfilledPromise

File

vendor/php-http/promise/src/FulfilledPromise.php, line 10

Namespace

Http\Promise
View source
final class FulfilledPromise implements Promise {
    
    /**
     * @var mixed
     */
    private $result;
    
    /**
     * @param mixed $result
     */
    public function __construct($result) {
        $this->result = $result;
    }
    public function then(?callable $onFulfilled = null, ?callable $onRejected = null) {
        if (null === $onFulfilled) {
            return $this;
        }
        try {
            return new self($onFulfilled($this->result));
        } catch (\Exception $e) {
            return new RejectedPromise($e);
        }
    }
    public function getState() {
        return Promise::FULFILLED;
    }
    public function wait($unwrap = true) {
        if ($unwrap) {
            return $this->result;
        }
        return null;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
FulfilledPromise::$result private property
FulfilledPromise::getState public function Returns the state of the promise, one of PENDING, FULFILLED or REJECTED. Overrides Promise::getState
FulfilledPromise::then public function Adds behavior for when the promise is resolved or rejected (response will be available, or error happens). Overrides Promise::then
FulfilledPromise::wait public function Wait for the promise to be fulfilled or rejected. Overrides Promise::wait
FulfilledPromise::__construct public function
Promise::FULFILLED constant Promise has been fulfilled.
Promise::PENDING constant Promise has not been fulfilled or rejected.
Promise::REJECTED constant Promise has been rejected.

API Navigation

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