mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
- MFH: Improved parameter handling
This commit is contained in:
parent
f37a1316fe
commit
a1ce847cd5
1 changed files with 19 additions and 12 deletions
|
@ -2833,28 +2833,35 @@ static void php_array_intersect_key(INTERNAL_FUNCTION_PARAMETERS, int data_compa
|
||||||
int (*intersect_data_compare_func)(zval **, zval ** TSRMLS_DC) = NULL;
|
int (*intersect_data_compare_func)(zval **, zval ** TSRMLS_DC) = NULL;
|
||||||
zend_bool ok;
|
zend_bool ok;
|
||||||
zval **data;
|
zval **data;
|
||||||
|
int req_args;
|
||||||
|
char *param_spec;
|
||||||
|
|
||||||
/* Get the argument count */
|
/* Get the argument count */
|
||||||
argc = ZEND_NUM_ARGS();
|
argc = ZEND_NUM_ARGS();
|
||||||
if (data_compare_type == INTERSECT_COMP_DATA_USER) {
|
if (data_compare_type == INTERSECT_COMP_DATA_USER) {
|
||||||
if (argc < 3) {
|
/* INTERSECT_COMP_DATA_USER - array_uintersect_assoc() */
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "at least 3 parameters are required, %d given", ZEND_NUM_ARGS());
|
req_args = 3;
|
||||||
return;
|
param_spec = "+f";
|
||||||
}
|
|
||||||
|
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "+f", &args, &argc, &BG(user_compare_fci), &BG(user_compare_fci_cache)) == FAILURE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
intersect_data_compare_func = zval_user_compare;
|
intersect_data_compare_func = zval_user_compare;
|
||||||
} else {
|
} else {
|
||||||
if (argc < 2 || zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "+", &args, &argc) == FAILURE) {
|
/* INTERSECT_COMP_DATA_NONE - array_intersect_key()
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "at least 2 parameters are required, %d given", ZEND_NUM_ARGS());
|
INTERSECT_COMP_DATA_INTERNAL - array_intersect_assoc() */
|
||||||
return;
|
req_args = 2;
|
||||||
}
|
param_spec = "+";
|
||||||
|
|
||||||
if (data_compare_type == INTERSECT_COMP_DATA_INTERNAL) {
|
if (data_compare_type == INTERSECT_COMP_DATA_INTERNAL) {
|
||||||
intersect_data_compare_func = zval_compare;
|
intersect_data_compare_func = zval_compare;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (argc < req_args) {
|
||||||
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "at least %d parameters are required, %d given", req_args, argc);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, param_spec, &args, &argc, &BG(user_compare_fci), &BG(user_compare_fci_cache)) == FAILURE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
if (Z_TYPE_PP(args[i]) != IS_ARRAY) {
|
if (Z_TYPE_PP(args[i]) != IS_ARRAY) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue