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 (5) {
74  ["a"]=>
75  string(7) "changed"
76  ["b"]=>
77  int(2)
78  ["c"]=>
79  int(3)
80  ["priv":"UsesMagic":private]=>
81  string(6) "secret"
82  ["dynamic"]=>
83  string(11) "new.changed"
84}
85  Wrapping ArrayObject:
86object(ArrayObject)#2 (1) {
87  ["storage":"ArrayObject":private]=>
88  object(UsesMagic)#1 (5) {
89    ["a"]=>
90    string(7) "changed"
91    ["b"]=>
92    int(2)
93    ["c"]=>
94    int(3)
95    ["priv":"UsesMagic":private]=>
96    string(6) "secret"
97    ["dynamic"]=>
98    string(11) "new.changed"
99  }
100}
101
102--> Read existent, non-existent and dynamic:
103string(7) "changed"
104
105Warning: Undefined array key "nonexistent" in %s on line %d
106NULL
107string(11) "new.changed"
108  Original wrapped object:
109object(UsesMagic)#1 (5) {
110  ["a"]=>
111  string(7) "changed"
112  ["b"]=>
113  int(2)
114  ["c"]=>
115  int(3)
116  ["priv":"UsesMagic":private]=>
117  string(6) "secret"
118  ["dynamic"]=>
119  string(11) "new.changed"
120}
121  Wrapping ArrayObject:
122object(ArrayObject)#2 (1) {
123  ["storage":"ArrayObject":private]=>
124  object(UsesMagic)#1 (5) {
125    ["a"]=>
126    string(7) "changed"
127    ["b"]=>
128    int(2)
129    ["c"]=>
130    int(3)
131    ["priv":"UsesMagic":private]=>
132    string(6) "secret"
133    ["dynamic"]=>
134    string(11) "new.changed"
135  }
136}
137
138--> isset existent, non-existent and dynamic:
139bool(true)
140bool(false)
141bool(true)
142  Original wrapped object:
143object(UsesMagic)#1 (5) {
144  ["a"]=>
145  string(7) "changed"
146  ["b"]=>
147  int(2)
148  ["c"]=>
149  int(3)
150  ["priv":"UsesMagic":private]=>
151  string(6) "secret"
152  ["dynamic"]=>
153  string(11) "new.changed"
154}
155  Wrapping ArrayObject:
156object(ArrayObject)#2 (1) {
157  ["storage":"ArrayObject":private]=>
158  object(UsesMagic)#1 (5) {
159    ["a"]=>
160    string(7) "changed"
161    ["b"]=>
162    int(2)
163    ["c"]=>
164    int(3)
165    ["priv":"UsesMagic":private]=>
166    string(6) "secret"
167    ["dynamic"]=>
168    string(11) "new.changed"
169  }
170}
171
172--> Unset existent, non-existent and dynamic:
173
174Warning: Undefined array key "nonexistent" in %s on line %d
175  Original wrapped object:
176object(UsesMagic)#1 (3) {
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 (3) {
188    ["b"]=>
189    int(2)
190    ["c"]=>
191    int(3)
192    ["priv":"UsesMagic":private]=>
193    string(6) "secret"
194  }
195}
196