diff options
| author | Christoph M. Becker <cmbecker69@gmx.de> | 2018-09-05 15:07:59 +0200 |
|---|---|---|
| committer | Christoph M. Becker <cmbecker69@gmx.de> | 2018-09-05 15:07:59 +0200 |
| commit | 7a2c9585c47a9ddcff0cb8246d4981e086528877 (patch) | |
| tree | 931ed3d83f37adf82a90e7c8b55fc59b37af720b | |
| parent | 21f8cd2a92fc105a0a782e35658389d0dc33a0c9 (diff) | |
| parent | c0a389a9277070f5ef53c230f34aa5072a9f0985 (diff) | |
| download | php-git-7a2c9585c47a9ddcff0cb8246d4981e086528877.tar.gz | |
Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
Fix #74454: Wrong exception being thrown when using ReflectionMethod
| -rw-r--r-- | NEWS | 4 | ||||
| -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 |
4 files changed, 31 insertions, 2 deletions
@@ -9,6 +9,10 @@ PHP NEWS - POSIX: . Fixed bug #75696 (posix_getgrnam fails to print details of group). (cmb) +- Reflection: + . Fixed bug #74454 (Wrong exception being thrown when using ReflectionMethod). + (cmb) + - Standard: . Fixed bug #73457 (Wrong error message when fopen FTP wrapped fails to open data connection). (Ville Hukkamäki) diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index a0d4ebb4a0..3bd31e48a8 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -3010,8 +3010,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_dtor(&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=== |
