1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-02 09:37:59 +01:00

Off-by-one fun

This commit is contained in:
Daniil Gentili 2022-11-26 18:44:11 +01:00
parent 65f849a5a2
commit 95e0614b2e
3 changed files with 3 additions and 3 deletions

View File

@ -340,7 +340,7 @@ class TKeyedArray extends Atomic
$value_type = $value_type->setPossiblyUndefined(false);
if ($this->fallback_params === null) {
$key_type = new Union([new TIntRange(0, count($this->properties), false, $list_var_id)]);
$key_type = new Union([new TIntRange(0, count($this->properties)-1, false, $list_var_id)]);
} else {
$key_type = new Union([new TIntRange(0, null, false, $list_var_id)]);
}

View File

@ -291,7 +291,7 @@ class FunctionTemplateTest extends TestCase
$a = splat_proof(...$foo);',
'assertions' => [
'$a' => 'array<int, int>',
'$a' => 'array<int<0, 2>, int>',
],
],
'passArrayByRef' => [

View File

@ -624,7 +624,7 @@ class TypeCombinationTest extends TestCase
],
],
'combineNonEmptyListWithTKeyedArrayList' => [
'list{null|string, ...<int, string>}',
'list{null|string, ...<int<0, max>, string>}',
[
'non-empty-list<string>',
'array{null}'