1--TEST-- 2Multiple yield from on a same Generator instance 3--FILE-- 4<?php 5 6function gen($a = 0) { 7 yield 1 + $a; 8 if ($a < 1) { 9 var_dump(yield from gen($a + 1)); 10 } 11 yield 3 + $a; 12 return 5 + $a; 13} 14 15function bar($gen) { 16 var_dump(yield from $gen); 17} 18 19/* Twice a Generator from bar() using yield from on $gen */ 20$gen = gen(); 21$gens[] = bar($gen); 22$gens[] = bar($gen); 23 24do { 25 foreach ($gens as $g) { 26 var_dump($g->current()); 27 $g->next(); 28 } 29} while($gens[0]->valid()); 30var_dump($gens[1]->valid()); 31 32?> 33--EXPECT-- 34int(1) 35int(2) 36int(4) 37int(6) 38int(3) 39int(5) 40int(3) 41int(5) 42NULL 43bool(false) 44