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

Fix array_filter return type

This commit is contained in:
Matthew Brown 2016-12-25 01:33:14 +00:00
parent 513fcea101
commit 6a19aa63d2

View File

@ -544,7 +544,7 @@ class FunctionChecker extends FunctionLikeChecker
CodeLocation $code_location,
array $suppressed_issues
) {
if ($call_map_key === 'array_map' || $call_map_key === 'array_filter') {
if ($call_map_key === 'array_map') {
return self::getArrayMapReturnType($call_map_key, $call_args, $code_location, $suppressed_issues);
}
@ -646,6 +646,14 @@ class FunctionChecker extends FunctionLikeChecker
]);
}
if ($call_map_key === 'array_filter') {
if (!$first_arg_array_generic) {
return Type::getArray();
}
return clone $first_arg_array_generic;
}
if ($call_map_key === 'array_diff_key') {
if (!$first_arg_array_generic) {
return Type::getArray();