ジェネレータの $this の値を取得する
$this
ジェネレータがアクセスできる $this の値を取得します。
この関数にはパラメータはありません。
$this の値を返します。 ジェネレータがクラスコンテキストの中で作られていない場合は null を返します。
null
例1 ReflectionGenerator::getThis の例
<?php class GenExample { public function gen() { yield 1; } } $gen = (new GenExample)->gen(); $reflectionGen = new ReflectionGenerator($gen); var_dump($reflectionGen->getThis());
上の例の出力は、 たとえば以下のようになります。
object(GenExample)#3 (0) { }