diff --git a/Zend/tests/closure_068.phpt b/Zend/tests/closure_068.phpt new file mode 100644 index 0000000000000..977d3946770ab --- /dev/null +++ b/Zend/tests/closure_068.phpt @@ -0,0 +1,13 @@ +--TEST-- +ReflectionFunction::getShortName() returns the short name for first class callables defined in namespaces. +--FILE-- +getShortName()); +?> +--EXPECT-- +string(3) "foo" diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index d2be2f869ae20..8d5895d1f6c1e 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -3609,7 +3609,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getShortName) GET_REFLECTION_OBJECT_PTR(fptr); zend_string *name = fptr->common.function_name; - if (!(fptr->common.fn_flags & ZEND_ACC_CLOSURE)) { + if ((fptr->common.fn_flags & (ZEND_ACC_CLOSURE | ZEND_ACC_FAKE_CLOSURE)) != ZEND_ACC_CLOSURE) { const char *backslash = zend_memrchr(ZSTR_VAL(name), '\\', ZSTR_LEN(name)); if (backslash) { RETURN_STRINGL(backslash + 1, ZSTR_LEN(name) - (backslash - ZSTR_VAL(name) + 1));