mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix #5809 - remove unnecessary issue suppression
This commit is contained in:
parent
110c9ef4e1
commit
4b17cc9a4b
@ -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;
|
||||
|
@ -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',
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user