Skip to content
Permalink
Browse files

Fix #2611 - fix combination of inferred closure return types

  • Loading branch information
muglug committed Jan 13, 2020
1 parent 7a65eb1 commit eb7c3dcc110e97bbcebb9c99a3d65a87717c371d
@@ -592,7 +592,10 @@ function (FunctionLikeParameter $p) {
);

if ($closure_return_types) {
$closure_return_type = new Type\Union($closure_return_types);
$closure_return_type = \Psalm\Internal\Type\TypeCombination::combineTypes(
$closure_return_types,
$codebase
);

if (($storage->return_type === $storage->signature_return_type)
&& (!$storage->return_type
@@ -90,6 +90,7 @@ public static function getFunctionReturnType(

if ($closure_types = $function_call_type->getClosureTypes()) {
$closure_atomic_type = \reset($closure_types);

$closure_return_type = $closure_atomic_type->return_type ?: Type::getMixed();

if ($closure_return_type->isVoid()) {
@@ -2429,6 +2429,31 @@ function makeAList(int $ofThisInteger): array {
return array_filter([$ofThisInteger]);
}'
],
'arrayMapWithEmptyArrayReturn' => [
'<?php
/**
* @param array<array<string>> $elements
* @return list<string>
*/
function resolvePossibleFilePaths($elements) : array
{
return array_values(
array_filter(
array_merge(
...array_map(
function (array $element) : array {
if (rand(0,1) == 1) {
return [];
}
return $element;
},
$elements
)
)
)
);
}'
]
];
}

0 comments on commit eb7c3dc

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