ReflectionGenerator::getTrace

(PHP 7, PHP 8)

ReflectionGenerator::getTraceObtiene la traza del generador en ejecución

Descripción

public ReflectionGenerator::getTrace(int $options = DEBUG_BACKTRACE_PROVIDE_OBJECT): array

Obtiene la traza del generador actualmente en ejecución.

Parámetros

options

El valor de options puede ser cualquiera de los flags siguientes.

Opciones disponibles
Opción Descripción
DEBUG_BACKTRACE_PROVIDE_OBJECT Por omisión.
DEBUG_BACKTRACE_IGNORE_ARGS No incluye las informaciones de los argumentos para las funciones en la traza de llamadas.

Valores devueltos

Devuelve la traza del generador actualmente en ejecución.

Ejemplos

Ejemplo #1 Ejemplo con 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());

El resultado del ejemplo sería algo similar a:

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) {
    }
  }
}

Ver también

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top