diff options
-rw-r--r-- | ext/reflection/php_reflection.c | 6 | ||||
-rw-r--r-- | ext/reflection/tests/bug74454.inc | 4 | ||||
-rw-r--r-- | ext/reflection/tests/bug74454.phpt | 19 |
3 files changed, 27 insertions, 2 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 8fe8da071a..eeb3ac66b8 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -2974,8 +2974,10 @@ ZEND_METHOD(reflection_method, __construct) switch (Z_TYPE_P(classname)) { case IS_STRING: if ((ce = zend_lookup_class(Z_STR_P(classname))) == NULL) { - zend_throw_exception_ex(reflection_exception_ptr, 0, - "Class %s does not exist", Z_STRVAL_P(classname)); + if (!EG(exception)) { + zend_throw_exception_ex(reflection_exception_ptr, 0, + "Class %s does not exist", Z_STRVAL_P(classname)); + } if (classname == &ztmp) { zval_ptr_dtor_str(&ztmp); } diff --git a/ext/reflection/tests/bug74454.inc b/ext/reflection/tests/bug74454.inc new file mode 100644 index 0000000000..5136591367 --- /dev/null +++ b/ext/reflection/tests/bug74454.inc @@ -0,0 +1,4 @@ +<?php +class A { + if (wrongsyntax) +} diff --git a/ext/reflection/tests/bug74454.phpt b/ext/reflection/tests/bug74454.phpt new file mode 100644 index 0000000000..d2d6e88649 --- /dev/null +++ b/ext/reflection/tests/bug74454.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #74454 (Wrong exception being thrown when using ReflectionMethod) +--FILE-- +<?php +spl_autoload_register('load_file'); +try { + $x = new ReflectionMethod('A', 'b'); +} catch (\Throwable $e) { + echo get_class($e), ': ', $e->getMessage(), PHP_EOL; +} + +function load_file() { + require __DIR__ . '/bug74454.inc'; +} +?> +===DONE=== +--EXPECTF-- +ParseError: syntax error, unexpected 'if' (T_IF), expecting function (T_FUNCTION) or const (T_CONST) +===DONE=== |