doctrine / doctrine/annotations

Build an AST (Abstract syntax tree), before resolving classes and constants?

Open
#139 5 comments 2 reactions 0 assignees View on GitHub
Improvement question
Dominant language
PHP
Stars
6.7k
Forks
234
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.