More Attribute UsageΒΆ

PHP attributes are for classes, but also for enums, traits and interfaces. With ::TARGET_CLASS.

PHP attributes are for functions, and also for closures and arrow functions (but not for methods). With ::TARGET_FUNCTION.

Beware of the position of the attribute with closures and arrow functions, though.

../_images/attributes_for_all.png