You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

242 lines
3.9 KiB

  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. var_dump($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 __destruct() {}
  28. public function __call($a, $b) {}
  29. public function __clone() {}
  30. public function __get($a) {}
  31. public function __set($a, $b) {}
  32. public function __unset($a) {}
  33. public function __isset($a) {}
  34. public function __tostring() {}
  35. public function __sleep() {}
  36. public function __wakeup() {}
  37. public function __set_state() {}
  38. public function __autoload() {}
  39. }
  40. class DerivedClass extends TestClass {}
  41. interface TestInterface {
  42. public function int();
  43. public function __clone();
  44. }
  45. abstract class AbstractClass {
  46. public abstract function foo();
  47. }
  48. reflectMethodModifiers("TestClass");
  49. reflectMethodModifiers("DerivedClass");
  50. reflectMethodModifiers("TestInterface");
  51. reflectMethodModifiers("AbstractClass");
  52. echo "Wrong number of params:\n";
  53. $a = new ReflectionMethod('TestClass::foo');
  54. $a->getModifiers(1);
  55. $a = new ReflectionMethod('ReflectionMethod::getModifiers');
  56. echo "\nReflectionMethod::getModifiers() modifiers:\n";
  57. var_dump($a->getModifiers());
  58. ?>
  59. --EXPECTF--
  60. Modifiers for method TestClass::foo():
  61. int(65792)
  62. Modifiers for method TestClass::stat():
  63. int(257)
  64. Modifiers for method TestClass::priv():
  65. int(66560)
  66. Modifiers for method TestClass::prot():
  67. int(66048)
  68. Modifiers for method TestClass::fin():
  69. int(65796)
  70. Modifiers for method TestClass::__destruct():
  71. int(16640)
  72. Modifiers for method TestClass::__call():
  73. int(256)
  74. Modifiers for method TestClass::__clone():
  75. int(33024)
  76. Modifiers for method TestClass::__get():
  77. int(256)
  78. Modifiers for method TestClass::__set():
  79. int(256)
  80. Modifiers for method TestClass::__unset():
  81. int(256)
  82. Modifiers for method TestClass::__isset():
  83. int(256)
  84. Modifiers for method TestClass::__tostring():
  85. int(256)
  86. Modifiers for method TestClass::__sleep():
  87. int(65792)
  88. Modifiers for method TestClass::__wakeup():
  89. int(65792)
  90. Modifiers for method TestClass::__set_state():
  91. int(65792)
  92. Modifiers for method TestClass::__autoload():
  93. int(65792)
  94. Modifiers for method DerivedClass::foo():
  95. int(65792)
  96. Modifiers for method DerivedClass::stat():
  97. int(257)
  98. Modifiers for method DerivedClass::priv():
  99. int(66560)
  100. Modifiers for method DerivedClass::prot():
  101. int(66048)
  102. Modifiers for method DerivedClass::fin():
  103. int(65796)
  104. Modifiers for method DerivedClass::__destruct():
  105. int(16640)
  106. Modifiers for method DerivedClass::__call():
  107. int(256)
  108. Modifiers for method DerivedClass::__clone():
  109. int(33024)
  110. Modifiers for method DerivedClass::__get():
  111. int(256)
  112. Modifiers for method DerivedClass::__set():
  113. int(256)
  114. Modifiers for method DerivedClass::__unset():
  115. int(256)
  116. Modifiers for method DerivedClass::__isset():
  117. int(256)
  118. Modifiers for method DerivedClass::__tostring():
  119. int(256)
  120. Modifiers for method DerivedClass::__sleep():
  121. int(65792)
  122. Modifiers for method DerivedClass::__wakeup():
  123. int(65792)
  124. Modifiers for method DerivedClass::__set_state():
  125. int(65792)
  126. Modifiers for method DerivedClass::__autoload():
  127. int(65792)
  128. Modifiers for method TestInterface::int():
  129. int(258)
  130. Modifiers for method TestInterface::__clone():
  131. int(258)
  132. Modifiers for method AbstractClass::foo():
  133. int(65794)
  134. Wrong number of params:
  135. Warning: Wrong parameter count for ReflectionMethod::getModifiers() in %s on line %d
  136. ReflectionMethod::getModifiers() modifiers:
  137. int(256)