1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Fix checking if union type with mixed is nullable (#2253)

Fixes #2249
This commit is contained in:
Tyson Andre 2019-10-20 17:06:59 -04:00 committed by Matthew Brown
parent 05ace25817
commit 94636476d2
2 changed files with 11 additions and 2 deletions

View File

@ -48,7 +48,6 @@ use function preg_match;
use function preg_quote;
use function strtolower;
use function strlen;
use DeepCopy\TypeMatcher\TypeMatcher;
/**
* @internal
@ -450,7 +449,7 @@ class BinaryOpAnalyzer
$naive_type = $stmt->left->inferredType ?? null;
if ($naive_type
&& !$naive_type->isMixed()
&& !$naive_type->hasMixed()
&& !$naive_type->isNullable()
) {
$var_id = ExpressionAnalyzer::getVarId($stmt->left, $context->self);

View File

@ -1497,6 +1497,16 @@ class TypeReconciliationTest extends TestCase
return $a;
}'
],
'nullCoalescePossibleMixed' => [
'<?php
/**
* @psalm-suppress MixedReturnStatement
* @psalm-suppress MixedInferredReturnType
*/
function foo() : array {
return filter_input_array(INPUT_POST) ?? [];
}',
],
];
}