-
Notifications
You must be signed in to change notification settings - Fork 12
Annotation
The annotation library allows parsing of "annotation" like statements out of docblocks.
Annotation names are expected to resolve to PHP classes which have been annotated with the "@\Weasel\Annotation\Config\Annotations\Annotation" annotation. The resolution of names will make use of any namespace aliasing.
You can parse annotations using the combination of an AnnotationReader and an AnnotationConfigurator. The AnnotationReader providers an interface that allows you to read back the annotation objects for a given class. The Configurator provides the configuration for annotations.
At present the only implementation of AnnotationConfigurator knows about a small number of "built in" annotations, and then expects to be able to use those to configure any further annotations it runs into.
- @Annotation Marks a class as being an annotation
- @AnnotationCreator Allows constructor args or a factory method for creating an annotation object
- @Enum Marks a property as being an enum
- @Parameter Configuration for parameters of an @AnnotationCreator
- @Property A property to be set from the parameters to the annotation
(using w3c XML style EBNFish)
DocAnnotation ::= Annotation S;
Annotation ::= "@" ClassName ("(" Parameters ")")?;
Parameters ::= S* Parameter S* ("," S* Parameter S*)*;
Parameter ::= (QuotedString | Integer | Bool | Float | Annotation | Array);
QuotedString ::= "\"" (NotQuotes | "\"\"")* "\"";
Integer ::= ("+" | "-")? Digits+;
Float ::= ("+" | "-")? Digits+ ( "." Digits+ )? ( ( "e" | "E" ) ( "+" | "-" ) Digits+)?;
Array ::= "{" Parameters "}";
ClassName ::= '\'? Identifier ("\", Identifier)*;
Identifier ::= [a-zA-Z_\x7f-\xff] [a-zA-Z0-9_\x7f-\xff]*;
S ::= ? white space characters ? ;
NotQuotes ::= AllCharacters - "\"";
AllCharacters ::= ? all visible characters ? ;
Digits ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;