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