ReflectionMethod::getDeclaringClass()
(PHP 5, PHP 7)
获取反射函数调用参数的类表达
说明
public ReflectionMethod::getDeclaringClass(void) :ReflectionClass
获取反射函数参数的一个表达类。译者注:应该是将这个方法作为一个类返回,他的参数将成为类属性,执行内容变成什么不知道,下面的范例能够说明一些问题
参数
此函数没有参数。
返回值
返回ReflectionClass对象,其中包含这个方法。
范例
Example #1ReflectionMethod::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" }
参见
- ReflectionMethod::isAbstract() 判断方法是否是抽象方法