Attribute
final class Attribute (View source)
Attributes offer the ability to add structured, machine-readable metadata information on declarations in code: Classes, methods, functions, parameters, properties and class constants can be the target of an attribute. The metadata defined by attributes can then be inspected at runtime using the Reflection APIs. Attributes could therefore be thought of as a configuration language embedded directly into code.
Constants
| TARGET_CLASS |
Marks that attribute declaration is allowed only in classes. |
| TARGET_FUNCTION |
Marks that attribute declaration is allowed only in functions. |
| TARGET_METHOD |
Marks that attribute declaration is allowed only in class methods. |
| TARGET_PROPERTY |
Marks that attribute declaration is allowed only in class properties. |
| TARGET_CLASS_CONSTANT |
Marks that attribute declaration is allowed only in class constants. |
| TARGET_PARAMETER |
Marks that attribute declaration is allowed only in function or method parameters. |
|
TARGET_CONSTANT
Since: 8.5
|
Marks that attribute declaration is allowed only in constants. |
| TARGET_ALL |
Marks that attribute declaration is allowed anywhere. |
| IS_REPEATABLE |
Notes that an attribute declaration in the same place is
allowed multiple times. |
Properties
| int | $flags |
Methods
Construct a new Attribute instance
Details
__construct(int $flags = Attribute::TARGET_ALL)
Construct a new Attribute instance
Constructs a new Attribute instance.