![]() ![]() | ![]() |
1.1 misho 1: --TEST--
2: Bug #42819 (namespaces in indexes of constant arrays)
3: --SKIPIF--
1.1.1.2 ! misho 4: <?php if (!extension_loaded("spl")) print "skip SPL extension required"; ?>
1.1 misho 5: --FILE--
6: <?php
7: namespace foo\foo;
8:
9: const C = "foo\\foo\\C\n";
10: const I = 12;
11:
12: class foo {
13: const I = 32;
14: const C = "foo\\foo\\foo::C\n";
15: }
16:
17: namespace foo;
18: use \ArrayObject;
19:
20: const C = "foo\\C\n";
21: const I = 11;
22:
23: class foo {
24: const C = "foo\\foo::C\n";
25: const I = 22;
26: const C1 = C;
27: const C2 = foo\C;
28: const C3 = foo\foo::C;
29: const C4 = \foo\C;
30: const C5 = \foo\foo::C;
31: const C6 = ArrayObject::STD_PROP_LIST;
32: const C7 = E_ERROR;
33: }
34:
35: class bar1 {
36: static $a1 = array(I => 0);
37: static $a2 = array(foo\I => 0);
38: static $a3 = array(foo\foo::I => 0);
39: static $a4 = array(\foo\I => 0);
40: static $a5 = array(\foo\foo::I => 0);
41: static $a6 = array(ArrayObject::STD_PROP_LIST => 0);
42: static $a7 = array(E_ERROR => 0);
43: }
44:
45: class bar2 {
46: static $a1 = array(I => I);
47: static $a2 = array(foo\I => I);
48: static $a3 = array(foo\foo::I => I);
49: static $a4 = array(\foo\I => I);
50: static $a5 = array(\foo\foo::I => I);
51: static $a6 = array(ArrayObject::STD_PROP_LIST => I);
52: static $a7 = array(E_ERROR => I);
53: }
54:
55: class bar3 {
56: static $a1 = array(I => foo\I);
57: static $a2 = array(foo\I => foo\I);
58: static $a3 = array(foo\foo::I => foo\I);
59: static $a4 = array(\foo\I => foo\I);
60: static $a5 = array(\foo\foo::I => foo\I);
61: static $a6 = array(ArrayObject::STD_PROP_LIST => foo\I);
62: static $a7 = array(E_ERROR => foo\I);
63: }
64:
65: class bar4 {
66: static $a1 = array(I => ArrayObject::STD_PROP_LIST);
67: static $a2 = array(foo\I => ArrayObject::STD_PROP_LIST);
68: static $a3 = array(foo\foo::I => ArrayObject::STD_PROP_LIST);
69: static $a4 = array(\foo\I => ArrayObject::STD_PROP_LIST);
70: static $a5 = array(\foo\foo::I => ArrayObject::STD_PROP_LIST);
71: static $a6 = array(ArrayObject::STD_PROP_LIST => ArrayObject::STD_PROP_LIST);
72: static $a7 = array(E_ERROR => ArrayObject::STD_PROP_LIST);
73: }
74:
75: class bar5 {
76: static $a1 = array(I => E_ERROR);
77: static $a2 = array(foo\I => E_ERROR);
78: static $a3 = array(foo\foo::I => E_ERROR);
79: static $a4 = array(\foo\I => E_ERROR);
80: static $a5 = array(\foo\foo::I => E_ERROR);
81: static $a6 = array(ArrayObject::STD_PROP_LIST => E_ERROR);
82: static $a7 = array(E_ERROR => E_ERROR);
83: }
84:
85: echo "first\n";
86: echo C;
87: echo foo\C;
88: echo foo\foo::C;
89: echo foo::C;
90: echo \foo\foo::C;
91: echo ArrayObject::STD_PROP_LIST . "\n";
92: echo E_ERROR . "\n";
93: echo "second\n";
94: echo \foo\foo::C1;
95: echo \foo\foo::C2;
96: echo \foo\foo::C3;
97: echo \foo\foo::C4;
98: echo \foo\foo::C5;
99: echo \foo\foo::C6 . "\n";
100: echo \foo\foo::C7 . "\n";
101:
102: print_r(bar1::$a1);
103: print_r(bar1::$a2);
104: print_r(bar1::$a3);
105: print_r(bar1::$a4);
106: print_r(bar1::$a5);
107: print_r(bar1::$a6);
108: print_r(bar1::$a7);
109:
110: print_r(bar2::$a1);
111: print_r(bar2::$a2);
112: print_r(bar2::$a3);
113: print_r(bar2::$a4);
114: print_r(bar2::$a5);
115: print_r(bar2::$a6);
116: print_r(bar2::$a7);
117:
118: print_r(bar3::$a1);
119: print_r(bar3::$a2);
120: print_r(bar3::$a3);
121: print_r(bar3::$a4);
122: print_r(bar3::$a5);
123: print_r(bar3::$a6);
124: print_r(bar3::$a7);
125:
126: print_r(bar4::$a1);
127: print_r(bar4::$a2);
128: print_r(bar4::$a3);
129: print_r(bar4::$a4);
130: print_r(bar4::$a5);
131: print_r(bar4::$a6);
132: print_r(bar4::$a7);
133:
134: print_r(bar5::$a1);
135: print_r(bar5::$a2);
136: print_r(bar5::$a3);
137: print_r(bar5::$a4);
138: print_r(bar5::$a5);
139: print_r(bar5::$a6);
140: print_r(bar5::$a7);
141: function oops($a = array(foo\unknown)){}
142: oops();
143: ?>
144: --EXPECTF--
145: first
146: foo\C
147: foo\foo\C
148: foo\foo\foo::C
149: foo\foo::C
150: foo\foo::C
151: 1
152: 1
153: second
154: foo\C
155: foo\foo\C
156: foo\foo\foo::C
157: foo\C
158: foo\foo::C
159: 1
160: 1
161: Array
162: (
163: [11] => 0
164: )
165: Array
166: (
167: [12] => 0
168: )
169: Array
170: (
171: [32] => 0
172: )
173: Array
174: (
175: [11] => 0
176: )
177: Array
178: (
179: [22] => 0
180: )
181: Array
182: (
183: [1] => 0
184: )
185: Array
186: (
187: [1] => 0
188: )
189: Array
190: (
191: [11] => 11
192: )
193: Array
194: (
195: [12] => 11
196: )
197: Array
198: (
199: [32] => 11
200: )
201: Array
202: (
203: [11] => 11
204: )
205: Array
206: (
207: [22] => 11
208: )
209: Array
210: (
211: [1] => 11
212: )
213: Array
214: (
215: [1] => 11
216: )
217: Array
218: (
219: [11] => 12
220: )
221: Array
222: (
223: [12] => 12
224: )
225: Array
226: (
227: [32] => 12
228: )
229: Array
230: (
231: [11] => 12
232: )
233: Array
234: (
235: [22] => 12
236: )
237: Array
238: (
239: [1] => 12
240: )
241: Array
242: (
243: [1] => 12
244: )
245: Array
246: (
247: [11] => 1
248: )
249: Array
250: (
251: [12] => 1
252: )
253: Array
254: (
255: [32] => 1
256: )
257: Array
258: (
259: [11] => 1
260: )
261: Array
262: (
263: [22] => 1
264: )
265: Array
266: (
267: [1] => 1
268: )
269: Array
270: (
271: [1] => 1
272: )
273: Array
274: (
275: [11] => 1
276: )
277: Array
278: (
279: [12] => 1
280: )
281: Array
282: (
283: [32] => 1
284: )
285: Array
286: (
287: [11] => 1
288: )
289: Array
290: (
291: [22] => 1
292: )
293: Array
294: (
295: [1] => 1
296: )
297: Array
298: (
299: [1] => 1
300: )
301:
302: Fatal error: Undefined constant 'foo\foo\unknown' in %sbug42819.php on line %d