ReflectionMethod::__constructTworzy obiekt ReflectionMethod
&reftitle.description;
publicReflectionMethod::__constructobjectstringobjectOrMethodstringmethodAlternative signature (not supported with named arguments):publicReflectionMethod::__constructstringclassMethod
Alternatywna sygnatura jest przestarzała od PHP 8.4.0,
zamiast niej skorzystaj z ReflectionMethod::createFromMethodName.
Tworzy obiekt ReflectionMethod.
&reftitle.parameters;
objectOrMethod
Nazwa klasy lub obiekt (instancja klasy), która zawiera metodę.
method
Nazwa metody.
classMethod
Nazwa klasy i nazwa metody oddzielone ::.
&reftitle.errors;
Rzuca ReflectionException jeśli podana metoda nie istnieje.
&reftitle.examples;
Przykład użycia ReflectionMethod::__construct
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()))
);
// Wyświetl komentarz dokumentujący
printf("---> Dokumentacja:\n %s\n", var_export($method->getDocComment(), true));
// Wyświetl właściwości statyczne jeśli istnieją
if ($statics= $method->getStaticVariables()) {
printf("---> Statyczne właściwości: %s\n", var_export($statics, true));
}
// Wywołaj metodę
printf("---> Wynik wywołania: ");
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]
---> Dokumentacja:
'/**
* Zwiększa licznik
*
* @final
* @static
* @access public
* @return int
*/'
---> Wynik wywołania: int(1)
]]>
&reftitle.seealso;
ReflectionMethod::exportKonstruktory