#29877 [Ver->Csd]: variable assign by reference works even when methods don't return by reference
| From: | vrana@php.net | Date: | Thu, 07 Apr 2005 14:27:06 +0000 |
| Subject: | #29877 [Ver->Csd]: variable assign by reference works even when methods don't return by reference | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969367782@lists.php.net to get a copy of this message | ||
ID: 29877
Updated by: vrana@php.net
Reported By: bharat at menalto dot com
-Status: Verified
+Status: Closed
Bug Type: Documentation problem
Operating System: FreeBSD 4.8
PHP Version: 4CVS, 5CVS (2004-12-10)
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
"& by function definition is optional in class methods."
Previous Comments:
------------------------------------------------------------------------
[2004-12-14 02:59:28] alindeman@php.net
This is definitely not how the current documentation describes how
references work. Does this require a trivial documentation change, or
is it something in the engine/language that is not copasetic?
------------------------------------------------------------------------
[2004-12-13 09:54:21] bharat at menalto dot com
I left the old script with the bug intact, but have created a second
one with the fix that Jakub suggests, here:
http://www.menalto.com/.outgoing/php/ref2.php
------------------------------------------------------------------------
[2004-12-13 09:47:15] vrana@php.net
There's a small mistake in the sample script but it doesn't affect the
issue: There should be $test2->_data instead of $test1->_data on the
last line.
It's worth noting that if get() method returns literal instead of
variable, PHP doesn't issue any warning and the variable
is not bound.
------------------------------------------------------------------------
[2004-12-13 09:09:23] bharat at menalto dot com
Jani,
I appreciate that this behaviour hasn't changed in a while. If it's
part of the language, I'm ok with it. However, in the documentation
that I referenced, it clearly states:
---
Note: Unlike parameter passing, here you have to use & in both places
- to indicate that you return by-reference, not a copy as usual, and to
indicate that reference binding, rather than usual assignment, should be
done for $foo.
---
But as my sample code indicates (unless you can demonstrate a bug in my
code), the & is not required on the function. So if this is the desired
behaviour, then let us please update the documentation to state that it
is NOT required that there be an & on the function for you to get back
a reference. Either way we resolve this, there's a discrepancy that
should be removed.
Thanks!
------------------------------------------------------------------------
[2004-12-12 16:29:31] sniper@php.net
Note: Tested with 4.2.2 and it works exactly the same.
IMO this is not a bug.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/29877
--
Edit this bug report at http://bugs.php.net/?id=29877&edit=1