ID: 29877 Updated by: [EMAIL PROTECTED] Reported By: bharat at menalto dot com Status: Closed Bug Type: Documentation problem Operating System: FreeBSD 4.8 PHP Version: 4CVS, 5CVS (2004-12-10) New Comment:
If $_data is initialized through "var $_data" and not in constructor, get() doesn't return a reference. This inconsistency is fixed in PHP 5.1. Previous Comments: ------------------------------------------------------------------------ [2005-04-07 16:27:04] [EMAIL PROTECTED] 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." ------------------------------------------------------------------------ [2004-12-14 02:59:28] [EMAIL PROTECTED] 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] [EMAIL PROTECTED] 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! ------------------------------------------------------------------------ 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