Bug #71479 [NEW]: Array value turning into reference after passed to any function by reference
| From: | maxrodikov at gmail dot com | Date: | Thu, 28 Jan 2016 19:28:08 +0000 |
| Subject: | Bug #71479 [NEW]: Array value turning into reference after passed to any function by reference | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-198951@lists.php.net to get a copy of this message | ||
From: maxrodikov at gmail dot com
Operating system: Any
PHP version: 7.0.2
Package: *General Issues
Bug Type: Bug
Bug description:Array value turning into reference after passed to any function by reference
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 bug report at https://bugs.php.net/bug.php?id=71479&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71479&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71479&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71479&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=71479&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=71479&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=71479&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=71479&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=71479&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=71479&r=support
Expected behavior: https://bugs.php.net/fix.php?id=71479&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=71479&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=71479&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=71479&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71479&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=71479&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=71479&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=71479&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71479&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=71479&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=71479&r=mysqlcfg