array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'reflectiongenerator.getfunction.php', 1 => 'ReflectionGenerator::getFunction', ), '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', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 7, PHP 8)
ReflectionGenerator::getFunction — Gets the function name of the generator
Enables the function name of the generator to be obtained by returning a class derived from ReflectionFunctionAbstract.
此函数没有参数。
Returns a ReflectionFunctionAbstract class. This will be ReflectionFunction for functions, or ReflectionMethod for methods.
示例 #1 ReflectionGenerator::getFunction() example
<?php
function gen()
{
yield 1;
}
$gen = gen();
$reflectionGen = new ReflectionGenerator($gen);
var_dump($reflectionGen->getFunction());
以上示例的输出类似于:
object(ReflectionFunction)#3 (1) { ["name"]=> string(3) "gen" }