summaryrefslogtreecommitdiff
path: root/Zend/zend_API.c
diff options
context:
space:
mode:
Diffstat (limited to 'Zend/zend_API.c')
-rw-r--r--Zend/zend_API.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index c6e4b03dfc..62387d1be5 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -234,6 +234,9 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_error(int error_code,
case ZPP_ERROR_WRONG_STRING_OR_CLASS_OR_NULL:
zend_wrong_parameter_string_or_class_or_null_error(num, name, arg);
break;
+ case ZPP_ERROR_UNEXPECTED_EXTRA_NAMED:
+ zend_unexpected_extra_named_error();
+ break;
default:
ZEND_ASSERT(error_code != ZPP_ERROR_OK);
}
@@ -306,6 +309,14 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(uint32_t num, ch
}
/* }}} */
+ZEND_API ZEND_COLD void ZEND_FASTCALL zend_unexpected_extra_named_error(void)
+{
+ const char *space;
+ const char *class_name = get_active_class_name(&space);
+ zend_argument_count_error("%s%s%s() does not accept unknown named parameters",
+ class_name, space, get_active_function_name());
+}
+
static ZEND_COLD void ZEND_FASTCALL zend_argument_error_variadic(zend_class_entry *error_ce, uint32_t arg_num, const char *format, va_list va) /* {{{ */
{
const char *space;
@@ -950,6 +961,11 @@ static int zend_parse_va_args(uint32_t num_args, const char *type_spec, va_list
}
/* mark the beginning of varargs */
post_varargs = max_num_args;
+
+ if (ZEND_CALL_INFO(EG(current_execute_data)) & ZEND_CALL_HAS_EXTRA_NAMED_PARAMS) {
+ zend_unexpected_extra_named_error();
+ return FAILURE;
+ }
break;
default:
@@ -2298,11 +2314,20 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
if (reg_function->common.arg_info && reg_function->common.num_args) {
uint32_t i;
for (i = 0; i < reg_function->common.num_args; i++) {
- zend_arg_info *arg_info = &reg_function->common.arg_info[i];
+ zend_internal_arg_info *arg_info = &reg_function->internal_function.arg_info[i];
ZEND_ASSERT(arg_info->name && "Parameter must have a name");
if (ZEND_TYPE_IS_SET(arg_info->type)) {
reg_function->common.fn_flags |= ZEND_ACC_HAS_TYPE_HINTS;
}
+#if ZEND_DEBUG
+ for (uint32_t j = 0; j < i; j++) {
+ if (!strcmp(arg_info->name, reg_function->internal_function.arg_info[j].name)) {
+ zend_error_noreturn(E_CORE_ERROR,
+ "Duplicate parameter name $%s for function %s%s%s()", arg_info->name,
+ scope ? ZSTR_VAL(scope->name) : "", scope ? "::" : "", ptr->fname);
+ }
+ }
+#endif
}
}
@@ -3305,6 +3330,7 @@ ZEND_API int zend_fcall_info_init(zval *callable, uint32_t check_flags, zend_fca
fci->retval = NULL;
fci->param_count = 0;
fci->params = NULL;
+ fci->named_params = NULL;
return SUCCESS;
}