#33352 [NEW]: returning references document says that class methods return reference is wrong
| From: | cmoore at iyd dot com | Date: | Wed, 15 Jun 2005 13:58:24 +0000 |
| Subject: | #33352 [NEW]: returning references document says that class methods return reference is wrong | ||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969368622@lists.php.net to get a copy of this message | ||
From: cmoore at iyd dot com
Operating system: Gentoo Linux
PHP version: Irrelevant
PHP Bug Type: Documentation problem
Bug description: returning references document says that class methods return reference is wrong
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 bug report at http://bugs.php.net/?id=33352&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33352&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33352&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33352&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33352&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33352&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33352&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33352&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33352&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33352&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33352&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=33352&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=33352&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33352&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33352&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33352&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33352&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33352&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33352&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33352&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33352&r=mysqlcfg