PHP 5.5.16 is released

ReflectionClass::getMethod

(PHP 5)

ReflectionClass::getMethodدریافت ReflectionMethod

Description

public object ReflectionClass::getMethod ( string $name )

دریافت ReflectionMethod درباره متد.

Warning

This function is currently not documented; only its argument list is available.

Parameters

name

نام متد برای بازتاب.

Return Values

ReflectionMethod.

See Also

  • ReflectionClass::getMethod()

add a note add a note

User Contributed Notes 2 notes

up
4
Christopher Turner
3 years ago
If the method doesn't exist within the class that the ReflectionClass is reflecting an Exception is thrown.
up
0
Jarrod Nettles
3 years ago
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;
}

?>
To Top