public function ThrowPromise::execute in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/phpspec/prophecy/src/Prophecy/Promise/ThrowPromise.php \Prophecy\Promise\ThrowPromise::execute()
Throws predefined exception.
Parameters
array $args:
ObjectProphecy $object:
MethodProphecy $method:
Throws
object
Overrides PromiseInterface::execute
File
- vendor/
phpspec/ prophecy/ src/ Prophecy/ Promise/ ThrowPromise.php, line 71
Class
- ThrowPromise
- Throw promise.
Namespace
Prophecy\PromiseCode
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
->isPublic() && 0 == $constructor
->getNumberOfRequiredParameters()) {
throw $reflection
->newInstance();
}
if (!$this->instantiator) {
$this->instantiator = new Instantiator();
}
throw $this->instantiator
->instantiate($classname);
}
throw $this->exception;
}