2013-06-22 02:08:15 +00:00
|
|
|
--TEST--
|
2013-09-29 18:18:12 +00:00
|
|
|
Bug #64979 (Wrong behavior of static variables in closure generators)
|
2013-06-22 02:08:15 +00:00
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
|
|
|
|
function new_closure_gen() {
|
2013-09-29 18:18:12 +00:00
|
|
|
return function() {
|
|
|
|
static $foo = 0;
|
|
|
|
yield ++$foo;
|
|
|
|
};
|
2013-06-22 02:08:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$closure1 = new_closure_gen();
|
|
|
|
$closure2 = new_closure_gen();
|
|
|
|
|
|
|
|
$gen1 = $closure1();
|
|
|
|
$gen2 = $closure1();
|
|
|
|
$gen3 = $closure2();
|
|
|
|
|
|
|
|
foreach (array($gen1, $gen2, $gen3) as $gen) {
|
2013-09-29 18:18:12 +00:00
|
|
|
foreach ($gen as $val) {
|
|
|
|
var_dump($val);
|
|
|
|
}
|
2013-06-22 02:08:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
--EXPECT--
|
|
|
|
int(1)
|
|
|
|
int(2)
|
|
|
|
int(1)
|