xref: /PHP-7.3/ext/spl/tests/iterator_069.phpt (revision 782352c5)
1--TEST--
2SPL: RecursiveIteratorIterator cannot be used with foreach by reference
3--FILE--
4<?php
5
6$arr = array(array(1,2));
7$arrOb = new ArrayObject($arr);
8
9$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
10
11$recItIt = new RecursiveIteratorIterator($recArrIt);
12
13foreach ($recItIt as &$val) echo "$val\n";
14
15?>
16--EXPECTF--
17Fatal error: Uncaught RuntimeException: An iterator cannot be used with foreach by reference in %s:%d
18Stack trace:
19#0 {main}
20  thrown in %s on line %d
21