summaryrefslogtreecommitdiff
path: root/Zend/tests/bug64979.phpt
blob: 6122ccf2707176794bc9ec45348b11b8cfa8abc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
--TEST--
Bug #64979 (Wrong behavior of static variables in closure generators)
--FILE--
<?php

function new_closure_gen() {
    return function() {
        static $foo = 0;
        yield ++$foo;
    };
}

$closure1 = new_closure_gen();
$closure2 = new_closure_gen();

$gen1 = $closure1();
$gen2 = $closure1();
$gen3 = $closure2();

foreach (array($gen1, $gen2, $gen3) as $gen) {
    foreach ($gen as $val) {
        var_dump($val);
    }
}

?>
--EXPECT--
int(1)
int(2)
int(1)