Skip to content

Commit 11f62c9

Browse files
committed
Revert "IteratorIterator::getInnerIterator() can't return null"
This reverts commit c252420. This (currently) does not hold for invalid AppendIterators, revert for now.
1 parent c252420 commit 11f62c9

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

ext/spl/spl_iterators.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,9 +1447,13 @@ PHP_METHOD(IteratorIterator, getInnerIterator)
14471447

14481448
SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
14491449

1450-
zval *value = &intern->inner.zobject;
1451-
ZEND_ASSERT(!Z_ISUNDEF_P(value));
1452-
ZVAL_COPY_DEREF(return_value, value);
1450+
if (!Z_ISUNDEF(intern->inner.zobject)) {
1451+
zval *value = &intern->inner.zobject;
1452+
1453+
ZVAL_COPY_DEREF(return_value, value);
1454+
} else {
1455+
RETURN_NULL();
1456+
}
14531457
} /* }}} */
14541458

14551459
static inline void spl_dual_it_free(spl_dual_it_object *intern)

ext/spl/spl_iterators.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class IteratorIterator implements OuterIterator
117117
{
118118
public function __construct(Traversable $iterator, ?string $class = null) {}
119119

120-
/** @return Iterator */
120+
/** @return Iterator|null */
121121
public function getInnerIterator() {}
122122

123123
/** @return void */

ext/spl/spl_iterators_arginfo.h

Lines changed: 1 addition & 1 deletion
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: d1cb33b7c3d1b480b68c6e52672a8ee2a3b382ef */
2+
* Stub hash: de49628718b5fff1a3b2516cc89108e01b67c312 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_EmptyIterator_current, 0, 0, 0)
55
ZEND_END_ARG_INFO()

0 commit comments

Comments
 (0)