mirror of
https://github.com/php/php-src.git
synced 2026-04-28 18:53:33 +02:00
Use the default type error message for Exception::__construct()
Closes GH-5460
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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}
|
||||
|
||||
+2
-23
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user