ReflectionMethod_getModifiers_basic.phpt 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. --TEST--
  2. ReflectionMethod::getModifiers()
  3. --FILE--
  4. <?php
  5. function reflectMethodModifiers($class) {
  6. $classInfo = new reflectionClass($class);
  7. $methodArray = $classInfo->getMethods();
  8. foreach ($methodArray as $method) {
  9. echo "Modifiers for method $method->class::$method->name():\n";
  10. printf("0x%08x\n", $method->getModifiers());
  11. echo "\n\n";
  12. }
  13. }
  14. class TestClass
  15. {
  16. public function foo() {
  17. echo "Called foo()\n";
  18. }
  19. static function stat() {
  20. echo "Called stat()\n";
  21. }
  22. private function priv() {
  23. echo "Called priv()\n";
  24. }
  25. protected function prot() {}
  26. public final function fin() {}
  27. public function __construct() {}
  28. public function __destruct() {}
  29. public function __call($a, $b) {}
  30. public static function __callStatic($a, $b) {}
  31. public function __clone() {}
  32. public function __get($a) {}
  33. public function __set($a, $b) {}
  34. public function __unset($a) {}
  35. public function __invoke() {}
  36. public function __isset($a) {}
  37. public function __tostring() {}
  38. public function __sleep() {}
  39. public function __wakeup() {}
  40. public static function __set_state($a) {}
  41. public function __autoload() {}
  42. public function __serialize() {}
  43. public function __unserialize($data) {}
  44. public function __debugInfo() {}
  45. }
  46. class DerivedClass extends TestClass {}
  47. interface TestInterface {
  48. public function int();
  49. public function __clone();
  50. }
  51. abstract class AbstractClass {
  52. public abstract function foo();
  53. }
  54. reflectMethodModifiers("TestClass");
  55. reflectMethodModifiers("DerivedClass");
  56. reflectMethodModifiers("TestInterface");
  57. reflectMethodModifiers("AbstractClass");
  58. $a = new ReflectionMethod('ReflectionMethod::getModifiers');
  59. echo "ReflectionMethod::getModifiers() modifiers:\n";
  60. printf("0x%08x\n", $a->getModifiers());
  61. ?>
  62. --EXPECT--
  63. Modifiers for method TestClass::foo():
  64. 0x00000001
  65. Modifiers for method TestClass::stat():
  66. 0x00000011
  67. Modifiers for method TestClass::priv():
  68. 0x00000004
  69. Modifiers for method TestClass::prot():
  70. 0x00000002
  71. Modifiers for method TestClass::fin():
  72. 0x00000021
  73. Modifiers for method TestClass::__construct():
  74. 0x00000001
  75. Modifiers for method TestClass::__destruct():
  76. 0x00000001
  77. Modifiers for method TestClass::__call():
  78. 0x00000001
  79. Modifiers for method TestClass::__callStatic():
  80. 0x00000011
  81. Modifiers for method TestClass::__clone():
  82. 0x00000001
  83. Modifiers for method TestClass::__get():
  84. 0x00000001
  85. Modifiers for method TestClass::__set():
  86. 0x00000001
  87. Modifiers for method TestClass::__unset():
  88. 0x00000001
  89. Modifiers for method TestClass::__invoke():
  90. 0x00000001
  91. Modifiers for method TestClass::__isset():
  92. 0x00000001
  93. Modifiers for method TestClass::__tostring():
  94. 0x00000001
  95. Modifiers for method TestClass::__sleep():
  96. 0x00000001
  97. Modifiers for method TestClass::__wakeup():
  98. 0x00000001
  99. Modifiers for method TestClass::__set_state():
  100. 0x00000011
  101. Modifiers for method TestClass::__autoload():
  102. 0x00000001
  103. Modifiers for method TestClass::__serialize():
  104. 0x00000001
  105. Modifiers for method TestClass::__unserialize():
  106. 0x00000001
  107. Modifiers for method TestClass::__debugInfo():
  108. 0x00000001
  109. Modifiers for method TestClass::foo():
  110. 0x00000001
  111. Modifiers for method TestClass::stat():
  112. 0x00000011
  113. Modifiers for method TestClass::prot():
  114. 0x00000002
  115. Modifiers for method TestClass::fin():
  116. 0x00000021
  117. Modifiers for method TestClass::__construct():
  118. 0x00000001
  119. Modifiers for method TestClass::__destruct():
  120. 0x00000001
  121. Modifiers for method TestClass::__call():
  122. 0x00000001
  123. Modifiers for method TestClass::__callStatic():
  124. 0x00000011
  125. Modifiers for method TestClass::__clone():
  126. 0x00000001
  127. Modifiers for method TestClass::__get():
  128. 0x00000001
  129. Modifiers for method TestClass::__set():
  130. 0x00000001
  131. Modifiers for method TestClass::__unset():
  132. 0x00000001
  133. Modifiers for method TestClass::__invoke():
  134. 0x00000001
  135. Modifiers for method TestClass::__isset():
  136. 0x00000001
  137. Modifiers for method TestClass::__tostring():
  138. 0x00000001
  139. Modifiers for method TestClass::__sleep():
  140. 0x00000001
  141. Modifiers for method TestClass::__wakeup():
  142. 0x00000001
  143. Modifiers for method TestClass::__set_state():
  144. 0x00000011
  145. Modifiers for method TestClass::__autoload():
  146. 0x00000001
  147. Modifiers for method TestClass::__serialize():
  148. 0x00000001
  149. Modifiers for method TestClass::__unserialize():
  150. 0x00000001
  151. Modifiers for method TestClass::__debugInfo():
  152. 0x00000001
  153. Modifiers for method TestInterface::int():
  154. 0x00000041
  155. Modifiers for method TestInterface::__clone():
  156. 0x00000041
  157. Modifiers for method AbstractClass::foo():
  158. 0x00000041
  159. ReflectionMethod::getModifiers() modifiers:
  160. 0x00000001