PHP 8.4.0 RC4 available for testing

ReflectionGenerator::__construct

(PHP 7, PHP 8)

ReflectionGenerator::__constructConstructs a ReflectionGenerator object

Опис

public ReflectionGenerator::__construct(Generator $generator)

Constructs a ReflectionGenerator object.

Параметри

generator

A generator object.

Приклади

Приклад #1 ReflectionGenerator::__construct() example

<?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

Прогляньте також

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top