Wallogit.com
2017 © Pedro Peláez
Alternative to other annotation parsers. Specifically doctrine/annotations., (*2)
use Donquixote\Annotation\Parser\AnnotationParser;
$docText = '
@Foo(
x = "7",
y = @Bar()
)
@return bool
';
$parser = new AnnotationParser($docText);
if (false !== $position = strpos('@Foo', $docText)) {
$annotation = $parser->doctrineAnnotation($position);
}
There are two main differences: - Annotations are parsed into an abstract syntax tree (AST), before resolving identifiers and constants. - Unlike in Doctrine, there is no such a concept like "annotation classes". An annotation name is just a string, it is not interpreted a class alias., (*3)
This being said, I imagine it not too hard to implement Doctrine's "annotation class" concept on top of this library., (*4)
For now, I created this to use it in my own projects, such as https://drupal.org/project/cfr. For this project I did not need "annotation classes". I might change my mind in the future., (*5)
If others find it useful, let me know!, (*6)