From: miha dot vrhovnik at domenca dot com
Operating system: Linux
PHP version: 5.2.5
PHP Bug Type: Feature/Change Request
Bug description: __destruct 2
Description:
------------
Followup to #43264 as i cannot add another comment there :(
__constructor was a typo :( (Old habits die hard.)(I've seen that then it
also dies in constructor if there is no base class)
Why each class should have __destruct, __construct function let's take
another look from another perspective.
I take external class from the web e.g. Smarty
I extend Smarty class, but I need class destructor. As currently Smarty
doesn't have destructor I don't write parent:__destruct into my destructor.
Then Smarty guys decide they need it and somebody at my company decides
that it will upgrade Smarty to that version. In most cases we just
introduced a difficult to find bug.
After making some more research. The same applies if I comment out a
__constuct in base class. Not calling parent::__construct in extended class
if base class gets constructor might result in difficult to find bugs.
So I beleive that php should provide parent class constructor/destructor
if it doesn't have it already. Well or at least this shouldn't be a fatal
error.
Reproduce code:
---------------
error_reporting(E_ALL);
$c = new extender();
class base
{
public function __construct()
{
//parent::__construct();
}
}
class extender extends base
{
public function __construct()
{
parent::__construct();
}
public function __destruct()
{
parent::__destruct();
}
}
Expected result:
----------------
Not exiting with fatal error. e.g provide default constructor/destructor
functions for every class.
--
Edit bug report at http://bugs.php.net/?id=43274&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=43274&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=43274&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=43274&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=43274&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=43274&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=43274&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=43274&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=43274&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=43274&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=43274&r=support
Expected behavior: http://bugs.php.net/fix.php?id=43274&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=43274&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=43274&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=43274&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43274&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=43274&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=43274&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=43274&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=43274&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=43274&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=43274&r=mysqlcfg