From ca7511470ab311243f0dcbcb0e2c89e9ee8cb5e7 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Fri, 9 Jan 2026 07:08:29 +0100 Subject: [PATCH 1/2] Optimize keepVoidType --- src/Analyser/MutatingScope.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Analyser/MutatingScope.php b/src/Analyser/MutatingScope.php index 4bbd20b34f..6ff4f9b033 100644 --- a/src/Analyser/MutatingScope.php +++ b/src/Analyser/MutatingScope.php @@ -2746,6 +2746,7 @@ public function getKeepVoidType(Expr $node): Type ( !$node instanceof FuncCall && !$node instanceof MethodCall + && !$node instanceof Expr\NullsafeMethodCall && !$node instanceof Expr\StaticCall ) || $node->isFirstClassCallable() ) From 4389fb51cc456c387e14e0cf81189292ed9c88e8 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Fri, 9 Jan 2026 07:14:33 +0100 Subject: [PATCH 2/2] added test --- .../CallToFunctionParametersRuleTest.php | 5 +++++ tests/PHPStan/Rules/Functions/data/bug-6720b.php | 15 +++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 tests/PHPStan/Rules/Functions/data/bug-6720b.php diff --git a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php index 45025db9c2..2ef94a9202 100644 --- a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php +++ b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php @@ -1768,6 +1768,11 @@ public function testBug6720(): void $this->analyse([__DIR__ . '/data/bug-6720.php'], []); } + public function testBug6720b(): void + { + $this->analyse([__DIR__ . '/data/bug-6720b.php'], []); + } + public function testBug8659(): void { $this->analyse([__DIR__ . '/data/bug-8659.php'], []); diff --git a/tests/PHPStan/Rules/Functions/data/bug-6720b.php b/tests/PHPStan/Rules/Functions/data/bug-6720b.php new file mode 100644 index 0000000000..ebcf9064f5 --- /dev/null +++ b/tests/PHPStan/Rules/Functions/data/bug-6720b.php @@ -0,0 +1,15 @@ +a()); +}