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:
parent
f3e0201a99
commit
58736924dd
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user