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    public function __construct($arg);
53    public function __destruct();
54}
55
56trait TestTrait {
57    public abstract function __construct();
58    public function __destruct() {
59    }
60}
61
62reflectMethod("DerivedClass", "foo");
63reflectMethod("TestClass", "stat");
64reflectMethod("TestClass", "priv");
65reflectMethod("TestClass", "prot");
66reflectMethod("DerivedClass", "prot");
67reflectMethod("TestInterface", "int");
68reflectMethod("ReflectionProperty", "__construct");
69reflectMethod("TestClass", "__destruct");
70reflectMethod("TestInterface", "__construct");
71reflectMethod("TestInterface", "__destruct");
72reflectMethod("TestTrait", "__construct");
73reflectMethod("TestTrait", "__destruct");
74
75?>
76--EXPECT--
77**********************************
78Reflecting on method DerivedClass::foo()
79
80
81isFinal():
82bool(false)
83
84isAbstract():
85bool(false)
86
87isPublic():
88bool(true)
89
90isPrivate():
91bool(false)
92
93isProtected():
94bool(false)
95
96isStatic():
97bool(false)
98
99isConstructor():
100bool(false)
101
102isDestructor():
103bool(false)
104
105**********************************
106**********************************
107Reflecting on method TestClass::stat()
108
109
110isFinal():
111bool(false)
112
113isAbstract():
114bool(false)
115
116isPublic():
117bool(true)
118
119isPrivate():
120bool(false)
121
122isProtected():
123bool(false)
124
125isStatic():
126bool(true)
127
128isConstructor():
129bool(false)
130
131isDestructor():
132bool(false)
133
134**********************************
135**********************************
136Reflecting on method TestClass::priv()
137
138
139isFinal():
140bool(false)
141
142isAbstract():
143bool(false)
144
145isPublic():
146bool(false)
147
148isPrivate():
149bool(true)
150
151isProtected():
152bool(false)
153
154isStatic():
155bool(false)
156
157isConstructor():
158bool(false)
159
160isDestructor():
161bool(false)
162
163**********************************
164**********************************
165Reflecting on method TestClass::prot()
166
167
168isFinal():
169bool(false)
170
171isAbstract():
172bool(false)
173
174isPublic():
175bool(false)
176
177isPrivate():
178bool(false)
179
180isProtected():
181bool(true)
182
183isStatic():
184bool(false)
185
186isConstructor():
187bool(false)
188
189isDestructor():
190bool(false)
191
192**********************************
193**********************************
194Reflecting on method DerivedClass::prot()
195
196
197isFinal():
198bool(false)
199
200isAbstract():
201bool(false)
202
203isPublic():
204bool(false)
205
206isPrivate():
207bool(false)
208
209isProtected():
210bool(true)
211
212isStatic():
213bool(false)
214
215isConstructor():
216bool(false)
217
218isDestructor():
219bool(false)
220
221**********************************
222**********************************
223Reflecting on method TestInterface::int()
224
225
226isFinal():
227bool(false)
228
229isAbstract():
230bool(true)
231
232isPublic():
233bool(true)
234
235isPrivate():
236bool(false)
237
238isProtected():
239bool(false)
240
241isStatic():
242bool(false)
243
244isConstructor():
245bool(false)
246
247isDestructor():
248bool(false)
249
250**********************************
251**********************************
252Reflecting on method ReflectionProperty::__construct()
253
254
255isFinal():
256bool(false)
257
258isAbstract():
259bool(false)
260
261isPublic():
262bool(true)
263
264isPrivate():
265bool(false)
266
267isProtected():
268bool(false)
269
270isStatic():
271bool(false)
272
273isConstructor():
274bool(true)
275
276isDestructor():
277bool(false)
278
279**********************************
280**********************************
281Reflecting on method TestClass::__destruct()
282
283
284isFinal():
285bool(false)
286
287isAbstract():
288bool(false)
289
290isPublic():
291bool(true)
292
293isPrivate():
294bool(false)
295
296isProtected():
297bool(false)
298
299isStatic():
300bool(false)
301
302isConstructor():
303bool(false)
304
305isDestructor():
306bool(true)
307
308**********************************
309**********************************
310Reflecting on method TestInterface::__construct()
311
312
313isFinal():
314bool(false)
315
316isAbstract():
317bool(true)
318
319isPublic():
320bool(true)
321
322isPrivate():
323bool(false)
324
325isProtected():
326bool(false)
327
328isStatic():
329bool(false)
330
331isConstructor():
332bool(true)
333
334isDestructor():
335bool(false)
336
337**********************************
338**********************************
339Reflecting on method TestInterface::__destruct()
340
341
342isFinal():
343bool(false)
344
345isAbstract():
346bool(true)
347
348isPublic():
349bool(true)
350
351isPrivate():
352bool(false)
353
354isProtected():
355bool(false)
356
357isStatic():
358bool(false)
359
360isConstructor():
361bool(false)
362
363isDestructor():
364bool(true)
365
366**********************************
367**********************************
368Reflecting on method TestTrait::__construct()
369
370
371isFinal():
372bool(false)
373
374isAbstract():
375bool(true)
376
377isPublic():
378bool(true)
379
380isPrivate():
381bool(false)
382
383isProtected():
384bool(false)
385
386isStatic():
387bool(false)
388
389isConstructor():
390bool(true)
391
392isDestructor():
393bool(false)
394
395**********************************
396**********************************
397Reflecting on method TestTrait::__destruct()
398
399
400isFinal():
401bool(false)
402
403isAbstract():
404bool(false)
405
406isPublic():
407bool(true)
408
409isPrivate():
410bool(false)
411
412isProtected():
413bool(false)
414
415isStatic():
416bool(false)
417
418isConstructor():
419bool(false)
420
421isDestructor():
422bool(true)
423
424**********************************
425