1--TEST-- 2SPL: RecursiveIteratorIterator::endIteration() is called when ::valid() first returns false 3--CREDITS-- 4Matt Raines matt@raines.me.uk 5#testfest London 2009-05-09 6--FILE-- 7<?php 8$sample_array = array(1, 2); 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 EndIterationRecursiveIteratorIterator extends RecursiveIteratorIterator { 17 public function endIteration() { 18 echo "::endIteration() was invoked\n"; 19 } 20} 21$iterator = new EndIterationRecursiveIteratorIterator($sub_iterator); 22foreach ($iterator as $element) { 23 var_dump($element); 24} 25?> 26--EXPECT-- 27int(1) 28int(2) 29int(1) 30int(2) 31::endIteration() was invoked 32 33