summaryrefslogtreecommitdiff
path: root/Zend/tests/generators/no_foreach_var_leaks.phpt
blob: c9d56b9fb7b05c5ada8c60f5fa6d00bea7c02407 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
--TEST--
foreach() (and other) variables aren't leaked on premature close
--FILE--
<?php

function gen(array $array) {
    foreach ($array as $value) {
        yield $value;
    }
}

$gen = gen(['Foo', 'Bar']);
var_dump($gen->current());

// generator is closed here, without running SWITCH_FREE

?>
--EXPECT--
string(3) "Foo"