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

Breadcrumb

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

function Promise::cancel

Same name in this branch
  1. 11.1.x vendor/react/promise/src/Promise.php \React\Promise\Promise::cancel()

Overrides PromiseInterface::cancel

File

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

Class

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

Namespace

GuzzleHttp\Promise

Code

public function cancel() : void {
    if ($this->state !== self::PENDING) {
        return;
    }
    $this->waitFn = $this->waitList = null;
    if ($this->cancelFn) {
        $fn = $this->cancelFn;
        $this->cancelFn = null;
        try {
            $fn();
        } catch (\Throwable $e) {
            $this->reject($e);
        }
    }
    // Reject the promise only if it wasn't rejected in a then callback.
    
    /** @psalm-suppress RedundantCondition */
    if ($this->state === self::PENDING) {
        $this->reject(new CancellationException('Promise has been cancelled'));
    }
}

API Navigation

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