1--TEST--
2SPL: Cloning nested ArrayObjects.
3--FILE--
4<?php
5
6#[AllowDynamicProperties]
7class C {
8    public $p = 'C::p.orig';
9}
10
11$wrappedObject = new C;
12$innerArrayObject = new ArrayObject($wrappedObject);
13
14$outerArrayObject =  new ArrayObject($innerArrayObject);
15
16$wrappedObject->dynamic1 = 'new prop added to $wrappedObject before clone';
17$clonedOuterArrayObject = clone $outerArrayObject;
18$wrappedObject->dynamic2 = 'new prop added to $wrappedObject after clone';
19
20$innerArrayObject['new.iAO'] = 'new element added $innerArrayObject';
21$outerArrayObject['new.oAO'] = 'new element added to $outerArrayObject';
22$clonedOuterArrayObject['new.coAO'] = 'new element added to $clonedOuterArrayObject';
23
24var_dump($wrappedObject, $innerArrayObject, $outerArrayObject, $clonedOuterArrayObject);
25?>
26--EXPECT--
27object(C)#1 (5) {
28  ["p"]=>
29  string(9) "C::p.orig"
30  ["dynamic1"]=>
31  string(45) "new prop added to $wrappedObject before clone"
32  ["dynamic2"]=>
33  string(44) "new prop added to $wrappedObject after clone"
34  ["new.iAO"]=>
35  string(35) "new element added $innerArrayObject"
36  ["new.oAO"]=>
37  string(38) "new element added to $outerArrayObject"
38}
39object(ArrayObject)#2 (1) {
40  ["storage":"ArrayObject":private]=>
41  object(C)#1 (5) {
42    ["p"]=>
43    string(9) "C::p.orig"
44    ["dynamic1"]=>
45    string(45) "new prop added to $wrappedObject before clone"
46    ["dynamic2"]=>
47    string(44) "new prop added to $wrappedObject after clone"
48    ["new.iAO"]=>
49    string(35) "new element added $innerArrayObject"
50    ["new.oAO"]=>
51    string(38) "new element added to $outerArrayObject"
52  }
53}
54object(ArrayObject)#3 (1) {
55  ["storage":"ArrayObject":private]=>
56  object(ArrayObject)#2 (1) {
57    ["storage":"ArrayObject":private]=>
58    object(C)#1 (5) {
59      ["p"]=>
60      string(9) "C::p.orig"
61      ["dynamic1"]=>
62      string(45) "new prop added to $wrappedObject before clone"
63      ["dynamic2"]=>
64      string(44) "new prop added to $wrappedObject after clone"
65      ["new.iAO"]=>
66      string(35) "new element added $innerArrayObject"
67      ["new.oAO"]=>
68      string(38) "new element added to $outerArrayObject"
69    }
70  }
71}
72object(ArrayObject)#4 (1) {
73  ["storage":"ArrayObject":private]=>
74  array(3) {
75    ["p"]=>
76    string(9) "C::p.orig"
77    ["dynamic1"]=>
78    string(45) "new prop added to $wrappedObject before clone"
79    ["new.coAO"]=>
80    string(44) "new element added to $clonedOuterArrayObject"
81  }
82}
83