Annotation of embedaddon/php/ext/reflection/tests/ReflectionParameter_001.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: ReflectionParameter class - getNames() method.
3: --CREDITS--
4: Robin Fernandes <robinf@php.net>
5: Steve Seear <stevseea@php.net>
6: --FILE--
7: <?php
8: class ReflectTestClass {
9: public static function twoArgFunction($theIncrement, $anotherParam) {
10: return ++$theIncrement;
11: }
12:
13: public function oneArgNonStatic($theParam) {
14: $theParam--;
15: }
16:
17: public function noArgs() {
18: echo "No arg function\n";
19: }
20: }
21:
22: // Create an instance of the Reflection_Method class
23: $method = new ReflectionMethod('ReflectTestClass', 'twoArgFunction');
24: // Get the parameters
25: $parameters = $method->getParameters();
26: echo "Parameters from twoArgMethod:\n\n";
27: foreach($parameters as $parameter) {
28: var_dump($parameter);
29: $name = $parameter->getName();
30: echo "\n";
31: }
32:
33: $method = new ReflectionMethod('ReflectTestClass', 'oneArgNonStatic');
34: $parameters = $method->getParameters();
35: echo "Parameters from oneArgNonStatic:\n\n";
36: foreach($parameters as $parameter) {
37: var_dump($parameter);
38: $name = $parameter->getName();
39: echo "\n";
40: }
41:
42:
43: $method = new ReflectionMethod('ReflectTestClass', 'noArgs');
44: $parameters = $method->getParameters();
45: echo "Parameters from noArgs:\n\n";
46: var_dump($parameters);
47: foreach($parameters as $parameter) {
48: var_dump($parameter);
49: $name = $parameter->getName();
50: echo "\n";
51: }
52:
53: echo "done\n";
54:
55: ?>
56: --EXPECTF--
57: Parameters from twoArgMethod:
58:
59: object(ReflectionParameter)#%i (1) {
60: ["name"]=>
61: string(12) "theIncrement"
62: }
63:
64: object(ReflectionParameter)#%i (1) {
65: ["name"]=>
66: string(12) "anotherParam"
67: }
68:
69: Parameters from oneArgNonStatic:
70:
71: object(ReflectionParameter)#%i (1) {
72: ["name"]=>
73: string(8) "theParam"
74: }
75:
76: Parameters from noArgs:
77:
78: array(0) {
79: }
80: done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>