Annotation of embedaddon/php/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: ReflectionMethod::getModifiers()
3: --FILE--
4: <?php
5:
6: function reflectMethodModifiers($class) {
7: $classInfo = new reflectionClass($class);
8: $methodArray = $classInfo->getMethods();
9:
10: foreach ($methodArray as $method) {
11: echo "Modifiers for method $method->class::$method->name():\n";
12: var_dump($method->getModifiers());
13: echo "\n\n";
14: }
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 final function fin() {}
34:
35: public function __destruct() {}
36:
37: public function __call($a, $b) {}
38:
39: public function __clone() {}
40:
41: public function __get($a) {}
42:
43: public function __set($a, $b) {}
44:
45: public function __unset($a) {}
46:
47: public function __isset($a) {}
48:
49: public function __tostring() {}
50:
51: public function __sleep() {}
52:
53: public function __wakeup() {}
54:
55: public function __set_state() {}
56:
57: public function __autoload() {}
58: }
59:
60: class DerivedClass extends TestClass {}
61:
62: interface TestInterface {
63: public function int();
64: public function __clone();
65: }
66:
67: abstract class AbstractClass {
68: public abstract function foo();
69: }
70:
71:
72:
73: reflectMethodModifiers("TestClass");
74: reflectMethodModifiers("DerivedClass");
75: reflectMethodModifiers("TestInterface");
76: reflectMethodModifiers("AbstractClass");
77:
78: echo "Wrong number of params:\n";
79: $a = new ReflectionMethod('TestClass::foo');
80: $a->getModifiers(1);
81:
82: $a = new ReflectionMethod('ReflectionMethod::getModifiers');
83:
84: echo "\nReflectionMethod::getModifiers() modifiers:\n";
85: var_dump($a->getModifiers());
86:
87: ?>
88: --EXPECTF--
89: Modifiers for method TestClass::foo():
90: int(65792)
91:
92:
93: Modifiers for method TestClass::stat():
94: int(257)
95:
96:
97: Modifiers for method TestClass::priv():
98: int(66560)
99:
100:
101: Modifiers for method TestClass::prot():
102: int(66048)
103:
104:
105: Modifiers for method TestClass::fin():
106: int(65796)
107:
108:
109: Modifiers for method TestClass::__destruct():
110: int(16640)
111:
112:
113: Modifiers for method TestClass::__call():
114: int(256)
115:
116:
117: Modifiers for method TestClass::__clone():
118: int(33024)
119:
120:
121: Modifiers for method TestClass::__get():
122: int(256)
123:
124:
125: Modifiers for method TestClass::__set():
126: int(256)
127:
128:
129: Modifiers for method TestClass::__unset():
130: int(256)
131:
132:
133: Modifiers for method TestClass::__isset():
134: int(256)
135:
136:
137: Modifiers for method TestClass::__tostring():
138: int(256)
139:
140:
141: Modifiers for method TestClass::__sleep():
142: int(65792)
143:
144:
145: Modifiers for method TestClass::__wakeup():
146: int(65792)
147:
148:
149: Modifiers for method TestClass::__set_state():
150: int(65792)
151:
152:
153: Modifiers for method TestClass::__autoload():
154: int(65792)
155:
156:
157: Modifiers for method TestClass::foo():
158: int(65792)
159:
160:
161: Modifiers for method TestClass::stat():
162: int(257)
163:
164:
165: Modifiers for method TestClass::priv():
166: int(66560)
167:
168:
169: Modifiers for method TestClass::prot():
170: int(66048)
171:
172:
173: Modifiers for method TestClass::fin():
174: int(65796)
175:
176:
177: Modifiers for method TestClass::__destruct():
178: int(16640)
179:
180:
181: Modifiers for method TestClass::__call():
182: int(256)
183:
184:
185: Modifiers for method TestClass::__clone():
186: int(33024)
187:
188:
189: Modifiers for method TestClass::__get():
190: int(256)
191:
192:
193: Modifiers for method TestClass::__set():
194: int(256)
195:
196:
197: Modifiers for method TestClass::__unset():
198: int(256)
199:
200:
201: Modifiers for method TestClass::__isset():
202: int(256)
203:
204:
205: Modifiers for method TestClass::__tostring():
206: int(256)
207:
208:
209: Modifiers for method TestClass::__sleep():
210: int(65792)
211:
212:
213: Modifiers for method TestClass::__wakeup():
214: int(65792)
215:
216:
217: Modifiers for method TestClass::__set_state():
218: int(65792)
219:
220:
221: Modifiers for method TestClass::__autoload():
222: int(65792)
223:
224:
225: Modifiers for method TestInterface::int():
226: int(258)
227:
228:
229: Modifiers for method TestInterface::__clone():
230: int(258)
231:
232:
233: Modifiers for method AbstractClass::foo():
234: int(65794)
235:
236:
237: Wrong number of params:
238:
239: Warning: ReflectionMethod::getModifiers() expects exactly 0 parameters, 1 given in %s on line %d
240:
241: ReflectionMethod::getModifiers() modifiers:
242: int(256)
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>