3v4l.org

run code in 300+ PHP versions simultaneously
<?php class FooManager { public function test($foos) { foreach ($foos as $item) { yield from $item->test(); } } } class Foo { public function test() { return $this->getGenerator(range(0, 10)); } public function getGenerator(array $items) { foreach ($items as $item) { yield $item; } } } $f = new FooManager; $foos = [new Foo,new Foo,new Foo,new Foo]; foreach ($f->test($foos) as $int) { var_dump($int); }

preferences:
46.48 ms | 402 KiB | 5 Q