1--TEST-- 2Creating ReflectionGenerator is legal after termination. 3--FILE-- 4<?php 5 6function foo() { 7 yield; 8} 9 10$gens = [ 11 (new class() { 12 function a() { 13 yield from foo(); 14 } 15 })->a(), 16 (function() { 17 yield; 18 })(), 19 foo(), 20]; 21 22foreach ($gens as $gen) { 23 foreach ($gen as $dummy); 24 25 $ref = new ReflectionGenerator($gen); 26 echo $ref->getFunction()->getName(), PHP_EOL; 27} 28 29?> 30--EXPECTF-- 31a 32{closure:%s:%d} 33foo 34