(PHP 5, PHP 7)
ReflectionClass::getMethods — ��ȡ����������
$filter
] ) : array��ȡ��ķ�����һ�����顣
filter
���˽��Ϊ������ijЩ���Եķ�����Ĭ�ϲ����ˡ�
ReflectionMethod::IS_STATIC
��
ReflectionMethod::IS_PUBLIC
��
ReflectionMethod::IS_PROTECTED
��
ReflectionMethod::IS_PRIVATE
��
ReflectionMethod::IS_ABSTRACT
��
ReflectionMethod::IS_FINAL
�İ�λ��OR�����ͻ᷵�������������������ԡ�
Note: ��ע�⣺����λ���������� ~ ����Ԥ�����С��������Ҳ����˵������ȡ���еķǾ�̬������
����ÿ������ ReflectionMethod �����������
Example #1 ReflectionClass::getMethods() �Ļ����÷�
<?php
class Apple {
public function firstMethod() { }
final protected function secondMethod() { }
private static function thirdMethod() { }
}
$class = new ReflectionClass('Apple');
$methods = $class->getMethods();
var_dump($methods);
?>
�������̻������
array(3) { [0]=> &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" } }
Example #2 �� ReflectionClass::getMethods() �й��˽��
<?php
class Apple {
public function firstMethod() { }
final protected function secondMethod() { }
private static function thirdMethod() { }
}
$class = new ReflectionClass('Apple');
$methods = $class->getMethods(ReflectionMethod::IS_STATIC | ReflectionMethod::IS_FINAL);
var_dump($methods);
?>
�������̻������
array(2) { [0]=> &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" } }