1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Fix #5809 - remove unnecessary issue suppression

This commit is contained in:
Matt Brown 2021-05-21 07:35:01 -04:00
parent 110c9ef4e1
commit 4b17cc9a4b
2 changed files with 20 additions and 16 deletions

View File

@ -793,18 +793,10 @@ class FunctionCallAnalyzer extends CallAnalyzer
$suppressed_issues = $statements_analyzer->getSuppressedIssues();
if (!in_array('PossiblyNullReference', $suppressed_issues, true)) {
$statements_analyzer->addSuppressedIssues(['PossiblyNullReference']);
}
if (!in_array('InternalMethod', $suppressed_issues, true)) {
$statements_analyzer->addSuppressedIssues(['InternalMethod']);
}
if (!in_array('PossiblyInvalidMethodCall', $suppressed_issues, true)) {
$statements_analyzer->addSuppressedIssues(['PossiblyInvalidMethodCall']);
}
$statements_analyzer->node_data->setType($function_name, new Type\Union([$atomic_type]));
\Psalm\Internal\Analyzer\Statements\Expression\Call\MethodCallAnalyzer::analyze(
@ -814,18 +806,10 @@ class FunctionCallAnalyzer extends CallAnalyzer
false
);
if (!in_array('PossiblyNullReference', $suppressed_issues, true)) {
$statements_analyzer->removeSuppressedIssues(['PossiblyNullReference']);
}
if (!in_array('InternalMethod', $suppressed_issues, true)) {
$statements_analyzer->removeSuppressedIssues(['InternalMethod']);
}
if (!in_array('PossiblyInvalidMethodCall', $suppressed_issues, true)) {
$statements_analyzer->removeSuppressedIssues(['PossiblyInvalidMethodCall']);
}
$fake_method_call_type = $statements_analyzer->node_data->getType($fake_method_call);
$statements_analyzer->node_data = $old_data_provider;

View File

@ -1479,6 +1479,26 @@ class MethodCallTest extends TestCase
}',
'error_message' => 'InvalidScalarArgument',
],
'possiblyNullReferenceInInvokedCall' => [
'<?php
interface Location {
public function getId(): int;
}
/** @psalm-immutable */
interface Application {
public function getLocation(): ?Location;
}
interface TakesId {
public function __invoke(int $location): int;
}
function f(TakesId $takesId, Application $application): void {
($takesId)($application->getLocation()->getId());
}',
'error_message' => 'PossiblyNullReference',
]
];
}
}