diff --git a/src/Psalm/Internal/Analyzer/CommentAnalyzer.php b/src/Psalm/Internal/Analyzer/CommentAnalyzer.php index b72b9a86cd6..2edf07eb841 100644 --- a/src/Psalm/Internal/Analyzer/CommentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/CommentAnalyzer.php @@ -76,7 +76,9 @@ public static function getTypeFromComment( $type_start = $offset + $comment->getFilePos(); $type_end = $type_start + strlen($line_parts[0]); - $line_parts[0] = str_replace("\n", '', preg_replace('@^[ \t]*\*@m', '', $line_parts[0])); + $line_parts[0] = preg_replace('@^[ \t]*\*@m', '', $line_parts[0]); + $line_parts[0] = preg_replace('/,\n\s+\}/', '}', $line_parts[0]); + $line_parts[0] = str_replace("\n", '', $line_parts[0]); if ($line_parts[0] === '' || ($line_parts[0][0] === '$' @@ -308,7 +310,9 @@ public static function extractFunctionDocblockInfo(PhpParser\Comment\Doc $commen $start = $offset + $comment->getFilePos(); $end = $start + strlen($line_parts[0]); - $line_parts[0] = str_replace("\n", '', preg_replace('@^[ \t]*\*@m', '', $line_parts[0])); + $line_parts[0] = preg_replace('@^[ \t]*\*@m', '', $line_parts[0]); + $line_parts[0] = preg_replace('/,\n\s+\}/', '}', $line_parts[0]); + $line_parts[0] = str_replace("\n", '', $line_parts[0]); if ($line_parts[0] === '' || ($line_parts[0][0] === '$' diff --git a/tests/AnnotationTest.php b/tests/AnnotationTest.php index acfea60fe41..3d484ff5573 100644 --- a/tests/AnnotationTest.php +++ b/tests/AnnotationTest.php @@ -1014,6 +1014,30 @@ function f(A $a) : void { $a->bar(); }' ], + 'allowClosingComma' => [ + ' "", "bar" => "", "baz" => ""];' + ], ]; }