ReflectionMethod
PHP 手册

ReflectionMethod::getDeclaringClass

(PHP 5)

ReflectionMethod::getDeclaringClassGets declaring class for the reflected method.

说明

public ReflectionClass ReflectionMethod::getDeclaringClass ( void )

Gets the declaring class for the reflected method.

参数

此函数没有参数。

返回值

A ReflectionClass object of the class that the reflected method is part of.

范例

Example #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"
}

参见


ReflectionMethod
PHP 手册