Skip to content

Commit 34132a7

Browse files
Deprecate using null as an array offset and when calling array_key_exists()
1 parent 0bf2959 commit 34132a7

26 files changed

+902
-42
lines changed

Zend/tests/assign_dim_op_undef.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Warning: Undefined variable $a in %s on line %d
1010

1111
Warning: Undefined variable $b in %s on line %d
1212

13+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
14+
1315
Warning: Undefined array key "" in %s on line %d
1416
array(1) {
1517
[""]=>

Zend/tests/bug72543_2.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ unset($ref);
99
$arr[0][$arr[0]] = null;
1010
var_dump($arr);
1111
?>
12-
--EXPECT--
12+
--EXPECTF--
13+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
1314
array(1) {
1415
[0]=>
1516
array(1) {

Zend/tests/gc/bug67314.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ echo "ok\n";
1717
?>
1818
--EXPECTF--
1919
Warning: Undefined variable $i in %s on line %d
20+
21+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
2022
made it once
2123

2224
Warning: Undefined variable $i in %s on line %d
25+
26+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
2327
ok

Zend/tests/isset/isset_array.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ bool(true)
4242
Deprecated: Implicit conversion from float 0.6 to int loses precision in %s on line %d
4343
bool(true)
4444
bool(false)
45+
46+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
4547
bool(false)
4648

4749
Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d

Zend/tests/list/list_keyed_conversions.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ list(STDIN => $resource) = [];
2121

2222
?>
2323
--EXPECTF--
24+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
25+
2426
Deprecated: Implicit conversion from float 1.5 to int loses precision in %s on line %d
2527
string(0) ""
2628
int(1)

Zend/tests/nullsafe_operator/013.phpt

127 Bytes
Binary file not shown.

Zend/tests/offset_array.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ int(2)
3838
Deprecated: Implicit conversion from float 0.0836 to int loses precision in %s on line %d
3939
int(1)
4040

41+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
42+
4143
Warning: Undefined array key "" in %s on line %d
4244
NULL
4345

Zend/tests/offsets/ArrayObject_container_offset_behaviour.phpt

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,93 @@ OUTPUT;
132132

133133
$EXPECTED_OUTPUT_FLOAT_OFFSETS_REGEX = '/^' . expectf_to_regex(EXPECTF_OUTPUT_FLOAT_OFFSETS) . '$/s';
134134

135+
const EXPECTED_OUTPUT_NULL_OFFSETS = <<<OUTPUT
136+
Read before write:
137+
138+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
139+
140+
Warning: Undefined array key "" in %s on line %d
141+
NULL
142+
Write:
143+
144+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
145+
Read:
146+
147+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
148+
int(5)
149+
Read-Write:
150+
151+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
152+
153+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
154+
isset():
155+
156+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
157+
bool(true)
158+
empty():
159+
160+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
161+
bool(false)
162+
null coalesce:
163+
164+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
165+
int(25)
166+
Reference to dimension:
167+
168+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
169+
Value of reference:
170+
int(25)
171+
Value of container dimension after write to reference (should be int(100) if successful):
172+
173+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
174+
int(100)
175+
unset():
176+
177+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
178+
Nested read:
179+
180+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
181+
182+
Warning: Undefined array key "" in %s on line %d
183+
184+
Warning: Trying to access array offset on null in %s on line %d
185+
NULL
186+
Nested write:
187+
188+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
189+
190+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
191+
Nested Read-Write:
192+
193+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
194+
195+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
196+
Nested isset():
197+
198+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
199+
200+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
201+
bool(true)
202+
Nested empty():
203+
204+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
205+
206+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
207+
bool(false)
208+
Nested null coalesce:
209+
210+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
211+
212+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
213+
int(30)
214+
Nested unset():
215+
216+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
217+
218+
OUTPUT;
219+
220+
$EXPECTED_OUTPUT_NULL_OFFSETS_REGEX = '/^' . expectf_to_regex(EXPECTED_OUTPUT_NULL_OFFSETS) . '$/s';
221+
135222
const EXPECTED_OUTPUT_INVALID_OFFSETS = <<<OUTPUT
136223
Read before write:
137224
Cannot access offset of type %s on ArrayObject
@@ -175,44 +262,86 @@ $EXPECTED_OUTPUT_INVALID_OFFSETS_REGEX = '/^' . expectf_to_regex(EXPECTED_OUTPUT
175262
const EXPECTED_OUTPUT_NULL_OFFSET = <<<OUTPUT
176263
Read before write:
177264
265+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 8
266+
178267
Warning: Undefined array key "" in %s on line 8
179268
NULL
180269
Write:
181270
Read:
182271
272+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 22
273+
183274
Warning: Undefined array key "" in %s on line 22
184275
NULL
185276
Read-Write:
186277
278+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 29
279+
187280
Warning: Undefined array key "" in %s on line 29
188281
isset():
282+
283+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 36
189284
bool(false)
190285
empty():
286+
287+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 42
191288
bool(true)
192289
null coalesce:
290+
291+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 48
193292
string(7) "default"
194293
Reference to dimension:
294+
295+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 55
195296
Value of reference:
196297
NULL
197298
Value of container dimension after write to reference (should be int(100) if successful):
299+
300+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 60
198301
int(100)
199302
unset():
303+
304+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 67
200305
Nested read:
201306
307+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 74
308+
202309
Warning: Undefined array key "" in %s on line 74
203310
204311
Warning: Trying to access array offset on null in %s on line 74
205312
NULL
206313
Nested write:
314+
315+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 81
316+
317+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 81
207318
Nested Read-Write:
319+
320+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 88
321+
322+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 88
208323
Nested isset():
324+
325+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 95
326+
327+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 95
209328
bool(true)
210329
Nested empty():
330+
331+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 101
332+
333+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 101
211334
bool(false)
212335
Nested null coalesce:
336+
337+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 107
338+
339+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 107
213340
int(30)
214341
Nested unset():
215342
343+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 114
344+
216345
OUTPUT;
217346

218347
const EXPECTED_OUTPUT_RESOURCE_STDERR_OFFSETS = <<<OUTPUT
@@ -323,6 +452,7 @@ foreach ($offsets as $dimension) {
323452
!preg_match($EXPECTED_OUTPUT_VALID_OFFSETS_REGEX, $varOutput)
324453
&& !preg_match($EXPECTED_OUTPUT_INVALID_OFFSETS_REGEX, $varOutput)
325454
&& !preg_match($EXPECTED_OUTPUT_FLOAT_OFFSETS_REGEX, $varOutput)
455+
&& !preg_match($EXPECTED_OUTPUT_NULL_OFFSETS_REGEX, $varOutput)
326456
&& $varOutput !== EXPECTED_OUTPUT_NULL_OFFSET
327457
&& $varOutput !== EXPECTED_OUTPUT_RESOURCE_STDERR_OFFSETS
328458
) {
@@ -354,6 +484,7 @@ foreach ($offsets as $offset) {
354484
!preg_match($EXPECTED_OUTPUT_VALID_OFFSETS_REGEX, $varOutput)
355485
&& !preg_match($EXPECTED_OUTPUT_INVALID_OFFSETS_REGEX, $varOutput)
356486
&& !preg_match($EXPECTED_OUTPUT_FLOAT_OFFSETS_REGEX, $varOutput)
487+
&& !preg_match($EXPECTED_OUTPUT_NULL_OFFSETS_REGEX, $varOutput)
357488
&& $varOutput !== EXPECTED_OUTPUT_NULL_OFFSET
358489
&& $varOutput !== EXPECTED_OUTPUT_RESOURCE_STDERR_OFFSETS
359490
) {

Zend/tests/offsets/array_container_offset_behaviour.phpt

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,89 @@ OUTPUT;
132132

133133
$EXPECTED_OUTPUT_FLOAT_OFFSETS_REGEX = '/^' . expectf_to_regex(EXPECTF_OUTPUT_FLOAT_OFFSETS) . '$/s';
134134

135+
const EXPECTED_OUTPUT_NULL_OFFSETS = <<<OUTPUT
136+
Read before write:
137+
138+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
139+
140+
Warning: Undefined array key "" in %s on line %d
141+
NULL
142+
Write:
143+
144+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
145+
Read:
146+
147+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
148+
int(5)
149+
Read-Write:
150+
151+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
152+
isset():
153+
154+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
155+
bool(true)
156+
empty():
157+
158+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
159+
bool(false)
160+
null coalesce:
161+
162+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
163+
int(25)
164+
Reference to dimension:
165+
166+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
167+
Value of reference:
168+
int(25)
169+
Value of container dimension after write to reference (should be int(100) if successful):
170+
171+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
172+
int(100)
173+
unset():
174+
Nested read:
175+
176+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
177+
178+
Warning: Undefined array key "" in %s on line %d
179+
180+
Warning: Trying to access array offset on null in %s on line %d
181+
NULL
182+
Nested write:
183+
184+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
185+
186+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
187+
Nested Read-Write:
188+
189+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
190+
191+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
192+
Nested isset():
193+
194+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
195+
196+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
197+
bool(true)
198+
Nested empty():
199+
200+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
201+
202+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
203+
bool(false)
204+
Nested null coalesce:
205+
206+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
207+
208+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
209+
int(30)
210+
Nested unset():
211+
212+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
213+
214+
OUTPUT;
215+
216+
$EXPECTED_OUTPUT_NULL_OFFSETS_REGEX = '/^' . expectf_to_regex(EXPECTED_OUTPUT_NULL_OFFSETS) . '$/s';
217+
135218
const EXPECTED_OUTPUT_INVALID_OFFSETS = <<<OUTPUT
136219
Read before write:
137220
Cannot access offset of type %s on array
@@ -273,6 +356,7 @@ foreach ($offsets as $dimension) {
273356
!preg_match($EXPECTED_OUTPUT_VALID_OFFSETS_REGEX, $varOutput)
274357
&& !preg_match($EXPECTED_OUTPUT_INVALID_OFFSETS_REGEX, $varOutput)
275358
&& !preg_match($EXPECTED_OUTPUT_FLOAT_OFFSETS_REGEX, $varOutput)
359+
&& !preg_match($EXPECTED_OUTPUT_NULL_OFFSETS_REGEX, $varOutput)
276360
&& $varOutput !== EXPECTED_OUTPUT_RESOURCE_STDERR_OFFSETS
277361
) {
278362
file_put_contents(__DIR__ . DIRECTORY_SEPARATOR . "debug_array_container_{$failuresNb}.txt", $varOutput);
@@ -300,6 +384,7 @@ foreach ($offsets as $offset) {
300384
!preg_match($EXPECTED_OUTPUT_VALID_OFFSETS_REGEX, $varOutput)
301385
&& !preg_match($EXPECTED_OUTPUT_INVALID_OFFSETS_REGEX, $varOutput)
302386
&& !preg_match($EXPECTED_OUTPUT_FLOAT_OFFSETS_REGEX, $varOutput)
387+
&& !preg_match($EXPECTED_OUTPUT_NULL_OFFSETS_REGEX, $varOutput)
303388
&& $varOutput !== EXPECTED_OUTPUT_RESOURCE_STDERR_OFFSETS
304389
) {
305390
file_put_contents(__DIR__ . DIRECTORY_SEPARATOR . "debug_array_container_{$failuresNb}.txt", $varOutput);

0 commit comments

Comments
 (0)