ReflectionClass
在线手册:中文 英文
PHP手册

ReflectionClass::getMethod

(PHP 5)

ReflectionClass::getMethodGets a ReflectionMethod

说明

public ReflectionMethod ReflectionClass::getMethod ( string $name )

Gets a ReflectionMethod about a method.

Warning

本函数还未编写文档,仅有参数列表。

参数

name

The method name to reflect.

返回值

A ReflectionMethod.

参见


ReflectionClass
在线手册:中文 英文
PHP手册
PHP手册 - N: Gets a ReflectionMethod

用户评论:

Christopher Turner (24-Mar-2011 03:04)

If the method doesn't exist within the class that the ReflectionClass is reflecting an Exception is thrown.

Jarrod Nettles (22-Dec-2010 08:58)

If you ever need to get the type hint of a parameter in a method use this.

<?php

//Target our class
$reflector = new ReflectionClass('MyClass');

//Get the parameters of a method
$parameters = $reflector->getMethod('FireCannon')->getParameters();

//Loop through each parameter and get the type
foreach($parameters as $param)
{
    
//Before you call getClass() that class must be defined!
    
echo $param->getClass()->name;
}

?>