xref: /PHP-8.1/ext/spl/tests/bug34548.phpt (revision c6357b80)
1--TEST--
2Bug #34548 (Method append() in class extended from ArrayObject crashes PHP)
3--FILE--
4<?php
5
6class Collection extends ArrayObject
7{
8    public function add($dataArray)
9    {
10        foreach($dataArray as $value) $this->append($value);
11    }
12
13    public function offsetSet($index, $value): void
14    {
15        parent::offsetSet($index, $value);
16    }
17}
18
19$data1=array('one', 'two', 'three');
20$data2=array('four', 'five');
21
22$foo=new Collection($data1);
23$foo->add($data2);
24
25print_r($foo->getArrayCopy());
26
27echo "Done\n";
28?>
29--EXPECT--
30Array
31(
32    [0] => one
33    [1] => two
34    [2] => three
35    [3] => four
36    [4] => five
37)
38Done
39