mirror of
https://github.com/danog/psalm.git
synced 2024-12-03 10:07:52 +01:00
Fix
This commit is contained in:
parent
156d629fbe
commit
a342a26f0d
@ -621,7 +621,7 @@ class ArrayAssignmentAnalyzer
|
||||
),
|
||||
null,
|
||||
[
|
||||
new Union([new TIntRange($prop_count, null)]),
|
||||
new Union([new TIntRange(0, null)]),
|
||||
$array_atomic_type_list
|
||||
],
|
||||
true
|
||||
@ -650,7 +650,7 @@ class ArrayAssignmentAnalyzer
|
||||
),
|
||||
null,
|
||||
[
|
||||
new Union([new TIntRange(count($atomic_root_types['array']->properties), null)]),
|
||||
new Union([new TIntRange(0, null)]),
|
||||
$array_atomic_type_list
|
||||
],
|
||||
true
|
||||
|
@ -1501,7 +1501,7 @@ class TypeCombiner
|
||||
$array_type = new TKeyedArray(
|
||||
$properties,
|
||||
null,
|
||||
[new Union([new TIntRange($cnt, null)]), $generic_type_params[1]],
|
||||
[new Union([new TIntRange(0, null)]), $generic_type_params[1]],
|
||||
true
|
||||
);
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ class TKeyedArray extends Atomic
|
||||
public function getGenericKeyType(bool $possibly_undefined = false): Union
|
||||
{
|
||||
if ($this->is_list) {
|
||||
return new Union([new TIntRange($this->getMinCount(), $this->getMaxCount())]);
|
||||
return new Union([new TIntRange(0, $this->getMaxCount())]);
|
||||
}
|
||||
|
||||
$key_types = [];
|
||||
@ -313,12 +313,8 @@ class TKeyedArray extends Atomic
|
||||
|
||||
$has_defined_keys = false;
|
||||
|
||||
$min_count = 0;
|
||||
foreach ($this->properties as $key => $property) {
|
||||
if ($this->is_list) {
|
||||
if (!$property->possibly_undefined) {
|
||||
$min_count++;
|
||||
}
|
||||
// Do nothing
|
||||
} elseif (is_int($key)) {
|
||||
$key_types[] = new TLiteralInt($key);
|
||||
@ -343,9 +339,9 @@ class TKeyedArray extends Atomic
|
||||
$value_type = $value_type->setPossiblyUndefined(false);
|
||||
|
||||
if ($this->fallback_params === null) {
|
||||
$key_type = new Union([new TIntRange($min_count, count($this->properties), false, $list_var_id)]);
|
||||
$key_type = new Union([new TIntRange(0, count($this->properties), false, $list_var_id)]);
|
||||
} else {
|
||||
$key_type = new Union([new TIntRange($min_count, null, false, $list_var_id)]);
|
||||
$key_type = new Union([new TIntRange(0, null, false, $list_var_id)]);
|
||||
}
|
||||
|
||||
if ($has_defined_keys) {
|
||||
|
Loading…
Reference in New Issue
Block a user