php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #49485 Allow & when passing parameters by reference
Submitted: 2009-09-06 13:21 UTC Modified: 2010-12-29 12:26 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: mjomble at gmail dot com Assigned:
Status: Wont fix Package: *General Issues
PHP Version: 5.3.0 OS: Windows
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mjomble at gmail dot com
New email:
PHP Version: OS:

 

 [2009-09-06 13:21 UTC] mjomble at gmail dot com
Description:
------------
NB! I'm not asking for the un-deprecation of call-time pass-by-reference.

The way I understand it, this could previously alter the behavior of a function at call time. I agree that this can make things ugly and I can see the reason for it being deprecated.

However, I would still like to be able to use the & for decorative purposes.

When you see a call to a function without knowing/remembering/looking up the function definition, there's no way of telling whether the call can modify the variable or not.

In most cases, it is simply assumed that parameters are not passed by reference and will have the exact same value after the call. Which can cause problems when they're actually passed by reference.

Currently, to avoid such problems, I often add comments like this:

// $someParameter is passed by reference and may be modified by someMethod()
$someObject->someMethod($someParameter);

It would make things much clearer if it could be called like in the reproduce code, but ONLY if the function actually uses the first parameter by reference.

Reproduce code:
---------------
$someObject->someMethod(&$someParameter);

Expected result:
----------------
If the definition of someMethod() does not use the first parameter by reference, a warning should appear.

Otherwise, the code should execute normally.

Actual result:
--------------
A warning always appears, regardless of how the parameter is used.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-29 12:26 UTC] jani@php.net
-Status: Open +Status: Wont fix -Package: Feature/Change Request +Package: *General Issues
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 23:01:28 2024 UTC