1--TEST--
2ReflectionMethod class - various methods
3--FILE--
4<?php
5
6function reflectMethod($class, $method) {
7    $methodInfo = new ReflectionMethod($class, $method);
8    echo "**********************************\n";
9    echo "Reflecting on method $class::$method()\n\n";
10    echo "\nisFinal():\n";
11    var_dump($methodInfo->isFinal());
12    echo "\nisAbstract():\n";
13    var_dump($methodInfo->isAbstract());
14    echo "\nisPublic():\n";
15    var_dump($methodInfo->isPublic());
16    echo "\nisPrivate():\n";
17    var_dump($methodInfo->isPrivate());
18    echo "\nisProtected():\n";
19    var_dump($methodInfo->isProtected());
20    echo "\nisStatic():\n";
21    var_dump($methodInfo->isStatic());
22    echo "\nisConstructor():\n";
23    var_dump($methodInfo->isConstructor());
24    echo "\nisDestructor():\n";
25    var_dump($methodInfo->isDestructor());
26    echo "\n**********************************\n";
27}
28
29class TestClass
30{
31    public function foo() {
32        echo "Called foo()\n";
33    }
34
35    static function stat() {
36        echo "Called stat()\n";
37    }
38
39    private function priv() {
40        echo "Called priv()\n";
41    }
42
43    protected function prot() {}
44
45    public function __destruct() {}
46}
47
48class DerivedClass extends TestClass {}
49
50interface TestInterface {
51    public function int();
52}
53
54reflectMethod("DerivedClass", "foo");
55reflectMethod("TestClass", "stat");
56reflectMethod("TestClass", "priv");
57reflectMethod("TestClass", "prot");
58reflectMethod("DerivedClass", "prot");
59reflectMethod("TestInterface", "int");
60reflectMethod("ReflectionProperty", "__construct");
61reflectMethod("TestClass", "__destruct");
62
63?>
64--EXPECT--
65**********************************
66Reflecting on method DerivedClass::foo()
67
68
69isFinal():
70bool(false)
71
72isAbstract():
73bool(false)
74
75isPublic():
76bool(true)
77
78isPrivate():
79bool(false)
80
81isProtected():
82bool(false)
83
84isStatic():
85bool(false)
86
87isConstructor():
88bool(false)
89
90isDestructor():
91bool(false)
92
93**********************************
94**********************************
95Reflecting on method TestClass::stat()
96
97
98isFinal():
99bool(false)
100
101isAbstract():
102bool(false)
103
104isPublic():
105bool(true)
106
107isPrivate():
108bool(false)
109
110isProtected():
111bool(false)
112
113isStatic():
114bool(true)
115
116isConstructor():
117bool(false)
118
119isDestructor():
120bool(false)
121
122**********************************
123**********************************
124Reflecting on method TestClass::priv()
125
126
127isFinal():
128bool(false)
129
130isAbstract():
131bool(false)
132
133isPublic():
134bool(false)
135
136isPrivate():
137bool(true)
138
139isProtected():
140bool(false)
141
142isStatic():
143bool(false)
144
145isConstructor():
146bool(false)
147
148isDestructor():
149bool(false)
150
151**********************************
152**********************************
153Reflecting on method TestClass::prot()
154
155
156isFinal():
157bool(false)
158
159isAbstract():
160bool(false)
161
162isPublic():
163bool(false)
164
165isPrivate():
166bool(false)
167
168isProtected():
169bool(true)
170
171isStatic():
172bool(false)
173
174isConstructor():
175bool(false)
176
177isDestructor():
178bool(false)
179
180**********************************
181**********************************
182Reflecting on method DerivedClass::prot()
183
184
185isFinal():
186bool(false)
187
188isAbstract():
189bool(false)
190
191isPublic():
192bool(false)
193
194isPrivate():
195bool(false)
196
197isProtected():
198bool(true)
199
200isStatic():
201bool(false)
202
203isConstructor():
204bool(false)
205
206isDestructor():
207bool(false)
208
209**********************************
210**********************************
211Reflecting on method TestInterface::int()
212
213
214isFinal():
215bool(false)
216
217isAbstract():
218bool(true)
219
220isPublic():
221bool(true)
222
223isPrivate():
224bool(false)
225
226isProtected():
227bool(false)
228
229isStatic():
230bool(false)
231
232isConstructor():
233bool(false)
234
235isDestructor():
236bool(false)
237
238**********************************
239**********************************
240Reflecting on method ReflectionProperty::__construct()
241
242
243isFinal():
244bool(false)
245
246isAbstract():
247bool(false)
248
249isPublic():
250bool(true)
251
252isPrivate():
253bool(false)
254
255isProtected():
256bool(false)
257
258isStatic():
259bool(false)
260
261isConstructor():
262bool(true)
263
264isDestructor():
265bool(false)
266
267**********************************
268**********************************
269Reflecting on method TestClass::__destruct()
270
271
272isFinal():
273bool(false)
274
275isAbstract():
276bool(false)
277
278isPublic():
279bool(true)
280
281isPrivate():
282bool(false)
283
284isProtected():
285bool(false)
286
287isStatic():
288bool(false)
289
290isConstructor():
291bool(false)
292
293isDestructor():
294bool(true)
295
296**********************************
297
298
299