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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?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.