Bug #14539 Updated: Assigning null to reference has unexpected results.
| From: | cox@php.net | Date: | Thu, 27 Dec 2001 12:46:33 +0000 |
| Subject: | Bug #14539 Updated: Assigning null to reference has unexpected results. | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-3711@lists.php.net to get a copy of this message | ||
ID: 14539
Updated by: cox
Reported By: jfrisby@mrjoy.com
Old Status: Open
Status: Bogus
Bug Type: PEAR related
Operating System: All
PHP Version: 4.0.6
New Comment:
References are not C pointers. It's documented in:
http://www.php.net/manual/en/language.references.php
-- Tomas V.V.Cox
Previous Comments:
------------------------------------------------------------------------
[2001-12-15 20:15:14] jfrisby@mrjoy.com
$foo =& new SomePEARDervidedClassWithADestructor();
$foo = null;
In the above case, the destructor is never called. Presumably, the assignment is being interpreted
as requesting that the object instance be nullified, rather than the more intuitive (IMNSHO) notion
of nullifying the reference to the object.
If you change the null-assignment line above to be:
function &nullref() { return null; }
$foo =& nullref();
The desired semantics are preserved. Of course, the following is presently invalid:
$foo =& null;
May I suggest that the above be added to allow the desired semantics in a simple fashion? Or at the
very least, document this rather unexpected behavior?
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=14539&edit=1