1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +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) {
return false;
}
$stmt->inferredType = isset($stmt->expr->inferredType) ? $stmt->expr->inferredType : null;
} elseif ($stmt instanceof PhpParser\Node\Expr\ShellExec) {
if (IssueBuffer::accepts(
new ForbiddenCode(

View File

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