1--TEST--
2SPL: ArrayObject: ensure a wrapped object's magic methods for property access are not invoked when manipulating the ArrayObject's elements using ->.
3--FILE--
4<?php
5class UsesMagic {
6    public $a = 1;
7    public $b = 2;
8    public $c = 3;
9
10    private $priv = 'secret';
11
12    function __get($name) {
13        $args = func_get_args();
14        echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
15    }
16    function __set($name, $value) {
17        $args = func_get_args();
18        echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
19    }
20    function __isset($name) {
21        $args = func_get_args();
22        echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
23    }
24    function __unset($name) {
25        $args = func_get_args();
26        echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
27    }
28
29}
30
31$obj = new UsesMagic;
32
33$ao = new ArrayObject($obj);
34echo "\n--> Write existent, non-existent and dynamic:\n";
35$ao->a = 'changed';
36$ao->dynamic = 'new';
37$ao->dynamic = 'new.changed';
38echo "  Original wrapped object:\n";
39var_dump($obj);
40echo "  Wrapping ArrayObject:\n";
41var_dump($ao);
42
43echo "\n--> Read existent, non-existent and dynamic:\n";
44var_dump($ao->a);
45var_dump($ao->nonexistent);
46var_dump($ao->dynamic);
47echo "  Original wrapped object:\n";
48var_dump($obj);
49echo "  Wrapping ArrayObject:\n";
50var_dump($ao);
51
52echo "\n--> isset existent, non-existent and dynamic:\n";
53var_dump(isset($ao->a));
54var_dump(isset($ao->nonexistent));
55var_dump(isset($ao->dynamic));
56echo "  Original wrapped object:\n";
57var_dump($obj);
58echo "  Wrapping ArrayObject:\n";
59var_dump($ao);
60
61echo "\n--> Unset existent, non-existent and dynamic:\n";
62unset($ao->a);
63unset($ao->nonexistent);
64unset($ao->dynamic);
65echo "  Original wrapped object:\n";
66var_dump($obj);
67echo "  Wrapping ArrayObject:\n";
68var_dump($ao);
69?>
70--EXPECTF--
71--> Write existent, non-existent and dynamic:
72  Original wrapped object:
73object(UsesMagic)#1 (4) {
74  ["a"]=>
75  int(1)
76  ["b"]=>
77  int(2)
78  ["c"]=>
79  int(3)
80  ["priv":"UsesMagic":private]=>
81  string(6) "secret"
82}
83  Wrapping ArrayObject:
84object(ArrayObject)#2 (3) {
85  ["a"]=>
86  string(7) "changed"
87  ["dynamic"]=>
88  string(11) "new.changed"
89  ["storage":"ArrayObject":private]=>
90  object(UsesMagic)#1 (4) {
91    ["a"]=>
92    int(1)
93    ["b"]=>
94    int(2)
95    ["c"]=>
96    int(3)
97    ["priv":"UsesMagic":private]=>
98    string(6) "secret"
99  }
100}
101
102--> Read existent, non-existent and dynamic:
103string(7) "changed"
104
105Warning: Undefined property: ArrayObject::$nonexistent in %s on line %d
106NULL
107string(11) "new.changed"
108  Original wrapped object:
109object(UsesMagic)#1 (4) {
110  ["a"]=>
111  int(1)
112  ["b"]=>
113  int(2)
114  ["c"]=>
115  int(3)
116  ["priv":"UsesMagic":private]=>
117  string(6) "secret"
118}
119  Wrapping ArrayObject:
120object(ArrayObject)#2 (3) {
121  ["a"]=>
122  string(7) "changed"
123  ["dynamic"]=>
124  string(11) "new.changed"
125  ["storage":"ArrayObject":private]=>
126  object(UsesMagic)#1 (4) {
127    ["a"]=>
128    int(1)
129    ["b"]=>
130    int(2)
131    ["c"]=>
132    int(3)
133    ["priv":"UsesMagic":private]=>
134    string(6) "secret"
135  }
136}
137
138--> isset existent, non-existent and dynamic:
139bool(true)
140bool(false)
141bool(true)
142  Original wrapped object:
143object(UsesMagic)#1 (4) {
144  ["a"]=>
145  int(1)
146  ["b"]=>
147  int(2)
148  ["c"]=>
149  int(3)
150  ["priv":"UsesMagic":private]=>
151  string(6) "secret"
152}
153  Wrapping ArrayObject:
154object(ArrayObject)#2 (3) {
155  ["a"]=>
156  string(7) "changed"
157  ["dynamic"]=>
158  string(11) "new.changed"
159  ["storage":"ArrayObject":private]=>
160  object(UsesMagic)#1 (4) {
161    ["a"]=>
162    int(1)
163    ["b"]=>
164    int(2)
165    ["c"]=>
166    int(3)
167    ["priv":"UsesMagic":private]=>
168    string(6) "secret"
169  }
170}
171
172--> Unset existent, non-existent and dynamic:
173  Original wrapped object:
174object(UsesMagic)#1 (4) {
175  ["a"]=>
176  int(1)
177  ["b"]=>
178  int(2)
179  ["c"]=>
180  int(3)
181  ["priv":"UsesMagic":private]=>
182  string(6) "secret"
183}
184  Wrapping ArrayObject:
185object(ArrayObject)#2 (1) {
186  ["storage":"ArrayObject":private]=>
187  object(UsesMagic)#1 (4) {
188    ["a"]=>
189    int(1)
190    ["b"]=>
191    int(2)
192    ["c"]=>
193    int(3)
194    ["priv":"UsesMagic":private]=>
195    string(6) "secret"
196  }
197}
198