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

Breadcrumb

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

function ThrowPromise::execute

Overrides PromiseInterface::execute

File

vendor/phpspec/prophecy/src/Prophecy/Promise/ThrowPromise.php, line 62

Class

ThrowPromise
Throws predefined exception.

Namespace

Prophecy\Promise

Code

public function execute(array $args, ObjectProphecy $object, MethodProphecy $method) {
    if (is_string($this->exception)) {
        $classname = $this->exception;
        $reflection = new ReflectionClass($classname);
        $constructor = $reflection->getConstructor();
        if ($constructor === null || $constructor->isPublic() && 0 == $constructor->getNumberOfRequiredParameters()) {
            throw $reflection->newInstance();
        }
        if (!$this->instantiator) {
            $this->instantiator = new Instantiator();
        }
        throw $this->instantiator
            ->instantiate($classname);
    }
    throw $this->exception;
}
RSS feed
Powered by Drupal