1.2.738. Multiple Index Definition¶
This rules lists the indexes that are defined multiple times in the same array.
In reality, they are overwriting each other. This is most probably a typo or a failed copy/paste.
<?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 is the index 2
2 => 4); // this index is overwritten
?>
Name |
Default |
Type |
Description |
arrayMaxSize |
15000 |
integer |
Maximal size of arrays to be analyzed. This directive speeds up analysis, and leaves the largest arrays untouched. |
1.2.738.1. Connex PHP features¶
1.2.738.1.1. Suggestions¶
Review the code and check that arrays only have keys defined once.
Review carefully the code and check indirect values, like constants and static constants.
1.2.738.1.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 |
Examples |
|
Available in |