|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-12-22 13:40 UTC] johannes@php.net
-Status: Open
+Status: Bogus
-Package: Feature/Change Request
+Package: *General Issues
[2010-12-22 13:40 UTC] johannes@php.net
[2010-12-23 07:40 UTC] miha dot vrhovnik at domenca dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 00:00:02 2025 UTC |
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.