1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

fix wrong cast to int when string offset is a number > MAX INT (#4702)

This commit is contained in:
orklah 2020-11-25 21:48:53 +01:00 committed by Daniil Gentili
parent 033a209950
commit 3593a41060
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7

View File

@ -15,6 +15,7 @@ use function preg_match;
use function array_merge;
use function array_values;
use function count;
use const PHP_INT_MAX;
/**
* @internal
@ -170,6 +171,7 @@ class ArrayAnalyzer
if ($item->key instanceof PhpParser\Node\Scalar\String_
&& preg_match('/^(0|[1-9][0-9]*)$/', $item->key->value)
&& (int) $item->key->value <= PHP_INT_MAX
) {
$key_type = Type::getInt(false, (int) $item->key->value);
}