xref: /PHP-5.4/ext/spl/tests/array_022.phpt (revision 610c7fbe)
1--TEST--
2SPL: ArrayObject/Iterator and reference to self
3--FILE--
4==ArrayObject===
5<?php
6
7class MyArrayObject extends ArrayObject
8{
9	public function __construct()
10	{
11		parent::__construct($this);
12		$this['bar'] = 'baz';
13	}
14}
15
16$a = new MyArrayObject;
17
18$b = clone $a;
19$b['baz'] = 'Foo';
20
21var_dump($a);
22var_dump($b);
23
24?>
25==ArrayIterator===
26<?php
27
28class MyArrayIterator extends ArrayIterator
29{
30	public function __construct()
31	{
32		parent::__construct($this);
33		$this['bar'] = 'baz';
34	}
35}
36
37$a = new MyArrayIterator;
38
39$b = clone $a;
40$b['baz'] = 'Foo';
41
42var_dump($a);
43var_dump($b);
44
45?>
46===DONE===
47--EXPECTF--
48==ArrayObject===
49object(MyArrayObject)#%d (1) {
50  ["bar"]=>
51  string(3) "baz"
52}
53object(MyArrayObject)#%d (3) {
54  ["bar"]=>
55  string(3) "baz"
56  ["baz"]=>
57  string(3) "Foo"
58  ["storage":"ArrayObject":private]=>
59  array(1) {
60    ["bar"]=>
61    string(3) "baz"
62  }
63}
64==ArrayIterator===
65object(MyArrayIterator)#%d (1) {
66  ["bar"]=>
67  string(3) "baz"
68}
69object(MyArrayIterator)#%d (3) {
70  ["bar"]=>
71  string(3) "baz"
72  ["baz"]=>
73  string(3) "Foo"
74  ["storage":"ArrayIterator":private]=>
75  object(MyArrayIterator)#%d (1) {
76    ["bar"]=>
77    string(3) "baz"
78  }
79}
80===DONE===
81