1--TEST-- 2SPL: RecursiveIteratorIterator::nextElement() is called when the next element is ready 3--CREDITS-- 4Matt Raines matt@raines.me.uk 5#testfest London 2009-05-09 6--FILE-- 7<?php 8$sample_array = array(1, 2, array(3, 4)); 9$sub_iterator = new RecursiveArrayIterator($sample_array); 10 11$iterator = new RecursiveIteratorIterator($sub_iterator); 12foreach ($iterator as $element) { 13 var_dump($element); 14} 15 16class NextElementRecursiveIteratorIterator extends RecursiveIteratorIterator { 17 public function nextElement() { 18 echo "::nextElement() was invoked\n"; 19 } 20} 21$iterator = new NextElementRecursiveIteratorIterator($sub_iterator); 22foreach ($iterator as $element) { 23 var_dump($element); 24} 25?> 26--EXPECT-- 27int(1) 28int(2) 29int(3) 30int(4) 31::nextElement() was invoked 32int(1) 33::nextElement() was invoked 34int(2) 35::nextElement() was invoked 36int(3) 37::nextElement() was invoked 38int(4) 39 40