1
0
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:
Tim Düsterhus
2024-04-30 17:27:11 +02:00
committed by GitHub
parent b5ffac7f6a
commit 6e8b134023
2 changed files with 14 additions and 1 deletions

View 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"

View File

@@ -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));