From 9975986b7ef849c3a8e73a48748befbfdc50e416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Sun, 16 Aug 2020 21:49:20 +0200 Subject: Improve error messages mentioning parameters instead of arguments Closes GH-5999 --- Zend/zend_execute_API.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'Zend/zend_execute_API.c') diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index f1bcc74a58..030455a94e 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -443,6 +443,7 @@ ZEND_API const char *get_active_class_name(const char **space) /* {{{ */ } func = EG(current_execute_data)->func; + switch (func->type) { case ZEND_USER_FUNCTION: case ZEND_INTERNAL_FUNCTION: @@ -470,7 +471,9 @@ ZEND_API const char *get_active_function_name(void) /* {{{ */ if (!zend_is_executing()) { return NULL; } + func = EG(current_execute_data)->func; + switch (func->type) { case ZEND_USER_FUNCTION: { zend_string *function_name = func->common.function_name; @@ -491,6 +494,24 @@ ZEND_API const char *get_active_function_name(void) /* {{{ */ } /* }}} */ +ZEND_API zend_string *get_active_function_or_method_name(void) /* {{{ */ +{ + ZEND_ASSERT(zend_is_executing()); + + return get_function_or_method_name(EG(current_execute_data)->func); +} +/* }}} */ + +ZEND_API zend_string *get_function_or_method_name(const zend_function *func) /* {{{ */ +{ + if (func->common.scope) { + return zend_create_member_string(func->common.scope->name, func->common.function_name); + } + + return func->common.function_name ? zend_string_copy(func->common.function_name) : zend_string_init("main", sizeof("main") - 1, 0); +} +/* }}} */ + ZEND_API const char *get_active_function_arg_name(uint32_t arg_num) /* {{{ */ { zend_function *func; -- cgit v1.2.1