Skip to content

Commit 2b15061

Browse files
authoredMar 1, 2023
Use zend_result in ext/spl where appropriate (#10734)
* Convert functions in spl_heap to return zend_result * Convert functions in spl_iterators to return zend_result
1 parent da4167b commit 2b15061

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed
 

‎UPGRADING.INTERNALS

+4
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ PHP 8.3 INTERNALS UPGRADE NOTES
8282
- The function pcre_get_compiled_regex_ex has been removed.
8383
Use pcre_get_compiled_regex instead.
8484

85+
e. ext/spl
86+
- The PHPAPI spl_iterator_apply() function now returns zend_result instead of int.
87+
There are no functional changes.
88+
8589
========================
8690
4. OpCode changes
8791
========================

‎ext/spl/spl_heap.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ static void spl_ptr_heap_pqueue_elem_ctor(void *elem) { /* {{{ */
121121
}
122122
/* }}} */
123123

124-
static int spl_ptr_heap_cmp_cb_helper(zval *object, spl_heap_object *heap_object, zval *a, zval *b, zend_long *result) { /* {{{ */
124+
static zend_result spl_ptr_heap_cmp_cb_helper(zval *object, spl_heap_object *heap_object, zval *a, zval *b, zend_long *result) { /* {{{ */
125125
zval zresult;
126126

127127
zend_call_method_with_2_params(Z_OBJ_P(object), heap_object->std.ce, &heap_object->fptr_cmp, "compare", &zresult, a, b);
@@ -302,7 +302,7 @@ static void *spl_ptr_heap_top(spl_ptr_heap *heap) { /* {{{ */
302302
}
303303
/* }}} */
304304

305-
static int spl_ptr_heap_delete_top(spl_ptr_heap *heap, void *elem, void *cmp_userdata) { /* {{{ */
305+
static zend_result spl_ptr_heap_delete_top(spl_ptr_heap *heap, void *elem, void *cmp_userdata) { /* {{{ */
306306
int i, j;
307307
const int limit = (heap->count-1)/2;
308308
void *bottom;

‎ext/spl/spl_iterators.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ static zend_object_iterator *spl_recursive_it_get_iterator(zend_class_entry *ce,
514514
return (zend_object_iterator*)iterator;
515515
}
516516

517-
static int spl_get_iterator_from_aggregate(zval *retval, zend_class_entry *ce, zend_object *obj) {
517+
static zend_result spl_get_iterator_from_aggregate(zval *retval, zend_class_entry *ce, zend_object *obj) {
518518
zend_function **getiterator_cache =
519519
ce->iterator_funcs_ptr ? &ce->iterator_funcs_ptr->zf_new_iterator : NULL;
520520
zend_call_method_with_0_params(obj, ce, getiterator_cache, "getiterator", retval);
@@ -1301,9 +1301,9 @@ static zend_function *spl_dual_it_get_method(zend_object **object, zend_string *
13011301

13021302
#define APPENDIT_CHECK_CTOR(intern) SPL_CHECK_CTOR(intern, AppendIterator)
13031303

1304-
static inline int spl_dual_it_fetch(spl_dual_it_object *intern, int check_more);
1304+
static inline zend_result spl_dual_it_fetch(spl_dual_it_object *intern, int check_more);
13051305

1306-
static inline int spl_cit_check_flags(zend_long flags)
1306+
static inline zend_result spl_cit_check_flags(zend_long flags)
13071307
{
13081308
zend_long cnt = 0;
13091309

@@ -1542,7 +1542,7 @@ static inline int spl_dual_it_valid(spl_dual_it_object *intern)
15421542
return intern->inner.iterator->funcs->valid(intern->inner.iterator);
15431543
}
15441544

1545-
static inline int spl_dual_it_fetch(spl_dual_it_object *intern, int check_more)
1545+
static inline zend_result spl_dual_it_fetch(spl_dual_it_object *intern, int check_more)
15461546
{
15471547
zval *data;
15481548

@@ -2874,7 +2874,7 @@ PHP_METHOD(EmptyIterator, next)
28742874
}
28752875
} /* }}} */
28762876

2877-
int spl_append_it_next_iterator(spl_dual_it_object *intern) /* {{{*/
2877+
zend_result spl_append_it_next_iterator(spl_dual_it_object *intern) /* {{{*/
28782878
{
28792879
spl_dual_it_free(intern);
28802880

@@ -3051,7 +3051,7 @@ PHP_METHOD(AppendIterator, getArrayIterator)
30513051
RETURN_COPY_DEREF(value);
30523052
} /* }}} */
30533053

3054-
PHPAPI int spl_iterator_apply(zval *obj, spl_iterator_apply_func_t apply_func, void *puser)
3054+
PHPAPI zend_result spl_iterator_apply(zval *obj, spl_iterator_apply_func_t apply_func, void *puser)
30553055
{
30563056
zend_object_iterator *iter;
30573057
zend_class_entry *ce = Z_OBJCE_P(obj);

‎ext/spl/spl_iterators.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,6 @@ typedef enum {
114114

115115
typedef int (*spl_iterator_apply_func_t)(zend_object_iterator *iter, void *puser);
116116

117-
PHPAPI int spl_iterator_apply(zval *obj, spl_iterator_apply_func_t apply_func, void *puser);
117+
PHPAPI zend_result spl_iterator_apply(zval *obj, spl_iterator_apply_func_t apply_func, void *puser);
118118

119119
#endif /* SPL_ITERATORS_H */

0 commit comments

Comments
 (0)