1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Add PossiblyInvalidArgument for closure param type checks

This commit is contained in:
Matthew Brown 2017-04-08 09:47:03 -04:00
parent 64361ad2c3
commit a985fd9324

View File

@ -1746,6 +1746,12 @@ class CallChecker
}
if (!$type_match_found) {
$types_can_be_identical = TypeChecker::canBeIdenticalTo(
$input_type,
$closure_param_type,
$statements_checker->getFileChecker()
);
if ($scalar_type_match_found) {
if (IssueBuffer::accepts(
new InvalidScalarArgument(
@ -1757,6 +1763,17 @@ class CallChecker
)) {
return false;
}
} elseif ($types_can_be_identical) {
if (IssueBuffer::accepts(
new PossiblyInvalidArgument(
'First parameter of closure passed to function ' . $method_id . ' expects ' .
$closure_param_type . ', possibly different type ' . $input_type . ' provided',
new CodeLocation($statements_checker->getSource(), $closure_arg)
),
$statements_checker->getSuppressedIssues()
)) {
return false;
}
} elseif (IssueBuffer::accepts(
new InvalidArgument(
'First parameter of closure passed to function ' . $method_id . ' expects ' .