Skip to content

Commit 31e2033

Browse files
committed
make exceeding arglists behave the same for both native and userland functions
1 parent fd46184 commit 31e2033

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

Zend/zend_API.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_error(int num_
208208
class_name, \
209209
class_name[0] ? "::" : "", \
210210
ZSTR_VAL(active_function->common.function_name),
211-
min_num_args == max_num_args ? "exactly" : num_args < min_num_args ? "at least" : "at most",
212-
num_args < min_num_args ? min_num_args : max_num_args,
211+
min_num_args == max_num_args ? "exactly" : "at least",
212+
min_num_args,
213213
(num_args < min_num_args ? min_num_args : max_num_args) == 1 ? "" : "s",
214214
num_args);
215215
}
@@ -738,7 +738,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons
738738
/* 'Z' iz not supported anymore and should be replaced with 'z' */
739739
ZEND_ASSERT(c != 'Z');
740740
default:
741-
return "unknown";
741+
return NULL;
742742
}
743743

744744
*spec = spec_walk;
@@ -872,7 +872,7 @@ static int zend_parse_va_args(int num_args, const char *type_spec, va_list *va,
872872
max_num_args = -1;
873873
}
874874

875-
if (num_args < min_num_args || (num_args > max_num_args && max_num_args >= 0)) {
875+
if (num_args < min_num_args) {
876876
if (!(flags & ZEND_PARSE_PARAMS_QUIET)) {
877877
zend_function *active_function = EG(current_execute_data)->func;
878878
const char *class_name = active_function->common.scope ? ZSTR_VAL(active_function->common.scope->name) : "";
@@ -881,8 +881,8 @@ static int zend_parse_va_args(int num_args, const char *type_spec, va_list *va,
881881
class_name,
882882
class_name[0] ? "::" : "",
883883
ZSTR_VAL(active_function->common.function_name),
884-
min_num_args == max_num_args ? "exactly" : num_args < min_num_args ? "at least" : "at most",
885-
num_args < min_num_args ? min_num_args : max_num_args,
884+
min_num_args == max_num_args ? "exactly" : "at least",
885+
min_num_args,
886886
(num_args < min_num_args ? min_num_args : max_num_args) == 1 ? "" : "s",
887887
num_args);
888888
}

Zend/zend_API.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -725,9 +725,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int severity, in
725725
((void)_optional); \
726726
\
727727
do { \
728-
if (UNEXPECTED(_num_args < _min_num_args) || \
729-
(UNEXPECTED(_num_args > _max_num_args) && \
730-
EXPECTED(_max_num_args >= 0))) { \
728+
if (UNEXPECTED(_num_args < _min_num_args)) { \
731729
if (!(_flags & ZEND_PARSE_PARAMS_QUIET)) { \
732730
zend_wrong_parameters_count_error(_num_args, _min_num_args, _max_num_args); \
733731
} \

0 commit comments

Comments
 (0)