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