diff options
author | Máté Kocsis <kocsismate@woohoolabs.com> | 2020-04-26 00:15:52 +0200 |
---|---|---|
committer | Máté Kocsis <kocsismate@woohoolabs.com> | 2020-04-26 00:25:42 +0200 |
commit | 5bf01fca60ed802db9182b495b229846d8c95af4 (patch) | |
tree | e71128989822c6a476fa82bad150a61e860b0597 | |
parent | d7f7080bb5b42a4dd2d08c91c02645b9d9a74a50 (diff) | |
download | php-git-5bf01fca60ed802db9182b495b229846d8c95af4.tar.gz |
Use the default type error message for Exception::__construct()
Closes GH-5460
-rw-r--r-- | Zend/tests/exception_018.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/exception_019.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/exception_020.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/exception_021.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/exception_022.phpt | 2 | ||||
-rw-r--r-- | Zend/zend_exceptions.c | 25 |
6 files changed, 7 insertions, 28 deletions
diff --git a/Zend/tests/exception_018.phpt b/Zend/tests/exception_018.phpt index aa39d53b67..6789cfe981 100644 --- a/Zend/tests/exception_018.phpt +++ b/Zend/tests/exception_018.phpt @@ -8,7 +8,7 @@ throw new Hello(new stdClass); ?> --EXPECTF-- -Fatal error: Uncaught Error: Wrong parameters for Hello([string $message [, long $code [, Throwable $previous = NULL]]]) in %sexception_018.php:%d +Fatal error: Uncaught TypeError: Exception::__construct(): Argument #1 ($message) must be of type string, object given in %s:%d Stack trace: #0 %sexception_018.php(%d): Exception->__construct(Object(stdClass)) #1 {main} diff --git a/Zend/tests/exception_019.phpt b/Zend/tests/exception_019.phpt index 4ebb077fe6..7aa20c2bc7 100644 --- a/Zend/tests/exception_019.phpt +++ b/Zend/tests/exception_019.phpt @@ -7,7 +7,7 @@ throw new Exception(new stdClass); ?> --EXPECTF-- -Fatal error: Uncaught Error: Wrong parameters for Exception([string $message [, long $code [, Throwable $previous = NULL]]]) in %sexception_019.php:%d +Fatal error: Uncaught TypeError: Exception::__construct(): Argument #1 ($message) must be of type string, object given in %s:%d Stack trace: #0 %sexception_019.php(%d): Exception->__construct(Object(stdClass)) #1 {main} diff --git a/Zend/tests/exception_020.phpt b/Zend/tests/exception_020.phpt index 6f8981f5e6..3135ef3633 100644 --- a/Zend/tests/exception_020.phpt +++ b/Zend/tests/exception_020.phpt @@ -8,7 +8,7 @@ throw new MyErrorException(new stdClass); ?> --EXPECTF-- -Fatal error: Uncaught Error: Wrong parameters for MyErrorException([string $message [, long $code, [ long $severity, [ string $filename, [ long $lineno [, Throwable $previous = NULL]]]]]]) in %sexception_020.php:%d +Fatal error: Uncaught TypeError: ErrorException::__construct(): Argument #1 ($message) must be of type string, object given in %s:%d Stack trace: #0 %sexception_020.php(%d): ErrorException->__construct(Object(stdClass)) #1 {main} diff --git a/Zend/tests/exception_021.phpt b/Zend/tests/exception_021.phpt index 5955e7989b..70ca3caa57 100644 --- a/Zend/tests/exception_021.phpt +++ b/Zend/tests/exception_021.phpt @@ -8,7 +8,7 @@ throw new Hello(new stdClass); ?> --EXPECTF-- -Fatal error: Uncaught Error: Wrong parameters for Hello([string $message [, long $code [, Throwable $previous = NULL]]]) in %sexception_021.php:%d +Fatal error: Uncaught TypeError: Error::__construct(): Argument #1 ($message) must be of type string, object given in %s:%d Stack trace: #0 %sexception_021.php(%d): Error->__construct(Object(stdClass)) #1 {main} diff --git a/Zend/tests/exception_022.phpt b/Zend/tests/exception_022.phpt index 83d47145c3..e9b9da87e9 100644 --- a/Zend/tests/exception_022.phpt +++ b/Zend/tests/exception_022.phpt @@ -7,7 +7,7 @@ throw new Error(new stdClass); ?> --EXPECTF-- -Fatal error: Uncaught Error: Wrong parameters for Error([string $message [, long $code [, Throwable $previous = NULL]]]) in %sexception_022.php:%d +Fatal error: Uncaught TypeError: Error::__construct(): Argument #1 ($message) must be of type string, object given in %s:%d Stack trace: #0 %sexception_022.php(%d): Error->__construct(Object(stdClass)) #1 {main} diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index fb48d34bdf..60893095ae 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -273,22 +273,11 @@ ZEND_METHOD(exception, __construct) zend_long code = 0; zval tmp, *object, *previous = NULL; zend_class_entry *base_ce; - int argc = ZEND_NUM_ARGS(); object = ZEND_THIS; base_ce = i_get_exception_base(object); - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc, "|SlO!", &message, &code, &previous, zend_ce_throwable) == FAILURE) { - zend_class_entry *ce; - - if (Z_TYPE(EX(This)) == IS_OBJECT) { - ce = Z_OBJCE(EX(This)); - } else if (Z_CE(EX(This))) { - ce = Z_CE(EX(This)); - } else { - ce = base_ce; - } - zend_throw_error(NULL, "Wrong parameters for %s([string $message [, long $code [, Throwable $previous = NULL]]])", ZSTR_VAL(ce->name)); + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|SlO!", &message, &code, &previous, zend_ce_throwable) == FAILURE) { RETURN_THROWS(); } @@ -344,17 +333,7 @@ ZEND_METHOD(error_exception, __construct) zval tmp, *object, *previous = NULL; int argc = ZEND_NUM_ARGS(); - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc, "|SllSlO!", &message, &code, &severity, &filename, &lineno, &previous, zend_ce_throwable) == FAILURE) { - zend_class_entry *ce; - - if (Z_TYPE(EX(This)) == IS_OBJECT) { - ce = Z_OBJCE(EX(This)); - } else if (Z_CE(EX(This))) { - ce = Z_CE(EX(This)); - } else { - ce = zend_ce_error_exception; - } - zend_throw_error(NULL, "Wrong parameters for %s([string $message [, long $code, [ long $severity, [ string $filename, [ long $lineno [, Throwable $previous = NULL]]]]]])", ZSTR_VAL(ce->name)); + if (zend_parse_parameters(argc, "|SllSlO!", &message, &code, &severity, &filename, &lineno, &previous, zend_ce_throwable) == FAILURE) { RETURN_THROWS(); } |