ReflectionMethod
PHP Manual

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.

例1 ReflectionFunction::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 Manual