Bug #71479 [Opn->Wfx]: Array value turning into reference after passed to any function by reference
| From: | laruence@php.net | Date: | Sat, 30 Jan 2016 04:21:46 +0000 |
| Subject: | Bug #71479 [Opn->Wfx]: Array value turning into reference after passed to any function by reference | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-198965@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71479&edit=1
ID: 71479
Updated by: laruence@php.net
Reported by: maxrodikov at gmail dot com
Summary: Array value turning into reference after passed to
any function by reference
-Status: Open
+Status: Wont fix
Type: Bug
Package: *General Issues
Operating System: Any
PHP Version: 7.0.2
Block user comment: N
Private report: N
New Comment:
this is a side affect by new design, I don't think it's a problem in general.
it will be truns to no-reference in some other points if it is needed.
thanks
Previous Comments:
------------------------------------------------------------------------
[2016-01-28 19:28:06] maxrodikov at gmail dot com
Description:
------------
Bug can be reproduced on almost any 7.* package and almost any OS.
Tested by myself on Ubuntu / FreeBSD / Windows on PHP package without additional modules.
Seems, that when you pass associative array element to any function/method, that require argument to
be passed by reference, you get reference at passed array key instead of scalar/array/NULL value.
Didn't found at documentation anything about such conduct.
Test script:
---------------
<?php
// Can be any user or internal function (class method, e.t.c), accepting parameters by reference
function make_nothing(&$param) {}
$arr1 = ['val' => NULL];
$arr2 = ['val' => 5]; // instead "5" there can be any scalar/array/NULL
// Pass array element to function, that doing nothing
make_nothing($arr2['val']);
// ok, now we have reference instead of value
$arr1 = array_merge($arr1, $arr2);
var_dump($arr1, $arr2);
Expected result:
----------------
array(1) {
["val"]=>
int(5)
}
array(1) {
["val"]=>
int(5)
}
Actual result:
--------------
array(1) {
["val"]=>
&int(5)
}
array(1) {
["val"]=>
&int(5)
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71479&edit=1