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:
parent
033a209950
commit
3593a41060
@ -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