Skip to content

Commit 37c3ffa

Browse files
committed
Address code review comments
1 parent d6a12de commit 37c3ffa

File tree

3 files changed

+16
-46
lines changed

3 files changed

+16
-46
lines changed

ext/spl/spl_iterators.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -485,11 +485,12 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla
485485

486486
switch (rit_type) {
487487
case RIT_RecursiveTreeIterator: {
488-
zval caching_it_flags, *user_caching_it_flags = NULL;
488+
zval caching_it_flags;
489+
zend_long user_caching_it_flags = 0;
489490
mode = RIT_SELF_FIRST;
490491
flags = RTIT_BYPASS_KEY;
491492

492-
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "o|lzl", &iterator, &flags, &user_caching_it_flags, &mode) == SUCCESS) {
493+
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "o|lll", &iterator, &flags, &user_caching_it_flags, &mode) == SUCCESS) {
493494
if (instanceof_function(Z_OBJCE_P(iterator), zend_ce_aggregate)) {
494495
zend_call_method_with_0_params(Z_OBJ_P(iterator), Z_OBJCE_P(iterator), &Z_OBJCE_P(iterator)->iterator_funcs_ptr->zf_new_iterator, "getiterator", &aggregate_retval);
495496
iterator = &aggregate_retval;
@@ -498,7 +499,7 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla
498499
}
499500

500501
if (user_caching_it_flags) {
501-
ZVAL_COPY(&caching_it_flags, user_caching_it_flags);
502+
ZVAL_LONG(&caching_it_flags, user_caching_it_flags);
502503
} else {
503504
ZVAL_LONG(&caching_it_flags, CIT_CATCH_GET_CHILD);
504505
}
@@ -771,7 +772,7 @@ SPL_METHOD(RecursiveIteratorIterator, callHasChildren)
771772
}
772773

773774
if (!object->iterators) {
774-
RETURN_NULL();
775+
RETURN_FALSE;
775776
}
776777

777778
SPL_FETCH_SUB_ELEMENT(ce, object, ce);
@@ -1435,10 +1436,10 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
14351436
break;
14361437
}
14371438
case DIT_AppendIterator:
1438-
zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling);
14391439
if (zend_parse_parameters_none() == FAILURE) {
14401440
return NULL;
14411441
}
1442+
zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling);
14421443
spl_instantiate(spl_ce_ArrayIterator, &intern->u.append.zarrayit);
14431444
zend_call_method_with_0_params(Z_OBJ(intern->u.append.zarrayit), spl_ce_ArrayIterator, &spl_ce_ArrayIterator->constructor, "__construct", NULL);
14441445
intern->u.append.iterator = spl_ce_ArrayIterator->get_iterator(spl_ce_ArrayIterator, &intern->u.append.zarrayit, 0);

ext/spl/spl_iterators.stub.php

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function next() {}
6969
/** @return int */
7070
public function getDepth() {}
7171

72-
/** @return RecursiveIterator */
72+
/** @return RecursiveIterator|null */
7373
public function getSubIterator(int $level = UNKNOWN) {}
7474

7575
/** @return RecursiveIterator */
@@ -81,7 +81,7 @@ public function beginIteration() {}
8181
/** @return void */
8282
public function endIteration() {}
8383

84-
/** @return bool|null */
84+
/** @return bool */
8585
public function callHasChildren() {}
8686

8787
/** @return RecursiveIterator|null */
@@ -282,24 +282,6 @@ class RecursiveCachingIterator extends CachingIterator implements RecursiveItera
282282
{
283283
public function __construct(Iterator $iterator, int $flags = self::CALL_TOSTRING) {}
284284

285-
/** @return void */
286-
public function rewind() {}
287-
288-
/** @return bool */
289-
public function valid() {}
290-
291-
/** @return mixed */
292-
public function key() {}
293-
294-
/** @return mixed */
295-
public function current() {}
296-
297-
/** @return void */
298-
public function next() {}
299-
300-
/** @return Iterator|null */
301-
public function getInnerIterator() {}
302-
303285
/** @return bool */
304286
public function hasChildren() {}
305287

@@ -415,23 +397,22 @@ public function getChildren() {}
415397

416398
class RecursiveTreeIterator extends RecursiveIteratorIterator
417399
{
418-
/**
419-
* @param RecursiveIterator|IteratorAggregate $iterator
420-
* @param int $caching_it_flags
421-
*/
422-
public function __construct($iterator, int $flags = self::BYPASS_KEY, $caching_it_flags = CachingIterator::CATCH_GET_CHILD,
423-
int $mode = self::SELF_FIRST) {}
400+
/** @param RecursiveIterator|IteratorAggregate $iterator */
401+
public function __construct(
402+
$iterator, int $flags = self::BYPASS_KEY, int $caching_it_flags = CachingIterator::CATCH_GET_CHILD,
403+
int $mode = self::SELF_FIRST
404+
) {}
424405

425406
/** @return void */
426407
public function rewind() {}
427408

428409
/** @return bool */
429410
public function valid() {}
430411

431-
/** @return string */
412+
/** @return mixed */
432413
public function key() {}
433414

434-
/** @return string|null */
415+
/** @return mixed */
435416
public function current() {}
436417

437418
/** @return void */

ext/spl/spl_iterators_arginfo.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -197,18 +197,6 @@ ZEND_END_ARG_INFO()
197197

198198
#define arginfo_class_RecursiveCachingIterator___construct arginfo_class_CachingIterator___construct
199199

200-
#define arginfo_class_RecursiveCachingIterator_rewind arginfo_class_EmptyIterator_current
201-
202-
#define arginfo_class_RecursiveCachingIterator_valid arginfo_class_EmptyIterator_current
203-
204-
#define arginfo_class_RecursiveCachingIterator_key arginfo_class_EmptyIterator_current
205-
206-
#define arginfo_class_RecursiveCachingIterator_current arginfo_class_EmptyIterator_current
207-
208-
#define arginfo_class_RecursiveCachingIterator_next arginfo_class_EmptyIterator_current
209-
210-
#define arginfo_class_RecursiveCachingIterator_getInnerIterator arginfo_class_EmptyIterator_current
211-
212200
#define arginfo_class_RecursiveCachingIterator_hasChildren arginfo_class_EmptyIterator_current
213201

214202
#define arginfo_class_RecursiveCachingIterator_getChildren arginfo_class_EmptyIterator_current
@@ -296,7 +284,7 @@ ZEND_END_ARG_INFO()
296284
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RecursiveTreeIterator___construct, 0, 0, 1)
297285
ZEND_ARG_INFO(0, iterator)
298286
ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 0)
299-
ZEND_ARG_INFO(0, caching_it_flags)
287+
ZEND_ARG_TYPE_INFO(0, caching_it_flags, IS_LONG, 0)
300288
ZEND_ARG_TYPE_INFO(0, mode, IS_LONG, 0)
301289
ZEND_END_ARG_INFO()
302290

0 commit comments

Comments
 (0)