Re: [RFC] [Discussion] #[\DelayedTargetValidation] attribute
| From: | Rob Landers | Date: | Wed, 18 Jun 2025 09:24:25 +0000 |
| Subject: | Re: [RFC] [Discussion] #[\DelayedTargetValidation] attribute | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-127703@lists.php.net to get a copy of this message | ||
On Wed, Jun 18, 2025, at 01:26, Daniel Scherzer wrote:
> Hi internals,
>
> I'd like to start the discussion for a new RFC about adding a AÇ!ó
> €e5~‚N¾ÖÏ#[\DelayedTargetValidation] attribute.
>
> * RFC:
> https://wiki.php.net/rfc/delayedtargetvalidation_attribute
> * Implementation: https://github.com/php/php-src/pull/18817
>
> --Daniel
Interesting. I’d also argue for the inverse more than this, though. I’d like for my attributes
to be validated during compilation instead of delayed to runtime -- which, it isn’t actually.
Runtime validation ONLY happens when calling ->newInstance() on ReflectionAttribute, and never
before then. So, only when an attribute is actually read during reflection is it validated. Further,
if you never actually instantiate it ... it is never actually validated (i.e., just looking for the
presence of an attribute, not the details).
https://3v4l.org/UqQKi
— Rob