php-src/ext/reflection/tests/ReflectionGenerator_in_Generator.phpt
Dmitry Stogov ca49e53670 Stop inserting fake frames on VM stack.
Now similar "fake" frames now materialized when fetching debug
backtraces. The patch also fixes few incorrect backtraces for generators
in *.phpt tests.
2021-04-15 15:30:10 +03:00

85 lines
1.4 KiB
PHP

--TEST--
ReflectionGenerator while being currently executed
--FILE--
<?php
function call(ReflectionGenerator $ref, $method, $rec = true) {
if ($rec) {
call($ref, $method, false);
return;
}
var_dump($ref->$method());
}
function doCalls(ReflectionGenerator $ref) {
call($ref, "getTrace");
call($ref, "getExecutingLine");
call($ref, "getExecutingFile");
call($ref, "getExecutingGenerator");
call($ref, "getFunction");
call($ref, "getThis");
}
($gen = (function() use (&$gen) {
$ref = new ReflectionGenerator($gen);
doCalls($ref);
yield from (function() use ($ref) {
doCalls($ref);
yield; // Generator !
})();
})())->next();
?>
--EXPECTF--
array(1) {
[0]=>
array(2) {
["function"]=>
string(9) "{closure}"
["args"]=>
array(0) {
}
}
}
int(%d)
string(%d) "%sReflectionGenerator_in_Generator.%s"
object(Generator)#2 (0) {
}
object(ReflectionFunction)#4 (1) {
["name"]=>
string(9) "{closure}"
}
NULL
array(2) {
[0]=>
array(4) {
["file"]=>
string(%d) "%s"
["line"]=>
int(%d)
["function"]=>
string(9) "{closure}"
["args"]=>
array(0) {
}
}
[1]=>
array(2) {
["function"]=>
string(9) "{closure}"
["args"]=>
array(0) {
}
}
}
int(%d)
string(%d) "%sReflectionGenerator_in_Generator.%s"
object(Generator)#5 (0) {
}
object(ReflectionFunction)#6 (1) {
["name"]=>
string(9) "{closure}"
}
NULL