1--TEST--
2SPL: RecursiveIteratorIterator - Exception thrown in endchildren which should be handled in next()
3--FILE--
4<?php
5
6$arr = array(array(1,2));
7$arrOb = new ArrayObject($arr);
8
9$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
10
11class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
12
13    function endchildren(): void {
14        throw new Exception;
15    }
16}
17
18
19$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);
20
21foreach ($recItIt as $val) echo "$val\n";
22
23$recItIt2 = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);
24
25echo "===NEXT LOOP===\n";
26
27foreach ($recItIt2 as $val) echo "$val\n";
28
29?>
30--EXPECTF--
311
322
33===NEXT LOOP===
341
352
36
37Fatal error: Uncaught Exception in %s
38Stack trace:
39#0 [internal function]: MyRecursiveIteratorIterator->endchildren()
40#1 %s: RecursiveIteratorIterator->next()
41#2 {main}
42  thrown in %s on line %d
43