ReflectionMethod::getDeclaringClass
(PHP 5, PHP 7)
ReflectionMethod :: getDeclaringClass - 获取反射方法的类声明。
描述
public ReflectionClass ReflectionMethod::getDeclaringClass ( void )
获取反射方法的声明类。
参数
该功能没有参数。
返回值
反射方法所属类的ReflectionClass对象。
例子
示例#1 ReflectionMethod :: getDeclaringClass()示例
<?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"
}
← ReflectionMethod::getClosure
ReflectionMethod::getModifiers →
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com