(PHP 7, PHP 8)
ReflectionGenerator::getTrace — 実行中のジェネレータのトレースを取得する
現在実行中のジェネレータのトレースを取得します。
options
options の値は以下のフラグのうちのいずれかです:
| オプション | 説明 |
|---|---|
DEBUG_BACKTRACE_PROVIDE_OBJECT
|
デフォルト |
DEBUG_BACKTRACE_IGNORE_ARGS
|
スタックトレース内の関数に引数の情報を含めない |
現在実行中のジェネレータのトレースを返します。
例1 ReflectionGenerator::getTrace() の例
<?php
function foo() {
yield 1;
}
function bar()
{
yield from foo();
}
function baz()
{
yield from bar();
}
$gen = baz();
$gen->valid(); // ジェネレータを開始
var_dump((new ReflectionGenerator($gen))->getTrace());上の例の出力は、 たとえば以下のようになります。
array(2) {
[0]=>
array(4) {
["file"]=>
string(18) "example.php"
["line"]=>
int(8)
["function"]=>
string(3) "foo"
["args"]=>
array(0) {
}
}
[1]=>
array(4) {
["file"]=>
string(18) "example.php"
["line"]=>
int(12)
["function"]=>
string(3) "bar"
["args"]=>
array(0) {
}
}
}