1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Copy inferred type when suppressing errors

This commit is contained in:
Matt Brown 2018-09-04 13:57:05 -04:00
parent 34fe935eb6
commit 5d6fb4efdf
2 changed files with 8 additions and 0 deletions

View File

@ -509,6 +509,7 @@ class ExpressionChecker
if (self::analyze($statements_checker, $stmt->expr, $context) === false) { if (self::analyze($statements_checker, $stmt->expr, $context) === false) {
return false; return false;
} }
$stmt->inferredType = isset($stmt->expr->inferredType) ? $stmt->expr->inferredType : null;
} elseif ($stmt instanceof PhpParser\Node\Expr\ShellExec) { } elseif ($stmt instanceof PhpParser\Node\Expr\ShellExec) {
if (IssueBuffer::accepts( if (IssueBuffer::accepts(
new ForbiddenCode( new ForbiddenCode(

View File

@ -941,6 +941,13 @@ class FunctionCallTest extends TestCase
*/ */
function acceptsAShape(array $a): void {}', function acceptsAShape(array $a): void {}',
], ],
'suppressError' => [
'<?php
$a = @file_get_contents("foo");',
'assertions' => [
'$a' => 'string|false',
],
],
]; ];
} }