Skip to content

Commit

Permalink
reflection: Fix ReflectionFunction::getShortName() for first class ca…
Browse files Browse the repository at this point in the history
…llables

Fix fixes an incorrect fix in php#14001.
  • Loading branch information
TimWolla committed Apr 30, 2024
1 parent 3626e2d commit cfd5105
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Zend/tests/closure_068.phpt
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion ext/reflection/php_reflection.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit cfd5105

Please sign in to comment.