Using this class you can analyze parameters of any method and take action
accordingly. Let us take a look at the object structure:
class ReflectionParameter implements Reflector
{
final private __clone()
public object __construct(string name)
public string __toString()
public static string export(mixed function, mixed parameter,
bool return)
public string getName()
public bool isPassedByReference()
public ReflectionFunction getDeclaringFunction()
public ReflectionClass getDeclaringClass()
public ReflectionClass getClass()
public bool isArray()
public bool allowsNull()
public bool isPassedByReference()
public bool getPosition()
public bool isOptional()
public bool isDefaultValueAvailable()
public mixed getDefaultValue()
}
?>
Chapter 5
[ 107 ]
To make things easier, have a look at the following example to see how this
thing works.
function foo($a, $b, $c) { }
function bar(Exception $a, &$b, $c) { }
function baz(ReflectionFunction $a, $b = 1, $c = null) { }
function abc() { }
// Create an instance of Reflection_Function with the
// parameter given from the command line.
$reflect = new ReflectionFunction("baz");
echo $reflect;
foreach ($reflect->getParameters() as $i => $param)
{
printf(
"-- Parameter #%d: %s {\n".
Pages:
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122