ReflectionClass_getMethods_001.phpt 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. --TEST--
  2. ReflectionClass::getMethods()
  3. --CREDITS--
  4. Robin Fernandes <robinf@php.net>
  5. Steve Seear <stevseea@php.net>
  6. --FILE--
  7. <?php
  8. class pubf {
  9. public function f() {}
  10. static public function s() {}
  11. }
  12. class subpubf extends pubf {
  13. }
  14. class protf {
  15. protected function f() {}
  16. static protected function s() {}
  17. }
  18. class subprotf extends protf {
  19. }
  20. class privf {
  21. private function f() {}
  22. static private function s() {}
  23. }
  24. class subprivf extends privf {
  25. }
  26. $classes = array("pubf", "subpubf", "protf", "subprotf",
  27. "privf", "subprivf");
  28. foreach($classes as $class) {
  29. echo "Reflecting on class $class: \n";
  30. $rc = new ReflectionClass($class);
  31. var_dump($rc->getMethods());
  32. }
  33. ?>
  34. --EXPECTF--
  35. Reflecting on class pubf:
  36. array(2) {
  37. [0]=>
  38. &object(ReflectionMethod)#%d (2) {
  39. [%u|b%"name"]=>
  40. %unicode|string%(1) "f"
  41. [%u|b%"class"]=>
  42. %unicode|string%(4) "pubf"
  43. }
  44. [1]=>
  45. &object(ReflectionMethod)#%d (2) {
  46. [%u|b%"name"]=>
  47. %unicode|string%(1) "s"
  48. [%u|b%"class"]=>
  49. %unicode|string%(4) "pubf"
  50. }
  51. }
  52. Reflecting on class subpubf:
  53. array(2) {
  54. [0]=>
  55. &object(ReflectionMethod)#%d (2) {
  56. [%u|b%"name"]=>
  57. %unicode|string%(1) "f"
  58. [%u|b%"class"]=>
  59. %unicode|string%(4) "pubf"
  60. }
  61. [1]=>
  62. &object(ReflectionMethod)#%d (2) {
  63. [%u|b%"name"]=>
  64. %unicode|string%(1) "s"
  65. [%u|b%"class"]=>
  66. %unicode|string%(4) "pubf"
  67. }
  68. }
  69. Reflecting on class protf:
  70. array(2) {
  71. [0]=>
  72. &object(ReflectionMethod)#%d (2) {
  73. [%u|b%"name"]=>
  74. %unicode|string%(1) "f"
  75. [%u|b%"class"]=>
  76. %unicode|string%(5) "protf"
  77. }
  78. [1]=>
  79. &object(ReflectionMethod)#%d (2) {
  80. [%u|b%"name"]=>
  81. %unicode|string%(1) "s"
  82. [%u|b%"class"]=>
  83. %unicode|string%(5) "protf"
  84. }
  85. }
  86. Reflecting on class subprotf:
  87. array(2) {
  88. [0]=>
  89. &object(ReflectionMethod)#%d (2) {
  90. [%u|b%"name"]=>
  91. %unicode|string%(1) "f"
  92. [%u|b%"class"]=>
  93. %unicode|string%(5) "protf"
  94. }
  95. [1]=>
  96. &object(ReflectionMethod)#%d (2) {
  97. [%u|b%"name"]=>
  98. %unicode|string%(1) "s"
  99. [%u|b%"class"]=>
  100. %unicode|string%(5) "protf"
  101. }
  102. }
  103. Reflecting on class privf:
  104. array(2) {
  105. [0]=>
  106. &object(ReflectionMethod)#%d (2) {
  107. [%u|b%"name"]=>
  108. %unicode|string%(1) "f"
  109. [%u|b%"class"]=>
  110. %unicode|string%(5) "privf"
  111. }
  112. [1]=>
  113. &object(ReflectionMethod)#%d (2) {
  114. [%u|b%"name"]=>
  115. %unicode|string%(1) "s"
  116. [%u|b%"class"]=>
  117. %unicode|string%(5) "privf"
  118. }
  119. }
  120. Reflecting on class subprivf:
  121. array(2) {
  122. [0]=>
  123. &object(ReflectionMethod)#%d (2) {
  124. [%u|b%"name"]=>
  125. %unicode|string%(1) "f"
  126. [%u|b%"class"]=>
  127. %unicode|string%(5) "privf"
  128. }
  129. [1]=>
  130. &object(ReflectionMethod)#%d (2) {
  131. [%u|b%"name"]=>
  132. %unicode|string%(1) "s"
  133. [%u|b%"class"]=>
  134. %unicode|string%(5) "privf"
  135. }
  136. }