1--TEST-- 2Bug #42654 (RecursiveIteratorIterator modifies only part of leaves) 3--FILE-- 4<?php 5$data = array(1 => 'val1', 6 array(2 => 'val2', 7 array(3 => 'val3'), 8 ), 9 4 => 'val4' 10 ); 11 12$iterator = new RecursiveIteratorIterator(new 13RecursiveArrayIterator($data)); 14foreach($iterator as $foo) { 15 $key = $iterator->key(); 16 echo "update $key\n"; 17 var_dump($iterator->getInnerIterator()); 18 $iterator->offsetSet($key, 'alter'); 19 var_dump($iterator->getInnerIterator()); 20} 21$copy = $iterator->getArrayCopy(); 22var_dump($copy); 23?> 24--EXPECTF-- 25update 1 26object(RecursiveArrayIterator)#%d (1) { 27 ["storage":"ArrayIterator":private]=> 28 array(3) { 29 [1]=> 30 string(4) "val1" 31 [2]=> 32 array(2) { 33 [2]=> 34 string(4) "val2" 35 [3]=> 36 array(1) { 37 [3]=> 38 string(4) "val3" 39 } 40 } 41 [4]=> 42 string(4) "val4" 43 } 44} 45object(RecursiveArrayIterator)#%d (1) { 46 ["storage":"ArrayIterator":private]=> 47 array(3) { 48 [1]=> 49 string(5) "alter" 50 [2]=> 51 array(2) { 52 [2]=> 53 string(4) "val2" 54 [3]=> 55 array(1) { 56 [3]=> 57 string(4) "val3" 58 } 59 } 60 [4]=> 61 string(4) "val4" 62 } 63} 64update 2 65object(RecursiveArrayIterator)#%d (1) { 66 ["storage":"ArrayIterator":private]=> 67 array(2) { 68 [2]=> 69 string(4) "val2" 70 [3]=> 71 array(1) { 72 [3]=> 73 string(4) "val3" 74 } 75 } 76} 77object(RecursiveArrayIterator)#%d (1) { 78 ["storage":"ArrayIterator":private]=> 79 array(2) { 80 [2]=> 81 string(5) "alter" 82 [3]=> 83 array(1) { 84 [3]=> 85 string(4) "val3" 86 } 87 } 88} 89update 3 90object(RecursiveArrayIterator)#%d (1) { 91 ["storage":"ArrayIterator":private]=> 92 array(1) { 93 [3]=> 94 string(4) "val3" 95 } 96} 97object(RecursiveArrayIterator)#%d (1) { 98 ["storage":"ArrayIterator":private]=> 99 array(1) { 100 [3]=> 101 string(5) "alter" 102 } 103} 104update 4 105object(RecursiveArrayIterator)#%d (1) { 106 ["storage":"ArrayIterator":private]=> 107 array(3) { 108 [1]=> 109 string(5) "alter" 110 [2]=> 111 array(2) { 112 [2]=> 113 string(4) "val2" 114 [3]=> 115 array(1) { 116 [3]=> 117 string(4) "val3" 118 } 119 } 120 [4]=> 121 string(4) "val4" 122 } 123} 124object(RecursiveArrayIterator)#%d (1) { 125 ["storage":"ArrayIterator":private]=> 126 array(3) { 127 [1]=> 128 string(5) "alter" 129 [2]=> 130 array(2) { 131 [2]=> 132 string(4) "val2" 133 [3]=> 134 array(1) { 135 [3]=> 136 string(4) "val3" 137 } 138 } 139 [4]=> 140 string(5) "alter" 141 } 142} 143array(3) { 144 [1]=> 145 string(5) "alter" 146 [2]=> 147 array(2) { 148 [2]=> 149 string(4) "val2" 150 [3]=> 151 array(1) { 152 [3]=> 153 string(4) "val3" 154 } 155 } 156 [4]=> 157 string(5) "alter" 158} 159