Annotation of embedaddon/php/ext/standard/tests/array/bug42850.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Bug #42850 (array_walk_recursive() leaves references)
! 3: --FILE--
! 4: <?php
! 5:
! 6: // Bug #42850
! 7: $data = array ('key1' => 'val1', array('key2' => 'val2'));
! 8: function apply_dumb($item, $key) {};
! 9: var_dump($data);
! 10: array_walk_recursive($data, 'apply_dumb');
! 11: $data2 = $data;
! 12: $data2[0] = 'altered';
! 13: var_dump($data);
! 14: var_dump($data2);
! 15:
! 16: // Bug #34982
! 17: function myfunc($data) {
! 18: array_walk_recursive($data, 'apply_changed');
! 19: }
! 20: function apply_changed(&$input, $key) {
! 21: $input = 'changed';
! 22: }
! 23: myfunc($data);
! 24: var_dump($data);
! 25:
! 26: --EXPECT--
! 27: array(2) {
! 28: ["key1"]=>
! 29: string(4) "val1"
! 30: [0]=>
! 31: array(1) {
! 32: ["key2"]=>
! 33: string(4) "val2"
! 34: }
! 35: }
! 36: array(2) {
! 37: ["key1"]=>
! 38: string(4) "val1"
! 39: [0]=>
! 40: array(1) {
! 41: ["key2"]=>
! 42: string(4) "val2"
! 43: }
! 44: }
! 45: array(2) {
! 46: ["key1"]=>
! 47: string(4) "val1"
! 48: [0]=>
! 49: string(7) "altered"
! 50: }
! 51: array(2) {
! 52: ["key1"]=>
! 53: string(4) "val1"
! 54: [0]=>
! 55: array(1) {
! 56: ["key2"]=>
! 57: string(4) "val2"
! 58: }
! 59: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>