File tree Expand file tree Collapse file tree 1 file changed +25
-8
lines changed
tests/PHPStan/Rules/DeadCode Expand file tree Collapse file tree 1 file changed +25
-8
lines changed Original file line number Diff line number Diff line change 88use PHPStan \Rules \Rule ;
99use PHPStan \Rules \RuleErrorBuilder ;
1010use 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
You can’t perform that action at this time.
0 commit comments