1--TEST-- 2ReflectionGenerator while being currently executed 3--FILE-- 4<?php 5 6function call(ReflectionGenerator $ref, $method, $rec = true) { 7 if ($rec) { 8 call($ref, $method, false); 9 return; 10 } 11 var_dump($ref->$method()); 12} 13 14function doCalls(ReflectionGenerator $ref) { 15 call($ref, "getTrace"); 16 call($ref, "getExecutingLine"); 17 call($ref, "getExecutingFile"); 18 call($ref, "getExecutingGenerator"); 19 call($ref, "getFunction"); 20 call($ref, "getThis"); 21} 22 23($gen = (function() use (&$gen) { 24 $ref = new ReflectionGenerator($gen); 25 26 doCalls($ref); 27 28 yield from (function() use ($ref) { 29 doCalls($ref); 30 yield; // Generator ! 31 })(); 32})())->next(); 33 34?> 35--EXPECTF-- 36array(0) { 37} 38int(%d) 39string(%d) "%sReflectionGenerator_in_Generator.%s" 40object(Generator)#2 (0) { 41} 42object(ReflectionFunction)#4 (1) { 43 ["name"]=> 44 string(9) "{closure}" 45} 46NULL 47array(1) { 48 [0]=> 49 array(4) { 50 ["file"]=> 51 string(%d) "%s" 52 ["line"]=> 53 int(%d) 54 ["function"]=> 55 string(9) "{closure}" 56 ["args"]=> 57 array(0) { 58 } 59 } 60} 61int(%d) 62string(%d) "%sReflectionGenerator_in_Generator.%s" 63object(Generator)#5 (0) { 64} 65object(ReflectionFunction)#6 (1) { 66 ["name"]=> 67 string(9) "{closure}" 68} 69NULL 70