(PHP 7)
ReflectionGenerator::getTrace — Gets the trace of the executing generator
public ReflectionGenerator::getTrace ([ int $options = DEBUG_BACKTRACE_PROVIDE_OBJECT ] ) : array
Get the trace of the currently executing generator.
options
The value of options
can be any of the following flags.
Option | Description |
---|---|
DEBUG_BACKTRACE_PROVIDE_OBJECT | Default. |
DEBUG_BACKTRACE_IGNORE_ARGS | Don't include the argument information for functions in the stack trace. |
Returns the trace of the currently executing generator.
Example #1 ReflectionGenerator::getTrace() example
<?php function foo() { yield 1; } function bar() { yield from foo(); } function baz() { yield from bar(); } $gen = baz(); $gen->valid(); // start the generator var_dump((new ReflectionGenerator($gen))->getTrace());
The above example will output something similar to:
© 1997–2020 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/reflectiongenerator.gettrace.php