|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32315 Destructor is called although Constructor throws an exc. after =& assignment
Submitted: 2005-03-15 15:40 UTC Modified: 2005-03-25 01:48 UTC
From: m dot wiegard at brandsetter dot de Assigned:
Status: No Feedback Package: Class/Object related
PHP Version: 5.0.3 OS: MacOs x (10.3.7)
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: m dot wiegard at brandsetter dot de
New email:
PHP Version: OS:


 [2005-03-15 15:40 UTC] m dot wiegard at brandsetter dot de
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 
if an Exception is thrown after that within the 
constructor, the destructor is called, although no 
object was instantiated.

Reproduce code:
	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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-18 19:27 UTC]
Please try using this CVS snapshot:
For Windows:

 [2005-03-25 01:48 UTC]
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jun 20 12:01:29 2024 UTC