1--TEST--
2SPL: ArrayObject::__construct basic usage.
3--FILE--
4<?php
5class C {
6    public $prop = 'C::prop.orig';
7}
8
9class MyArrayObject extends ArrayObject {
10    public $prop = 'MyArrayObject::prop.orig';
11}
12
13echo "--> Access prop on instance of ArrayObject:\n";
14$c = new C;
15$ao = new ArrayObject($c);
16testAccess($c, $ao);
17
18echo "\n--> Access prop on instance of MyArrayObject:\n";
19$c = new C;
20$ao = new MyArrayObject($c);
21testAccess($c, $ao);
22
23function testAccess($c, $ao) {
24    echo "  - Iteration:\n";
25    foreach ($ao as $key=>$value) {
26        echo "      $key=>$value\n";
27    }
28
29    echo "  - Read:\n";
30    @var_dump($ao->prop, $ao['prop']);
31
32    echo "  - Write:\n";
33    $ao->prop = 'changed1';
34    $ao['prop'] = 'changed2';
35    var_dump($ao->prop, $ao['prop']);
36
37    echo "  - Isset:\n";
38    var_dump(isset($ao->prop), isset($ao['prop']));
39
40    echo "  - Unset:\n";
41    unset($ao->prop);
42    unset($ao['prop']);
43    var_dump($ao->prop, $ao['prop']);
44
45    echo "  - After:\n";
46    var_dump($ao, $c);
47}
48?>
49--EXPECTF--
50--> Access prop on instance of ArrayObject:
51  - Iteration:
52      prop=>C::prop.orig
53  - Read:
54NULL
55string(12) "C::prop.orig"
56  - Write:
57
58Deprecated: Creation of dynamic property ArrayObject::$prop is deprecated in %s on line %d
59string(8) "changed1"
60string(8) "changed2"
61  - Isset:
62bool(true)
63bool(true)
64  - Unset:
65
66Warning: Undefined property: ArrayObject::$prop in %s on line %d
67
68Warning: Undefined array key "prop" in %s on line %d
69NULL
70NULL
71  - After:
72object(ArrayObject)#2 (1) {
73  ["storage":"ArrayObject":private]=>
74  object(C)#1 (0) {
75  }
76}
77object(C)#1 (0) {
78}
79
80--> Access prop on instance of MyArrayObject:
81  - Iteration:
82      prop=>C::prop.orig
83  - Read:
84string(24) "MyArrayObject::prop.orig"
85string(12) "C::prop.orig"
86  - Write:
87string(8) "changed1"
88string(8) "changed2"
89  - Isset:
90bool(true)
91bool(true)
92  - Unset:
93
94Warning: Undefined property: MyArrayObject::$prop in %s on line %d
95
96Warning: Undefined array key "prop" in %s on line %d
97NULL
98NULL
99  - After:
100object(MyArrayObject)#3 (1) {
101  ["storage":"ArrayObject":private]=>
102  object(C)#4 (0) {
103  }
104}
105object(C)#4 (0) {
106}
107