Build an AST (Abstract syntax tree), before resolving classes and constants?
Author: donquixoteCreated Aug 4, 2017Updated Jul 9, 2021
LabelsquestionImprovement
Hello there, every time I looked at the Doctrine annotation discovery (today, and many years ago), it made me wonder: How would I implement an annotation parser?
Currently, \Doctrine\Common\Annotations\DocParser does two things at once:
- Parse annotations in the doc comment.
- Resolve class aliases and constants.
This makes the component more complex than it needs to be.
Instead, this could be split up:
- One component to parse the doc comment as an abstract syntax tree.
- A separate component to resolve class aliases and constants.
For absolutely no reason, I am posting a link to my own annotation parser, which follows this philosophy (but does not care about annotation classes). https://github.com/donquixote/annotation-parser
This entire issue is "food for thought". I currently do not have a personal use case where I would absolutely need this change.
Source: doctrine/annotations