summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2018-09-05 15:11:09 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2018-09-05 15:11:09 +0200
commitf94518dca14010693668c72487af47a68c002a8b (patch)
treea826603274082ac955a527f41a0590b818cac188
parent8939c4d96b8382abe84f35e69f4f6ebd6f0f749d (diff)
parent21cd552e1e6685048ed159091274a8311b84d4c8 (diff)
downloadphp-git-f94518dca14010693668c72487af47a68c002a8b.tar.gz
Merge branch 'PHP-7.3'
* PHP-7.3: Fix #74454: Wrong exception being thrown when using ReflectionMethod
-rw-r--r--ext/reflection/php_reflection.c6
-rw-r--r--ext/reflection/tests/bug74454.inc4
-rw-r--r--ext/reflection/tests/bug74454.phpt19
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===