1--TEST-- 2SPL: IteratorIterator and ArrayIterator/Object 3--FILE-- 4<?php 5 6class ArrayIteratorEx extends ArrayIterator 7{ 8 function rewind(): void 9 { 10 echo __METHOD__ . "\n"; 11 parent::rewind(); 12 } 13} 14 15$it = new ArrayIteratorEx(range(0,3)); 16 17foreach(new IteratorIterator($it) as $v) 18{ 19 var_dump($v); 20} 21 22class ArrayObjectEx extends ArrayObject 23{ 24 function getIterator(): Iterator 25 { 26 echo __METHOD__ . "\n"; 27 return parent::getIterator(); 28 } 29} 30 31$it = new ArrayObjectEx(range(0,3)); 32 33foreach(new IteratorIterator($it) as $v) 34{ 35 var_dump($v); 36} 37 38?> 39--EXPECT-- 40ArrayIteratorEx::rewind 41int(0) 42int(1) 43int(2) 44int(3) 45ArrayObjectEx::getIterator 46int(0) 47int(1) 48int(2) 49int(3) 50