Consider this common scenario: I use some OOP library, that is a "black box" and I like it that way.
As part of the integration, I need to extend one of the library's classes: class App_bar extends Library_foo{ function __construct(){ //do whatever I need to do here. } } So I write this code, and it works, and I'm happy. Years go by and new releases of the library come out, steadily improving features and fixing bugs etc. But at some point, the library needed a resource in a __construct() somewhere in the ancestry of Library_foo, to perform something at the time of construction. So they re-factored or re-implemented the black box library to have a constructor in Library_foo class, or any of its numerous ancestors. Suddenly my code doesn't work. Maybe the resource is only needed under certain conditions. So their __construct doesn't get called, but nothing bad happens until the circumstances where they need the __construct called. So now I don't just have a bug, I have an intermittent bug. And as much as we all like to think our testing covers 100% of the functionality... I'm tearing my hair out trying to find where things went wrong in code that worked for years. Right now, to avoid this situation, you have to do: if (method_exists(get_parent_class(), '__construct')) parent::__construct(); If you don't check for the method existing, you get: Fatal error: Cannot call constructor ... I don't want to have an intimate knowledge of the internals of the library; just the documented API. That's one of the major reasons for using a library. I would think that as PHP climbs up the chain of "extends" et al, if it never found a parent method, if wouldn't complain about it, much less E_FATAL... I mean, so you didn't find a method that's not there to find. And I should call parent::__construct just in case there is one there, because I don't know, or care, really, how the black box is implemented. So long as the library does what's on the tin (in the docs). -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php