xref: /PHP-5.5/Zend/tests/bug64979.phpt (revision 6b68f44e)
1--TEST--
2Bug #64979 (Wrong behavior of static variables in closure generators)
3--FILE--
4<?php
5
6function new_closure_gen() {
7    return function() {
8        static $foo = 0;
9        yield ++$foo;
10    };
11}
12
13$closure1 = new_closure_gen();
14$closure2 = new_closure_gen();
15
16$gen1 = $closure1();
17$gen2 = $closure1();
18$gen3 = $closure2();
19
20foreach (array($gen1, $gen2, $gen3) as $gen) {
21    foreach ($gen as $val) {
22        var_dump($val);
23    }
24}
25
26?>
27--EXPECT--
28int(1)
29int(2)
30int(1)
31