ReflectionClass_getModifierNames_basic.phpt 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. --TEST--
  2. ReflectionClass::getModifierNames() basic tests
  3. --CREDITS--
  4. Felix De Vliegher <felix.devliegher@gmail.com>
  5. --FILE--
  6. <?php
  7. class a {}
  8. abstract class b {}
  9. final class c {}
  10. class x
  11. {
  12. function __construct() {}
  13. function __destruct() {}
  14. private function a() {}
  15. private static function b() {}
  16. protected function c() {}
  17. protected static function d() {}
  18. public function e() {}
  19. public static function f() {}
  20. final function g() {}
  21. function h() {}
  22. }
  23. abstract class y
  24. {
  25. abstract function a();
  26. abstract protected function b();
  27. }
  28. function dump_modifierNames($class) {
  29. $obj = new ReflectionClass($class);
  30. var_dump($obj->getName(), Reflection::getModifierNames($obj->getModifiers()));
  31. }
  32. function dump_methodModifierNames($class) {
  33. $obj = new ReflectionClass($class);
  34. foreach($obj->getMethods() as $method) {
  35. var_dump($obj->getName() . "::" . $method->getName(), Reflection::getModifierNames($method->getModifiers()));
  36. }
  37. }
  38. dump_modifierNames('a');
  39. dump_modifierNames('b');
  40. dump_modifierNames('c');
  41. dump_methodModifierNames('x');
  42. dump_methodModifierNames('y');
  43. ?>
  44. ==DONE==
  45. --EXPECT--
  46. string(1) "a"
  47. array(0) {
  48. }
  49. string(1) "b"
  50. array(1) {
  51. [0]=>
  52. string(8) "abstract"
  53. }
  54. string(1) "c"
  55. array(1) {
  56. [0]=>
  57. string(5) "final"
  58. }
  59. string(14) "x::__construct"
  60. array(1) {
  61. [0]=>
  62. string(6) "public"
  63. }
  64. string(13) "x::__destruct"
  65. array(1) {
  66. [0]=>
  67. string(6) "public"
  68. }
  69. string(4) "x::a"
  70. array(1) {
  71. [0]=>
  72. string(7) "private"
  73. }
  74. string(4) "x::b"
  75. array(2) {
  76. [0]=>
  77. string(7) "private"
  78. [1]=>
  79. string(6) "static"
  80. }
  81. string(4) "x::c"
  82. array(1) {
  83. [0]=>
  84. string(9) "protected"
  85. }
  86. string(4) "x::d"
  87. array(2) {
  88. [0]=>
  89. string(9) "protected"
  90. [1]=>
  91. string(6) "static"
  92. }
  93. string(4) "x::e"
  94. array(1) {
  95. [0]=>
  96. string(6) "public"
  97. }
  98. string(4) "x::f"
  99. array(2) {
  100. [0]=>
  101. string(6) "public"
  102. [1]=>
  103. string(6) "static"
  104. }
  105. string(4) "x::g"
  106. array(2) {
  107. [0]=>
  108. string(5) "final"
  109. [1]=>
  110. string(6) "public"
  111. }
  112. string(4) "x::h"
  113. array(1) {
  114. [0]=>
  115. string(6) "public"
  116. }
  117. string(4) "y::a"
  118. array(2) {
  119. [0]=>
  120. string(8) "abstract"
  121. [1]=>
  122. string(6) "public"
  123. }
  124. string(4) "y::b"
  125. array(2) {
  126. [0]=>
  127. string(8) "abstract"
  128. [1]=>
  129. string(9) "protected"
  130. }
  131. ==DONE==