xref: /PHP-8.1/ext/spl/tests/bug36941.phpt (revision a555cc0b)
1--TEST--
2Bug #36941 (ArrayIterator does not clone itself)
3--FILE--
4===ArrayObject===
5<?php
6$a = new ArrayObject();
7$a[] = 1;
8
9$b = clone $a;
10
11var_dump($a[0], $b[0]);
12$b[0] = $b[0] + 1;
13var_dump($a[0], $b[0]);
14$b[0] = 3;
15var_dump($a[0], $b[0]);
16?>
17===ArrayIterator===
18<?php
19$a = new ArrayIterator();
20$a[] = 1;
21
22$b = clone $a;
23
24var_dump($a[0], $b[0]);
25$b[0] = $b[0] + 1;
26var_dump($a[0], $b[0]);
27$b[0] = 3;
28var_dump($a[0], $b[0]);
29?>
30--EXPECT--
31===ArrayObject===
32int(1)
33int(1)
34int(1)
35int(2)
36int(1)
37int(3)
38===ArrayIterator===
39int(1)
40int(1)
41int(2)
42int(2)
43int(3)
44int(3)
45