mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
parent
3728837ef9
commit
df2ec48018
@ -1219,7 +1219,7 @@ class TypeCombiner
|
||||
}
|
||||
|
||||
if ($combination->ints !== null && count($combination->ints) < $literal_limit) {
|
||||
$combination->ints[$type_key] = $type;
|
||||
$combination->ints[(string) $type_key] = $type;
|
||||
} else {
|
||||
$combination->ints[$type_key] = $type;
|
||||
|
||||
@ -1269,7 +1269,12 @@ class TypeCombiner
|
||||
&& isset($combination->value_types['int'])
|
||||
&& $combination->value_types['int'] instanceof TPositiveInt
|
||||
) {
|
||||
$combination->ints = ['int(0)' => new TLiteralInt(0)];
|
||||
if ($combination->ints === null) {
|
||||
$combination->ints = ['int(0)' => new TLiteralInt(0)];
|
||||
} elseif ($type->value < 0) {
|
||||
$combination->ints = null;
|
||||
$combination->value_types['int'] = new TInt();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -591,6 +591,14 @@ class TypeCombinationTest extends TestCase
|
||||
'-1',
|
||||
],
|
||||
],
|
||||
'combinePositiveIntZeroAndMinusOne' => [
|
||||
'int',
|
||||
[
|
||||
'0',
|
||||
'positive-int',
|
||||
'-1',
|
||||
],
|
||||
],
|
||||
'combineMinusOneAndPositiveInt' => [
|
||||
'int',
|
||||
[
|
||||
|
Loading…
Reference in New Issue
Block a user