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:
57string(8) "changed1"
58string(8) "changed2"
59  - Isset:
60bool(true)
61bool(true)
62  - Unset:
63
64Warning: Undefined property: ArrayObject::$prop in %s on line %d
65
66Warning: Undefined array key "prop" in %s on line %d
67NULL
68NULL
69  - After:
70object(ArrayObject)#2 (1) {
71  ["storage":"ArrayObject":private]=>
72  object(C)#1 (0) {
73  }
74}
75object(C)#1 (0) {
76}
77
78--> Access prop on instance of MyArrayObject:
79  - Iteration:
80      prop=>C::prop.orig
81  - Read:
82string(24) "MyArrayObject::prop.orig"
83string(12) "C::prop.orig"
84  - Write:
85string(8) "changed1"
86string(8) "changed2"
87  - Isset:
88bool(true)
89bool(true)
90  - Unset:
91
92Warning: Undefined property: MyArrayObject::$prop in %s on line %d
93
94Warning: Undefined array key "prop" in %s on line %d
95NULL
96NULL
97  - After:
98object(MyArrayObject)#3 (1) {
99  ["storage":"ArrayObject":private]=>
100  object(C)#4 (0) {
101  }
102}
103object(C)#4 (0) {
104}
105