php-src/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt

291 lines
4.6 KiB
Plaintext
Raw Normal View History

--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 __construct() {}
public function __destruct() {}
public function __call($a, $b) {}
public static function __callStatic($a, $b) {}
public function __clone() {}
public function __get($a) {}
public function __set($a, $b) {}
public function __unset($a) {}
public function __invoke() {}
public function __isset($a) {}
public function __tostring() {}
public function __sleep() {}
public function __wakeup() {}
2020-07-20 08:54:59 +00:00
public static function __set_state($a) {}
public function __autoload() {}
public function __serialize() {}
public function __unserialize($data) {}
public function __debugInfo() {}
}
class DerivedClass extends TestClass {}
interface TestInterface {
2020-02-03 21:52:20 +00:00
public function int();
public function __clone();
}
abstract class AbstractClass {
2020-02-03 21:52:20 +00:00
public abstract function foo();
}
reflectMethodModifiers("TestClass");
reflectMethodModifiers("DerivedClass");
reflectMethodModifiers("TestInterface");
reflectMethodModifiers("AbstractClass");
$a = new ReflectionMethod('ReflectionMethod::getModifiers');
2019-02-19 16:11:00 +00:00
echo "ReflectionMethod::getModifiers() modifiers:\n";
printf("0x%08x\n", $a->getModifiers());
?>
--EXPECT--
Modifiers for method TestClass::foo():
2018-09-11 14:21:17 +00:00
0x00000001
Modifiers for method TestClass::stat():
2018-09-11 14:21:17 +00:00
0x00000011
Modifiers for method TestClass::priv():
2018-09-11 14:21:17 +00:00
0x00000004
Modifiers for method TestClass::prot():
2018-09-11 14:21:17 +00:00
0x00000002
Modifiers for method TestClass::fin():
2018-09-11 14:21:17 +00:00
0x00000021
Modifiers for method TestClass::__construct():
0x00000001
Modifiers for method TestClass::__destruct():
2018-09-11 14:21:17 +00:00
0x00000001
Modifiers for method TestClass::__call():
2018-09-11 14:21:17 +00:00
0x00000001
Modifiers for method TestClass::__callStatic():
0x00000011
Modifiers for method TestClass::__clone():
2018-09-11 14:21:17 +00:00
0x00000001
Modifiers for method TestClass::__get():
2018-09-11 14:21:17 +00:00
0x00000001
Modifiers for method TestClass::__set():
2018-09-11 14:21:17 +00:00
0x00000001
Modifiers for method TestClass::__unset():
2018-09-11 14:21:17 +00:00
0x00000001
Modifiers for method TestClass::__invoke():
0x00000001
Modifiers for method TestClass::__isset():
2018-09-11 14:21:17 +00:00
0x00000001
Modifiers for method TestClass::__tostring():
2018-09-11 14:21:17 +00:00
0x00000001
Modifiers for method TestClass::__sleep():
2018-09-11 14:21:17 +00:00
0x00000001
Modifiers for method TestClass::__wakeup():
2018-09-11 14:21:17 +00:00
0x00000001
Modifiers for method TestClass::__set_state():
0x00000011
Modifiers for method TestClass::__autoload():
2018-09-11 14:21:17 +00:00
0x00000001
Modifiers for method TestClass::__serialize():
0x00000001
Modifiers for method TestClass::__unserialize():
0x00000001
Modifiers for method TestClass::__debugInfo():
0x00000001
Modifiers for method TestClass::foo():
2018-09-11 14:21:17 +00:00
0x00000001
Modifiers for method TestClass::stat():
2018-09-11 14:21:17 +00:00
0x00000011
Modifiers for method TestClass::prot():
2018-09-11 14:21:17 +00:00
0x00000002
Modifiers for method TestClass::fin():
2018-09-11 14:21:17 +00:00
0x00000021
Modifiers for method TestClass::__construct():
0x00000001
Modifiers for method TestClass::__destruct():
2018-09-11 14:21:17 +00:00
0x00000001
Modifiers for method TestClass::__call():
2018-09-11 14:21:17 +00:00
0x00000001
Modifiers for method TestClass::__callStatic():
0x00000011
Modifiers for method TestClass::__clone():
2018-09-11 14:21:17 +00:00
0x00000001
Modifiers for method TestClass::__get():
2018-09-11 14:21:17 +00:00
0x00000001
Modifiers for method TestClass::__set():
2018-09-11 14:21:17 +00:00
0x00000001
Modifiers for method TestClass::__unset():
2018-09-11 14:21:17 +00:00
0x00000001
Modifiers for method TestClass::__invoke():
0x00000001
Modifiers for method TestClass::__isset():
2018-09-11 14:21:17 +00:00
0x00000001
Modifiers for method TestClass::__tostring():
2018-09-11 14:21:17 +00:00
0x00000001
Modifiers for method TestClass::__sleep():
2018-09-11 14:21:17 +00:00
0x00000001
Modifiers for method TestClass::__wakeup():
2018-09-11 14:21:17 +00:00
0x00000001
Modifiers for method TestClass::__set_state():
0x00000011
Modifiers for method TestClass::__autoload():
2018-09-11 14:21:17 +00:00
0x00000001
Modifiers for method TestClass::__serialize():
0x00000001
Modifiers for method TestClass::__unserialize():
0x00000001
Modifiers for method TestClass::__debugInfo():
0x00000001
Modifiers for method TestInterface::int():
2018-09-11 14:21:17 +00:00
0x00000041
Modifiers for method TestInterface::__clone():
2018-09-11 14:21:17 +00:00
0x00000041
Modifiers for method AbstractClass::foo():
2018-09-11 14:21:17 +00:00
0x00000041
ReflectionMethod::getModifiers() modifiers:
2018-09-11 14:21:17 +00:00
0x00000001