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

Fix PHPMAXINT offset (#4707)

This commit is contained in:
orklah 2020-11-26 15:24:32 +01:00 committed by GitHub
parent 01ceaf7006
commit 4bbb72329e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -171,7 +171,10 @@ class ArrayAnalyzer
if ($item->key instanceof PhpParser\Node\Scalar\String_ if ($item->key instanceof PhpParser\Node\Scalar\String_
&& preg_match('/^(0|[1-9][0-9]*)$/', $item->key->value) && preg_match('/^(0|[1-9][0-9]*)$/', $item->key->value)
&& (int) $item->key->value <= PHP_INT_MAX && (
(int) $item->key->value < PHP_INT_MAX ||
$item->key->value === (string) PHP_INT_MAX
)
) { ) {
$key_type = Type::getInt(false, (int) $item->key->value); $key_type = Type::getInt(false, (int) $item->key->value);
} }

View File

@ -1545,6 +1545,14 @@ class ArrayAssignmentTest extends TestCase
$_a = [$b => "a"]; $_a = [$b => "a"];
', ',
], ],
'ArrayOffsetNumericSupPHPINTMAX' => [
'<?php
$_a = [
"9223372036854775808" => 1,
"9223372036854775809" => 2
];
',
],
]; ];
} }