- var_dump: documentation ( source)
<?php
function gen() {
// TODO: HHVM currently does not support yield from (or yield) as
// expressions. As such, this test had to be slightly modified.
// The original line was:
// var_dump(yield from gen($a + 1));
//$b = yield from gen($a + 1);
yield 1;
yield 2;
var_dump('in the middle of gen');
yield 3;
yield 4;
}
function bar($gen) {
// TODO: HHVM currently does not support yield from (or yield) as
// expressions. As such, this test had to be slightly modified.
// The original line was:
// var_dump(yield from gen($a + 1));
yield from $gen;
}
/* Twice a Generator from bar() using yield from on $gen */
$gen = gen();
$gens[] = bar($gen);
$gens[] = bar($gen);
do {
foreach ($gens as $g) {
var_dump($g->current());
$g->next();
}
} while($gens[0]->valid());
var_dump($gens[1]->valid());