xref: /PHP-7.0/Zend/tests/bug42819.phpt (revision e97d5fab)
1--TEST--
2Bug #42819 (namespaces in indexes of constant arrays)
3--SKIPIF--
4<?php if (!extension_loaded("spl")) print "skip SPL extension required"; ?>
5--FILE--
6<?php
7namespace foo\foo;
8
9const C = "foo\\foo\\C\n";
10const I = 12;
11
12class foo {
13const I = 32;
14const C = "foo\\foo\\foo::C\n";
15}
16
17namespace foo;
18use \ArrayObject;
19
20const C = "foo\\C\n";
21const I = 11;
22
23class 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
35class 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
45class 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
55class 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
65class 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
75class 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
85echo "first\n";
86echo C;
87echo foo\C;
88echo foo\foo::C;
89echo foo::C;
90echo \foo\foo::C;
91echo ArrayObject::STD_PROP_LIST . "\n";
92echo E_ERROR . "\n";
93echo "second\n";
94echo \foo\foo::C1;
95echo \foo\foo::C2;
96echo \foo\foo::C3;
97echo \foo\foo::C4;
98echo \foo\foo::C5;
99echo \foo\foo::C6 . "\n";
100echo \foo\foo::C7 . "\n";
101
102print_r(bar1::$a1);
103print_r(bar1::$a2);
104print_r(bar1::$a3);
105print_r(bar1::$a4);
106print_r(bar1::$a5);
107print_r(bar1::$a6);
108print_r(bar1::$a7);
109
110print_r(bar2::$a1);
111print_r(bar2::$a2);
112print_r(bar2::$a3);
113print_r(bar2::$a4);
114print_r(bar2::$a5);
115print_r(bar2::$a6);
116print_r(bar2::$a7);
117
118print_r(bar3::$a1);
119print_r(bar3::$a2);
120print_r(bar3::$a3);
121print_r(bar3::$a4);
122print_r(bar3::$a5);
123print_r(bar3::$a6);
124print_r(bar3::$a7);
125
126print_r(bar4::$a1);
127print_r(bar4::$a2);
128print_r(bar4::$a3);
129print_r(bar4::$a4);
130print_r(bar4::$a5);
131print_r(bar4::$a6);
132print_r(bar4::$a7);
133
134print_r(bar5::$a1);
135print_r(bar5::$a2);
136print_r(bar5::$a3);
137print_r(bar5::$a4);
138print_r(bar5::$a5);
139print_r(bar5::$a6);
140print_r(bar5::$a7);
141function oops($a = array(foo\unknown)){}
142oops();
143?>
144--EXPECTF--
145first
146foo\C
147foo\foo\C
148foo\foo\foo::C
149foo\foo::C
150foo\foo::C
1511
1521
153second
154foo\C
155foo\foo\C
156foo\foo\foo::C
157foo\C
158foo\foo::C
1591
1601
161Array
162(
163    [11] => 0
164)
165Array
166(
167    [12] => 0
168)
169Array
170(
171    [32] => 0
172)
173Array
174(
175    [11] => 0
176)
177Array
178(
179    [22] => 0
180)
181Array
182(
183    [1] => 0
184)
185Array
186(
187    [1] => 0
188)
189Array
190(
191    [11] => 11
192)
193Array
194(
195    [12] => 11
196)
197Array
198(
199    [32] => 11
200)
201Array
202(
203    [11] => 11
204)
205Array
206(
207    [22] => 11
208)
209Array
210(
211    [1] => 11
212)
213Array
214(
215    [1] => 11
216)
217Array
218(
219    [11] => 12
220)
221Array
222(
223    [12] => 12
224)
225Array
226(
227    [32] => 12
228)
229Array
230(
231    [11] => 12
232)
233Array
234(
235    [22] => 12
236)
237Array
238(
239    [1] => 12
240)
241Array
242(
243    [1] => 12
244)
245Array
246(
247    [11] => 1
248)
249Array
250(
251    [12] => 1
252)
253Array
254(
255    [32] => 1
256)
257Array
258(
259    [11] => 1
260)
261Array
262(
263    [22] => 1
264)
265Array
266(
267    [1] => 1
268)
269Array
270(
271    [1] => 1
272)
273Array
274(
275    [11] => 1
276)
277Array
278(
279    [12] => 1
280)
281Array
282(
283    [32] => 1
284)
285Array
286(
287    [11] => 1
288)
289Array
290(
291    [22] => 1
292)
293Array
294(
295    [1] => 1
296)
297Array
298(
299    [1] => 1
300)
301
302Fatal error: Uncaught Error: Undefined constant 'foo\foo\unknown' in %sbug42819.php:%d
303Stack trace:
304#0 %s(%d): foo\oops()
305#1 {main}
306  thrown in %sbug42819.php on line %d