Correctly determine arg name of USER_ARG_INFO functions

This commit is contained in:
Nikita Popov 2020-07-06 11:49:56 +02:00
parent 8d1a1120bf
commit 75c4e613e4
2 changed files with 17 additions and 7 deletions

View File

@ -0,0 +1,13 @@
--TEST--
Argument name for Closure::__invoke via call_user_func reference warning
--FILE--
<?php
$test = function(&$arg) {};
call_user_func([$test, '__invoke'], null);
?>
--EXPECTF--
Warning: Closure::__invoke(): Argument #1 ($arg) must be passed by reference, value given in %s on line %d
Warning: {closure}(): Argument #1 ($arg) must be passed by reference, value given in %s on line %d

View File

@ -507,13 +507,10 @@ ZEND_API const char *get_function_arg_name(const zend_function *func, uint32_t a
return NULL;
}
switch (func->type) {
case ZEND_USER_FUNCTION:
return ZSTR_VAL(func->common.arg_info[arg_num - 1].name);
case ZEND_INTERNAL_FUNCTION:
return ((zend_internal_arg_info*) func->common.arg_info)[arg_num - 1].name;
default:
return NULL;
if (func->type == ZEND_USER_FUNCTION || (func->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) {
return ZSTR_VAL(func->common.arg_info[arg_num - 1].name);
} else {
return ((zend_internal_arg_info*) func->common.arg_info)[arg_num - 1].name;
}
}
/* }}} */