From 98d04a40e3cfb0a9ebc3ea814d0a3188d836e45f Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Sun, 27 Jul 2025 22:32:51 +0200 Subject: [PATCH] Add non regression test --- .../BooleanAndConstantConditionRuleTest.php | 7 +++++ .../Rules/Comparison/data/bug-4284.php | 30 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 tests/PHPStan/Rules/Comparison/data/bug-4284.php diff --git a/tests/PHPStan/Rules/Comparison/BooleanAndConstantConditionRuleTest.php b/tests/PHPStan/Rules/Comparison/BooleanAndConstantConditionRuleTest.php index e8744f7f51..d0e736dc64 100644 --- a/tests/PHPStan/Rules/Comparison/BooleanAndConstantConditionRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/BooleanAndConstantConditionRuleTest.php @@ -425,6 +425,13 @@ public function testReportAlwaysTrueInLastCondition(bool $reportAlwaysTrueInLast $this->analyse([__DIR__ . '/data/boolean-and-report-always-true-last-condition.php'], $expectedErrors); } + public function testBug4284(): void + { + $this->treatPhpDocTypesAsCertain = true; + $this->reportAlwaysTrueInLastCondition = true; + $this->analyse([__DIR__ . '/data/bug-4284.php'], []); + } + public function testBug5365(): void { $this->treatPhpDocTypesAsCertain = true; diff --git a/tests/PHPStan/Rules/Comparison/data/bug-4284.php b/tests/PHPStan/Rules/Comparison/data/bug-4284.php new file mode 100644 index 0000000000..4fba5d5991 --- /dev/null +++ b/tests/PHPStan/Rules/Comparison/data/bug-4284.php @@ -0,0 +1,30 @@ +