Skip to content
Permalink
Browse files

Fix #2576 - remove literal key values if array_filter has no args

  • Loading branch information
muglug committed Jan 11, 2020
1 parent 85966d8 commit 40406c7ff03015d3b14f079c7be1309ec35cb8f3
@@ -76,6 +76,14 @@ public static function getFunctionReturnType(
null,
$statements_source->getSuppressedIssues()
);

if ($key_type->getLiteralStrings()) {
$key_type->addType(new Type\Atomic\TString);
}

if ($key_type->getLiteralInts()) {
$key_type->addType(new Type\Atomic\TInt);
}
} elseif (!isset($call_args[2])) {
$function_call_arg = $call_args[1];

@@ -3025,6 +3025,14 @@ function test() : void {
(print "test") === 2;',
'error_message' => 'TypeDoesNotContainType',
],
'arrayFilterObjectLike' => [
'<?php
/** @param list<int> $ints */
function ints(array $ints) : void {}
$brr = array_filter([2,3,0,4,5]);
ints($brr);',
'error_message' => 'ArgumentTypeCoercion - src/somefile.php:5:26 - Argument 1 of ints expects list<int>, parent type array<int, int(2)|int(3)|int(4)|int(5)> provided',
],
];
}
}

0 comments on commit 40406c7

Please sign in to comment.
You can’t perform that action at this time.