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