diff --git a/src/Psalm/Checker/Statements/ExpressionChecker.php b/src/Psalm/Checker/Statements/ExpressionChecker.php index a41947f23..792bd64d0 100644 --- a/src/Psalm/Checker/Statements/ExpressionChecker.php +++ b/src/Psalm/Checker/Statements/ExpressionChecker.php @@ -509,6 +509,7 @@ class ExpressionChecker if (self::analyze($statements_checker, $stmt->expr, $context) === false) { return false; } + $stmt->inferredType = isset($stmt->expr->inferredType) ? $stmt->expr->inferredType : null; } elseif ($stmt instanceof PhpParser\Node\Expr\ShellExec) { if (IssueBuffer::accepts( new ForbiddenCode( diff --git a/tests/FunctionCallTest.php b/tests/FunctionCallTest.php index e137bb9d8..28d05975e 100644 --- a/tests/FunctionCallTest.php +++ b/tests/FunctionCallTest.php @@ -941,6 +941,13 @@ class FunctionCallTest extends TestCase */ function acceptsAShape(array $a): void {}', ], + 'suppressError' => [ + ' [ + '$a' => 'string|false', + ], + ], ]; }