From 0cca1ec0694c7e802cc788bfcaf161c53599e651 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Fri, 9 Jan 2026 17:06:57 +0100 Subject: [PATCH] Added regression test --- ...odStatementWithoutImpurePointsRuleTest.php | 5 +++ .../PHPStan/Rules/DeadCode/data/bug-13956.php | 31 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/PHPStan/Rules/DeadCode/data/bug-13956.php diff --git a/tests/PHPStan/Rules/DeadCode/CallToMethodStatementWithoutImpurePointsRuleTest.php b/tests/PHPStan/Rules/DeadCode/CallToMethodStatementWithoutImpurePointsRuleTest.php index 7b705df880..b269005969 100644 --- a/tests/PHPStan/Rules/DeadCode/CallToMethodStatementWithoutImpurePointsRuleTest.php +++ b/tests/PHPStan/Rules/DeadCode/CallToMethodStatementWithoutImpurePointsRuleTest.php @@ -92,6 +92,11 @@ public function testBug12379(): void $this->analyse([__DIR__ . '/data/bug-12379.php'], []); } + public function testBug13956(): void + { + $this->analyse([__DIR__ . '/data/bug-13956.php'], []); + } + #[RequiresPhp('>= 8.5')] public function testPipeOperator(): void { diff --git a/tests/PHPStan/Rules/DeadCode/data/bug-13956.php b/tests/PHPStan/Rules/DeadCode/data/bug-13956.php new file mode 100644 index 0000000000..0a5bb1e645 --- /dev/null +++ b/tests/PHPStan/Rules/DeadCode/data/bug-13956.php @@ -0,0 +1,31 @@ + $successMessages + */ + public function __construct( + private array $successMessages = [], + ) { + } + + public function addSuccess(string $message): self + { + $this->successMessages[] = $message; + + return $this; + } + + /** + * @return string[] + */ + public function getSuccessMessages(): array { + return $this->successMessages; + } +} + +function doBar(Foo $foo):void { + $foo->addSuccess("Hello World"); +}