(PHP 5, PHP 7, PHP 8)
ReflectionFunction::__construct — Constrói um objeto ReflectionFunction
Constrói um objeto ReflectionFunction.
   Uma ReflectionException se o parâmetro function
   não contém uma função válida.
  
Exemplo #1 Exemplo de ReflectionFunction::__construct()
<?php
/**
 * Um contador simples
 *
 * @return    int
 */
function counter1()
{
    static $c = 0;
    return ++$c;
}
/**
 * Outro contador simples
 *
 * @return    int
 */
$counter2 = function()
{
    static $d = 0;
    return ++$d;
};
function dumpReflectionFunction($func)
{
    // Exibe informação básica
    printf(
        "\n\n===> A função do tipo %s '%s'\n".
        "     declarada em %s\n".
        "     linhas %d a %d\n",
        $func->isInternal() ? 'internal' : 'user-defined',
        $func->getName(),
        $func->getFileName(),
        $func->getStartLine(),
        $func->getEndline()
    );
    // Exibe comentário de documentação documentation comment
    printf("---> Documentação:\n %s\n", var_export($func->getDocComment(), 1));
    // Exibe variáveis estáticas se existirem
    if ($statics = $func->getStaticVariables())
    {
        printf("---> Variáveis estáticas: %s\n", var_export($statics, 1));
    }
}
// Cria uma instância da classe ReflectionFunction
dumpReflectionFunction(new ReflectionFunction('counter1'));
dumpReflectionFunction(new ReflectionFunction($counter2));
?>O exemplo acima produzirá algo semelhante a:
===> A função do tipo user-defined 'counter1'
     declarada em Z:\reflectcounter.php
     linhas 7 a 11
---> Documentação
 '/**
 * Um contador simples
 *
 * @return    int
 */'
---> Variáveis estáticas: array (
  'c' => 0,
)
===> A função do tipo user-defined '{closure}'
     declarada em Z:\reflectcounter.php
     linhas 18 a 23
---> Documentação
 '/**
 * Outro contador simples
 *
 * @return    int
 */'
---> Static variables: array (
  'd' => 0,
)
