1.2.734. Multiple Index Definition¶
Indexes that are defined multiple times in the same array.
They are indeed overwriting each other. This is most probably a typo.
<?php
// Multiple identical keys
$x = array(1 => 2,
2 => 3,
1 => 3);
// Multiple identical keys (sneaky version)
$x = array(1 => 2,
1.1 => 3,
true => 4);
// Multiple identical keys (automated version)
$x = array(1 => 2,
3, // This will be index 2
2 => 4); // this index is overwritten
?>
Name |
Default |
Type |
Description |
arrayMaxSize |
15000 |
integer |
Maximal size of arrays to be analyzed. This will speed up analysis, and leave the largest arrays untouched. |
1.2.734.1. Suggestions¶
Review your code and check that arrays only have keys defined once.
Review carefully your code and check indirect values, like constants, static constants.
1.2.734.2. Specs¶
Short name |
Arrays/MultipleIdenticalKeys |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Instant (5 mins) |
Precision |
Very high |
Features |
array, index |
Examples |
|
Available in |