|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63087 Passing a reference to a function does not work when parentheses are used
Submitted: 2012-09-14 07:01 UTC Modified: 2013-02-18 00:36 UTC
From: charlie at charliesomerville dot com Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: master-Git-2012-09-14 (Git) OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
28 + 10 = ?
Subscribe to this entry?

 [2012-09-14 07:01 UTC] charlie at charliesomerville dot com
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:

function &return_a() {
    global $a;
    return $a;

$a = [1,2,3];

$a = [1,2,3];

Expected result:
    [0] => 2
    [1] => 3
    [0] => 2
    [1] => 3

Actual result:
    [0] => 2
    [1] => 3
    [0] => 1
    [1] => 2
    [2] => 3


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-09-14 09:45 UTC]
yes, this is a knew issue, the similar thing will also happen while you use '@';

you will get a STRICT WARNING about this. right?

I'd like mark this as wont'fix, it's a compiler issue, fix this is expensive
 [2012-09-14 09:52 UTC] charlie at charliesomerville dot com
If you leave the ticket open, I might try my hand at fixing this.
 [2012-09-14 09:55 UTC]
it will be appreciated, thanks
 [2012-09-14 09:55 UTC]
-Status: Open +Status: Analyzed
 [2012-09-14 09:56 UTC]
wrong status.
 [2012-09-14 09:56 UTC]
-Status: Analyzed +Status: Feedback
 [2012-09-14 13:31 UTC]
@charlie: You can find a detailed description of why this happens here:

This is once again an issue caused by the AST-less compilation process. (
 [2013-02-18 00:36 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Jan 28 00:04:48 2023 UTC