Skip to content

Commit b00c43d

Browse files
committed
Add an appending test
1 parent f5eb7a2 commit b00c43d

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
--TEST--
2+
Appending containers
3+
--FILE--
4+
<?php
5+
6+
$containers = [
7+
null,
8+
false,
9+
true,
10+
10,
11+
25.5,
12+
'string',
13+
[],
14+
new stdClass(),
15+
STDERR,
16+
];
17+
18+
foreach ($containers as $container) {
19+
try {
20+
$container[] = 'value';
21+
var_dump($container);
22+
} catch (\Throwable $e) {
23+
echo $e->getMessage(), "\n";
24+
}
25+
}
26+
27+
?>
28+
--EXPECT--
29+
array(1) {
30+
[0]=>
31+
string(5) "value"
32+
}
33+
34+
Deprecated: Automatic conversion of false to array is deprecated in /home/girgias/Dev/php-src/Zend/tests/offsets/appending_containers.php on line 17
35+
array(1) {
36+
[0]=>
37+
string(5) "value"
38+
}
39+
Cannot use a scalar value as an array
40+
Cannot use a scalar value as an array
41+
Cannot use a scalar value as an array
42+
[] operator not supported for strings
43+
array(1) {
44+
[0]=>
45+
string(5) "value"
46+
}
47+
Cannot use object of type stdClass as array
48+
Cannot use a scalar value as an array

0 commit comments

Comments
 (0)