1--TEST-- 2Bug GH-9750 008 (Generator memory leak when interrupted during argument evaluation) 3--SKIPIF-- 4<?php 5if (version_compare(PHP_VERSION, '8.1', '<')) { die('skip Broken on PHP < 8.1'); } 6?> 7--FILE-- 8<?php 9 10class C { 11 function __destruct() { 12 echo __METHOD__, "\n"; 13 } 14} 15 16class D { 17 function __destruct() { 18 echo __METHOD__, "\n"; 19 } 20} 21 22$gen = function ($c) use (&$gen) { 23 new D($gen, yield); 24}; 25 26$gen = $gen(new C()); 27 28foreach ($gen as $value) { 29 break; 30} 31 32$gen = null; 33 34gc_collect_cycles(); 35 36?> 37==DONE== 38--EXPECT-- 39C::__destruct 40==DONE== 41