ReflectionGenerator::__construct

(PHP 7, PHP 8)

ReflectionGenerator::__constructReflectionGenerator オブジェクトを構築する

説明

publicReflectionGenerator::__construct(Generator$generator)

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

参考

To Top