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        printf("0x%08x\n", $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";
85printf("0x%08x\n", $a->getModifiers());
86
87?>
88--EXPECTF--
89Modifiers for method TestClass::foo():
900x00000001
91
92
93Modifiers for method TestClass::stat():
940x00000011
95
96
97Modifiers for method TestClass::priv():
980x00000004
99
100
101Modifiers for method TestClass::prot():
1020x00000002
103
104
105Modifiers for method TestClass::fin():
1060x00000021
107
108
109Modifiers for method TestClass::__destruct():
1100x00000001
111
112
113Modifiers for method TestClass::__call():
1140x00000001
115
116
117Modifiers for method TestClass::__clone():
1180x00000001
119
120
121Modifiers for method TestClass::__get():
1220x00000001
123
124
125Modifiers for method TestClass::__set():
1260x00000001
127
128
129Modifiers for method TestClass::__unset():
1300x00000001
131
132
133Modifiers for method TestClass::__isset():
1340x00000001
135
136
137Modifiers for method TestClass::__tostring():
1380x00000001
139
140
141Modifiers for method TestClass::__sleep():
1420x00000001
143
144
145Modifiers for method TestClass::__wakeup():
1460x00000001
147
148
149Modifiers for method TestClass::__set_state():
1500x00000001
151
152
153Modifiers for method TestClass::__autoload():
1540x00000001
155
156
157Modifiers for method TestClass::foo():
1580x00000001
159
160
161Modifiers for method TestClass::stat():
1620x00000011
163
164
165Modifiers for method TestClass::priv():
1660x00000004
167
168
169Modifiers for method TestClass::prot():
1700x00000002
171
172
173Modifiers for method TestClass::fin():
1740x00000021
175
176
177Modifiers for method TestClass::__destruct():
1780x00000001
179
180
181Modifiers for method TestClass::__call():
1820x00000001
183
184
185Modifiers for method TestClass::__clone():
1860x00000001
187
188
189Modifiers for method TestClass::__get():
1900x00000001
191
192
193Modifiers for method TestClass::__set():
1940x00000001
195
196
197Modifiers for method TestClass::__unset():
1980x00000001
199
200
201Modifiers for method TestClass::__isset():
2020x00000001
203
204
205Modifiers for method TestClass::__tostring():
2060x00000001
207
208
209Modifiers for method TestClass::__sleep():
2100x00000001
211
212
213Modifiers for method TestClass::__wakeup():
2140x00000001
215
216
217Modifiers for method TestClass::__set_state():
2180x00000001
219
220
221Modifiers for method TestClass::__autoload():
2220x00000001
223
224
225Modifiers for method TestInterface::int():
2260x00000041
227
228
229Modifiers for method TestInterface::__clone():
2300x00000041
231
232
233Modifiers for method AbstractClass::foo():
2340x00000041
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:
2420x00000001
243