Skip to content

Commit

Permalink
Parsing @phpstan-ignore - allow comma in description
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed May 3, 2024
1 parent 3361c84 commit c84a072
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Parser/RichParser.php
Expand Up @@ -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) {
Expand Down
8 changes: 8 additions & 0 deletions tests/PHPStan/Parser/RichParserTest.php
Expand Up @@ -85,6 +85,14 @@ public function dataLinesToIgnore(): iterable
],
];

yield [
'<?php' . PHP_EOL .
'test(); // @phpstan-ignore return.ref, return.non (foo, because...)',
[
2 => ['return.ref', 'return.non'],
],
];

yield [
'<?php' . PHP_EOL .
'test(); // @phpstan-ignore return.ref, return.non čičí',
Expand Down

0 comments on commit c84a072

Please sign in to comment.