xref: /PHP-7.1/ext/spl/tests/array_022.phpt (revision 7af945e2)
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 (2) {
54  ["bar"]=>
55  string(3) "baz"
56  ["baz"]=>
57  string(3) "Foo"
58}
59==ArrayIterator===
60object(MyArrayIterator)#%d (1) {
61  ["bar"]=>
62  string(3) "baz"
63}
64object(MyArrayIterator)#%d (2) {
65  ["bar"]=>
66  string(3) "baz"
67  ["baz"]=>
68  string(3) "Foo"
69}
70===DONE===
71