Skip to content

Commit 75c4e61

Browse files
committed
Correctly determine arg name of USER_ARG_INFO functions
1 parent 8d1a112 commit 75c4e61

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Argument name for Closure::__invoke via call_user_func reference warning
3+
--FILE--
4+
<?php
5+
6+
$test = function(&$arg) {};
7+
call_user_func([$test, '__invoke'], null);
8+
9+
?>
10+
--EXPECTF--
11+
Warning: Closure::__invoke(): Argument #1 ($arg) must be passed by reference, value given in %s on line %d
12+
13+
Warning: {closure}(): Argument #1 ($arg) must be passed by reference, value given in %s on line %d

Zend/zend_execute_API.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -507,13 +507,10 @@ ZEND_API const char *get_function_arg_name(const zend_function *func, uint32_t a
507507
return NULL;
508508
}
509509

510-
switch (func->type) {
511-
case ZEND_USER_FUNCTION:
512-
return ZSTR_VAL(func->common.arg_info[arg_num - 1].name);
513-
case ZEND_INTERNAL_FUNCTION:
514-
return ((zend_internal_arg_info*) func->common.arg_info)[arg_num - 1].name;
515-
default:
516-
return NULL;
510+
if (func->type == ZEND_USER_FUNCTION || (func->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) {
511+
return ZSTR_VAL(func->common.arg_info[arg_num - 1].name);
512+
} else {
513+
return ((zend_internal_arg_info*) func->common.arg_info)[arg_num - 1].name;
517514
}
518515
}
519516
/* }}} */

0 commit comments

Comments
 (0)