Skip to content

Commit

Permalink
IgnoreLexer: exclude all parentheses in T_OTHER
Browse files Browse the repository at this point in the history
  • Loading branch information
janedbal authored and ondrejmirtes committed May 24, 2024
1 parent 0055aac commit da6e9ae
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Analyser/Ignore/IgnoreLexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ private function generateRegexp(): string
self::TOKEN_OPEN_PARENTHESIS => '\\(',
self::TOKEN_CLOSE_PARENTHESIS => '\\)',

// everything except whitespaces, TOKEN_CLOSE_PARENTHESIS
self::TOKEN_OTHER => '(?:(?!\\))[^\\s])++',
// everything except whitespaces and parentheses
self::TOKEN_OTHER => '([^\\s\\)\\(])++',
];

foreach ($patterns as $type => &$pattern) {
Expand Down
24 changes: 24 additions & 0 deletions tests/PHPStan/Parser/RichParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,30 @@ public function dataLinesToIgnore(): iterable
2 => ['identifier'],
],
];

yield [
'<?php' . PHP_EOL .
'test(); // @phpstan-ignore identifier (var_export() is used intentionally)' . PHP_EOL,
[
2 => ['identifier'],
],
];

yield [
'<?php' . PHP_EOL .
'test(); // @phpstan-ignore identifier (FileSystem::write() does not support LOCK_EX)' . PHP_EOL,
[
2 => ['identifier'],
],
];

yield [
'<?php' . PHP_EOL .
'test(); // @phpstan-ignore identifier (type ensured in self::createClient())' . PHP_EOL,
[
2 => ['identifier'],
],
];
}

/**
Expand Down

0 comments on commit da6e9ae

Please sign in to comment.