Constructor Needed

no-email (Damien Seguy), Damien Seguy
Fri, 04 Oct 2024 00:00:00 +0000

By default, classes don't need a constructor, and it may be omitted. It is also true in the case of child classes: PHP look for a local constructor, then a parent constructor, and it is valid to have none of them.
On the other hand, if any of the child makes an explicit call to ``parent::__construct``, then, there must be at least an explicit constructor in the family. Or, PHP generates ``Cannot call constructor`` error message.
As a rule of thumb, it might be good to always include the constructor definition, to avoid adding it later, down the road.