ReflectionMethod::getPrototype

(PHP 5 >= 5.1.2, PHP 7, PHP 8)

ReflectionMethod::getPrototypeメソッドのプロトタイプを (存在すれば) 取得する

説明

publicReflectionMethod::getPrototype(): ReflectionMethod

メソッドのプロトタイプを取得します。

パラメータ

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

戻り値

メソッドのプロトタイプの ReflectionMethod オブジェクトを返します。

エラー / 例外

メソッドがプロトタイプを持たない場合に ReflectionException をスローします。

例1 ReflectionMethod::getPrototype() の例

<?php
class Hello {

public function
sayHelloTo($name) {
return
'Hello ' . $name;
}

}
class
HelloWorld extends Hello {

public function
sayHelloTo($name) {
return
'Hello world: ' . $name;
}

}

$reflectionMethod = new ReflectionMethod('HelloWorld', 'sayHelloTo');
var_dump($reflectionMethod->getPrototype());
?>

上の例の出力は以下となります。

object(ReflectionMethod)#2 (2) { ["name"]=> string(10) "sayHelloTo" ["class"]=> string(5) "Hello" }

参考

To Top