php-src/ext/spl/tests/iterator_069.phpt
Nikita Popov ede663f381 Convert iterator by reference errors to exceptions
I'm using RuntimeException in SPL, because other SPL classes that
throw this error used it. Error is used for everything else, because
that's what core does.
2018-02-19 21:58:56 +01:00

21 lines
485 B
PHP

--TEST--
SPL: RecursiveIteratorIterator cannot be used with foreach by reference
--FILE--
<?php
$arr = array(array(1,2));
$arrOb = new ArrayObject($arr);
$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
$recItIt = new RecursiveIteratorIterator($recArrIt);
foreach ($recItIt as &$val) echo "$val\n";
?>
--EXPECTF--
Fatal error: Uncaught RuntimeException: An iterator cannot be used with foreach by reference in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d