(PHP 5)
ReflectionMethod::__construct — Construit un nouvel objet ReflectionMethod
Construit un nouvel objet ReflectionMethod.
class
     Nom de classe -ou instance de celle-ci- qui contient la méthode.
name
     Nom de la méthode.
Aucune valeur n'est retournée.
Une ReflectionException est émise si la méthode considérée n'existe pas.
Exemple #1 Exemple avec ReflectionMethod::__construct()
<?php
class Counter
{
    private static $c = 0;
    /**
     * Compteur qui s'incrémente
     *
     * @final
     * @static
     * @access  public
     * @return  int
     */
    final public static function increment()
    {
        return ++self::$c;
    }
}
// Crée une nouvelle instance de la classe ReflectionMethod
$method = new ReflectionMethod('Counter', 'increment');
// Affiche des informations
printf(
    "===> The %s%s%s%s%s%s%s method '%s' (which is %s)\n" .
    "     declared in %s\n" .
    "     lines %d to %d\n" .
    "     having the modifiers %d[%s]\n",
        $method->isInternal() ? 'internal' : 'user-defined',
        $method->isAbstract() ? ' abstract' : '',
        $method->isFinal() ? ' final' : '',
        $method->isPublic() ? ' public' : '',
        $method->isPrivate() ? ' private' : '',
        $method->isProtected() ? ' protected' : '',
        $method->isStatic() ? ' static' : '',
        $method->getName(),
        $method->isConstructor() ? 'the constructor' : 'a regular method',
        $method->getFileName(),
        $method->getStartLine(),
        $method->getEndline(),
        $method->getModifiers(),
        implode(' ', Reflection::getModifierNames($method->getModifiers()))
);
// Affiche le commentaire de la documentation
printf("---> Documentation:\n %s\n", var_export($method->getDocComment(), 1));
// Affiche les variables statiques, si elles existent
if ($statics= $method->getStaticVariables()) {
    printf("---> Static variables: %s\n", var_export($statics, 1));
}
// Invoque la méthode
printf("---> Invocation results in: ");
var_dump($method->invoke(NULL));
?>
L'exemple ci-dessus va afficher quelque chose de similaire à :
===> The user-defined final public static method 'increment' (which is a regular method)
     declared in /Users/philip/cvs/phpdoc/test.php
     lines 14 to 17
     having the modifiers 261[final public static]
---> Documentation:
 '/**
     * Compteur qui s'incrémente
     *
     * @final
     * @static
     * @access  public
     * @return  int
     */'
---> Invocation results in: int(1)