Skip to content

Zend: Fix anonymous closure names #19011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Zend/tests/closures/closure_016.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ Foo::__invoke
bool(true)
Foo::__invoke
bool(true)
Closure::__invoke
{closure:foo():9}
bool(true)
Closure::__invoke
{closure:foo():9}
bool(true)
Closure::__invoke
bool(true)
Expand Down
9 changes: 3 additions & 6 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -4160,13 +4160,10 @@ ZEND_API zend_string *zend_get_callable_name_ex(zval *callable, zend_object *obj
if (ce == zend_ce_closure) {
const zend_function *fn = zend_get_closure_method_def(Z_OBJ_P(callable));

if (fn->common.fn_flags & ZEND_ACC_FAKE_CLOSURE) {
if (fn->common.scope) {
return zend_create_member_string(fn->common.scope->name, fn->common.function_name);
} else {
return zend_string_copy(fn->common.function_name);
}
if ((fn->common.fn_flags & ZEND_ACC_FAKE_CLOSURE) && fn->common.scope) {
return zend_create_member_string(fn->common.scope->name, fn->common.function_name);
}
return zend_string_copy(fn->common.function_name);
}

return zend_string_concat2(
Expand Down
6 changes: 3 additions & 3 deletions tests/output/ob_013.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ Array
[5] => E::f
[6] => E::g
[7] => E::__invoke
[8] => Closure::__invoke
[8] => {closure:%s:%d}
)
Array
(
[name] => Closure::__invoke
[name] => {closure:%s:%d}
[type] => 1
[flags] => 20593
[level] => 8
Expand Down Expand Up @@ -161,7 +161,7 @@ Array

[8] => Array
(
[name] => Closure::__invoke
[name] => {closure:%s:%d}
[type] => 1
[flags] => 20593
[level] => 8
Expand Down