ReflectionClass_getProperties_001.phpt 2.3 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. [%u|b%"name"]=>
  40. %unicode|string%(1) "a"
  41. [%u|b%"class"]=>
  42. %unicode|string%(4) "pubf"
  43. }
  44. [1]=>
  45. &object(ReflectionProperty)#%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(ReflectionProperty)#%d (2) {
  56. [%u|b%"name"]=>
  57. %unicode|string%(1) "a"
  58. [%u|b%"class"]=>
  59. %unicode|string%(4) "pubf"
  60. }
  61. [1]=>
  62. &object(ReflectionProperty)#%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(ReflectionProperty)#%d (2) {
  73. [%u|b%"name"]=>
  74. %unicode|string%(1) "a"
  75. [%u|b%"class"]=>
  76. %unicode|string%(5) "protf"
  77. }
  78. [1]=>
  79. &object(ReflectionProperty)#%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(ReflectionProperty)#%d (2) {
  90. [%u|b%"name"]=>
  91. %unicode|string%(1) "a"
  92. [%u|b%"class"]=>
  93. %unicode|string%(5) "protf"
  94. }
  95. [1]=>
  96. &object(ReflectionProperty)#%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(ReflectionProperty)#%d (2) {
  107. [%u|b%"name"]=>
  108. %unicode|string%(1) "a"
  109. [%u|b%"class"]=>
  110. %unicode|string%(5) "privf"
  111. }
  112. [1]=>
  113. &object(ReflectionProperty)#%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(0) {
  122. }