#24637 [Bgs]: __destruct not called
| From: | Bertrand dot Willm at laposte dot net | Date: | Mon, 14 Jul 2003 20:24:41 +0000 |
| Subject: | #24637 [Bgs]: __destruct not called | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-43981@lists.php.net to get a copy of this message | ||
ID: 24637
User updated by: Bertrand dot Willm at laposte dot net
Reported By: Bertrand dot Willm at laposte dot net
Status: Bogus
Bug Type: Class/Object related
Operating System: Windows XP
PHP Version: 5.0.0b1 (beta1)
New Comment:
I probably make an error entering the bug.
What should be read is:
Actual result:
--------------
Creation of ExtObject
ExtObject->CBaseClass::__construct()
End of script
Expected result:
----------------
Creation of ExtObject
ExtObject->CBaseClass::__construct()
End of script
ExtObject->CBaseClass::__destruct()
Previous Comments:
------------------------------------------------------------------------
[2003-07-14 14:20:04] helly@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
The instance is destructed of course after script termination if the
script doesn't destroy it itself. And when a derived class has no
specialized destructor then of course the inherited destructor is to be
called.
------------------------------------------------------------------------
[2003-07-13 15:33:01] Bertrand dot Willm at laposte dot net
Description:
------------
There is no recursive call to __destruct when it is not defined in a
derived class.
There is not this problem with __construct.
This can be dangerous be cause if a destructor is declared, all the
derived clas have to declare a __destruct to be sure that the
destruction is done.
In other way __destruct is obligatory not to have problem, but this is
not flexible.
Reproduce code:
---------------
class CBaseClass {
var $name;
function __construct($name) {
$this->name = $name;
echo "$this->name->CBaseClass::__construct()<br>";
}
function __destruct() {
echo "$this->name->CBaseClass::__destruct()<br>";
}
}
class CExtClass extends CBaseClass {
}
echo 'Creation of ExtObject<br>';
$ExtObject = new CExtClass('ExtObject');
echo 'End of script<br>';
Expected result:
----------------
Creation of ExtObject
ExtObject->CBaseClass::__construct()
End of script
Actual result:
--------------
Creation of ExtObject
ExtObject->CBaseClass::__construct()
End of script
ExtObject->CBaseClass::__destruct()
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24637&edit=1