Skip to content

Commit d553fb3

Browse files
committed
Failing test for top level scope
1 parent 10dfba4 commit d553fb3

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

tests/PHPStan/Rules/DeadCode/UnreachableStatementNextStatementsRuleTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,22 @@ public function testRule(): void
7373
]);
7474
}
7575

76+
public function testRuleTopLevel(): void
77+
{
78+
$this->analyse([__DIR__ . '/data/multiple_unreachable_top_level.php'], [
79+
[
80+
'First unreachable',
81+
9,
82+
],
83+
[
84+
'Another unreachable',
85+
10,
86+
],
87+
[
88+
'Another unreachable',
89+
17,
90+
],
91+
]);
92+
}
93+
7694
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace MultipleUnreachableTopLevel;
4+
5+
if (true) {
6+
return 1;
7+
}
8+
9+
echo 'statement 1';
10+
echo 'statement 2';
11+
12+
function func()
13+
{
14+
echo 'statement 3';
15+
}
16+
17+
echo func();

0 commit comments

Comments
 (0)