#32315 [Opn->Fbk]: Destructor is called although Constructor throws an exc. after =& assignment

From: Date: Fri, 18 Mar 2005 18:27:47 +0000
Subject: #32315 [Opn->Fbk]: Destructor is called although Constructor throws an exc. after =& assignment
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-75485@lists.php.net to get a copy of this message
ID: 32315 Updated by: sniper@php.net Reported By: m dot wiegard at brandsetter dot de -Status: Open +Status: Feedback Bug Type: Class/Object related Operating System: MacOs x (10.3.7) PHP Version: 5.0.3 New Comment: Please try using this CVS snapshot: http://snaps.php.net/php5-latest.tar.gz For Windows: http://snaps.php.net/win32/php5-win32-latest.zip Previous Comments: ------------------------------------------------------------------------ [2005-03-15 15:40:18] m dot wiegard at brandsetter dot de Description: ------------ The bug appears if I'm using any method calls with & (and only with &, I read the other bug reports !!!!!!) to assign the result to a variable within the constructor. if an Exception is thrown after that within the constructor, the destructor is called, although no object was instantiated. Reproduce code: --------------- <?php class test1 { private $test; function __construct() { $this->test =& test1::staticMethod(); throw new Exception(); } static function staticMethod() { return true; } function __destruct() { print 'DESTRUCTOR'; } } $test = new test1(); ?> Expected result: ---------------- I Expected to see no output of my little listing itself, only the error messages. Actual result: -------------- After the exception was printed out in the output, DESTRUCTOR appeared. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=32315&edit=1

« previous php.bugs (#75485) next »