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