Maslosoft Addendum Logo Maslosoft Addendum Documentation
Easy to use php annotations

Edit

Built-in annotations

Addendum contains several built-in annotation, which are meant to be used on other annotations. These define constraints of annotations usage.

Conflicts

Disallow annotation if some other annotation exists. This is to avoid using conflicting annotations.

This annotation can only be used on other annotation classes. Only annotation name should be used here, not annotation class name.

Do not use class literals here. Only annotation name as string is recommended.

Assume we are defining MyAnnotation annotation, and want to forbid using this annotation with CombinedAnnotation. To achieve this use Conflicts annotation:

@Conflicts('Combined')

Ignored

Use this annotation to completely ignore method or property metadata. This should be used on components. This can also be used to explicitly mark that entity should be not ignored.

Examples:

Ignore field or method.

@Ignored()

Explicitly mark method or property as not ignored. This might be useful to inform other developers that method or property must be annotated.

@Ignored(false)

Target

Annotation target annotation This allow limiting annotation use for properties, class, method or concrete type Valid values are

  • class - limit annotation for class only
  • method - limit annotation for method only
  • property - limit annotation for property only
  • nested - set this to allow use of annotation only as nested annotation
  • Any existing class name - to restrict use of annotation only on concrete class or its descendants

Examples:

Allow only on selected class and subclasses

@Target(Some\Target\ClassName)

When use statement for Some\Target\ClassName is provided, it could be shortened:

@Target(ClassName)

Several targets can be specified. Only on this class and subclasses - on properties:

@Target(Some\Target\ClassName)
@Target('property')

Only on this class and subclasses - on methods:

@Target('Some\Target\ClassName')
@Target('method')

On methods and properties:

@Target('method')
@Target('property')