Skip to content

Commit 2862a7b

Browse files
committed
Changed linesToIgnore attribute format
1 parent 4c4f9c8 commit 2862a7b

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/Analyser/FileAnalyser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,10 @@ private function getLinesToIgnoreFromTokens(array $nodes): array
242242
return [];
243243
}
244244

245-
/** @var int[] $tokenLines */
245+
/** @var array<int, list<string>|null> $tokenLines */
246246
$tokenLines = $nodes[0]->getAttribute('linesToIgnore', []);
247247
$lines = [];
248-
foreach ($tokenLines as $tokenLine) {
248+
foreach (array_keys($tokenLines) as $tokenLine) {
249249
$lines[$tokenLine] = true;
250250
}
251251

src/Parser/RichParser.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
use PHPStan\File\FileReader;
1212
use PHPStan\ShouldNotHappenException;
1313
use function array_filter;
14-
use function array_values;
1514
use function is_string;
1615
use function strpos;
1716
use function substr_count;
17+
use const ARRAY_FILTER_USE_KEY;
1818
use const T_COMMENT;
1919
use const T_DOC_COMMENT;
2020

@@ -78,15 +78,15 @@ public function parseString(string $sourceCode): array
7878
}
7979

8080
foreach ($traitCollectingVisitor->traits as $trait) {
81-
$trait->setAttribute('linesToIgnore', array_values(array_filter($linesToIgnore, static fn (int $line): bool => $line >= $trait->getStartLine() && $line <= $trait->getEndLine())));
81+
$trait->setAttribute('linesToIgnore', array_filter($linesToIgnore, static fn (int $line): bool => $line >= $trait->getStartLine() && $line <= $trait->getEndLine(), ARRAY_FILTER_USE_KEY));
8282
}
8383

8484
return $nodes;
8585
}
8686

8787
/**
8888
* @param mixed[] $tokens
89-
* @return int[]
89+
* @return array<int, list<string>|null>
9090
*/
9191
private function getLinesToIgnore(array $tokens): array
9292
{
@@ -111,7 +111,7 @@ private function getLinesToIgnore(array $tokens): array
111111

112112
$line += substr_count($token[1], "\n");
113113

114-
$lines[] = $line;
114+
$lines[$line] = null;
115115
}
116116

117117
return $lines;

0 commit comments

Comments
 (0)