php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #8427 Unwanted references
Submitted: 2000-12-26 13:31 UTC Modified: 2010-12-01 15:54 UTC
From: pkalliok at cs dot helsinki dot fi Assigned: jani (profile)
Status: Closed Package: *General Issues
PHP Version: 4.0.4 OS: Any
Private report: No CVE-ID: None
 [2000-12-26 13:31 UTC] pkalliok at cs dot helsinki dot fi
There are at least three places I know of where normal values are silently turned into references:

- when setting a variable by reference from a part of array or object, the value being set _from_ is also turned into reference
- object contained in other objects are turned into references by settype() and calling their methods
- NULLs become references to NULLs when you set an object from them by reference

Because this all alters the behaviour of PHP in subtle, dangerous ways, makes debugging harder and because references have still bugs (for example, serialisation), I ask you not to turn things into references when I don't see there is any reason to. I understand it is your policy that "turning a value into a reference should be safe", but as long as references have problems, don't adopt this policy.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-18 14:19 UTC] moriyoshi@php.net
1) when setting a variable by reference from a part of array
   or object, the value being set _from_ is also turned into
   reference

This is not supposed to be a bug. See bug #20993.

2) object contained in other objects are turned into 
   references by settype() and calling their methods

This might be a bug, but this problem doesn't occur under ZendEngine2. Stay tuned.

3) NULLs become references to NULLs when you set an object
   from them by reference.

This is expected behaviour.


 
 [2010-12-01 15:54 UTC] jani@php.net
-Status: Analyzed +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: jani
 [2010-12-01 15:54 UTC] jani@php.net
Not an issue anymore. If it is, post new report with proper example scripts.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 08:01:35 2024 UTC