Skip to content

Commit 4cc241a

Browse files
committed
Fix a few Iterator signatures
1 parent 213b666 commit 4cc241a

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

ext/spl/spl_iterators.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -684,13 +684,17 @@ PHP_METHOD(RecursiveIteratorIterator, getDepth)
684684
PHP_METHOD(RecursiveIteratorIterator, getSubIterator)
685685
{
686686
spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(ZEND_THIS);
687-
zend_long level = object->level;
687+
zend_long level;
688+
zend_bool level_is_null = 1;
688689
zval *value;
689690

690-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &level) == FAILURE) {
691+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &level, &level_is_null) == FAILURE) {
691692
RETURN_THROWS();
692693
}
693-
if (level < 0 || level > object->level) {
694+
695+
if (level_is_null) {
696+
level = object->level;
697+
} else if (level < 0 || level > object->level) {
694698
RETURN_NULL();
695699
}
696700

ext/spl/spl_iterators.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function next() {}
7474
public function getDepth() {}
7575

7676
/** @return RecursiveIterator|null */
77-
public function getSubIterator(int $level = UNKNOWN) {}
77+
public function getSubIterator(?int $level = null) {}
7878

7979
/** @return RecursiveIterator */
8080
public function getInnerIterator() {}

ext/spl/spl_iterators_arginfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 38fb46070ea48e774343e59de53797969acf4b06 */
2+
* Stub hash: 3ae3f106e4691ec7958bed54164b5960c36d88e4 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_EmptyIterator_current, 0, 0, 0)
55
ZEND_END_ARG_INFO()
@@ -51,7 +51,7 @@ ZEND_END_ARG_INFO()
5151
#define arginfo_class_RecursiveIteratorIterator_getDepth arginfo_class_EmptyIterator_current
5252

5353
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RecursiveIteratorIterator_getSubIterator, 0, 0, 0)
54-
ZEND_ARG_TYPE_INFO(0, level, IS_LONG, 0)
54+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, level, IS_LONG, 1, "null")
5555
ZEND_END_ARG_INFO()
5656

5757
#define arginfo_class_RecursiveIteratorIterator_getInnerIterator arginfo_class_EmptyIterator_current

0 commit comments

Comments
 (0)