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