diff --git a/src/Analyser/NodeScopeResolver.php b/src/Analyser/NodeScopeResolver.php
index dbaa69adfb..17755a6da5 100644
--- a/src/Analyser/NodeScopeResolver.php
+++ b/src/Analyser/NodeScopeResolver.php
@@ -6765,7 +6765,7 @@ private function getNextUnreachableStatements(array $nodes, bool $earlyBinding):
$stmts[] = $node;
continue;
}
- if ($node instanceof Node\Stmt\Nop) {
+ if ($node instanceof Node\Stmt\Nop || $node instanceof Node\Stmt\InlineHTML) {
continue;
}
if (!$node instanceof Node\Stmt) {
diff --git a/tests/PHPStan/Rules/DeadCode/UnreachableStatementRuleTest.php b/tests/PHPStan/Rules/DeadCode/UnreachableStatementRuleTest.php
index 87e0dd0c11..1973234d60 100644
--- a/tests/PHPStan/Rules/DeadCode/UnreachableStatementRuleTest.php
+++ b/tests/PHPStan/Rules/DeadCode/UnreachableStatementRuleTest.php
@@ -229,6 +229,17 @@ public function testBug11992(): void
$this->analyse([__DIR__ . '/data/bug-11992.php'], []);
}
+ public function testBug7531(): void
+ {
+ $this->treatPhpDocTypesAsCertain = false;
+ $this->analyse([__DIR__ . '/data/bug-7531.php'], [
+ [
+ 'Unreachable statement - code above always terminates.',
+ 22,
+ ],
+ ]);
+ }
+
public function testMultipleUnreachable(): void
{
$this->treatPhpDocTypesAsCertain = true;
diff --git a/tests/PHPStan/Rules/DeadCode/data/bug-7531.php b/tests/PHPStan/Rules/DeadCode/data/bug-7531.php
new file mode 100644
index 0000000000..e30e32d60e
--- /dev/null
+++ b/tests/PHPStan/Rules/DeadCode/data/bug-7531.php
@@ -0,0 +1,24 @@
+
+
+
+ $compareTo) : ?>
+ some xml data
+
+
+
+
+
+
+ $compareTo) : ?>
+ some xml data
+
+
+
+
+