Attribute Without Class

no-email (Damien Seguy), Damien Seguy
Mon, 20 May 2024 00:00:00 +0000

PHP 8.0 has an attribute feature, where extra options may be attached to various structures. The option is defined as a class, and is accessible via the Reflection API, and the getAttribute() method.
The attribute class is not necessary, per se. As long at the attribute is not instanciated, it is possible to rely only on the name of the attribute to handle specific behaviors.