On Sun, Jun 22, 2025 at 10:24 PM Alexandru Pătrănescu <dreal...@gmail.com> wrote:
> Hi Daniel, internals, > > On Wed, Jun 18, 2025, 02:29 Daniel Scherzer <daniel.e.scher...@gmail.com> > wrote: > >> Hi internals, >> >> I'd like to start the discussion for a new RFC about adding a >> `#[\DelayedTargetValidation]` attribute. >> >> > How about completely disabling errors caused by a bad target at compile > time? > And just ignore the attribute, that can be validated at runtime if needed. > IDEs and static code analysis would show the problem and that might be > enough. > > -- > Alex > If you mean to always disable those errors, that is exactly what I responded to above - https://news-web.php.net/php.internals/127734. Basically, internal attributes are not pure metadata but also trigger engine behavior, while userland attributes are metadata (and the attributes don't even need to exist to be used!). Thus, there is a benefit to compile time errors, since otherwise you don't know that the engine behavior isn't being triggered. This attribute completely disables errors caused by a bad target at compile time *whenever the new #[\DelayedTargetValidation] is applied*. This gives the best of both worlds * you get errors if you misuse an internal attribute * you can suppress those errors intentionally if you have a reason (e.g. forward compatibility), and just delay the validation until runtime Since I proposed this RFC, a proposal to support `#[\Override]` on properties has been discussed (https://news-web.php.net/php.internals/127831), highlighting the benefits of this #[\DelayedTargetValidation] attribute. E.g. if we add it in 8.5, then when a later version adds #[\Override], a library can apply #[\Override] to properties without *requiring* a newer version of PHP. -Daniel