Annotation of embedaddon/php/ext/reflection/tests/ReflectionMethod_basic2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: ReflectionMethod class __toString() and export() methods
3: --FILE--
4: <?php
5:
6: function reflectMethod($class, $method) {
7: $methodInfo = new ReflectionMethod($class, $method);
8: echo "**********************************\n";
9: echo "Reflecting on method $class::$method()\n\n";
10: echo "__toString():\n";
11: var_dump($methodInfo->__toString());
12: echo "\nexport():\n";
13: var_dump(ReflectionMethod::export($class, $method, true));
14: echo "\n**********************************\n";
15: }
16:
17: class TestClass
18: {
19: public function foo() {
20: echo "Called foo()\n";
21: }
22:
23: static function stat() {
24: echo "Called stat()\n";
25: }
26:
27: private function priv() {
28: echo "Called priv()\n";
29: }
30:
31: protected function prot() {}
32:
33: public function __destruct() {}
34: }
35:
36: class DerivedClass extends TestClass {}
37:
38: interface TestInterface {
39: public function int();
40: }
41:
42: reflectMethod("DerivedClass", "foo");
43: reflectMethod("TestClass", "stat");
44: reflectMethod("TestClass", "priv");
45: reflectMethod("TestClass", "prot");
46: reflectMethod("DerivedClass", "prot");
47: reflectMethod("TestInterface", "int");
48: reflectMethod("ReflectionProperty", "__construct");
49: reflectMethod("TestClass", "__destruct");
50:
51: ?>
52: --EXPECTF--
53: **********************************
54: Reflecting on method DerivedClass::foo()
55:
56: __toString():
57: string(%d) "Method [ <user, inherits TestClass> public method foo ] {
58: @@ %s 16 - 18
59: }
60: "
61:
62: export():
63: string(%d) "Method [ <user, inherits TestClass> public method foo ] {
64: @@ %s 16 - 18
65: }
66: "
67:
68: **********************************
69: **********************************
70: Reflecting on method TestClass::stat()
71:
72: __toString():
73: string(%d) "Method [ <user> static public method stat ] {
74: @@ %s 20 - 22
75: }
76: "
77:
78: export():
79: string(%d) "Method [ <user> static public method stat ] {
80: @@ %s 20 - 22
81: }
82: "
83:
84: **********************************
85: **********************************
86: Reflecting on method TestClass::priv()
87:
88: __toString():
89: string(%d) "Method [ <user> private method priv ] {
90: @@ %s 24 - 26
91: }
92: "
93:
94: export():
95: string(%d) "Method [ <user> private method priv ] {
96: @@ %s 24 - 26
97: }
98: "
99:
100: **********************************
101: **********************************
102: Reflecting on method TestClass::prot()
103:
104: __toString():
105: string(%d) "Method [ <user> protected method prot ] {
106: @@ %s 28 - 28
107: }
108: "
109:
110: export():
111: string(%d) "Method [ <user> protected method prot ] {
112: @@ %s 28 - 28
113: }
114: "
115:
116: **********************************
117: **********************************
118: Reflecting on method DerivedClass::prot()
119:
120: __toString():
121: string(%d) "Method [ <user, inherits TestClass> protected method prot ] {
122: @@ %s 28 - 28
123: }
124: "
125:
126: export():
127: string(%d) "Method [ <user, inherits TestClass> protected method prot ] {
128: @@ %s 28 - 28
129: }
130: "
131:
132: **********************************
133: **********************************
134: Reflecting on method TestInterface::int()
135:
136: __toString():
137: string(%d) "Method [ <user> abstract public method int ] {
138: @@ %s 36 - 36
139: }
140: "
141:
142: export():
143: string(%d) "Method [ <user> abstract public method int ] {
144: @@ %s 36 - 36
145: }
146: "
147:
148: **********************************
149: **********************************
150: Reflecting on method ReflectionProperty::__construct()
151:
152: __toString():
153: string(%d) "Method [ <internal:Reflection, ctor> public method __construct ] {
154:
155: - Parameters [2] {
156: Parameter #0 [ <required> $class ]
157: Parameter #1 [ <required> $name ]
158: }
159: }
160: "
161:
162: export():
163: string(%d) "Method [ <internal:Reflection, ctor> public method __construct ] {
164:
165: - Parameters [2] {
166: Parameter #0 [ <required> $class ]
167: Parameter #1 [ <required> $name ]
168: }
169: }
170: "
171:
172: **********************************
173: **********************************
174: Reflecting on method TestClass::__destruct()
175:
176: __toString():
177: string(%d) "Method [ <user, dtor> public method __destruct ] {
178: @@ %s 30 - 30
179: }
180: "
181:
182: export():
183: string(%d) "Method [ <user, dtor> public method __destruct ] {
184: @@ %s 30 - 30
185: }
186: "
187:
188: **********************************
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>