Skip to content

Commit 954abcd

Browse files
committed
Add test for no offset in read op
1 parent 9d56ec9 commit 954abcd

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
--TEST--
2+
Appending containers via a read operation $c[][5] = $v;
3+
--FILE--
4+
<?php
5+
6+
require_once __DIR__ . DIRECTORY_SEPARATOR . 'test_offset_helpers.inc';
7+
8+
foreach ($containers as $container) {
9+
try {
10+
$container[][5] = 'value';
11+
var_dump($container);
12+
} catch (\Throwable $e) {
13+
echo $e::class, ': ', $e->getMessage(), "\n";
14+
}
15+
}
16+
17+
?>
18+
--EXPECTF--
19+
array(1) {
20+
[0]=>
21+
array(1) {
22+
[5]=>
23+
string(5) "value"
24+
}
25+
}
26+
27+
Deprecated: Automatic conversion of false to array is deprecated in %s on line %d
28+
array(1) {
29+
[0]=>
30+
array(1) {
31+
[5]=>
32+
string(5) "value"
33+
}
34+
}
35+
Error: Cannot use a scalar value as an array
36+
Error: Cannot use a scalar value as an array
37+
Error: Cannot use a scalar value as an array
38+
Error: [] operator not supported for strings
39+
Error: [] operator not supported for strings
40+
Error: [] operator not supported for strings
41+
array(1) {
42+
[0]=>
43+
array(1) {
44+
[5]=>
45+
string(5) "value"
46+
}
47+
}
48+
Error: Cannot use a scalar value as an array
49+
Error: Cannot use object of type stdClass as array
50+
51+
Notice: Indirect modification of overloaded element of ArrayObject has no effect in %s on line %d
52+
object(ArrayObject)#2 (1) {
53+
["storage":"ArrayObject":private]=>
54+
array(0) {
55+
}
56+
}
57+
string(12) "A::offsetGet"
58+
NULL
59+
60+
Notice: Indirect modification of overloaded element of A has no effect in %s on line %d
61+
62+
Warning: Only the first byte will be assigned to the string offset in %s on line %d
63+
object(A)#3 (0) {
64+
}
65+
66+
Notice: Indirect modification of overloaded element of B has no effect in %s on line %d
67+
ArgumentCountError: B::offsetGet(): Argument #1 ($offset) not passed

0 commit comments

Comments
 (0)