diff --git a/src/Psalm/Checker/FunctionChecker.php b/src/Psalm/Checker/FunctionChecker.php index 3018192e1..e78f6a126 100644 --- a/src/Psalm/Checker/FunctionChecker.php +++ b/src/Psalm/Checker/FunctionChecker.php @@ -373,6 +373,14 @@ class FunctionChecker extends FunctionLikeChecker // where there's no function passed to array_filter if ($call_map_key === 'array_filter' && $first_arg && isset($first_arg->inferredType) && $first_arg->inferredType->hasArray()) { $inner_type = clone $first_arg->inferredType->types['array']->type_params[1]; + + $second_arg = isset($call_args[1]->value) ? $call_args[1]->value : null; + + if (!$second_arg) { + $inner_type->removeType('null'); + $inner_type->removeType('false'); + } + return new Type\Union([new Type\Generic('array', [Type::getInt(), $inner_type])]); }