From 4e35f5907fa7c28bb3316671197cfa11a6cb3612 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Tue, 3 Jan 2023 10:50:29 +0100 Subject: [PATCH] Add non regression test for #8620 --- .../Analyser/NodeScopeResolverTest.php | 1 + .../DeadCode/UnreachableStatementRuleTest.php | 6 ++++ .../PHPStan/Rules/DeadCode/data/bug-8620.php | 33 +++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 tests/PHPStan/Rules/DeadCode/data/bug-8620.php diff --git a/tests/PHPStan/Analyser/NodeScopeResolverTest.php b/tests/PHPStan/Analyser/NodeScopeResolverTest.php index eb53bed1ef..e5d593210c 100644 --- a/tests/PHPStan/Analyser/NodeScopeResolverTest.php +++ b/tests/PHPStan/Analyser/NodeScopeResolverTest.php @@ -1155,6 +1155,7 @@ public function dataFileAsserts(): iterable } yield from $this->gatherAssertTypes(__DIR__ . '/data/pathinfo.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-8568.php'); + yield from $this->gatherAssertTypes(__DIR__ . '/../Rules/DeadCode/data/bug-8620.php'); } /** diff --git a/tests/PHPStan/Rules/DeadCode/UnreachableStatementRuleTest.php b/tests/PHPStan/Rules/DeadCode/UnreachableStatementRuleTest.php index 4cf373673f..d06ad023ef 100644 --- a/tests/PHPStan/Rules/DeadCode/UnreachableStatementRuleTest.php +++ b/tests/PHPStan/Rules/DeadCode/UnreachableStatementRuleTest.php @@ -131,4 +131,10 @@ public function testBug7188(): void ]); } + public function testBug8620(): void + { + $this->treatPhpDocTypesAsCertain = true; + $this->analyse([__DIR__ . '/data/bug-8620.php'], []); + } + } diff --git a/tests/PHPStan/Rules/DeadCode/data/bug-8620.php b/tests/PHPStan/Rules/DeadCode/data/bug-8620.php new file mode 100644 index 0000000000..cad6d811c2 --- /dev/null +++ b/tests/PHPStan/Rules/DeadCode/data/bug-8620.php @@ -0,0 +1,33 @@ +