Skip to content

Commit da6e9ae

Browse files
janedbalondrejmirtes
authored andcommitted
IgnoreLexer: exclude all parentheses in T_OTHER
1 parent 0055aac commit da6e9ae

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/Analyser/Ignore/IgnoreLexer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ private function generateRegexp(): string
8383
self::TOKEN_OPEN_PARENTHESIS => '\\(',
8484
self::TOKEN_CLOSE_PARENTHESIS => '\\)',
8585

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

9090
foreach ($patterns as $type => &$pattern) {

tests/PHPStan/Parser/RichParserTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,30 @@ public function dataLinesToIgnore(): iterable
237237
2 => ['identifier'],
238238
],
239239
];
240+
241+
yield [
242+
'<?php' . PHP_EOL .
243+
'test(); // @phpstan-ignore identifier (var_export() is used intentionally)' . PHP_EOL,
244+
[
245+
2 => ['identifier'],
246+
],
247+
];
248+
249+
yield [
250+
'<?php' . PHP_EOL .
251+
'test(); // @phpstan-ignore identifier (FileSystem::write() does not support LOCK_EX)' . PHP_EOL,
252+
[
253+
2 => ['identifier'],
254+
],
255+
];
256+
257+
yield [
258+
'<?php' . PHP_EOL .
259+
'test(); // @phpstan-ignore identifier (type ensured in self::createClient())' . PHP_EOL,
260+
[
261+
2 => ['identifier'],
262+
],
263+
];
240264
}
241265

242266
/**

0 commit comments

Comments
 (0)