Skip to content

Commit

Permalink
Changed linesToIgnore attribute format
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jul 25, 2023
1 parent 4c4f9c8 commit 2862a7b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Analyser/FileAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@ private function getLinesToIgnoreFromTokens(array $nodes): array
return [];
}

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

Expand Down
8 changes: 4 additions & 4 deletions src/Parser/RichParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
use PHPStan\File\FileReader;
use PHPStan\ShouldNotHappenException;
use function array_filter;
use function array_values;
use function is_string;
use function strpos;
use function substr_count;
use const ARRAY_FILTER_USE_KEY;
use const T_COMMENT;
use const T_DOC_COMMENT;

Expand Down Expand Up @@ -78,15 +78,15 @@ public function parseString(string $sourceCode): array
}

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

return $nodes;
}

/**
* @param mixed[] $tokens
* @return int[]
* @return array<int, list<string>|null>
*/
private function getLinesToIgnore(array $tokens): array
{
Expand All @@ -111,7 +111,7 @@ private function getLinesToIgnore(array $tokens): array

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

$lines[] = $line;
$lines[$line] = null;
}

return $lines;
Expand Down

0 comments on commit 2862a7b

Please sign in to comment.