#33352 [Opn->Csd]: returning references document says that class methods return reference is wrong
| From: | vrana@php.net | Date: | Thu, 14 Jul 2005 09:50:30 +0000 |
| Subject: | #33352 [Opn->Csd]: returning references document says that class methods return reference is wrong | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969369111@lists.php.net to get a copy of this message | ||
ID: 33352
Updated by: vrana@php.net
Reported By: cmoore at iyd dot com
-Status: Open
+Status: Closed
Bug Type: Documentation problem
Operating System: Gentoo Linux
PHP Version: Irrelevant
New Comment:
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at
http://www.php.net/downloads.php
Already fixed by Derick.
Previous Comments:
------------------------------------------------------------------------
[2005-06-15 16:11:26] vrana@php.net
Fur further reference: it was added for the sake of bug #29877.
------------------------------------------------------------------------
[2005-06-15 15:58:23] cmoore at iyd dot com
Description:
------------
On the document page:
http://us2.php.net/manual/en/language.references.return.php
"& by function definition is optional in class methods."
Reproduce code:
---------------
<?
class reftest
{
var $var = "original";
function by_copy()
{
return $this->var;
}
}
print "By copy:\n";
$t = new reftest;
var_dump($t);
$c =& $t->by_copy();
$c = "copy";
var_dump($t);
Expected result:
----------------
According to docs, $c should be a reference to the class variable.
$t->c should have the value "copy" in the output from the last
var_dump. When an ampersand is prefixed on the function by_copy(), it
works as expected.
Actual result:
--------------
as demonstrated by the above code, a copy is returned.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33352&edit=1