Req #49485 [Opn->Wfx]: Allow & when passing parameters by reference
| From: | jani@php.net | Date: | Wed, 29 Dec 2010 11:26:38 +0000 |
| Subject: | Req #49485 [Opn->Wfx]: Allow & when passing parameters by reference | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-157381@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=49485&edit=1
ID: 49485
Updated by: jani@php.net
Reported by: mjomble at gmail dot com
Summary: Allow & when passing parameters by reference
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
Operating System: Windows
PHP Version: 5.3.0
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2009-09-06 13:21:57] 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.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=49485&edit=1