mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Clarify failure behavior of spl_iterator_apply()
It only fails if it throws, in which case it is meaningless to set a return value.
This commit is contained in:
parent
de643aaa46
commit
5acedabfc0
2 changed files with 10 additions and 13 deletions
|
@ -983,11 +983,9 @@ static const zend_function_entry spl_functions[] = {
|
|||
PHP_FE(class_uses, arginfo_class_uses)
|
||||
PHP_FE(spl_object_hash, arginfo_spl_object_hash)
|
||||
PHP_FE(spl_object_id, arginfo_spl_object_id)
|
||||
#ifdef SPL_ITERATORS_H
|
||||
PHP_FE(iterator_to_array, arginfo_iterator_to_array)
|
||||
PHP_FE(iterator_count, arginfo_iterator)
|
||||
PHP_FE(iterator_apply, arginfo_iterator_apply)
|
||||
#endif /* SPL_ITERATORS_H */
|
||||
PHP_FE_END
|
||||
};
|
||||
/* }}} */
|
||||
|
|
|
@ -3573,11 +3573,7 @@ PHP_FUNCTION(iterator_to_array)
|
|||
}
|
||||
|
||||
array_init(return_value);
|
||||
|
||||
if (spl_iterator_apply(obj, use_keys ? spl_iterator_to_array_apply : spl_iterator_to_values_apply, (void*)return_value) != SUCCESS) {
|
||||
zval_ptr_dtor(return_value);
|
||||
RETURN_NULL();
|
||||
}
|
||||
spl_iterator_apply(obj, use_keys ? spl_iterator_to_array_apply : spl_iterator_to_values_apply, (void*)return_value);
|
||||
} /* }}} */
|
||||
|
||||
static int spl_iterator_count_apply(zend_object_iterator *iter, void *puser) /* {{{ */
|
||||
|
@ -3598,9 +3594,11 @@ PHP_FUNCTION(iterator_count)
|
|||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (spl_iterator_apply(obj, spl_iterator_count_apply, (void*)&count) == SUCCESS) {
|
||||
RETURN_LONG(count);
|
||||
if (spl_iterator_apply(obj, spl_iterator_count_apply, (void*)&count) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
RETURN_LONG(count);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -3639,12 +3637,13 @@ PHP_FUNCTION(iterator_apply)
|
|||
|
||||
apply_info.count = 0;
|
||||
zend_fcall_info_args(&apply_info.fci, apply_info.args);
|
||||
if (spl_iterator_apply(apply_info.obj, spl_iterator_func_apply, (void*)&apply_info) == SUCCESS) {
|
||||
RETVAL_LONG(apply_info.count);
|
||||
} else {
|
||||
RETVAL_FALSE;
|
||||
if (spl_iterator_apply(apply_info.obj, spl_iterator_func_apply, (void*)&apply_info) == FAILURE) {
|
||||
zend_fcall_info_args(&apply_info.fci, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
zend_fcall_info_args(&apply_info.fci, NULL);
|
||||
RETURN_LONG(apply_info.count);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue