ReflectionMethod::__constructConstructs a ReflectionMethod
&reftitle.description;
publicReflectionMethod::__constructmixedclassstringname
Constructs a new ReflectionMethod.
&reftitle.parameters;
class
Classname or object (instance of the class) that contains the method.
name
Name of the method.
&reftitle.returnvalues;
&return.void;
&reftitle.errors;
A ReflectionException is thrown if the given method does not exist.
&reftitle.examples;
ReflectionMethod::__construct example
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()))
);
// Print documentation comment
printf("---> Documentation:\n %s\n", var_export($method->getDocComment(), 1));
// Print static variables if existant
if ($statics= $method->getStaticVariables()) {
printf("---> Static variables: %s\n", var_export($statics, 1));
}
// Invoke the method
printf("---> Invocation results in: ");
var_dump($method->invoke(NULL));
?>
]]>
&example.outputs.similar;
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:
'/**
* Increment counter
*
* @final
* @static
* @access public
* @return int
*/'
---> Invocation results in: int(1)
]]>
&reftitle.seealso;
ReflectionMethod::exportConstructors