(PHP 7, PHP 8)
ReflectionGenerator::getTrace — Récupère la trace du générateur exécutant
$options = DEBUG_BACKTRACE_PROVIDE_OBJECT): arrayRécupère la trace du générateur actuellement exécuté.
options
       La valeur d'options peut être n'importe laquelle
       des drapeaux suivant.
      
| Option | Description | 
|---|---|
| DEBUG_BACKTRACE_PROVIDE_OBJECT | Par défaut. | 
| DEBUG_BACKTRACE_IGNORE_ARGS | N'inclue pas les informations des arguments pour les fonctions dans la trace d'appels. | 
Retourne la trace du générateur actuellement exécuté.
Exemple #1 Exemple avec ReflectionGenerator::getTrace()
<?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());
Résultat de l'exemple ci-dessus est similaire à :
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) {
    }
  }
}