diff options
Diffstat (limited to 'Zend/zend_execute_API.c')
-rw-r--r-- | Zend/zend_execute_API.c | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index e2410cf6af..80d0cf26ee 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -488,6 +488,37 @@ ZEND_API const char *get_active_function_name(void) /* {{{ */ } /* }}} */ +ZEND_API const char *get_active_function_arg_name(uint32_t arg_num) /* {{{ */ +{ + zend_function *func; + + if (!zend_is_executing()) { + return NULL; + } + + func = EG(current_execute_data)->func; + + return get_function_arg_name(func, arg_num); +} +/* }}} */ + +ZEND_API const char *get_function_arg_name(const zend_function *func, uint32_t arg_num) /* {{{ */ +{ + if (!func || func->common.num_args < arg_num) { + 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; + } +} +/* }}} */ + ZEND_API const char *zend_get_executed_filename(void) /* {{{ */ { zend_execute_data *ex = EG(current_execute_data); @@ -717,11 +748,18 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / } else if (!ARG_MAY_BE_SENT_BY_REF(func, i + 1)) { /* By-value send is not allowed -- emit a warning, * but still perform the call with a by-value send. */ + const char *arg_name = get_function_arg_name(func, i + 1); + zend_error(E_WARNING, - "Parameter %d to %s%s%s() expected to be a reference, value given", i+1, + "%s%s%s() expects argument #%d%s%s%s to be passed by reference, value given", func->common.scope ? ZSTR_VAL(func->common.scope->name) : "", func->common.scope ? "::" : "", - ZSTR_VAL(func->common.function_name)); + ZSTR_VAL(func->common.function_name), + i+1, + arg_name ? " ($" : "", + arg_name ? arg_name : "", + arg_name ? ")" : "" + ); if (UNEXPECTED(EG(exception))) { ZEND_CALL_NUM_ARGS(call) = i; zend_vm_stack_free_args(call); |