Re: Attributes and constructor property promotion

From: Date: Wed, 07 Oct 2020 08:01:44 +0000
Subject: Re: Attributes and constructor property promotion
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-112021@lists.php.net to get a copy of this message
On Tue, Oct 6, 2020 at 6:59 PM Rowan Tommins <rowan.collins@gmail.com> wrote: > On Tue, 6 Oct 2020 at 17:20, Andreas Leathley <a.leathley@gmx.net> wrote: > > > From my understanding suppressing the validation errors in this > > particular case would be a good solution, or are there any serious > > downsides to that? > > > > > The downside presumably is that a library author could implement an > attribute with a property-only restriction, and therefore write code > handling parameter attributes with the assumption that that attribute won't > be present. If a consumer of the library makes use of constructor property > promotion, that assumption can be violated. I can't quite picture what that > code would look like, though, since it's always necessary to filter the > list of attributes to exclude those from other libraries. > Yeah, this is my own view as well. If an attribute appears in an unexpected place, you'd just ignore it the same way you ignore all attributes you do not "own". For manual implementations, you wouldn't even notice (because for a property-only attribute, you'd only be looking at properties, duh) and general attribute handling libraries can easily accommodate this case (if it doesn't just happen automatically). Regards, Nikita

« previous php.internals (#112021) next »