When PHP instantiates one of your attributes, the constructor only receives the arguments you passed, with no idea what the attribute is attached to. This RFC from Daniel Scherzer lets an attribute find out, from inside its own constructor, which class, method, property or other element it's on.
The two new methods
ReflectionAttribute::getCurrent()is a static method. Call it inside an attribute's constructor and it returns theReflectionAttributefor that particular use of the attribute.ReflectionAttribute::getReflectionTarget()returns the reflection object for the element the attribute is attached to.
Today you can use debug_backtrace() tricks to learn the kind of element, like "a class," but not which class. Libraries like Crell/AttributeUtils and Symfony Console each work around this in their own way.
An example
This attribute makes sure it's only used on interfaces:
#[Attribute(Attribute::TARGET_CLASS)] class StableInterface { public function __construct() { $target = ReflectionAttribute::getCurrent()->getReflectionTarget(); assert($target instanceof ReflectionClass); if (!$target->isInterface()) { throw new Exception("#[StableInterface] is only for interfaces!"); } } }
getCurrent() only works when it's called directly from the constructor of an attribute being instantiated through ReflectionAttribute::newInstance(). Called anywhere else, it fails.
A new interface
An attribute can sit on many kinds of elements, so the target could be a ReflectionClass, ReflectionMethod, ReflectionParameter and more. The RFC adds a ReflectionAttributeTarget interface to cover all of them, and every reflection class that can carry attributes would implement it. You narrow the type with assert() or instanceof, which also helps static analysis tools and IDEs.
What it means for existing code
Nothing breaks, since only the reflection extension changes. Attribute libraries may want to adopt the new methods.
Where it stands
It's back in draft. The changelog for version 0.4 says the vote was cancelled after early votes and feedback, and that the RFC needs an overhaul. The page is dated April 19, 2026, and targets PHP 8.6.