Skip to content

Commit 3e9849c

Browse files
committed
Zend/tests/offsets: add tests for taking references
1 parent a74da53 commit 3e9849c

10 files changed

+455
-275
lines changed

Zend/tests/offsets/ArrayAccess_container_offset_behaviour.phpt

+10-4
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,32 @@ VAR_DUMP_OF_OFFSET
4040
string(12) "CLASS_NAME::offsetGet"
4141
VAR_DUMP_OF_OFFSET
4242
int(5)
43+
Reference to dimension:
44+
string(12) "CLASS_NAME::offsetGet"
45+
VAR_DUMP_OF_OFFSET
46+
47+
Notice: Indirect modification of overloaded element of CLASS_NAME has no effect in %s on line 55
48+
int(5)
4349
unset():
4450
string(14) "CLASS_NAME::offsetUnset"
4551
VAR_DUMP_OF_OFFSET
4652
Nested read:
4753
string(12) "CLASS_NAME::offsetGet"
4854
VAR_DUMP_OF_OFFSET
4955
50-
Warning: Trying to access array offset on int in %s on line 62
56+
Warning: Trying to access array offset on int in %s on line 70
5157
NULL
5258
Nested write:
5359
string(12) "CLASS_NAME::offsetGet"
5460
VAR_DUMP_OF_OFFSET
5561
56-
Notice: Indirect modification of overloaded element of CLASS_NAME has no effect in %s on line 69
62+
Notice: Indirect modification of overloaded element of CLASS_NAME has no effect in %s on line 77
5763
Cannot use a scalar value as an array
5864
Nested Read-Write:
5965
string(12) "CLASS_NAME::offsetGet"
6066
VAR_DUMP_OF_OFFSET
6167
62-
Notice: Indirect modification of overloaded element of CLASS_NAME has no effect in %s on line 76
68+
Notice: Indirect modification of overloaded element of CLASS_NAME has no effect in %s on line 84
6369
Cannot use a scalar value as an array
6470
Nested isset():
6571
string(15) "CLASS_NAME::offsetExists"
@@ -83,7 +89,7 @@ Nested unset():
8389
string(12) "CLASS_NAME::offsetGet"
8490
VAR_DUMP_OF_OFFSET
8591
86-
Notice: Indirect modification of overloaded element of CLASS_NAME has no effect in %s on line 102
92+
Notice: Indirect modification of overloaded element of CLASS_NAME has no effect in %s on line 110
8793
Cannot unset offset in a non-array variable
8894
8995
OUTPUT;

Zend/tests/offsets/ArrayObject_container_offset_behaviour.phpt

