mirror of
https://github.com/php/php-src.git
synced 2026-04-19 22:11:12 +02:00
The DO_INIT flag, which will skip the first resume on a primed generator, should always be set when starting to yield from a new generator, not only when the yield from happens during priming.
28 lines
413 B
PHP
28 lines
413 B
PHP
--TEST--
|
|
Bug #78434: Generator skips first item after valid() call
|
|
--FILE--
|
|
<?php
|
|
|
|
$function = function () {
|
|
yield 0;
|
|
};
|
|
|
|
$wrapper = function () use ($function) {
|
|
$generator = $function();
|
|
$generator->valid();
|
|
yield from $generator;
|
|
|
|
$generator = $function();
|
|
$generator->valid();
|
|
yield from $generator;
|
|
};
|
|
|
|
foreach ($wrapper() as $value) {
|
|
echo $value, "\n";
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
0
|
|
0
|