Annotation of embedaddon/php/ext/reflection/tests/ReflectionClass_getProperty_003.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: ReflectionClass::getProperty()
3: --CREDITS--
4: Robin Fernandes <robinf@php.net>
5: Steve Seear <stevseea@php.net>
6: --FILE--
7: <?php
8: class A {
9: static public $pubC = "pubC in A";
10: static protected $protC = "protC in A";
11: static private $privC = "privC in A";
12:
13: static public $pubA = "pubA in A";
14: static protected $protA = "protA in A";
15: static private $privA = "privA in A";
16: }
17:
18: class B extends A {
19: static public $pubC = "pubC in B";
20: static protected $protC = "protC in B";
21: static private $privC = "privC in B";
22:
23: static public $pubB = "pubB in B";
24: static protected $protB = "protB in B";
25: static private $privB = "privB in B";
26: }
27:
28: class C extends B {
29: static public $pubC = "pubC in C";
30: static protected $protC = "protC in C";
31: static private $privC = "privC in C";
32: }
33:
34: class X {
35: static public $pubC = "pubC in X";
36: static protected $protC = "protC in X";
37: static private $privC = "privC in X";
38: }
39:
40: $myC = new C;
41: $rc = new ReflectionClass("C");
42:
43: function showInfo($name) {
44: global $rc, $myC;
45: echo "--- (Reflecting on $name) ---\n";
46: try {
47: $rp = $rc->getProperty($name);
48: } catch (Exception $e) {
49: echo $e->getMessage() . "\n";
50: return;
51: }
52: try {
53: var_dump($rp);
54: var_dump($rp->getValue($myC));
55: } catch (Exception $e) {
56: echo $e->getMessage() . "\n";
57: return;
58: }
59: }
60:
61:
62: showInfo("pubA");
63: showInfo("protA");
64: showInfo("privA");
65:
66: showInfo("pubB");
67: showInfo("protB");
68: showInfo("privB");
69:
70: showInfo("pubC");
71: showInfo("protC");
72: showInfo("privC");
73: showInfo("doesntExist");
74:
75: showInfo("A::pubC");
76: showInfo("A::protC");
77: showInfo("A::privC");
78:
79: showInfo("B::pubC");
80: showInfo("B::protC");
81: showInfo("B::privC");
82:
83: showInfo("c::pubC");
84: showInfo("c::PUBC");
85: showInfo("C::pubC");
86: showInfo("C::protC");
87: showInfo("C::privC");
88:
89: showInfo("X::pubC");
90: showInfo("X::protC");
91: showInfo("X::privC");
92: showInfo("X::doesntExist");
93:
94: showInfo("doesntexist::doesntExist");
95:
96: ?>
97: --EXPECTF--
98: --- (Reflecting on pubA) ---
99: object(ReflectionProperty)#%d (2) {
100: [%u|b%"name"]=>
101: %unicode|string%(4) "pubA"
102: [%u|b%"class"]=>
103: %unicode|string%(1) "A"
104: }
105: %unicode|string%(9) "pubA in A"
106: --- (Reflecting on protA) ---
107: object(ReflectionProperty)#%d (2) {
108: [%u|b%"name"]=>
109: %unicode|string%(5) "protA"
110: [%u|b%"class"]=>
111: %unicode|string%(1) "A"
112: }
113: Cannot access non-public member C::protA
114: --- (Reflecting on privA) ---
115: Property privA does not exist
116: --- (Reflecting on pubB) ---
117: object(ReflectionProperty)#%d (2) {
118: [%u|b%"name"]=>
119: %unicode|string%(4) "pubB"
120: [%u|b%"class"]=>
121: %unicode|string%(1) "B"
122: }
123: %unicode|string%(9) "pubB in B"
124: --- (Reflecting on protB) ---
125: object(ReflectionProperty)#%d (2) {
126: [%u|b%"name"]=>
127: %unicode|string%(5) "protB"
128: [%u|b%"class"]=>
129: %unicode|string%(1) "B"
130: }
131: Cannot access non-public member C::protB
132: --- (Reflecting on privB) ---
133: Property privB does not exist
134: --- (Reflecting on pubC) ---
135: object(ReflectionProperty)#%d (2) {
136: [%u|b%"name"]=>
137: %unicode|string%(4) "pubC"
138: [%u|b%"class"]=>
139: %unicode|string%(1) "C"
140: }
141: %unicode|string%(9) "pubC in C"
142: --- (Reflecting on protC) ---
143: object(ReflectionProperty)#%d (2) {
144: [%u|b%"name"]=>
145: %unicode|string%(5) "protC"
146: [%u|b%"class"]=>
147: %unicode|string%(1) "C"
148: }
149: Cannot access non-public member C::protC
150: --- (Reflecting on privC) ---
151: object(ReflectionProperty)#%d (2) {
152: [%u|b%"name"]=>
153: %unicode|string%(5) "privC"
154: [%u|b%"class"]=>
155: %unicode|string%(1) "C"
156: }
157: Cannot access non-public member C::privC
158: --- (Reflecting on doesntExist) ---
159: Property doesntExist does not exist
160: --- (Reflecting on A::pubC) ---
161: object(ReflectionProperty)#%d (2) {
162: [%u|b%"name"]=>
163: %unicode|string%(4) "pubC"
164: [%u|b%"class"]=>
165: %unicode|string%(1) "A"
166: }
167: %unicode|string%(9) "pubC in A"
168: --- (Reflecting on A::protC) ---
169: object(ReflectionProperty)#%d (2) {
170: [%u|b%"name"]=>
171: %unicode|string%(5) "protC"
172: [%u|b%"class"]=>
173: %unicode|string%(1) "A"
174: }
175: Cannot access non-public member A::protC
176: --- (Reflecting on A::privC) ---
177: object(ReflectionProperty)#%d (2) {
178: [%u|b%"name"]=>
179: %unicode|string%(5) "privC"
180: [%u|b%"class"]=>
181: %unicode|string%(1) "A"
182: }
183: Cannot access non-public member A::privC
184: --- (Reflecting on B::pubC) ---
185: object(ReflectionProperty)#%d (2) {
186: [%u|b%"name"]=>
187: %unicode|string%(4) "pubC"
188: [%u|b%"class"]=>
189: %unicode|string%(1) "B"
190: }
191: %unicode|string%(9) "pubC in B"
192: --- (Reflecting on B::protC) ---
193: object(ReflectionProperty)#%d (2) {
194: [%u|b%"name"]=>
195: %unicode|string%(5) "protC"
196: [%u|b%"class"]=>
197: %unicode|string%(1) "B"
198: }
199: Cannot access non-public member B::protC
200: --- (Reflecting on B::privC) ---
201: object(ReflectionProperty)#%d (2) {
202: [%u|b%"name"]=>
203: %unicode|string%(5) "privC"
204: [%u|b%"class"]=>
205: %unicode|string%(1) "B"
206: }
207: Cannot access non-public member B::privC
208: --- (Reflecting on c::pubC) ---
209: object(ReflectionProperty)#%d (2) {
210: [%u|b%"name"]=>
211: %unicode|string%(4) "pubC"
212: [%u|b%"class"]=>
213: %unicode|string%(1) "C"
214: }
215: %unicode|string%(9) "pubC in C"
216: --- (Reflecting on c::PUBC) ---
217: Property PUBC does not exist
218: --- (Reflecting on C::pubC) ---
219: object(ReflectionProperty)#%d (2) {
220: [%u|b%"name"]=>
221: %unicode|string%(4) "pubC"
222: [%u|b%"class"]=>
223: %unicode|string%(1) "C"
224: }
225: %unicode|string%(9) "pubC in C"
226: --- (Reflecting on C::protC) ---
227: object(ReflectionProperty)#%d (2) {
228: [%u|b%"name"]=>
229: %unicode|string%(5) "protC"
230: [%u|b%"class"]=>
231: %unicode|string%(1) "C"
232: }
233: Cannot access non-public member C::protC
234: --- (Reflecting on C::privC) ---
235: object(ReflectionProperty)#%d (2) {
236: [%u|b%"name"]=>
237: %unicode|string%(5) "privC"
238: [%u|b%"class"]=>
239: %unicode|string%(1) "C"
240: }
241: Cannot access non-public member C::privC
242: --- (Reflecting on X::pubC) ---
243: Fully qualified property name X::pubC does not specify a base class of C
244: --- (Reflecting on X::protC) ---
245: Fully qualified property name X::protC does not specify a base class of C
246: --- (Reflecting on X::privC) ---
247: Fully qualified property name X::privC does not specify a base class of C
248: --- (Reflecting on X::doesntExist) ---
249: Fully qualified property name X::doesntExist does not specify a base class of C
250: --- (Reflecting on doesntexist::doesntExist) ---
251: Class doesntexist does not exist
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>