Re: [RFC] [Discussion] #[\DelayedTargetValidation] attribute
| From: | Rob Landers | Date: | Wed, 18 Jun 2025 11:58:36 +0000 |
| Subject: | Re: [RFC] [Discussion] #[\DelayedTargetValidation] attribute | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-127707@lists.php.net to get a copy of this message | ||
On Wed, Jun 18, 2025, at 13:09, kontakt@beberlei.de wrote:
>
> Von meinem iPhone gesendet
>
>> Am 18.06.2025 um 11:26 schrieb Rob Landers <rob@bottled.codes>:
>>
>> 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
>>>
#[\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
>
>
> As Daniel’s rfc mentions you need to differentiate between compiler and userland attributes.
>
> The compiler attributes are validated at compile time not dueing newInstance.
>
>>
>> — Rob
Yes, but when would it check it during runtime? It doesn't say in the RFC. From what I can
tell, it effectively disables the attribute, unless someone happens to enumerate and instantiate all
the attributes (which is unlikely).
— Rob