#43736 [NEW]: Cannot return an overloaded property by reference
| From: | robin_fernandes at uk dot ibm dot com | Date: | Thu, 03 Jan 2008 10:47:32 +0000 |
| Subject: | #43736 [NEW]: Cannot return an overloaded property by reference | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-121002@lists.php.net to get a copy of this message | ||
From: robin_fernandes at uk dot ibm dot com
Operating system: Windows
PHP version: 5.2.5
PHP Bug Type: Scripting Engine problem
Bug description: Cannot return an overloaded property by reference
Description:
------------
Even with a __get() that returns by reference, attempting to return an
overloaded property by reference directly will return by value with a
notice.
A work-around is to assign the overloaded property by reference to another
variable, and return that variable. However, I think it should be possible
to return the property by reference directly.
This affects 5.2.5 and the latest 5.3 and 6.0 snaps.
Reproduce code:
---------------
Testcase over 20 lines - see: http://pastebin.com/f35a74bdb
Expected result:
----------------
Get reference to global via return-by-ref __get() called implicitly - OK:
string(13) "First change!"
Get reference to global via return-by-ref __get() called explicitly from
return-by-ref function - OK:
string(14) "Second change!"
Get reference to global via return-by-ref __get() called implicitly from
return-by-ref function:
string(13) "Third change!"
Actual result:
--------------
Get reference to global via return-by-ref __get() called implicitly - OK:
string(13) "First change!"
Get reference to global via return-by-ref __get() called explicitly from
return-by-ref function - OK:
string(14) "Second change!"
Get reference to global via return-by-ref __get() called implicitly from
return-by-ref function:
Notice: Only variable references should be returned by reference in %s on
line 20
string(8) "original"
--
Edit bug report at http://bugs.php.net/?id=43736&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43736&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43736&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43736&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43736&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=43736&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=43736&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=43736&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=43736&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=43736&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=43736&r=support
Expected behavior: http://bugs.php.net/fix.php?id=43736&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=43736&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=43736&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=43736&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43736&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=43736&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=43736&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=43736&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=43736&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=43736&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=43736&r=mysqlcfg