Re: __destruct() behaviour

From: Date: Sun, 07 Mar 2004 22:35:36 +0000
Subject: Re: __destruct() behaviour
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-8437@lists.php.net to get a copy of this message
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

« previous php.internals (#8437) next »