ReflectionClass_getProperties_003.phpt 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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 C {
  9. public $pub1;
  10. public $pub2;
  11. private $priv1;
  12. private $priv2;
  13. static public $pubs;
  14. static public $pubs2;
  15. static private $privs1;
  16. static private $privs2;
  17. }
  18. $rc = new ReflectionClass("C");
  19. $StaticFlag = ReflectionProperty::IS_STATIC;
  20. $pubFlag = ReflectionProperty::IS_PUBLIC;
  21. $privFlag = ReflectionProperty::IS_PRIVATE;
  22. echo "No properties:";
  23. var_dump($rc->getProperties(0));
  24. echo "Public properties:";
  25. var_dump($rc->getProperties($pubFlag));
  26. echo "Private properties:";
  27. var_dump($rc->getProperties($privFlag));
  28. echo "Public or static properties:";
  29. var_dump($rc->getProperties($StaticFlag | $pubFlag));
  30. echo "Private or static properties:";
  31. var_dump($rc->getProperties($StaticFlag | $privFlag));
  32. ?>
  33. --EXPECTF--
  34. No properties:array(0) {
  35. }
  36. Public properties:array(4) {
  37. [0]=>
  38. object(ReflectionProperty)#%d (2) {
  39. ["name"]=>
  40. string(4) "pub1"
  41. ["class"]=>
  42. string(1) "C"
  43. }
  44. [1]=>
  45. object(ReflectionProperty)#%d (2) {
  46. ["name"]=>
  47. string(4) "pub2"
  48. ["class"]=>
  49. string(1) "C"
  50. }
  51. [2]=>
  52. object(ReflectionProperty)#%d (2) {
  53. ["name"]=>
  54. string(4) "pubs"
  55. ["class"]=>
  56. string(1) "C"
  57. }
  58. [3]=>
  59. object(ReflectionProperty)#%d (2) {
  60. ["name"]=>
  61. string(5) "pubs2"
  62. ["class"]=>
  63. string(1) "C"
  64. }
  65. }
  66. Private properties:array(4) {
  67. [0]=>
  68. object(ReflectionProperty)#%d (2) {
  69. ["name"]=>
  70. string(5) "priv1"
  71. ["class"]=>
  72. string(1) "C"
  73. }
  74. [1]=>
  75. object(ReflectionProperty)#%d (2) {
  76. ["name"]=>
  77. string(5) "priv2"
  78. ["class"]=>
  79. string(1) "C"
  80. }
  81. [2]=>
  82. object(ReflectionProperty)#%d (2) {
  83. ["name"]=>
  84. string(6) "privs1"
  85. ["class"]=>
  86. string(1) "C"
  87. }
  88. [3]=>
  89. object(ReflectionProperty)#%d (2) {
  90. ["name"]=>
  91. string(6) "privs2"
  92. ["class"]=>
  93. string(1) "C"
  94. }
  95. }
  96. Public or static properties:array(6) {
  97. [0]=>
  98. object(ReflectionProperty)#%d (2) {
  99. ["name"]=>
  100. string(4) "pub1"
  101. ["class"]=>
  102. string(1) "C"
  103. }
  104. [1]=>
  105. object(ReflectionProperty)#%d (2) {
  106. ["name"]=>
  107. string(4) "pub2"
  108. ["class"]=>
  109. string(1) "C"
  110. }
  111. [2]=>
  112. object(ReflectionProperty)#%d (2) {
  113. ["name"]=>
  114. string(4) "pubs"
  115. ["class"]=>
  116. string(1) "C"
  117. }
  118. [3]=>
  119. object(ReflectionProperty)#%d (2) {
  120. ["name"]=>
  121. string(5) "pubs2"
  122. ["class"]=>
  123. string(1) "C"
  124. }
  125. [4]=>
  126. object(ReflectionProperty)#%d (2) {
  127. ["name"]=>
  128. string(6) "privs1"
  129. ["class"]=>
  130. string(1) "C"
  131. }
  132. [5]=>
  133. object(ReflectionProperty)#%d (2) {
  134. ["name"]=>
  135. string(6) "privs2"
  136. ["class"]=>
  137. string(1) "C"
  138. }
  139. }
  140. Private or static properties:array(6) {
  141. [0]=>
  142. object(ReflectionProperty)#%d (2) {
  143. ["name"]=>
  144. string(5) "priv1"
  145. ["class"]=>
  146. string(1) "C"
  147. }
  148. [1]=>
  149. object(ReflectionProperty)#%d (2) {
  150. ["name"]=>
  151. string(5) "priv2"
  152. ["class"]=>
  153. string(1) "C"
  154. }
  155. [2]=>
  156. object(ReflectionProperty)#%d (2) {
  157. ["name"]=>
  158. string(4) "pubs"
  159. ["class"]=>
  160. string(1) "C"
  161. }
  162. [3]=>
  163. object(ReflectionProperty)#%d (2) {
  164. ["name"]=>
  165. string(5) "pubs2"
  166. ["class"]=>
  167. string(1) "C"
  168. }
  169. [4]=>
  170. object(ReflectionProperty)#%d (2) {
  171. ["name"]=>
  172. string(6) "privs1"
  173. ["class"]=>
  174. string(1) "C"
  175. }
  176. [5]=>
  177. object(ReflectionProperty)#%d (2) {
  178. ["name"]=>
  179. string(6) "privs2"
  180. ["class"]=>
  181. string(1) "C"
  182. }
  183. }