(PHP 5, PHP 7, PHP 8)
ReflectionMethod::getDeclaringClass — Gets declaring class for the reflected method
Gets the declaring class for the reflected method.
Esta função não possui parâmetros.
A ReflectionClass object of the class that the reflected method is part of.
Exemplo #1 ReflectionMethod::getDeclaringClass() example
<?php
class HelloWorld {
protected function sayHelloTo($name) {
return 'Hello ' . $name;
}
}
$reflectionMethod = new ReflectionMethod(new HelloWorld(), 'sayHelloTo');
var_dump($reflectionMethod->getDeclaringClass());
?>
O exemplo acima produzirá:
object(ReflectionClass)#2 (1) { ["name"]=> string(10) "HelloWorld" }