On Tue, Apr 14, 2020 at 9:17 PM Dmitry Stogov <dsto...@perforce.com> wrote:

> Hi Nikita,
>
> Personally, I don't see a big reason in introduction this syntax sugar.
> It allows to make class declaration more compact but less readable.
>
> Also, this feature doesn't work well with inheritance. RFC doesn't provide
> any examples with inherited classes.
> The implementation doesn't allow initialization of parent class
> properties, and doesn't allow to call parent constructor before
> initialization of child class properties (like C++ allows).
>

I have now added an example involving inheritance to the RFC:
https://wiki.php.net/rfc/constructor_promotion#inheritance

Constructor promotion does work with inheritance. As you pointed out, the
only oddity is that properties are assigned before the parent constructor
call, rather than after it. I don't think this makes a difference in
practice though.


> In my opinion, the existing PHP syntax is already clear and good enough.
>

Fair enough :)

Nikita

------------------------------
> *From:* Nikita Popov <nikita....@gmail.com>
> *Sent:* Tuesday, April 14, 2020 16:02
> *To:* PHP internals <internals@lists.php.net>
> *Subject:* [PHP-DEV] Re: [RFC] Constructor Property Promotion
>
> On Thu, Mar 26, 2020 at 2:30 PM Nikita Popov <nikita....@gmail.com> wrote:
>
> > Hi internals,
> >
> > I would like to submit the following RFC for your consideration:
> > https://wiki.php.net/rfc/constructor_promotion
> >
> > This is based on one off the suggestions made in
> > https://externals.io/message/109220, and some existing discussion on the
> > topic can be found in that thread.
> >
> > The primary motivation for this feature is to close the currently rather
> > wide gap between the use of ad-hoc array structures, and the use of
> > well-defined and type-safe value objects. The latter is what we want
> people
> > to use, but the former is, unfortunately, what is *easy* to use.
> >
>
> As the reception has been positive, I plan to open voting on this proposal
> soon. Please tell me if you have further concerns or the RFC needs
> additional clarification.
>
> Regards,
> Nikita
>
>
> CAUTION: This email originated from outside of the organization. Do not
> click on links or open attachments unless you recognize the sender and know
> the content is safe.
>
> This e-mail may contain information that is privileged or confidential. If
> you are not the intended recipient, please delete the e-mail and any
> attachments and notify us immediately.
>
>

Reply via email to