3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Baz{} class Test implements Iterator { function key(){ return new Baz(); } function next(){} function valid(){ $this->count++; return $this->count < 4; } function current(){ return "foo"; } function rewind(){} } foreach(new Test as $x => $v) var_dump($x, $v);

preferences:
57.93 ms | 402 KiB | 5 Q