mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +01:00
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_arrayobject_and_arrayiterator_with_objects This also moves tests into a subfolder.
44 lines
879 B
PHP
44 lines
879 B
PHP
--TEST--
|
|
SPL: RecursiveIteratorIterator - Exception thrown in endchildren which should be handled in next()
|
|
--FILE--
|
|
<?php
|
|
|
|
$recArrIt = new RecursiveArrayIterator([
|
|
[1, 2],
|
|
['a', 'b'],
|
|
]);
|
|
|
|
class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
|
|
|
|
function endchildren(): void {
|
|
throw new Exception;
|
|
}
|
|
}
|
|
|
|
|
|
$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);
|
|
|
|
foreach ($recItIt as $val) echo "$val\n";
|
|
|
|
$recItIt2 = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);
|
|
|
|
echo "===NEXT LOOP===\n";
|
|
|
|
foreach ($recItIt2 as $val) echo "$val\n";
|
|
|
|
?>
|
|
--EXPECTF--
|
|
1
|
|
2
|
|
a
|
|
b
|
|
===NEXT LOOP===
|
|
1
|
|
2
|
|
|
|
Fatal error: Uncaught Exception in %s
|
|
Stack trace:
|
|
#0 %s(%d): MyRecursiveIteratorIterator->endchildren()
|
|
#1 {main}
|
|
thrown in %s on line %d
|