Skip to content

Commit abefb6d

Browse files
Fix bug #75290
1 parent d11fcea commit abefb6d

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ PHP NEWS
1010
request). (Nikita)
1111
. Fixed bug #75220 (Segfault when calling is_callable on parent).
1212
(andrewnester)
13+
. Fixed bug #75290 (debug info of Closures of internal functions contain
14+
garbage argument names). (Andrea)
1315

1416
- litespeed:
1517
. Fixed bug #75248 (Binary directory doesn't get created when building

Zend/tests/bug75290.phpt

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Bug #75290 (debug info of Closures of internal functions contain garbage argument names)
3+
--FILE--
4+
<?php
5+
6+
var_dump((new ReflectionFunction('sin'))->getClosure());
7+
8+
var_dump(function ($someThing) {});
9+
10+
?>
11+
--EXPECT--
12+
object(Closure)#2 (1) {
13+
["parameter"]=>
14+
array(1) {
15+
["$number"]=>
16+
string(10) "<required>"
17+
}
18+
}
19+
object(Closure)#2 (1) {
20+
["parameter"]=>
21+
array(1) {
22+
["$someThing"]=>
23+
string(10) "<required>"
24+
}
25+
}
26+

Zend/zend_closures.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp) /* {{{
414414
zval val;
415415
struct _zend_arg_info *arg_info = closure->func.common.arg_info;
416416
HashTable *debug_info;
417+
zend_bool zstr_args = (closure->func.type == ZEND_USER_FUNCTION) || (closure->func.common.fn_flags & ZEND_ACC_USER_ARG_INFO);
417418

418419
*is_temp = 1;
419420

@@ -446,9 +447,15 @@ static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp) /* {{{
446447
zend_string *name;
447448
zval info;
448449
if (arg_info->name) {
449-
name = zend_strpprintf(0, "%s$%s",
450-
arg_info->pass_by_reference ? "&" : "",
451-
ZSTR_VAL(arg_info->name));
450+
if (zstr_args) {
451+
name = zend_strpprintf(0, "%s$%s",
452+
arg_info->pass_by_reference ? "&" : "",
453+
ZSTR_VAL(arg_info->name));
454+
} else {
455+
name = zend_strpprintf(0, "%s$%s",
456+
arg_info->pass_by_reference ? "&" : "",
457+
((zend_internal_arg_info*)arg_info)->name);
458+
}
452459
} else {
453460
name = zend_strpprintf(0, "%s$param%d",
454461
arg_info->pass_by_reference ? "&" : "",

0 commit comments

Comments
 (0)