Re: Proposal: retrieve line, filename and if user defined for ReflectionAttribute

From: Date: Fri, 05 Apr 2024 13:58:52 +0000
Subject: Re: Proposal: retrieve line, filename and if user defined for ReflectionAttribute
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-122970@lists.php.net to get a copy of this message
Hi Joel On Fri, Apr 5, 2024 at 3:10 PM Joel Wurtz <jwurtz@jolicode.com> wrote: > > Like a lot of libraries, we offer the possibility to configure behaviors with Attributes. > However in some cases it's wrongly configured by the user and this wrong configuration cannot > be detected on the attribute constructor but afterwards. > > In this case we may want to pinpoint which attribute (in which file and at which line) cause > this bad configuration. Since there was no method to retrieve those information in the > ReflectionAttribute I proposed a PR > https://github.com/php/php-src/pull/13889 to add those informations. > > I do believe this will allow better DX for end user when correctly used, I would propose negating and renaming isUserDefined() to isInternal(), since we already have several such methods. As hinted in the PR, I believe the implementation is wrong, or rather doesn't do what you would expect it to do. I'm also wondering whether it may be more useful to expose the attribute class as getClass(), without instantiating the attribute itself. This would allow you to check for isInternal() there, along with all the other class reflection information. Ilija

« previous php.internals (#122970) next »