mirror of
https://github.com/php/php-src.git
synced 2024-11-27 20:03:40 +08:00
backport zero args checks from HEAD
(fixes error message when passing parameters to a function accepting none)
This commit is contained in:
parent
400101ac5b
commit
7cef86c246
@ -788,11 +788,26 @@ static int zend_parse_va_args(int num_args, char *type_spec, va_list *va, int fl
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
#define RETURN_IF_ZERO_ARGS(num_args, type_spec, quiet) { \
|
||||
int __num_args = (num_args); \
|
||||
if (0 == (type_spec)[0] && 0 != __num_args && !(quiet)) { \
|
||||
char *__space; \
|
||||
char * __class_name = get_active_class_name(&__space TSRMLS_CC); \
|
||||
zend_error(E_WARNING, "%s%s%s() expects exactly 0 parameters, %d given", \
|
||||
__class_name, __space, \
|
||||
get_active_function_name(TSRMLS_C), __num_args); \
|
||||
return FAILURE; \
|
||||
}\
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_parse_parameters_ex(int flags, int num_args TSRMLS_DC, char *type_spec, ...)
|
||||
{
|
||||
va_list va;
|
||||
int retval;
|
||||
|
||||
RETURN_IF_ZERO_ARGS(num_args, type_spec, flags & ZEND_PARSE_PARAMS_QUIET);
|
||||
|
||||
va_start(va, type_spec);
|
||||
retval = zend_parse_va_args(num_args, type_spec, &va, flags TSRMLS_CC);
|
||||
va_end(va);
|
||||
@ -805,6 +820,8 @@ ZEND_API int zend_parse_parameters(int num_args TSRMLS_DC, char *type_spec, ...)
|
||||
va_list va;
|
||||
int retval;
|
||||
|
||||
RETURN_IF_ZERO_ARGS(num_args, type_spec, 0);
|
||||
|
||||
va_start(va, type_spec);
|
||||
retval = zend_parse_va_args(num_args, type_spec, &va, 0 TSRMLS_CC);
|
||||
va_end(va);
|
||||
@ -821,11 +838,15 @@ ZEND_API int zend_parse_method_parameters(int num_args TSRMLS_DC, zval *this_ptr
|
||||
zend_class_entry *ce;
|
||||
|
||||
if (!this_ptr) {
|
||||
RETURN_IF_ZERO_ARGS(num_args, p, 0);
|
||||
|
||||
va_start(va, type_spec);
|
||||
retval = zend_parse_va_args(num_args, type_spec, &va, 0 TSRMLS_CC);
|
||||
va_end(va);
|
||||
} else {
|
||||
p++;
|
||||
RETURN_IF_ZERO_ARGS(num_args, p, 0);
|
||||
|
||||
va_start(va, type_spec);
|
||||
|
||||
object = va_arg(va, zval **);
|
||||
@ -853,11 +874,15 @@ ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args TSRMLS_DC,
|
||||
int quiet = flags & ZEND_PARSE_PARAMS_QUIET;
|
||||
|
||||
if (!this_ptr) {
|
||||
RETURN_IF_ZERO_ARGS(num_args, p, quiet);
|
||||
|
||||
va_start(va, type_spec);
|
||||
retval = zend_parse_va_args(num_args, type_spec, &va, 0 TSRMLS_CC);
|
||||
va_end(va);
|
||||
} else {
|
||||
p++;
|
||||
RETURN_IF_ZERO_ARGS(num_args-1, p, quiet);
|
||||
|
||||
va_start(va, type_spec);
|
||||
|
||||
object = va_arg(va, zval **);
|
||||
|
Loading…
Reference in New Issue
Block a user