blob: e7abf2b1dc853680d7642cfbf030d91ad3ee84ed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
--TEST--
SPL: ArrayIterator
--SKIPIF--
<?php if (!extension_loaded("spl")) print "skip"; ?>
--INI--
allow_call_time_pass_reference=1
--FILE--
<?php
echo "==Normal==\n";
$arr = array(0=>0, 1=>1, 2=>2);
$obj = new ArrayObject($arr);
foreach($obj as $ak=>$av) {
foreach($obj as $bk=>$bv) {
if ($ak==0 && $bk==0) {
$arr[0] = "modify";
}
echo "$ak=>$av - $bk=>$bv\n";
}
}
echo "==UseRef==\n";
$arr = array(0=>0, 1=>1, 2=>2);
$obj = new ArrayObject(&$arr);
foreach($obj as $ak=>$av) {
foreach($obj as $bk=>$bv) {
if ($ak==0 && $bk==0) {
$arr[0] = "modify";
}
echo "$ak=>$av - $bk=>$bv\n";
}
}
echo "==Modify==\n";
$arr = array(0=>0, 1=>1, 2=>2);
$obj = new ArrayObject(&$arr);
foreach($obj as $ak=>$av) {
foreach($obj as $bk=>$bv) {
if ($ak==0 && $bk==0) {
$arr[0] = "modify";
}
echo "$ak=>$av - $bk=>$bv\n";
}
}
echo "==Delete==\n";
$arr = array(0=>0, 1=>1, 2=>2);
$obj = new ArrayObject(&$arr);
foreach($obj as $ak=>$av) {
foreach($obj as $bk=>$bv) {
if ($ak==1 && $bk==1) {
unset($arr[1]);
}
echo "$ak=>$av - $bk=>$bv\n";
}
}
echo "==Change==\n";
$arr = array(0=>0, 1=>1, 2=>2);
$obj = new ArrayObject(&$arr);
foreach($obj as $ak=>$av) {
foreach($obj as $bk=>$bv) {
if ($ak==1 && $bk==1) {
$arr = NULL;
}
echo "$ak=>$av - $bk=>$bv\n";
}
}
echo "Done\n";
?>
--EXPECTF--
==Normal==
0=>0 - 0=>0
0=>0 - 1=>1
0=>0 - 2=>2
1=>1 - 0=>0
1=>1 - 1=>1
1=>1 - 2=>2
2=>2 - 0=>0
2=>2 - 1=>1
2=>2 - 2=>2
==UseRef==
0=>0 - 0=>0
0=>0 - 1=>1
0=>0 - 2=>2
1=>1 - 0=>modify
1=>1 - 1=>1
1=>1 - 2=>2
2=>2 - 0=>modify
2=>2 - 1=>1
2=>2 - 2=>2
==Modify==
0=>0 - 0=>0
0=>0 - 1=>1
0=>0 - 2=>2
1=>1 - 0=>modify
1=>1 - 1=>1
1=>1 - 2=>2
2=>2 - 0=>modify
2=>2 - 1=>1
2=>2 - 2=>2
==Delete==
0=>0 - 0=>0
0=>0 - 1=>1
0=>0 - 2=>2
1=>1 - 0=>0
1=>1 - 1=>1
Notice: main(): ArrayIterator::next(): Array was modified outside object and internal position is no longer valid in %sarray_004.php on line %d
1=>1 - 0=>0
1=>1 - 2=>2
Notice: main(): ArrayIterator::next(): Array was modified outside object and internal position is no longer valid in %sarray_004.php on line %d
0=>0 - 0=>0
0=>0 - 2=>2
2=>2 - 0=>0
2=>2 - 2=>2
==Change==
0=>0 - 0=>0
0=>0 - 1=>1
0=>0 - 2=>2
1=>1 - 0=>0
1=>1 - 1=>1
Notice: main(): ArrayIterator::current(): Array was modified outside object and is no longer an array in %sarray_004.php on line %d
Notice: main(): ArrayIterator::valid(): Array was modified outside object and is no longer an array in %sarray_004.php on line %d
Notice: main(): ArrayIterator::current(): Array was modified outside object and is no longer an array in %sarray_004.php on line %d
Notice: main(): ArrayIterator::valid(): Array was modified outside object and is no longer an array in %sarray_004.php on line %d
Done
|