Declaring Attribute Classes
It is recommended to define a separate class for each attribute. In the simplest
case, an empty class with the Example #1 Simple Attribute Class
To restrict the types of declarations an attribute can be applied to,
pass a bitmask as the first argument to the Example #2 Using target specification to restrict where attributes can be used
Declaring MyAttribute on another type will now throw an exception during the call to ReflectionAttribute::newInstance The following targets can be specified:
By default, an attribute can only be used once per declaration. To allow
an attribute to be repeatable, specify it in the bitmask of the
Example #3 Using IS_REPEATABLE to allow attribute on a declaration multiple times
|