php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43736 Cannot return an overloaded property by reference
Submitted: 2008-01-03 10:47 UTC Modified: 2008-01-28 23:51 UTC
From: robin_fernandes at uk dot ibm dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.5 OS: Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: robin_fernandes at uk dot ibm dot com
New email:
PHP Version: OS:

 

 [2008-01-03 10:47 UTC] robin_fernandes at uk dot ibm dot com
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"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-28 23:51 UTC] tony2001@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Aug 01 11:00:02 2025 UTC