ReflectionClass::getMethods
メソッドの配列を取得する
&reftitle.description;
public arrayReflectionClass::getMethods
intfilter
クラスのメソッドの配列を取得します。
&reftitle.parameters;
filter
結果をフィルタして、特定の属性を持つメソッドだけを含めるようにします。
デフォルトは、何もフィルタしません。
ReflectionMethod::IS_STATIC、
ReflectionMethod::IS_PUBLIC、
ReflectionMethod::IS_PROTECTED、
ReflectionMethod::IS_PRIVATE、
ReflectionMethod::IS_ABSTRACT、
ReflectionMethod::IS_FINAL
の任意の組み合わせ。
&reftitle.returnvalues;
各メソッドを表す ReflectionMethod オブジェクトの配列を返します。
&reftitle.examples;
ReflectionClass::getMethods の基本的な使用例
getMethods();
var_dump($methods);
?>
]]>
&example.outputs;
&object(ReflectionMethod)#2 (2) {
["name"]=>
string(11) "firstMethod"
["class"]=>
string(5) "Apple"
}
[1]=>
&object(ReflectionMethod)#3 (2) {
["name"]=>
string(12) "secondMethod"
["class"]=>
string(5) "Apple"
}
[2]=>
&object(ReflectionMethod)#4 (2) {
["name"]=>
string(11) "thirdMethod"
["class"]=>
string(5) "Apple"
}
}
]]>
ReflectionClass::getMethods のフィルタリング
getMethods(ReflectionMethod::IS_STATIC | ReflectionMethod::IS_FINAL);
var_dump($methods);
?>
]]>
&example.outputs;
&object(ReflectionMethod)#2 (2) {
["name"]=>
string(12) "secondMethod"
["class"]=>
string(5) "Apple"
}
[1]=>
&object(ReflectionMethod)#3 (2) {
["name"]=>
string(11) "thirdMethod"
["class"]=>
string(5) "Apple"
}
}
]]>
&reftitle.seealso;
ReflectionClass::getMethod