Attributes and constructor property promotion
| From: | Nikita Popov | Date: | Mon, 28 Sep 2020 10:36:33 +0000 |
| Subject: | Attributes and constructor property promotion | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-111942@lists.php.net to get a copy of this message | ||
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
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