(PHP 7, PHP 8)
ReflectionGenerator::getThis — 获取生成器的 $this 值
此函数没有参数。
返回 $this 值,如果生成器不是在类上下文中创建的,则返回 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) {
}