Skip to content

Commit 4372293

Browse files
Merge branch 'PHP-7.0' into PHP-7.1
2 parents 9fd33c1 + abefb6d commit 4372293

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
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

Lines changed: 26 additions & 0 deletions
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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp) /* {{{
503503
zval val;
504504
struct _zend_arg_info *arg_info = closure->func.common.arg_info;
505505
HashTable *debug_info;
506+
zend_bool zstr_args = (closure->func.type == ZEND_USER_FUNCTION) || (closure->func.common.fn_flags & ZEND_ACC_USER_ARG_INFO);
506507

507508
*is_temp = 1;
508509

@@ -535,9 +536,15 @@ static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp) /* {{{
535536
zend_string *name;
536537
zval info;
537538
if (arg_info->name) {
538-
name = zend_strpprintf(0, "%s$%s",
539-
arg_info->pass_by_reference ? "&" : "",
540-
ZSTR_VAL(arg_info->name));
539+
if (zstr_args) {
540+
name = zend_strpprintf(0, "%s$%s",
541+
arg_info->pass_by_reference ? "&" : "",
542+
ZSTR_VAL(arg_info->name));
543+
} else {
544+
name = zend_strpprintf(0, "%s$%s",
545+
arg_info->pass_by_reference ? "&" : "",
546+
((zend_internal_arg_info*)arg_info)->name);
547+
}
541548
} else {
542549
name = zend_strpprintf(0, "%s$param%d",
543550
arg_info->pass_by_reference ? "&" : "",

0 commit comments

Comments
 (0)