<?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);
}