ReflectionMethod::getDeclaringClass
(PHP 5, PHP 7, PHP 8)
ReflectionMethod::getDeclaringClass — 获取被反射的方法所在类的反射实例
参数
此函数没有参数。
返回值
返回一个类的 ReflectionClass 反射对象,被反射的方法是这个类的一部分。
范例
示例 #1 ReflectionMethod::getDeclaringClass() example
<?php
class HelloWorld {
protected function sayHelloTo($name) {
return 'Hello ' . $name;
}
}
$reflectionMethod = new ReflectionMethod(new HelloWorld(), 'sayHelloTo');
var_dump($reflectionMethod->getDeclaringClass());
?>
以上例程会输出:
object(ReflectionClass)#2 (1) { ["name"]=> string(10) "HelloWorld" }

User Contributed Notes
There are no user contributed notes for this page.
备份地址:http://www.lvesu.com/blog/php/reflectionmethod.getdeclaringclass.php