« ReflectionMethod::getClosure
ReflectionMethod::getModifiers »

ReflectionMethod::getDeclaringClass

(PHP 5, PHP 7, PHP 8)

ReflectionMethod::getDeclaringClass — メソッドが宣言されているクラスを取得する

説明

public function ReflectionMethod::getDeclaringClass(): ReflectionClass

そのメソッドが宣言されているクラスを取得します。

パラメータ

この関数にはパラメータはありません。

戻り値

そのメソッドが属するクラスをあらわす 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   getDeclaringClass   宣言   ReflectionClass   HelloWorld   sayHelloTo   reflectionMethod   getClosure   getModifiers   protected   return   Hello   dump   参考   isAbstract   抽象
関連する関数・ページ:
reflectionmethod.tostring   reflectionmethod.isabstract   reflectionmethod.invoke   reflectionmethod.ispublic   reflectionmethod.isconstructor   reflectionmethod.getprototype