Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f91f80c

Browse files
authored
Zend: Return anonymous closure names in zend_get_callable_name_ex() (#19011)
This returns the usual `{closure:FILE_NAME/FUNCTION:LINE_NO}` for anonymous functions rather than `Closure::__invoke` this is visible for `is_callable()` and any Engine call that uses `zend_fcall_info_init()` to get the name of the callable. Related to GH-18063.
1 parent 4492a42 commit f91f80c

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

‎Zend/tests/closures/closure_016.phpt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ Foo::__invoke
4242
bool(true)
4343
Foo::__invoke
4444
bool(true)
45-
Closure::__invoke
45+
{closure:foo():9}
4646
bool(true)
47-
Closure::__invoke
47+
{closure:foo():9}
4848
bool(true)
4949
Closure::__invoke
5050
bool(true)

‎Zend/zend_API.c‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4160,13 +4160,10 @@ ZEND_API zend_string *zend_get_callable_name_ex(zval *callable, zend_object *obj
41604160
if (ce == zend_ce_closure) {
41614161
const zend_function *fn = zend_get_closure_method_def(Z_OBJ_P(callable));
41624162

4163-
if (fn->common.fn_flags & ZEND_ACC_FAKE_CLOSURE) {
4164-
if (fn->common.scope) {
4165-
return zend_create_member_string(fn->common.scope->name, fn->common.function_name);
4166-
} else {
4167-
return zend_string_copy(fn->common.function_name);
4168-
}
4163+
if ((fn->common.fn_flags & ZEND_ACC_FAKE_CLOSURE) && fn->common.scope) {
4164+
return zend_create_member_string(fn->common.scope->name, fn->common.function_name);
41694165
}
4166+
return zend_string_copy(fn->common.function_name);
41704167
}
41714168

41724169
return zend_string_concat2(

‎tests/output/ob_013.phpt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ Array
5757
[5] => E::f
5858
[6] => E::g
5959
[7] => E::__invoke
60-
[8] => Closure::__invoke
60+
[8] => {closure:%s:%d}
6161
)
6262
Array
6363
(
64-
[name] => Closure::__invoke
64+
[name] => {closure:%s:%d}
6565
[type] => 1
6666
[flags] => 20593
6767
[level] => 8
@@ -161,7 +161,7 @@ Array
161161

162162
[8] => Array
163163
(
164-
[name] => Closure::__invoke
164+
[name] => {closure:%s:%d}
165165
[type] => 1
166166
[flags] => 20593
167167
[level] => 8

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /