|  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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: charlie at charliesomerville dot com
New email:
PHP Version: OS:


 [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-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 17 05:01:31 2024 UTC