From 46efcedd4ab2dee962eb80c7fbd552252581225b Mon Sep 17 00:00:00 2001 From: Sebastian Schendel Date: Tue, 9 Feb 2021 22:37:33 +0100 Subject: [PATCH] Allow Throwable for $previous param In current PHP versions the Exception-class seems to allow all Throwable values for its constructor's $previous param instead of only values of type Exception. Closes GH-442. --- language/exceptions.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/language/exceptions.xml b/language/exceptions.xml index 7a7cd12953..391205d7e9 100644 --- a/language/exceptions.xml +++ b/language/exceptions.xml @@ -25,7 +25,7 @@ class Exception extends Throwable private $trace; // backtrace private $previous; // previous exception if nested exception - public function __construct($message = null, $code = 0, Exception $previous = null); + public function __construct($message = null, $code = 0, Throwable $previous = null); final private function __clone(); // Inhibits cloning of exceptions. @@ -71,7 +71,7 @@ class Exception extends Throwable class MyException extends Exception { // Redefine the exception so message isn't optional - public function __construct($message, $code = 0, Exception $previous = null) { + public function __construct($message, $code = 0, Throwable $previous = null) { // some code // make sure everything is assigned properly