1
0
mirror of https://github.com/php/php-src.git synced 2026-04-13 19:14:16 +02:00
Files
archived-php-src/Zend/tests/generators/iterator_wrapper_leak.phpt
Nikita Popov 271bc689ea Add iterator get_gc function for generators
Closes GH-5787.
2020-07-01 15:17:26 +02:00

34 lines
612 B
PHP

--TEST--
A generator iterator wrapper involved in a cycle should not leak
--FILE--
<?php
class Test {
public function method() {
$this->gen1 = (function () {
yield 1;
yield 2;
yield 3;
})();
$gen2 = function() {
foreach ($this->gen1 as $x) {
echo "$x\n";
yield $x;
}
};
$this->gen2 = $gen2();
foreach ($this->gen2 as $x) {
if ($x == 2) {
break;
}
}
}
}
(new Test)->method();
gc_collect_cycles();
?>
--EXPECT--
1
2