Re: Implementing Generics, and none scalar default properties.
| From: | Pavel Kouřil | Date: | Sat, 26 Sep 2015 07:27:07 +0000 |
| Subject: | Re: Implementing Generics, and none scalar default properties. | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-88508@lists.php.net to get a copy of this message | ||
On Fri, Sep 25, 2015 at 11:53 PM, Stanislav Malyshev
<smalyshev@gmail.com> wrote:
> Hi!
>
>> I'm thinking primarily of the benefit to base or abstract classes. For
>
> Both can have constructors.
>
>> base classes which expect certain properties be set, they are exposed to
>> the danger of remaining unset if the derived class overrides the
>> constructor without calling the parent.
>
> You should always call the parent ctor. There's pretty much no reason to
> ever not to call parent ctor.
>
> --
> Stas Malyshev
> smalyshev@gmail.com
>
Since there is no reason not to call parent ctor, maybe PHP should
somehow make every class have default empty ctor, if it doesn't have
one defined already - so you can write automatically
parent::__construct() everywhere?
Regards
Pavel Kouřil