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