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(1) { 37 [0]=> 38 array(2) { 39 ["function"]=> 40 string(9) "{closure}" 41 ["args"]=> 42 array(0) { 43 } 44 } 45} 46int(%d) 47string(%d) "%sReflectionGenerator_in_Generator.%s" 48object(Generator)#2 (0) { 49} 50object(ReflectionFunction)#4 (1) { 51 ["name"]=> 52 string(9) "{closure}" 53} 54NULL 55array(2) { 56 [0]=> 57 array(4) { 58 ["file"]=> 59 string(%d) "%s" 60 ["line"]=> 61 int(%d) 62 ["function"]=> 63 string(9) "{closure}" 64 ["args"]=> 65 array(0) { 66 } 67 } 68 [1]=> 69 array(2) { 70 ["function"]=> 71 string(9) "{closure}" 72 ["args"]=> 73 array(0) { 74 } 75 } 76} 77int(%d) 78string(%d) "%sReflectionGenerator_in_Generator.%s" 79object(Generator)#5 (0) { 80} 81object(ReflectionFunction)#6 (1) { 82 ["name"]=> 83 string(9) "{closure}" 84} 85NULL 86