1
0
mirror of https://github.com/php/php-src.git synced 2026-04-17 21:11:02 +02:00
Files
archived-php-src/Zend/tests/generators/iterator_wrapper_leak.phpt
Nikita Popov 902d64390e Deprecate implicit dynamic properties
Writing to a proprety that hasn't been declared is deprecated,
unless the class uses the #[AllowDynamicProperties] attribute or
defines __get()/__set().

RFC: https://wiki.php.net/rfc/deprecate_dynamic_properties
2021-11-26 14:10:11 +01:00

36 lines
650 B
PHP

--TEST--
A generator iterator wrapper involved in a cycle should not leak
--FILE--
<?php
class Test {
private $gen1;
private $gen2;
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