If I have a parent class that is extended by lots and lots of other classes, and I want to make sure the parent class's constructor is ALWAYS run, is it a bad idea to declare the constructor final
?
I was thinking of doing something like this:
class ParentClass {
public final function __construct() {
//parent class initialization...
$this->construct();
}
protected function init() {
echo 'constructing<br>';
}
}
class ChildClass extends ParentClass {
protected function init() {
//child class initialization
echo 'constructing child<br>';
}
}
that way the child class can have a sort-of constructor, and the parent class's constructor will always execute. Is this bad practice?