Skip to content

Commit 82c19b1

Browse files
committed
MatchingTypeInSwitchCaseConditionRule - report more precise lines
1 parent 65cc4d8 commit 82c19b1

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/Rules/SwitchConditions/MatchingTypeInSwitchCaseConditionRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scop
4343
$conditionType->describe(VerbosityLevel::value()),
4444
$this->printer->prettyPrintExpr($case->cond),
4545
$caseType->describe(VerbosityLevel::typeOnly())
46-
))->build();
46+
))->line($case->getLine())->build();
4747
}
4848

4949
return $messages;

tests/Rules/SwitchConditions/MatchingTypeInSwitchCaseConditionRuleTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,23 @@ public function testRule(): void
2020
$this->analyse([__DIR__ . '/data/matching-type.php'], [
2121
[
2222
'Switch condition type (1) does not match case condition \'test\' (string).',
23-
8,
23+
11,
2424
],
2525
[
2626
'Switch condition type (1) does not match case condition 1 > 2 (false).',
27-
8,
27+
13,
2828
],
2929
[
3030
'Switch condition type (\'1\') does not match case condition 1 (int).',
31-
19,
31+
20,
3232
],
3333
[
3434
'Switch condition type (\'1\') does not match case condition \'test\' (string).',
35-
19,
35+
22,
3636
],
3737
[
3838
'Switch condition type (\'1\') does not match case condition 1 > 2 (false).',
39-
19,
39+
24,
4040
],
4141
]);
4242
}

0 commit comments

Comments
 (0)