xref: /PHP-8.2/ext/spl/tests/bug41692.phpt (revision 782352c5)
1--TEST--
2Bug #41692 (ArrayObject shows weird behaviour in respect to inheritance)
3--FILE--
4<?php
5
6class Bar extends ArrayObject {
7    private $foo = array( 1, 2, 3 );
8    function __construct()
9    {
10        parent::__construct($this->foo);
11    }
12}
13
14$foo = new Bar();
15var_dump($foo);
16$foo['foo'] = 23;
17
18$bar = new Bar();
19var_dump($bar);
20
21echo "Done\n";
22?>
23--EXPECTF--
24object(Bar)#%d (2) {
25  ["foo":"Bar":private]=>
26  array(3) {
27    [0]=>
28    int(1)
29    [1]=>
30    int(2)
31    [2]=>
32    int(3)
33  }
34  ["storage":"ArrayObject":private]=>
35  array(3) {
36    [0]=>
37    int(1)
38    [1]=>
39    int(2)
40    [2]=>
41    int(3)
42  }
43}
44object(Bar)#%d (2) {
45  ["foo":"Bar":private]=>
46  array(3) {
47    [0]=>
48    int(1)
49    [1]=>
50    int(2)
51    [2]=>
52    int(3)
53  }
54  ["storage":"ArrayObject":private]=>
55  array(3) {
56    [0]=>
57    int(1)
58    [1]=>
59    int(2)
60    [2]=>
61    int(3)
62  }
63}
64Done
65