diff --git a/src/Parser/RichParser.php b/src/Parser/RichParser.php index b21729086d..f7ef05a228 100644 --- a/src/Parser/RichParser.php +++ b/src/Parser/RichParser.php @@ -299,7 +299,7 @@ private function parseIdentifiers(string $text, int $ignorePos): array if ($i === 0) { throw new IgnoreParseException('First token is not an identifier', $tokenLine); } - if ($tokenType === IgnoreLexer::TOKEN_COMMA) { + if ($tokenType === IgnoreLexer::TOKEN_COMMA && $depth === 0) { throw new IgnoreParseException('Unexpected comma (,)', $tokenLine); } if ($tokenType === IgnoreLexer::TOKEN_CLOSE_PARENTHESIS) { diff --git a/tests/PHPStan/Parser/RichParserTest.php b/tests/PHPStan/Parser/RichParserTest.php index 228e562277..08a15b480b 100644 --- a/tests/PHPStan/Parser/RichParserTest.php +++ b/tests/PHPStan/Parser/RichParserTest.php @@ -85,6 +85,14 @@ public function dataLinesToIgnore(): iterable ], ]; + yield [ + ' ['return.ref', 'return.non'], + ], + ]; + yield [ '