xref: /PHP-8.2/Zend/tests/bug39018.phpt (revision 95cff3eb)
1--TEST--
2Bug #39018 (Error control operator '@' fails to suppress "Uninitialized string offset")
3--FILE--
4<?php
5
6error_reporting(E_ALL);
7
8$a = 'foo';
9$a[111111111111111111111];
10
11$a = '';
12
13$a[0];
14
15print $a[0]; // 12
16
17$a[-11111111111111111111111];
18
19print $a[-11111111111111111111111]; // 16
20
21$a[-0];
22
23$x = 'test';
24
25@$x[4];
26
27@$y = $x[4];
28
29@('a' == $x[4]);
30
31$x[4] == 'a'; // 28
32
33@$x[4] == 'a';
34
35(@$x[4]) == 'a';
36
37($x[4]) == 'a'; // 34
38
39(@($x[4])) == 'a';
40
41(($x[4])) == 'a'; // 38
42
43@($x[4]) == 'a';
44
45($x[4]) == 'a'; // 42
46
47@($x[4] == 'a');
48
49($x[4] == 'a'); // 46
50
51$y = 'foobar';
52
53$y[12.2];
54
55print $y[12.2]; // 52
56
57$y[3.5];
58
59print $y[3.5]; // 56
60
61print "\nDone\n";
62
63?>
64--EXPECTF--
65Warning: String offset cast occurred in %s on line %d
66
67Warning: Uninitialized string offset %d in %s on line %d
68
69Warning: Uninitialized string offset 0 in %s on line %d
70
71Warning: Uninitialized string offset 0 in %s on line %d
72
73Warning: String offset cast occurred in %s on line %d
74
75Warning: Uninitialized string offset %i in %s on line %d
76
77Warning: String offset cast occurred in %s on line %d
78
79Warning: Uninitialized string offset %i in %s on line %d
80
81Warning: Uninitialized string offset 0 in %s on line %d
82
83Warning: Uninitialized string offset 4 in %s on line %d
84
85Warning: Uninitialized string offset 4 in %s on line %d
86
87Warning: Uninitialized string offset 4 in %s on line %d
88
89Warning: Uninitialized string offset 4 in %s on line %d
90
91Warning: Uninitialized string offset 4 in %s on line %d
92
93Warning: String offset cast occurred in %s on line %d
94
95Warning: Uninitialized string offset 12 in %s on line %d
96
97Warning: String offset cast occurred in %s on line %d
98
99Warning: Uninitialized string offset 12 in %s on line %d
100
101Warning: String offset cast occurred in %s on line %d
102
103Warning: String offset cast occurred in %s on line %d
104b
105Done
106