From ecb7789d6a43b0dbfa6d74d8fb898d2286b73dd7 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Mon, 24 Apr 2023 15:16:27 +0200 Subject: [PATCH] Do not include TOKEN_PHPDOC_EOL in node tokens --- src/Parser/PhpDocParser.php | 2 ++ tests/PHPStan/Parser/PhpDocParserTest.php | 18 +++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Parser/PhpDocParser.php b/src/Parser/PhpDocParser.php index bf5b18a3..a3d43212 100644 --- a/src/Parser/PhpDocParser.php +++ b/src/Parser/PhpDocParser.php @@ -133,6 +133,8 @@ private function enrichWithAttributes(TokenIterator $tokens, Ast\Node $tag, int if ($tokensArray[$endIndex][Lexer::TYPE_OFFSET] === Lexer::TOKEN_HORIZONTAL_WS) { $endIndex--; } + } elseif ($tokensArray[$endIndex][Lexer::TYPE_OFFSET] === Lexer::TOKEN_PHPDOC_EOL) { + $endIndex--; } $tag->setAttribute(Ast\Attribute::START_INDEX, $startIndex); diff --git a/tests/PHPStan/Parser/PhpDocParserTest.php b/tests/PHPStan/Parser/PhpDocParserTest.php index 94bc7359..6d089d56 100644 --- a/tests/PHPStan/Parser/PhpDocParserTest.php +++ b/tests/PHPStan/Parser/PhpDocParserTest.php @@ -5540,8 +5540,8 @@ public function dataLinesAndIndexes(): iterable * @param Bar $bar 2nd multi world description */', [ - [2, 2, 2, 16], - [3, 3, 17, 31], + [2, 2, 2, 15], + [3, 3, 17, 30], ], ]; @@ -5560,13 +5560,13 @@ public function dataLinesAndIndexes(): iterable * )) */', [ - [2, 2, 2, 9], - [3, 3, 10, 13], - [4, 4, 14, 43], - [5, 5, 44, 44], - [6, 6, 45, 50], - [7, 7, 51, 51], - [8, 12, 52, 115], + [2, 2, 2, 8], + [3, 3, 10, 12], + [4, 4, 14, 42], + [5, 5, 44, 43], + [6, 6, 45, 49], + [7, 7, 51, 50], + [8, 12, 52, 114], ], ];