Re: [RFC] [Discussion] Add ReflectionAttribute::getCurrent()

From: Date: Sun, 17 May 2026 10:51:01 +0000
Subject: Re: [RFC] [Discussion] Add ReflectionAttribute::getCurrent()
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-130922@lists.php.net to get a copy of this message
Hi Am 2026-05-17 05:35, schrieb Larry Garfield:
But so far, this seems the least bad way to address the issue of attributes being fundamentally dumb about their context.
I consider that to be a feature, not an issue. Context-specific logic hidden in a function is neither obvious to humans, nor to code. If I write #[Field] with `public function __construct(public ?string $name = null), then I expect ->name to be null`, not something else. And code handling Attributes in a generic way - for example some code generation - expects “pass all the arguments to the constructor” to do the right thing.
I will also note the bonus feature in this RFC, the ReflectionAttributeTarget interface. I frankly want that even more than the reflection target. :-) Even if this RFC fails, that should be brought back in its own little RFC and needs to pass.
The interface makes sense to me. I suppose we could probably ship that without an RFC. Best regards Tim Düsterhus

« previous php.internals (#130922) next »