1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 12:55:26 +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 GitHub
parent f3e0201a99
commit 58736924dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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);
}