downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

ReflectionClass::getModifiers> <ReflectionClass::getMethod
[edit] Last updated: Fri, 25 May 2012

view this page in

ReflectionClass::getMethods

(PHP 5)

ReflectionClass::getMethodsメソッドの一覧を取得する

説明

public array ReflectionClass::getMethods ([ string $filter ] )

メソッドの一覧を取得します。

警告

この関数は、 現在のところ詳細な情報はありません。引数のリストのみが 記述されています。

パラメータ

filter

ReflectionMethod::IS_STATICReflectionMethod::IS_PUBLICReflectionMethod::IS_PROTECTEDReflectionMethod::IS_PRIVATEReflectionMethod::IS_ABSTRACTReflectionMethod::IS_FINAL の任意の組み合わせ。

返り値

メソッドの配列を返します。

参考



ReflectionClass::getModifiers> <ReflectionClass::getMethod
[edit] Last updated: Fri, 25 May 2012
 
add a note add a note User Contributed Notes ReflectionClass::getMethods
erik at dubbelboer dot com 29-Mar-2012 02:21
The $filter uses an OR to filter the methods.

So php ReflectionMethod::IS_STATIC | ReflectionMethod::IS_PUBLIC will return all methods which are static or public methods, NOT only the methods which are both static and private.
deminy at deminy dot net 22-Jun-2011 06:24
Method ReflectionClass::getMethods doesn't work constantly across different versions of PHP. For following code piece

<?php
class Dummy implements Iterator
{
    public function
current () {}
    public function
next () {}
    public function
key () {}
    public function
valid () {}
    public function
rewind () {}
}

$reflection = new ReflectionClass('Dummy');
$aMethods = $reflection->getMethods();
echo
'# of methods: ', count($aMethods), "\n";
?>

, it outputs "# of methods: 10" on PHP 5.2.14 and PHP 5.2.17, including all methods defined in the class itself and in the interface no matter if a method has been implemented or overridden; however, it returns "# of methods: 5" on PHP 5.3.5. Based on some other tests did by my colleagues, I assume it also returns "# of methods: 5" on PHP 5.2.10 and PHP 5.3.6.
calibhaan at gmail dot com 11-May-2010 06:57
This method return an array of ReflectionMethod;
For example:

<?php
$reflection
= new ReflectionClass('Test');
$aMethods = $reflection->getMethods();
var_dump($aMethods);
?>

Display:
array(2) {
 [0]=> &object(ReflectionMethod)#7 (2) {
  ["name"]=> string(11) "__construct"
  ["class"]=> string(9) "Test" }
 [1]=> &object(ReflectionMethod)#8 (2) {
  ["name"]=> string(3) "run"
  ["class"]=> string(9) "Test" }
}

 
show source | credits | stats | sitemap | contact | advertising | mirror sites