Bug #63087 [NEW]: Passing a reference to a function does not work when parentheses are used
| From: | charlie at charliesomerville dot com | Date: | Fri, 14 Sep 2012 07:01:05 +0000 |
| Subject: | Bug #63087 [NEW]: Passing a reference to a function does not work when parentheses are used | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-173431@lists.php.net to get a copy of this message | ||
From: charlie at charliesomerville dot com
Operating system: Linux
PHP version: master-Git-2012-09-14 (Git)
Package: Scripting Engine problem
Bug Type: Bug
Bug description:Passing a reference to a function does not work when parentheses are used
Description:
------------
To be specific, this only occurs when passing a reference returned by a
function
into another function that takes a reference.
This behaves as expected with a variable instead of a function call, so I
believe
this is a bug.
Test script:
---------------
<?php
function &return_a() {
global $a;
return $a;
}
$a = [1,2,3];
array_shift(return_a());
print_r($a);
$a = [1,2,3];
array_shift((return_a()));
print_r($a);
Expected result:
----------------
Array
(
[0] => 2
[1] => 3
)
Array
(
[0] => 2
[1] => 3
)
Actual result:
--------------
Array
(
[0] => 2
[1] => 3
)
Array
(
[0] => 1
[1] => 2
[2] => 3
)
--
Edit bug report at https://bugs.php.net/bug.php?id=63087&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63087&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63087&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63087&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=63087&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=63087&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=63087&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=63087&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=63087&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=63087&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=63087&r=support
Expected behavior: https://bugs.php.net/fix.php?id=63087&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=63087&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=63087&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=63087&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63087&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=63087&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=63087&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=63087&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63087&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=63087&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=63087&r=mysqlcfg