ReflectionGenerator::getThis

(PHP 7)
Gets the $this value of the generator
public object ReflectionGenerator::getThis ( void )

Get the $this value that the generator has access to.

Returns:

Returns the $this value, or NULL if the generator was not created in a class context.

Examples:
ReflectionGenerator::getThis() example
<?php

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

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

$reflectionGen = new ReflectionGenerator($gen);

var_dump($reflectionGen->getThis());

The above example will output something similar to:

object(GenExample)#3 (0) {
}
See also:

ReflectionGenerator::getFunction() -

ReflectionGenerator::getTrace() -

doc_php
2016-02-24 16:13:53
Comments
Leave a Comment

Please login to continue.