While http://www.php.net/zend-engine-2.php claims the following
'Like constructors, parent destructors will not be called
implicitly by the engine. In order to run a parent destructor,
one would have to explicitly call parent::__destruct() in the
destructor body.
the following code
php -r 'abstract class A { protected function __destruct() {} }
class B extends A {}
$b = new B;'
results in
Warning: Call to protected B::__destruct() from context ''
during shutdown ignored in Unknown on line 0
which is inconsistent with the quoted description.
It also introduces an asymmetry compared to constructors which I think
is confusing.
Any thoughts ?
--
Ard
Hello Ard,
Saturday, March 6, 2004, 6:21:38 PM, you wrote:
While http://www.php.net/zend-engine-2.php claims the following
'Like constructors, parent destructors will not be called
implicitly by the engine. In order to run a parent destructor,
one would have to explicitly call parent::__destruct() in the
destructor body.
the following code
php -r 'abstract class A { protected function __destruct() {} }
class B extends A {}
$b = new B;'
results in
Warning: Call to protected B::__destruct() from context ''
during shutdown ignored in Unknown on line 0
which is inconsistent with the quoted description.
It also introduces an asymmetry compared to constructors which I think
is confusing.
Any thoughts ?
Yes your understanding and your code is wrong. In your code you explicitly
decalre that the destructor may only be called from that class's context.
Normally this results in an E_ERROR. But when it happens we only issue
an E_WARNING
because the E_ERROR
would restart the Rshutdown process.
--
Best regards,
Marcus mailto:helly@php.net