ReflectionFunction::__constructConstruit un nouvel objet ReflectionFunction
&reftitle.description;
publicReflectionFunction::__constructClosurestringfunction
Construit un nouvel objet ReflectionFunction.
&reftitle.parameters;
function
Le nom de la fonction à refléter ou une
fermeture.
&reftitle.errors;
Une exception ReflectionException si le paramètre function
contient une fonction invalide.
&reftitle.examples;
Exemple avec ReflectionFunction::__construct
The %s function '%s'\n".
" declared in %s\n".
" lines %d to %d\n",
$func->isInternal() ? 'internal' : 'user-defined',
$func->getName(),
$func->getFileName(),
$func->getStartLine(),
$func->getEndline()
);
// Affiche les commentaires de documentation
printf("---> Documentation:\n %s\n", var_export($func->getDocComment(), 1));
// Affiche les variables statiques existantes
if ($statics = $func->getStaticVariables())
{
printf("---> Static variables: %s\n", var_export($statics, 1));
}
}
// Créer une instance de la classe ReflectionFunction
dumpReflectionFunction(new ReflectionFunction('counter1'));
dumpReflectionFunction(new ReflectionFunction($counter2));
?>
]]>
&example.outputs.similar;
The user-defined function 'counter1'
declared in Z:\reflectcounter.php
lines 7 to 11
---> Documentation:
'/**
* A simple counter
*
* @return int
*/'
---> Static variables: array (
'c' => 0,
)
===> The user-defined function '{closure}'
declared in Z:\reflectcounter.php
lines 18 to 23
---> Documentation:
'/**
* Another simple counter
*
* @return int
*/'
---> Static variables: array (
'd' => 0,
)
]]>
&reftitle.seealso;
ReflectionMethod::__constructLes constructeurs