mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix #1180 - array key maths was wrong
This commit is contained in:
parent
dfba6e0dec
commit
a89a201c71
@ -90,7 +90,7 @@ class ArrayAnalyzer
|
||||
$item_key_value = $item->key->inferredType->getSingleIntLiteral()->value;
|
||||
|
||||
if ($item_key_value > $int_offset + $int_offset_diff) {
|
||||
$int_offset_diff = $item_key_value - ($int_offset + $int_offset_diff);
|
||||
$int_offset_diff = $item_key_value - $int_offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1010,6 +1010,13 @@ class ArrayAssignmentTest extends TestCase
|
||||
$arr = [1 => 0, 1, 2, 3];
|
||||
$arr = [1 => "one", 2 => "two", "three"];',
|
||||
],
|
||||
'noDuplicateImplicitIntArrayKeyLargeOffset' => [
|
||||
'<?php
|
||||
$arr = [
|
||||
48 => "A",
|
||||
95 => "a", "b",
|
||||
];',
|
||||
],
|
||||
'constArrayAssignment' => [
|
||||
'<?php
|
||||
const BAR = 2;
|
||||
|
Loading…
x
Reference in New Issue
Block a user