Annotation of embedaddon/php/ext/standard/tests/array/bug33940.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Bug #33940 (array_map() fails to pass by reference when called recursively)
! 3: --INI--
! 4: allow_call_time_pass_reference=1
! 5: error_reporting=4095
! 6: --FILE--
! 7: <?php
! 8: function ref_map(&$item) {
! 9: if(!is_array($item)) {
! 10: $item = 1;
! 11: return 2;
! 12: } else {
! 13: $ret = array_map('ref_map', &$item);
! 14: return $ret;
! 15: }
! 16: }
! 17:
! 18: $a = array(array(0), 0);
! 19: $ret = array_map('ref_map', $a);
! 20: echo 'Array: '; print_r($a);
! 21: echo 'Return: '; print_r($ret);
! 22: $a = array(array(0), 0);
! 23: $ret = array_map('ref_map', &$a);
! 24: echo 'Array: '; print_r($a);
! 25: echo 'Return: '; print_r($ret);
! 26: ?>
! 27: --EXPECTF--
! 28: Array: Array
! 29: (
! 30: [0] => Array
! 31: (
! 32: [0] => 0
! 33: )
! 34:
! 35: [1] => 0
! 36: )
! 37: Return: Array
! 38: (
! 39: [0] => Array
! 40: (
! 41: [0] => 2
! 42: )
! 43:
! 44: [1] => 2
! 45: )
! 46: Array: Array
! 47: (
! 48: [0] => Array
! 49: (
! 50: [0] => 1
! 51: )
! 52:
! 53: [1] => 1
! 54: )
! 55: Return: Array
! 56: (
! 57: [0] => Array
! 58: (
! 59: [0] => 2
! 60: )
! 61:
! 62: [1] => 2
! 63: )
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>