1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
--TEST--
Taking reference of appended item $r = &$container[]
--FILE--
<?php
require_once __DIR__ . DIRECTORY_SEPARATOR . 'test_offset_helpers.inc';
foreach ($containers as $container) {
echo zend_test_var_export($container), " container:\n";
try {
$r = &$container[];
var_dump($container, $r);
} catch (\Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
}
?>
--EXPECTF--
NULL container:
array(1) {
[0]=>
&NULL
}
NULL
false container:
Deprecated: Automatic conversion of false to array is deprecated in %s on line %d
array(1) {
[0]=>
&NULL
}
NULL
true container:
Error: Cannot use a scalar value as an array
4 container:
Error: Cannot use a scalar value as an array
5.5 container:
Error: Cannot use a scalar value as an array
'10' container:
Error: [] operator not supported for strings
'25.5' container:
Error: [] operator not supported for strings
'string' container:
Error: [] operator not supported for strings
[] container:
array(1) {
[0]=>
&NULL
}
NULL
STDERR container:
Error: Cannot use a scalar value as an array
new stdClass() container:
Error: Cannot use object of type stdClass as array
new ArrayObject() container:
Notice: Indirect modification of overloaded element of ArrayObject has no effect in %s on line %d
object(ArrayObject)#2 (1) {
["storage":"ArrayObject":private]=>
array(0) {
}
}
NULL
new A() container:
string(12) "A::offsetGet"
NULL
Notice: Indirect modification of overloaded element of A has no effect in %s on line %d
object(A)#3 (0) {
}
int(5)
new B() container:
Notice: Indirect modification of overloaded element of B has no effect in %s on line %d
ArgumentCountError: B::offsetGet(): Argument #1 ($offset) not passed
|