Re: Attributes and constructor property promotion
| From: | Nikita Popov | Date: | Tue, 06 Oct 2020 14:54:15 +0000 |
| Subject: | Re: Attributes and constructor property promotion | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-112015@lists.php.net to get a copy of this message | ||
On Mon, Sep 28, 2020 at 12:36 PM Nikita Popov <nikita.ppv@gmail.com> wrote:
> Hi internals,
>
> When the constructor property promotion landed, the question of how it
> interacts with attributes on promoted properties did not get fully
> resolved. See https://wiki.php.net/rfc/constructor_promotion#attributesò?
> “4*DÜš:,ý(+}
> for what the issue is.
>
> The behavior that landed was to apply the attribute is applied to both the
> parameter and the property. However, this was with the understanding that
> we may have to adjust the behavior later, in particular depending on how
> the whole "attribute target validation" turns out. The way it is now, using
> a property-only attribute on a promoted parameter may result in spurious
> validation errors.
>
> I wanted to bring up this topic now to make sure it's not forgotten... I
> still don't really know what the best behavior here is.
>
> Regards,
> Nikita
>
I want to bump this topic, we should resolve this one way or another soon.
My two proposals are:
https://github.com/php/php-src/pull/6244:
Suppress target validation errors
for promoted properties (for property/parameter targets, the rest gets
validated as usual).
https://github.com/php/php-src/pull/6285:
Forbid use of attributes on
promoted properties altogether, punting on making a decision here.
Regards,
Nikita