Skip to content

Commit 8f780ab

Browse files
committed
Apply warning conversion to []
1 parent 4a904ff commit 8f780ab

File tree

5 files changed

+30
-28
lines changed

5 files changed

+30
-28
lines changed

Zend/tests/array_literal_next_element_error.phpt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@ Next free element may overflow in array literals
33
--FILE--
44
<?php
55

6-
$i = PHP_INT_MAX;
7-
$array = [$i => 42, new stdClass];
8-
var_dump($array);
6+
try {
7+
$i = PHP_INT_MAX;
8+
$array = [$i => 42, new stdClass];
9+
var_dump($array);
10+
} catch (\Error $e) {
11+
echo $e->getMessage() . "\n";
12+
}
913

10-
const FOO = [PHP_INT_MAX => 42, "foo"];
11-
var_dump(FOO);
14+
try {
15+
const FOO = [PHP_INT_MAX => 42, "foo"];
16+
var_dump(FOO);
17+
} catch (\Error $e) {
18+
echo $e->getMessage() . "\n";
19+
}
1220

1321
?>
14-
--EXPECTF--
15-
Warning: Cannot add element to the array as the next element is already occupied in %s on line %d
16-
array(1) {
17-
[%d]=>
18-
int(42)
19-
}
22+
--EXPECT--
23+
Cannot add element to the array as the next element is already occupied
24+
Cannot add element to the array as the next element is already occupied
2025

21-
Warning: Cannot add element to the array as the next element is already occupied in %s on line %d
22-
array(1) {
23-
[%d]=>
24-
int(42)
25-
}

Zend/tests/assign_dim_obj_null_return.phpt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ function test() {
1212
var_dump($array[new stdClass] = 123);
1313
var_dump($true[123] = 456);
1414

15-
var_dump($array[] += 123);
15+
try {
16+
var_dump($array[] += 123);
17+
} catch (\Error $e) {
18+
echo $e->getMessage() . "\n";
19+
}
1620
var_dump($array[[]] += 123);
1721
var_dump($array[new stdClass] += 123);
1822
var_dump($true[123] += 456);
@@ -36,9 +40,7 @@ NULL
3640

3741
Warning: Cannot use a scalar value as an array in %s on line %d
3842
NULL
39-
40-
Warning: Cannot add element to the array as the next element is already occupied in %s on line %d
41-
NULL
43+
Cannot add element to the array as the next element is already occupied
4244

4345
Warning: Illegal offset type in %s on line %d
4446
NULL

Zend/tests/bug47836.phpt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ Bug #47836 (array operator [] inconsistency when the array has PHP_INT_MAX index
44
<?php
55

66
$arr[PHP_INT_MAX] = 1;
7-
$arr[] = 2;
8-
7+
try {
8+
$arr[] = 2;
9+
} catch (\Error $e) {
10+
echo $e->getMessage() . "\n";
11+
}
912
var_dump($arr);
1013
?>
11-
--EXPECTF--
12-
Warning: Cannot add element to the array as the next element is already occupied in %s on line 4
14+
--EXPECT--
15+
Cannot add element to the array as the next element is already occupied
1316
array(1) {
1417
[%d]=>
1518
int(1)

Zend/tests/bug71841.phpt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,3 @@ var_dump($y[]++);
1818
NULL
1919
NULL
2020
NULL
21-
NULL
22-
NULL
23-
NULL

Zend/zend_execute.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1968,7 +1968,7 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_use_scalar_as_array(v
19681968

19691969
static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_cannot_add_element(void)
19701970
{
1971-
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
1971+
zend_throw_error(NULL, "Cannot add element to the array as the next element is already occupied");
19721972
}
19731973

19741974
static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_use_resource_as_offset(const zval *dim)

0 commit comments

Comments
 (0)