[php-src] master: reflection: Fix ReflectionFunction::getShortName() for first class callables (#14087)

From: Date: Tue, 30 Apr 2024 15:27:19 +0000
Subject: [php-src] master: reflection: Fix ReflectionFunction::getShortName() for first class callables (#14087)
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-128261@lists.php.net to get a copy of this message
Author: Tim Düsterhus (TimWolla) Committer: GitHub (web-flow) Pusher: TimWolla Date: 2024-04-30T17:27:11+02:00 Commit: https://github.com/php/php-src/commit/6e8b134023d1e7c6ae30b5eda06197dc3219bc55 Raw diff: https://github.com/php/php-src/commit/6e8b134023d1e7c6ae30b5eda06197dc3219bc55.diff reflection: Fix ReflectionFunction::getShortName() for first class callables (#14087) Fix fixes an incorrect fix in php/php-src#14001. Changed paths: A Zend/tests/closure_068.phpt M ext/reflection/php_reflection.c Diff: diff --git a/Zend/tests/closure_068.phpt b/Zend/tests/closure_068.phpt new file mode 100644 index 000000000000..977d3946770a --- /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-- +<?php +namespace Foo; + +function foo() { +} +$r = new \ReflectionFunction(foo(...)); +var_dump($r->getShortName()); +?> +--EXPECT-- +string(3) "foo" diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 0b43a2135d0e..54f1f46ce496 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));

« previous php.cvs (#128261) next »