Re: [RFC] [Discussion] #[\DelayedTargetValidation] attribute

From: Date: Wed, 18 Jun 2025 11:09:26 +0000
Subject: Re: [RFC] [Discussion] #[\DelayedTargetValidation] attribute
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-127704@lists.php.net to get a copy of this message
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

« previous php.internals (#127704) next »