Attribute Class

This is a native PHP attribute, which tells the engine that a class is a PHP attribute.

This attribute (sic) is not necessary to make a class a valid attribute. Yet, it is recommended to use it and make the classes explicitly attributes.

<?php

#[Attribute]
class MyAttribute { }

#[MyAttribute]
class MyClass { }

?>

Documentation

See also Attributes in PHP 8

Added in PHP 8.1+