Repository navigation
Convert Doctrine annotations with arguments on the next line - #8907
Open
ondrejmirtes wants to merge 1 commit into
Open
ondrejmirtes wants to merge 1 commit into
ondrejmirtes wants to merge 1 commit into
Conversation
Doctrine skips the whitespace and "*" between the tag name and "(", so
@action with (id="value") on the next line has the same arguments as
@action(id="value"). phpdoc-parser reads the arguments only when "("
follows the tag name directly, and AnnotationToAttributeRector created an
attribute without arguments and dropped them.
For a tag of an annotation class, the decorator now parses the arguments on
the next line. When they do not parse, e.g. a nested annotation on its own
line, the tag stays as it is.
Amp-Thread-ID: https://ampcode.com/threads/T-01a197b0-0078-7305-a757-b15baab1dfdf
Member
|
@bbrala could you verify this? Thank you |
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.
Merge this if you think it’s worth it, I’m not sure personally.
Follow-up to #8881, reported by @bbrala in #8881 (comment).
Doctrine skips the whitespace and
*between the tag name and(. So these two annotations have the same arguments:phpdoc-parser reads the arguments only when
(comes directly after the tag name.AnnotationToAttributeRectorturned the first annotation into#[Action]and dropped the arguments. This happened before #8881 too: Rector 2.8.3 does the same.For a tag of an annotation class,
DoctrineAnnotationDecoratornow parses the arguments on the next line with phpdoc-parser. When they do not parse, Rector keeps the tag as it is and does not create an attribute without arguments. An example is a nested annotation on its own line. Before, this made two unrelated attributes.The change is in Rector and not in phpdoc-parser. phpdoc-parser does not know which tags are annotations: a tag like
@todowith(maybe) fix thison the next line would become a Doctrine node.