xref: /PHP-7.1/ext/spl/tests/array_015.phpt (revision 2b6a568d)
1--TEST--
2SPL: ArrayIterator::next() with internal arrays
3--FILE--
4<?php
5
6$ar = new ArrayObject();
7
8$ar[0] = 1;
9$ar[1] = 2;
10$ar[2] = 3;
11$ar[3] = 4;
12$ar[4] = 5;
13
14var_dump($ar);
15
16$it = $ar->getIterator();
17
18$ar->offsetUnset($it->key());
19$it->next();
20
21var_dump($it->current());
22var_dump($ar);
23
24foreach($it as $k => $v)
25{
26	$ar->offsetUnset($k+1);
27	echo "$k=>$v\n";
28}
29
30var_dump($ar);
31
32foreach($it as $k => $v)
33{
34	$ar->offsetUnset($k);
35	echo "$k=>$v\n";
36}
37
38var_dump($ar);
39
40?>
41===DONE===
42<?php exit(0); ?>
43--EXPECTF--
44object(ArrayObject)#%d (1) {
45  %s"storage"%s"ArrayObject":private]=>
46  array(5) {
47    [0]=>
48    int(1)
49    [1]=>
50    int(2)
51    [2]=>
52    int(3)
53    [3]=>
54    int(4)
55    [4]=>
56    int(5)
57  }
58}
59int(3)
60object(ArrayObject)#%d (1) {
61  %s"storage"%s"ArrayObject":private]=>
62  array(4) {
63    [1]=>
64    int(2)
65    [2]=>
66    int(3)
67    [3]=>
68    int(4)
69    [4]=>
70    int(5)
71  }
72}
731=>2
743=>4
75object(ArrayObject)#%d (1) {
76  %s"storage"%s"ArrayObject":private]=>
77  array(2) {
78    [1]=>
79    int(2)
80    [3]=>
81    int(4)
82  }
83}
841=>2
85object(ArrayObject)#%d (1) {
86  %s"storage"%s"ArrayObject":private]=>
87  array(1) {
88    [3]=>
89    int(4)
90  }
91}
92===DONE===
93