+60-46
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require_once __DIR__ . DIRECTORY_SEPARATOR . 'test_offset_helpers.inc';
88
const EXPECTED_OUTPUT_VALID_OFFSETS = <<<OUTPUT
99
Read before write:
1010
11-
Warning: Undefined array key %s in %s on line 8
11+
Warning: Undefined array key %s in %s on line %d
1212
NULL
1313
Write:
1414
Read:
@@ -20,12 +20,14 @@ empty():
2020
bool(false)
2121
null coalesce:
2222
int(25)
23+
Reference to dimension:
24+
int(25)
2325
unset():
2426
Nested read:
2527
26-
Warning: Undefined array key %s in %s on line 62
28+
Warning: Undefined array key %s in %s on line %d
2729
28-
Warning: Trying to access array offset on null in %s on line 62
30+
Warning: Trying to access array offset on null in %s on line %d
2931
NULL
3032
Nested write:
3133
Nested Read-Write:
@@ -43,76 +45,80 @@ $EXPECTED_OUTPUT_VALID_OFFSETS_REGEX = '/^' . expectf_to_regex(EXPECTED_OUTPUT_V
4345
const EXPECTF_OUTPUT_FLOAT_OFFSETS = <<<OUTPUT
4446
Read before write:
4547
46-
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 8
48+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
4749
48-
Warning: Undefined array key %s in %s on line 8
50+
Warning: Undefined array key %s in %s on line %d
4951
NULL
5052
Write:
5153
52-
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 15
54+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
5355
Read:
5456
55-
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 22
57+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
5658
int(15)
5759
Read-Write:
5860
59-
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 29
61+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
6062
isset():
6163
62-
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 36
64+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
6365
bool(true)
6466
empty():
6567
66-
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 42
68+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
6769
bool(false)
6870
null coalesce:
6971
70-
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 48
72+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
73+
int(35)
74+
Reference to dimension:
75+
76+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
7177
int(35)
7278
unset():
7379
74-
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 55
80+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
7581
Nested read:
7682
77-
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 62
83+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
7884
79-
Warning: Undefined array key 0 in %s on line 62
85+
Warning: Undefined array key 0 in %s on line %d
8086
81-
Warning: Trying to access array offset on null in %s on line 62
87+
Warning: Trying to access array offset on null in %s on line %d
8288
NULL
8389
Nested write:
8490
85-
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 69
91+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
8692
87-
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 69
93+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
8894
Nested Read-Write:
8995
90-
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 76
96+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
9197
92-
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 76
98+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
9399
Nested isset():
94100
95-
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 83
101+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
96102
97-
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 83
103+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
98104
bool(true)
99105
Nested empty():
100106
101-
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 89
107+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
102108
103-
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 89
109+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
104110
bool(false)
105111
Nested null coalesce:
106112
107-
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 95
113+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
108114
109-
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 95
115+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
110116
int(25)
111117
Nested unset():
112118
113-
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 102
119+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
114120
115-
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 102
121+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line %d
116122
117123
OUTPUT;
118124

@@ -133,6 +139,8 @@ empty():
133139
Cannot access offset of type %s in isset or empty
134140
null coalesce:
135141
Cannot access offset of type %s in isset or empty
142+
Reference to dimension:
143+
Cannot access offset of type %s on ArrayObject
136144
unset():
137145
Cannot unset offset of type %s on ArrayObject
138146
Nested read:
@@ -149,7 +157,7 @@ Nested null coalesce:
149157
Cannot access offset of type %s in isset or empty
150158
Nested unset():
151159
152-
Notice: Indirect modification of overloaded element of ArrayObject has no effect in %s on line 102
160+
Notice: Indirect modification of overloaded element of ArrayObject has no effect in %s on line %d
153161
Cannot unset offset of type %s on ArrayObject
154162
155163
OUTPUT;
@@ -175,12 +183,14 @@ empty():
175183
bool(true)
176184
null coalesce:
177185
string(7) "default"
186+
Reference to dimension:
187+
NULL
178188
unset():
179189
Nested read:
180190
181-
Warning: Undefined array key "" in %s on line 62
191+
Warning: Undefined array key "" in %s on line 70
182192
183-
Warning: Trying to access array offset on null in %s on line 62
193+
Warning: Trying to access array offset on null in %s on line 70
184194
NULL
185195
Nested write:
186196
Nested Read-Write:
@@ -225,50 +235,54 @@ null coalesce:
225235
226236
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 48
227237
int(25)
228-
unset():
238+
Reference to dimension:
229239
230240
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 55
241+
int(25)
242+
unset():
243+
244+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 63
231245
Nested read:
232246
233-
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 62
247+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 70
234248
235-
Warning: Undefined array key 3 in %s on line 62
249+
Warning: Undefined array key 3 in %s on line 70
236250
237-
Warning: Trying to access array offset on null in %s on line 62
251+
Warning: Trying to access array offset on null in %s on line 70
238252
NULL
239253
Nested write:
240254
241-
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 69
255+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 77
242256
243-
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 69
257+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 77
244258
Nested Read-Write:
245259
246-
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 76
260+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 84
247261
248-
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 76
262+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 84
249263
Nested isset():
250264
251-
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 83
265+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 91
252266
253-
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 83
267+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 91
254268
bool(true)
255269
Nested empty():
256270
257-
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 89
271+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 97
258272
259-
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 89
273+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 97
260274
bool(false)
261275
Nested null coalesce:
262276
263-
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 95
277+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 103
264278
265-
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 95
279+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 103
266280
int(30)
267281
Nested unset():
268282
269-
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 102
283+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 110
270284
271-
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 102
285+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 110
272286
273287
OUTPUT;
274288

0 commit comments

Comments
 (0)