summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Faulds <ajf@ajf.me>2017-09-29 21:38:30 +0100
committerAndrea Faulds <ajf@ajf.me>2017-09-29 21:38:30 +0100
commit43722931920a5802befb2b012d92431e26aa6058 (patch)
tree1d8d69a60d43f3a519b2a2c2e1161ae975ddbb2b
parent9fd33c1f20a95c5cdbc7c161708ef0db6156877e (diff)
parentabefb6dfe76c57803e49969185183c2b4ef9352e (diff)
downloadphp-git-43722931920a5802befb2b012d92431e26aa6058.tar.gz
Merge branch 'PHP-7.0' into PHP-7.1
-rw-r--r--NEWS2
-rw-r--r--Zend/tests/bug75290.phpt26
-rw-r--r--Zend/zend_closures.c13
3 files changed, 38 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index 6d541d4a6e..312ba2921d 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,8 @@ PHP NEWS
request). (Nikita)
. Fixed bug #75220 (Segfault when calling is_callable on parent).
(andrewnester)
+ . Fixed bug #75290 (debug info of Closures of internal functions contain
+ garbage argument names). (Andrea)
- litespeed:
. Fixed bug #75248 (Binary directory doesn't get created when building
diff --git a/Zend/tests/bug75290.phpt b/Zend/tests/bug75290.phpt
new file mode 100644
index 0000000000..416af065c6
--- /dev/null
+++ b/Zend/tests/bug75290.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #75290 (debug info of Closures of internal functions contain garbage argument names)
+--FILE--
+<?php
+
+var_dump((new ReflectionFunction('sin'))->getClosure());
+
+var_dump(function ($someThing) {});
+
+?>
+--EXPECT--
+object(Closure)#2 (1) {
+ ["parameter"]=>
+ array(1) {
+ ["$number"]=>
+ string(10) "<required>"
+ }
+}
+object(Closure)#2 (1) {
+ ["parameter"]=>
+ array(1) {
+ ["$someThing"]=>
+ string(10) "<required>"
+ }
+}
+
diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c
index 806a4b786c..b047aaf3a9 100644
--- a/Zend/zend_closures.c
+++ b/Zend/zend_closures.c
@@ -503,6 +503,7 @@ static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp) /* {{{
zval val;
struct _zend_arg_info *arg_info = closure->func.common.arg_info;
HashTable *debug_info;
+ zend_bool zstr_args = (closure->func.type == ZEND_USER_FUNCTION) || (closure->func.common.fn_flags & ZEND_ACC_USER_ARG_INFO);
*is_temp = 1;
@@ -535,9 +536,15 @@ static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp) /* {{{
zend_string *name;
zval info;
if (arg_info->name) {
- name = zend_strpprintf(0, "%s$%s",
- arg_info->pass_by_reference ? "&" : "",
- ZSTR_VAL(arg_info->name));
+ if (zstr_args) {
+ name = zend_strpprintf(0, "%s$%s",
+ arg_info->pass_by_reference ? "&" : "",
+ ZSTR_VAL(arg_info->name));
+ } else {
+ name = zend_strpprintf(0, "%s$%s",
+ arg_info->pass_by_reference ? "&" : "",
+ ((zend_internal_arg_info*)arg_info)->name);
+ }
} else {
name = zend_strpprintf(0, "%s$param%d",
arg_info->pass_by_reference ? "&" : "",