(PHP 7, PHP 8)
ReflectionGenerator::__construct — 构造一个 ReflectionGenerator 对象
generator
一个生成器对象。
示例 #1 ReflectionGenerator::__construct() 示例
<?php
function gen()
{
yield 1;
}
$gen = gen();
$reflectionGen = new ReflectionGenerator($gen);
echo <<< output
{$reflectionGen->getFunction()->name}
Line: {$reflectionGen->getExecutingLine()}
File: {$reflectionGen->getExecutingFile()}
output;
上面的例子将输出类似于
gen Line: 5 File: /path/to/file/example.php