diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 2796c7b7a8d7d..afa0c4203bd2c 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -4436,7 +4436,10 @@ ZEND_METHOD(reflection_class, getReflectionConstant) } if ((constant = zend_hash_find_ptr(&ce->constants_table, name)) == NULL) { - RETURN_FALSE; + zend_throw_exception_ex(reflection_exception_ptr, 0, + "Constant %s::%s does not exist", ZSTR_VAL(ce->name), ZSTR_VAL(name)); + zval_dtor(return_value); + RETURN_NULL(); } reflection_class_constant_factory(ce, name, constant, return_value); } diff --git a/ext/reflection/tests/bug77326.phpt b/ext/reflection/tests/bug77326.phpt new file mode 100644 index 0000000000000..470dfcd73d3c8 --- /dev/null +++ b/ext/reflection/tests/bug77326.phpt @@ -0,0 +1,20 @@ +--TEST-- +ReflectionClass::getReflectionConstant() +--CREDITS-- +Yanlong He +--FILE-- +getReflectionConstant("XXX")); +} catch (Exception $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECTF-- +Constant C::XXX does not exist +NULL