xref: /PHP-8.2/Zend/tests/bug69955.phpt (revision 75a678a7)
1--TEST--
2Bug #69955 (Segfault when trying to combine [] and assign-op on ArrayAccess object).
3--FILE--
4<?php
5class C10 implements ArrayAccess
6{
7        function offsetExists($offset): bool
8        {
9                echo "\nInside " . __METHOD__ . "\n"; var_dump($offset);
10        }
11        function offsetGet($offset): mixed
12        {
13                echo "\nInside " . __METHOD__ . "\n"; var_dump($offset); return 100;
14        }
15        function offsetSet($offset, $value): void
16        {
17                echo "\nInside " . __METHOD__ . "\n"; var_dump($offset); var_dump($value);
18        }
19        function offsetUnset($offset): void
20        {
21                echo "\nInside " . __METHOD__ . "\n"; var_dump($offset);
22        }
23}
24
25$c10 = new C10;
26
27var_dump($c10[] += 5);
28?>
29--EXPECT--
30Inside C10::offsetGet
31NULL
32
33Inside C10::offsetSet
34NULL
35int(105)
36int(105)
37