GenericAnnotationParser
in package
implements
ParserInterface
Generic annotation parser
Expects registration of AnnotationInterface instances. Such instances will be passed annotation content to their initialize() method, which they are then responsible for parsing.
Interfaces, Classes, Traits and Enums
Table of Contents
- $aliases : array<string|int, mixed>
- $annotationNames : array<string|int, mixed>
- $annotations : array<string|int, AnnotationInterface>
- hasAnnotation() : bool
- Checks if the manager has annotations for a class
- onCreateAnnotation() : false|AnnotationInterface
- Listen to onCreateAnnotation, and attempt to return an annotation object instance.
- registerAnnotation() : void
- Register annotations
- registerAnnotations() : GenericAnnotationParser
- Register many annotations at once
- setAlias() : GenericAnnotationParser
- Alias an annotation name
- hasAlias() : bool
- Do we have an alias by the provided name?
- normalizeAlias() : string
- Normalize an alias name
- resolveAlias() : string
- Resolve an alias to a class name
Properties
$aliases
protected
array<string|int, mixed>
$aliases
= []
$annotationNames
protected
array<string|int, mixed>
$annotationNames
= []
$annotations
protected
array<string|int, AnnotationInterface>
$annotations
= []
Methods
hasAnnotation()
Checks if the manager has annotations for a class
public
hasAnnotation(string $class) : bool
Parameters
- $class : string
Return values
bool —onCreateAnnotation()
Listen to onCreateAnnotation, and attempt to return an annotation object instance.
public
onCreateAnnotation(EventInterface $e) : false|AnnotationInterface
If the annotation class or alias is not registered, immediately returns false. Otherwise, resolves the class, clones it, and, if any content is present, calls with the content.
Parameters
- $e : EventInterface
Return values
false|AnnotationInterface —registerAnnotation()
Register annotations
public
registerAnnotation(string|AnnotationInterface $annotation) : void
Parameters
- $annotation : string|AnnotationInterface
-
String class name of an AnnotationInterface implementation, or actual instance
Tags
Return values
void —registerAnnotations()
Register many annotations at once
public
registerAnnotations(array<string|int, mixed>|Traversable $annotations) : GenericAnnotationParser
Parameters
- $annotations : array<string|int, mixed>|Traversable
Tags
Return values
GenericAnnotationParser —setAlias()
Alias an annotation name
public
setAlias(string $alias, string $class) : GenericAnnotationParser
Parameters
- $alias : string
- $class : string
-
May be either a registered annotation name or another alias
Tags
Return values
GenericAnnotationParser —hasAlias()
Do we have an alias by the provided name?
protected
hasAlias(string $alias) : bool
Parameters
- $alias : string
Return values
bool —normalizeAlias()
Normalize an alias name
protected
normalizeAlias(string $alias) : string
Parameters
- $alias : string
Return values
string —resolveAlias()
Resolve an alias to a class name
protected
resolveAlias(string $alias) : string
Parameters
- $alias : string