File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / array / bug33940.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:48:03 2012 UTC (12 years, 4 months ago) by misho
Branches: php, MAIN
CVS tags: v5_3_10, HEAD
php

--TEST--
Bug #33940 (array_map() fails to pass by reference when called recursively)
--INI--
allow_call_time_pass_reference=1
error_reporting=4095
--FILE--
<?php
function ref_map(&$item) {
    if(!is_array($item)) {
        $item = 1;
        return 2;
    } else {
        $ret = array_map('ref_map', &$item);
        return $ret;
    }
}

$a = array(array(0), 0);
$ret = array_map('ref_map', $a);
echo 'Array: '; print_r($a);
echo 'Return: '; print_r($ret);
$a = array(array(0), 0);
$ret = array_map('ref_map', &$a);
echo 'Array: '; print_r($a);
echo 'Return: '; print_r($ret);
?>
--EXPECTF--
Array: Array
(
    [0] => Array
        (
            [0] => 0
        )

    [1] => 0
)
Return: Array
(
    [0] => Array
        (
            [0] => 2
        )

    [1] => 2
)
Array: Array
(
    [0] => Array
        (
            [0] => 1
        )

    [1] => 1
)
Return: Array
(
    [0] => Array
        (
            [0] => 2
        )

    [1] => 2
)

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>