ReflectionClass_getProperties_001.phpt 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. --TEST--
  2. ReflectionClass::getProperties()
  3. --CREDITS--
  4. Robin Fernandes <robinf@php.net>
  5. Steve Seear <stevseea@php.net>
  6. --FILE--
  7. <?php
  8. class pubf {
  9. public $a;
  10. static public $s;
  11. }
  12. class subpubf extends pubf {
  13. }
  14. class protf {
  15. protected $a;
  16. static protected $s;
  17. }
  18. class subprotf extends protf {
  19. }
  20. class privf {
  21. private $a;
  22. static private $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->getProperties());
  32. }
  33. ?>
  34. --EXPECTF--
  35. Reflecting on class pubf:
  36. array(2) {
  37. [0]=>
  38. object(ReflectionProperty)#%d (2) {
  39. ["name"]=>
  40. string(1) "a"
  41. ["class"]=>
  42. string(4) "pubf"
  43. }
  44. [1]=>
  45. object(ReflectionProperty)#%d (2) {
  46. ["name"]=>
  47. string(1) "s"
  48. ["class"]=>
  49. string(4) "pubf"
  50. }
  51. }
  52. Reflecting on class subpubf:
  53. array(2) {
  54. [0]=>
  55. object(ReflectionProperty)#%d (2) {
  56. ["name"]=>
  57. string(1) "a"
  58. ["class"]=>
  59. string(4) "pubf"
  60. }
  61. [1]=>
  62. object(ReflectionProperty)#%d (2) {
  63. ["name"]=>
  64. string(1) "s"
  65. ["class"]=>
  66. string(4) "pubf"
  67. }
  68. }
  69. Reflecting on class protf:
  70. array(2) {
  71. [0]=>
  72. object(ReflectionProperty)#%d (2) {
  73. ["name"]=>
  74. string(1) "a"
  75. ["class"]=>
  76. string(5) "protf"
  77. }
  78. [1]=>
  79. object(ReflectionProperty)#%d (2) {
  80. ["name"]=>
  81. string(1) "s"
  82. ["class"]=>
  83. string(5) "protf"
  84. }
  85. }
  86. Reflecting on class subprotf:
  87. array(2) {
  88. [0]=>
  89. object(ReflectionProperty)#%d (2) {
  90. ["name"]=>
  91. string(1) "a"
  92. ["class"]=>
  93. string(5) "protf"
  94. }
  95. [1]=>
  96. object(ReflectionProperty)#%d (2) {
  97. ["name"]=>
  98. string(1) "s"
  99. ["class"]=>
  100. string(5) "protf"
  101. }
  102. }
  103. Reflecting on class privf:
  104. array(2) {
  105. [0]=>
  106. object(ReflectionProperty)#%d (2) {
  107. ["name"]=>
  108. string(1) "a"
  109. ["class"]=>
  110. string(5) "privf"
  111. }
  112. [1]=>
  113. object(ReflectionProperty)#%d (2) {
  114. ["name"]=>
  115. string(1) "s"
  116. ["class"]=>
  117. string(5) "privf"
  118. }
  119. }
  120. Reflecting on class subprivf:
  121. array(0) {
  122. }