Skip to content

Commit e1aa8cb

Browse files
Fix issues identified by Psalm
1 parent c8dd7c9 commit e1aa8cb

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

.psalm/baseline.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,4 @@
198198
<code>assert(isset($parameter-&gt;var-&gt;name))</code>
199199
</RedundantConditionGivenDocblockType>
200200
</file>
201-
<file src="src/StaticAnalysis/IgnoredLinesFindingVisitor.php">
202-
<InvalidPropertyAssignmentValue occurrences="1">
203-
<code>$this-&gt;ignoredLines</code>
204-
</InvalidPropertyAssignmentValue>
205-
</file>
206201
</files>

src/StaticAnalysis/IgnoredLinesFindingVisitor.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
namespace SebastianBergmann\CodeCoverage\StaticAnalysis;
1111

1212
use function assert;
13-
use function range;
1413
use PhpParser\Node;
1514
use PhpParser\Node\Attribute;
1615
use PhpParser\Node\Stmt\Class_;
@@ -80,7 +79,7 @@ public function enterNode(Node $node): void
8079
$attributeGroup = $node->getAttribute('parent');
8180
$attributedNode = $attributeGroup->getAttribute('parent');
8281

83-
foreach (range($attributedNode->getStartLine(), $attributedNode->getEndLine()) as $line) {
82+
for ($line = $attributedNode->getStartLine(); $line <= $attributedNode->getEndLine(); $line++) {
8483
$this->ignoredLines[] = $line;
8584
}
8685

@@ -91,7 +90,7 @@ public function enterNode(Node $node): void
9190
}
9291

9392
/**
94-
* @psalm-return list<int>
93+
* @psalm-return array<int>
9594
*/
9695
public function ignoredLines(): array
9796
{
@@ -107,13 +106,13 @@ private function processDocComment(Node $node): void
107106
}
108107

109108
if (str_contains($docComment->getText(), '@codeCoverageIgnore')) {
110-
foreach (range($node->getStartLine(), $node->getEndLine()) as $line) {
109+
for ($line = $node->getStartLine(); $line <= $node->getEndLine(); $line++) {
111110
$this->ignoredLines[] = $line;
112111
}
113112
}
114113

115114
if ($this->ignoreDeprecated && str_contains($docComment->getText(), '@deprecated')) {
116-
foreach (range($node->getStartLine(), $node->getEndLine()) as $line) {
115+
for ($line = $node->getStartLine(); $line <= $node->getEndLine(); $line++) {
117116
$this->ignoredLines[] = $line;
118117
}
119118
}

0 commit comments

Comments
 (0)