" Class: %s\n".
" Allows NULL: %s\n".
" Passed to by reference: %s\n".
" Is optional?: %s\n".
"}\n",
$i,
$param->getName(),
var_export($param->getClass(), 1),
var_export($param->allowsNull(), 1),
var_export($param->isPassedByReference(), 1),
$param->isOptional() ? 'yes' : 'no'
);
}
?>
If you run the above code snippet, you will get the following output:
Function [
function baz ]
{
@@ C:\OOP with PHP5\Codes\ch5\test.php 4 - 4
- Parameters [3]
{
Parameter #0 [ ReflectionFunction &$a ]
Parameter #1 [ $b = 1 ]
Parameter #2 [ $c = NULL ]
}
}
-- Parameter #0: a
{
Class: ReflectionClass::__set_state(array(
'name' => 'ReflectionFunction',
))
Allows NULL: false
Reflection and Unit Testing
[ 108 ]
Passed to by reference: true
Is optional?: no
}
-- Parameter #1: b
{
Class: NULL
Allows NULL: true
Passed to by reference: false
Is optional?: yes
}
-- Parameter #2: c
{
Class: NULL
Allows NULL: true
Passed to by reference: false
Is optional?: yes
}
ReflectionProperty
This is the last one under the reflection family that we are going to discuss here. This
class helps you to investigate class properties and reverse engineer them.
Pages:
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123