Skip to content

Commit a951ac0

Browse files
authored
Optimize keepVoidType (#4735)
1 parent cb3b93b commit a951ac0

3 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/Analyser/MutatingScope.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2746,6 +2746,7 @@ public function getKeepVoidType(Expr $node): Type
27462746
(
27472747
!$node instanceof FuncCall
27482748
&& !$node instanceof MethodCall
2749+
&& !$node instanceof Expr\NullsafeMethodCall
27492750
&& !$node instanceof Expr\StaticCall
27502751
) || $node->isFirstClassCallable()
27512752
)

tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,6 +1768,11 @@ public function testBug6720(): void
17681768
$this->analyse([__DIR__ . '/data/bug-6720.php'], []);
17691769
}
17701770

1771+
public function testBug6720b(): void
1772+
{
1773+
$this->analyse([__DIR__ . '/data/bug-6720b.php'], []);
1774+
}
1775+
17711776
public function testBug8659(): void
17721777
{
17731778
$this->analyse([__DIR__ . '/data/bug-8659.php'], []);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug6720b;
4+
5+
class X {
6+
/** @return string|void */
7+
function a() {}
8+
9+
}
10+
11+
function b(?string $a): void {}
12+
13+
function doFoo(?X $x):void {
14+
b($x?->a());
15+
}

0 commit comments

Comments
 (0)