array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), 'this' => array ( 0 => 'reflectionmethod.getprototype.php', 1 => 'ReflectionMethod::getPrototype', ), 'up' => array ( 0 => 'class.reflectionmethod.php', 1 => 'ReflectionMethod', ), 'prev' => array ( 0 => 'reflectionmethod.getmodifiers.php', 1 => 'ReflectionMethod::getModifiers', ), 'next' => array ( 0 => 'reflectionmethod.hasprototype.php', 1 => 'ReflectionMethod::hasPrototype', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'ja', 'path' => 'reference/reflection/reflectionmethod/getprototype.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5 >= 5.1.2, PHP 7, PHP 8)
ReflectionMethod::getPrototype — メソッドのプロトタイプを (存在すれば) 取得する
この関数にはパラメータはありません。
メソッドのプロトタイプの 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" }