ReflectionClass_getDefaultProperties_001.phpt 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. --TEST--
  2. ReflectionClass::getDefaultProperties(), ReflectionClass::getStaticProperties()
  3. --CREDITS--
  4. Robin Fernandes <robinf@php.net>
  5. Steve Seear <stevseea@php.net>
  6. --FILE--
  7. <?php
  8. class A {
  9. static public $statPubC = "stat pubC in A";
  10. static protected $statProtC = "stat protC in A";
  11. static private $statPrivC = "stat privC in A";
  12. static public $statPubA = "stat pubA in A";
  13. static protected $statProtA = "stat protA in A";
  14. static private $statPrivA = "stat privA in A";
  15. public $pubC = "pubC in A";
  16. protected $protC = "protC in A";
  17. private $privC = "privC in A";
  18. public $pubA = "pubA in A";
  19. protected $protA = "protA in A";
  20. private $privA = "privA in A";
  21. }
  22. class B extends A {
  23. static public $statPubC = "stat pubC in B";
  24. static protected $statProtC = "stat protC in B";
  25. static private $statPrivC = "stat privC in B";
  26. static public $statPubB = "stat pubB in B";
  27. static protected $statProtB = "stat protB in B";
  28. static private $statPrivB = "stat privB in B";
  29. public $pubC = "pubC in B";
  30. protected $protC = "protC in B";
  31. private $privC = "privC in B";
  32. public $pubB = "pubB in B";
  33. protected $protB = "protB in B";
  34. private $privB = "privB in B";
  35. }
  36. class C extends B {
  37. static public $statPubC = "stat pubC in C";
  38. static protected $statProtC = "stat protC in C";
  39. static private $statPrivC = "stat privC in C";
  40. public $pubC = "pubC in C";
  41. protected $protC = "protC in C";
  42. private $privC = "privC in C";
  43. }
  44. class X {
  45. static public $statPubC = "stat pubC in X";
  46. static protected $statProtC = "stat protC in X";
  47. static private $statPrivC = "stat privC in X";
  48. public $pubC = "pubC in X";
  49. protected $protC = "protC in X";
  50. private $privC = "privC in X";
  51. }
  52. $classes = array('A', 'B', 'C', 'X');
  53. foreach ($classes as $class) {
  54. $rc = new ReflectionClass($class);
  55. echo "\n\n---- Static properties in $class ----\n";
  56. print_r($rc->getStaticProperties());
  57. echo "\n\n---- Default properties in $class ----\n";
  58. print_r($rc->getDefaultProperties());
  59. }
  60. ?>
  61. --EXPECT--
  62. ---- Static properties in A ----
  63. Array
  64. (
  65. [statPubC] => stat pubC in A
  66. [statProtC] => stat protC in A
  67. [statPrivC] => stat privC in A
  68. [statPubA] => stat pubA in A
  69. [statProtA] => stat protA in A
  70. [statPrivA] => stat privA in A
  71. )
  72. ---- Default properties in A ----
  73. Array
  74. (
  75. [statPubC] => stat pubC in A
  76. [statProtC] => stat protC in A
  77. [statPrivC] => stat privC in A
  78. [statPubA] => stat pubA in A
  79. [statProtA] => stat protA in A
  80. [statPrivA] => stat privA in A
  81. [pubC] => pubC in A
  82. [protC] => protC in A
  83. [privC] => privC in A
  84. [pubA] => pubA in A
  85. [protA] => protA in A
  86. [privA] => privA in A
  87. )
  88. ---- Static properties in B ----
  89. Array
  90. (
  91. [statPubC] => stat pubC in B
  92. [statProtC] => stat protC in B
  93. [statPrivC] => stat privC in B
  94. [statPubB] => stat pubB in B
  95. [statProtB] => stat protB in B
  96. [statPrivB] => stat privB in B
  97. [statPubA] => stat pubA in A
  98. [statProtA] => stat protA in A
  99. )
  100. ---- Default properties in B ----
  101. Array
  102. (
  103. [statPubC] => stat pubC in B
  104. [statProtC] => stat protC in B
  105. [statPrivC] => stat privC in B
  106. [statPubB] => stat pubB in B
  107. [statProtB] => stat protB in B
  108. [statPrivB] => stat privB in B
  109. [statPubA] => stat pubA in A
  110. [statProtA] => stat protA in A
  111. [pubC] => pubC in B
  112. [protC] => protC in B
  113. [privC] => privC in B
  114. [pubB] => pubB in B
  115. [protB] => protB in B
  116. [privB] => privB in B
  117. [pubA] => pubA in A
  118. [protA] => protA in A
  119. )
  120. ---- Static properties in C ----
  121. Array
  122. (
  123. [statPubC] => stat pubC in C
  124. [statProtC] => stat protC in C
  125. [statPrivC] => stat privC in C
  126. [statPubB] => stat pubB in B
  127. [statProtB] => stat protB in B
  128. [statPubA] => stat pubA in A
  129. [statProtA] => stat protA in A
  130. )
  131. ---- Default properties in C ----
  132. Array
  133. (
  134. [statPubC] => stat pubC in C
  135. [statProtC] => stat protC in C
  136. [statPrivC] => stat privC in C
  137. [statPubB] => stat pubB in B
  138. [statProtB] => stat protB in B
  139. [statPubA] => stat pubA in A
  140. [statProtA] => stat protA in A
  141. [pubC] => pubC in C
  142. [protC] => protC in C
  143. [privC] => privC in C
  144. [pubB] => pubB in B
  145. [protB] => protB in B
  146. [pubA] => pubA in A
  147. [protA] => protA in A
  148. )
  149. ---- Static properties in X ----
  150. Array
  151. (
  152. [statPubC] => stat pubC in X
  153. [statProtC] => stat protC in X
  154. [statPrivC] => stat privC in X
  155. )
  156. ---- Default properties in X ----
  157. Array
  158. (
  159. [statPubC] => stat pubC in X
  160. [statProtC] => stat protC in X
  161. [statPrivC] => stat privC in X
  162. [pubC] => pubC in X
  163. [protC] => protC in X
  164. [privC] => privC in X
  165. )