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