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() ) 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()); +}