Repository navigation
Convert Doctrine annotations from phpdoc-parser nodes, remove StaticDoctrineAnnotationParser - #8881
Merged
Merged
Conversation
samsonasik
reviewed
Oct 28, 2026
ondrejmirtes
marked this pull request as draft
October 28, 2026 19:17
samsonasik
reviewed
Oct 28, 2026
ondrejmirtes
force-pushed
the
doctrine-native-nodes
branch
3 times, most recently
from
October 28, 2026 20:10
1293dde to
54899d0
Compare
ondrejmirtes
marked this pull request as ready for review
October 28, 2026 21:58
…octrineAnnotationParser Amp-Thread-ID: https://ampcode.com/threads/T-01a17930-0285-73c5-a957-4325c77aa1b2
ondrejmirtes
force-pushed
the
doctrine-native-nodes
branch
from
October 29, 2026 05:56
54899d0 to
1815799
Compare
Contributor
Author
|
This is ready. |
Member
|
Thanks the updates 👍 Great to have these glitches resolve out of the box. I think we can leave the invalid docblock in Doctrine tags behind. Let's merge 🚀 |
Contributor
|
MIght regres drupal rector a bit this, not 100% sure yet. We used part of this code to do annotation to attribute conversion for Drupal |
Member
|
We still do annotation to attributes conversion as before. |
Contributor
|
Yeah will investigate and post back if there work in rector. |
Contributor
|
Well, seems this is not really an issue, but i did find a discrepancy between doctrines parser and rector. https://getrector.com/demo/0ffc42df-7754-41b2-969e-b8e30dde6c1e But it seems this might not be a rector issue but a phpstan issue ;x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
And now a dessert 😉
phpdoc-parser already parses Doctrine annotations (since 1.22.0) to
DoctrineTagValueNode. Before,DoctrineAnnotationDecoratorprinted these nodes back to a string and parsed the string again withStaticDoctrineAnnotationParser,ArrayParserandPlainValueParser. Now the decorator converts the phpdoc-parser nodes directly toDoctrineAnnotationTagValueNode,CurlyListNode,ArrayItemNodeandStringNode. The public API does not change.Removed:
StaticDoctrineAnnotationParser,ArrayParser,PlainValueParser,NextTokenType, and the@\FQNtext and description splitting inDoctrineAnnotationDecorator.Changes in behaviour. Rector now uses the phpdoc-parser and Doctrine semantics:
*line prefixes in the docblock node, as in doctrine/annotations. When Rector converts it to an attribute, it removes the prefixes.{}list in a{}list is aCurlyListNode. Before, it was a PHP array.{1="Foo"}.ArrayItemNodenow prints integer keys. Before, a changed annotation lost them.null. Before, the key was0.@Foo('bar'),@Foo("key"="value"). phpdoc-parser givesInvalidTagValueNodefor them, and Rector does not change them. Fixtures are updated.Needs rectorphp/rector-doctrine#543 to be merged first.