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