mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
reflection: Fix ReflectionFunction::getShortName() for first class callables (#14087)
Fix fixes an incorrect fix in php/php-src#14001.
This commit is contained in:
13
Zend/tests/closure_068.phpt
Normal file
13
Zend/tests/closure_068.phpt
Normal file
@@ -0,0 +1,13 @@
|
||||
--TEST--
|
||||
ReflectionFunction::getShortName() returns the short name for first class callables defined in namespaces.
|
||||
--FILE--
|
||||
<?php
|
||||
namespace Foo;
|
||||
|
||||
function foo() {
|
||||
}
|
||||
$r = new \ReflectionFunction(foo(...));
|
||||
var_dump($r->getShortName());
|
||||
?>
|
||||
--EXPECT--
|
||||
string(3) "foo"
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user