1--TEST-- 2ReflectionGenerator::getFunction() 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 $ref = new ReflectionGenerator($gen); 24 25 echo "Before: ", $ref->getFunction()->getName(), PHP_EOL; 26 27 foreach ($gen as $dummy) { 28 echo "Inside: ", $ref->getFunction()->getName(), PHP_EOL; 29 } 30 31 echo "After: ", $ref->getFunction()->getName(), PHP_EOL; 32} 33 34?> 35--EXPECTF-- 36Before: a 37Inside: a 38After: a 39Before: {closure:%s:%d} 40Inside: {closure:%s:%d} 41After: {closure:%s:%d} 42Before: foo 43Inside: foo 44After: foo 45