ReflectionGenerator::getThis

(PHP 7, PHP 8)

ReflectionGenerator::getThisObtiene el valor de $this del generador

Descripción

public ReflectionGenerator::getThis(): ?object

Obtiene el valor de $this del generador al que tiene acceso.

Parámetros

Esta función no tiene parámetros.

Valores devueltos

Devuelve el valor de $this, o null si el generador no ha sido creado en un contexto de clase.

Ejemplos

Ejemplo #1 Ejemplo con ReflectionGenerator::getThis()

<?php

class GenExample
{
public function
gen()
{
yield
1;
}
}

$gen = (new GenExample)->gen();

$reflectionGen = new ReflectionGenerator($gen);

var_dump($reflectionGen->getThis());

El resultado del ejemplo sería algo similar a:

object(GenExample)#3 (0) {
}

Ver también

add a note

User Contributed Notes

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