array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'it', ), 'this' => array ( 0 => 'reflectiongenerator.getfunction.php', 1 => 'ReflectionGenerator::getFunction', 2 => 'Gets the function name of the generator', ), 'up' => array ( 0 => 'class.reflectiongenerator.php', 1 => 'ReflectionGenerator', ), 'prev' => array ( 0 => 'reflectiongenerator.getexecutingline.php', 1 => 'ReflectionGenerator::getExecutingLine', ), 'next' => array ( 0 => 'reflectiongenerator.getthis.php', 1 => 'ReflectionGenerator::getThis', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/reflection/reflectiongenerator/getfunction.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>

ReflectionGenerator::getFunction

(PHP 7, PHP 8)

ReflectionGenerator::getFunctionGets the function name of the generator

Descrizione

public ReflectionGenerator::getFunction(): ReflectionFunctionAbstract

Enables the function name of the generator to be obtained by returning a class derived from ReflectionFunctionAbstract.

Elenco dei parametri

Questa funzione non contiene parametri.

Valori restituiti

Returns a ReflectionFunctionAbstract class. This will be ReflectionFunction for functions, or ReflectionMethod for methods.

Log delle modifiche

Versione Descrizione
8.4.0 ReflectionGenerator::getFunction() may now be called after the generator finished executing.

Esempi

Example #1 ReflectionGenerator::getFunction() example

<?php

function gen()
{
yield
1;
}

$gen = gen();

$reflectionGen = new ReflectionGenerator($gen);

var_dump($reflectionGen->getFunction());

Il precedente esempio visualizzerĂ  qualcosa simile a:

object(ReflectionFunction)#3 (1) {
  ["name"]=>
  string(3) "gen"
}

Vedere anche: