On Fri, Feb 25, 2022, at 4:57 PM, DANIEL VARGAS MUCCILLO wrote: > Hi Internals, hope you are all well. > > I've been playing around with Attributes and found that the only > way for safely type hint for reflection entities who implement the > getAttributes method is the following union: > > ReflectionClass|ReflectionClassConstant|ReflectionFunctionAbstract|ReflectionParameter|ReflectionProperty >> $reflectionEntity > > > For a single use case this was ok, but i would like to survey if > people here would be interested in the introduction of a interface > against which we could correctly ensure, with less effort, that > getAttribute is available. > > I believe that it would be something along the lines of: > >> interface AttributeReflector { > > public function getAttributes(?string $name = null, int $flags = 0): >> array; > > } > > > I have no experience with the PHP's source code, but if you think > that it's a good idea I would like to propose an RFC along with a PoC > patch to make this adition. > > Thanks for your time until now and all the good work I've seen here. > > -- > Daniel Vargas Muccillo
I've run into this problem as well. I *think* all Reflector children support attributes, so it may not need a separate interface. However, the entire Reflection class hierarchy is a mess and needs a number of additional interfaces added to it generally. It makes sense to overhaul it holistically to make sure it all fits together. I have zero availability until mid-March, but I'm open to helping at that point. --Larry Garfield -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php