bug64979.phpt 476 B

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