Laravel version update
Laravel version update
This commit is contained in:
@@ -34,24 +34,22 @@ class ThrowPromise implements PromiseInterface
|
||||
/**
|
||||
* Initializes promise.
|
||||
*
|
||||
* @param string|\Exception $exception Exception class name or instance
|
||||
* @param string|\Exception|\Throwable $exception Exception class name or instance
|
||||
*
|
||||
* @throws \Prophecy\Exception\InvalidArgumentException
|
||||
*/
|
||||
public function __construct($exception)
|
||||
{
|
||||
if (is_string($exception)) {
|
||||
if (!class_exists($exception)
|
||||
&& 'Exception' !== $exception
|
||||
&& !is_subclass_of($exception, 'Exception')) {
|
||||
if (!class_exists($exception) || !$this->isAValidThrowable($exception)) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'Exception class or instance expected as argument to ThrowPromise, but got %s.',
|
||||
'Exception / Throwable class or instance expected as argument to ThrowPromise, but got %s.',
|
||||
$exception
|
||||
));
|
||||
}
|
||||
} elseif (!$exception instanceof \Exception) {
|
||||
} elseif (!$exception instanceof \Exception && !$exception instanceof \Throwable) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'Exception class or instance expected as argument to ThrowPromise, but got %s.',
|
||||
'Exception / Throwable class or instance expected as argument to ThrowPromise, but got %s.',
|
||||
is_object($exception) ? get_class($exception) : gettype($exception)
|
||||
));
|
||||
}
|
||||
@@ -88,4 +86,14 @@ class ThrowPromise implements PromiseInterface
|
||||
|
||||
throw $this->exception;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $exception
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isAValidThrowable($exception)
|
||||
{
|
||||
return is_a($exception, 'Exception', true) || is_subclass_of($exception, 'Throwable', true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user