Skip to content

Commit 2c625cd

Browse files
committed
Adjust test
1 parent 2d7efbc commit 2c625cd

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

tests/PHPStan/Rules/DeadCode/UnreachableStatementNextStatementsRuleTest.php

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
use PHPStan\Rules\Rule;
99
use PHPStan\Rules\RuleErrorBuilder;
1010
use PHPStan\Testing\RuleTestCase;
11-
use function count;
12-
use function sprintf;
1311

1412
/**
1513
* @extends RuleTestCase<Rule>
@@ -34,13 +32,20 @@ public function getNodeType(): string
3432
*/
3533
public function processNode(Node $node, Scope $scope): array
3634
{
37-
$totalNextStatements = count($node->getNextStatements());
38-
39-
return [
40-
RuleErrorBuilder::message(sprintf('It has %d stmts over first unreachable statements', $totalNextStatements))
41-
->identifier('tests.total.next.unreachable.statement')
35+
$errors = [
36+
RuleErrorBuilder::message('First unreachable')
37+
->identifier('tests.nextUnreachableStatements')
4238
->build(),
4339
];
40+
41+
foreach ($node->getNextStatements() as $nextStatement) {
42+
$errors[] = RuleErrorBuilder::message('Another unreachable')
43+
->line($nextStatement->getStartLine())
44+
->identifier('tests.nextUnreachableStatements')
45+
->build();
46+
}
47+
48+
return $errors;
4449
}
4550

4651
};
@@ -50,9 +55,21 @@ public function testRule(): void
5055
{
5156
$this->analyse([__DIR__ . '/data/multiple_unreachable.php'], [
5257
[
53-
'It has 3 stmts over first unreachable statements',
58+
'First unreachable',
5459
14,
5560
],
61+
[
62+
'Another unreachable',
63+
15,
64+
],
65+
[
66+
'Another unreachable',
67+
17,
68+
],
69+
[
70+
'Another unreachable',
71+
22,
72+
],
5673
]);
5774
}
5875

0 commit comments

Comments
 (0)