Skip to content

Commit bdd1384

Browse files
committed
Use Z_PARAM_ITERABLE macro
1 parent 1a677ec commit bdd1384

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

ext/standard/array.c

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6287,7 +6287,7 @@ static inline void php_iterable_until(INTERNAL_FUNCTION_PARAMETERS, int stop_val
62876287
zend_fcall_info_cache fci_cache = empty_fcall_info_cache;
62886288

62896289
ZEND_PARSE_PARAMETERS_START(1, 2)
6290-
Z_PARAM_ZVAL(input)
6290+
Z_PARAM_ITERABLE(input)
62916291
Z_PARAM_OPTIONAL
62926292
Z_PARAM_FUNC_OR_NULL(fci, fci_cache)
62936293
ZEND_PARSE_PARAMETERS_END();
@@ -6296,28 +6296,24 @@ static inline void php_iterable_until(INTERNAL_FUNCTION_PARAMETERS, int stop_val
62966296
case IS_ARRAY:
62976297
php_array_until(return_value, Z_ARRVAL_P(input), fci, fci_cache, stop_value);
62986298
return;
6299-
case IS_OBJECT:
6300-
if (instanceof_function(Z_OBJCE_P(input), zend_ce_traversable)) {
6301-
php_iterator_until_info until_info;
6299+
case IS_OBJECT: {
6300+
ZEND_ASSERT(instanceof_function(Z_OBJCE_P(input), zend_ce_traversable));
6301+
php_iterator_until_info until_info;
63026302

6303-
until_info.obj = input;
6304-
until_info.fci = fci;
6305-
until_info.fcc = fci_cache;
6303+
until_info.obj = input;
6304+
until_info.fci = fci;
6305+
until_info.fcc = fci_cache;
63066306

6307-
until_info.stop_value = stop_value;
6308-
until_info.result = SUCCESS;
6309-
until_info.found = 0;
6307+
until_info.stop_value = stop_value;
6308+
until_info.result = SUCCESS;
6309+
until_info.found = 0;
63106310

6311-
if (spl_iterator_apply(until_info.obj, php_traversable_func_until, (void*)&until_info) == SUCCESS && until_info.result == SUCCESS) {
6312-
RETURN_BOOL(!(until_info.found ^ stop_value));
6313-
}
6314-
return;
6311+
if (spl_iterator_apply(until_info.obj, php_traversable_func_until, (void*)&until_info) == SUCCESS && until_info.result == SUCCESS) {
6312+
RETURN_BOOL(!(until_info.found ^ stop_value));
63156313
}
6316-
/* fallthrough */
6317-
default:
6318-
zend_argument_type_error(1, "must be of type iterable, %s given", zend_zval_type_name(input));
6319-
RETURN_THROWS();
6320-
break;
6314+
return;
6315+
}
6316+
EMPTY_SWITCH_DEFAULT_CASE();
63216317
}
63226318
}
63236319

0 commit comments

Comments
 (0)