ReflectionGenerator::getExecutingGenerator
ReflectionGenerator::getExecutingGenerator
(PHP 7)
ReflectionGenerator :: getExecutingGenerator - 获取正在执行的Generator对象
描述
public Generator ReflectionGenerator::getExecutingGenerator ( void )
获取正在执行的Generator对象
参数
该功能没有参数。
返回值
返回当前正在执行的Generator对象。
例子
示例#1 ReflectionGenerator :: getExecutingGenerator()示例
<?php
class GenExample
{
public function gen()
{
yield 1;
}
}
$gen = (new GenExample)->gen(
$reflectionGen = new ReflectionGenerator($gen
$gen2 = $reflectionGen->getExecutingGenerator(
var_dump($gen2 === $gen
var_dump($gen2->current()
上面的例子会输出类似于:
bool(true)
int(1
← ReflectionGenerator::getExecutingFile
ReflectionGenerator::getExecutingLine →