Closed samsonasik closed 1 year ago
Hi, this does not make sense for phpdoc-parser. It already supports Doctrine annotations parsing and printing.
Rector should adopt the way phpdoc-parser parses Doctrine annotations, meaning all of this code could be deleted (including SpacelessPhpDocTagNode):
The reason why Rector currently uses SpacelessPhpDocTagNode is instead solved here: https://github.com/phpstan/phpdoc-parser/blob/4a1ab8e11e9957f9cc9f89f87a7c912489f08119/src/Ast/PhpDoc/PhpDocTagNode.php#L29-L31
As an alternative solution, you can use your current SpacelessPhpDocTagNode and transform it into something phpdoc-parser understands, use these classes: https://github.com/phpstan/phpdoc-parser/tree/1.23.x/src/Ast/PhpDoc/Doctrine
@ondrejmirtes ok, I will try, thank you for the suggestion 👍
@ondrejmirtes since the
Printer
class isfinal
, in rector-src for usecase of our customSpacelessPhpDocTagNode
for FQCN doctrine use, I add this to thePhpDoc
namespace so can be used on rector-src to avoid space:https://github.com/rectorphp/rector-src/pull/4573#discussion_r1274786024 . We can't use
parseDoctrineAnnotations
flag on extendedPhpDocParser
athttps://github.com/rectorphp/rector-src/blob/729f03b6e9abccb7c4d7a4515e4dfed61e725e71/packages/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php#L57-L58
as it cause invalid output: