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