1--TEST-- 2A generator iterator wrapper involved in a cycle should not leak 3--FILE-- 4<?php 5 6class Test { 7 private $gen1; 8 private $gen2; 9 public function method() { 10 $this->gen1 = (function () { 11 yield 1; 12 yield 2; 13 yield 3; 14 })(); 15 $gen2 = function() { 16 foreach ($this->gen1 as $x) { 17 echo "$x\n"; 18 yield $x; 19 } 20 }; 21 $this->gen2 = $gen2(); 22 foreach ($this->gen2 as $x) { 23 if ($x == 2) { 24 break; 25 } 26 } 27 } 28} 29(new Test)->method(); 30gc_collect_cycles(); 31 32?> 33--EXPECT-- 341 352 36