.. _arrays-multipleidenticalkeys: .. _multiple-index-definition: 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. .. code-block:: php 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. | +--------------+---------+---------+--------------------------------------------------------------------------------------------------------------------+ Connex PHP features ------------------- + `array `_ + `index `_ 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. Specs _____ +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Short name | Arrays/MultipleIdenticalKeys | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All `, :ref:`Analyze `, :ref:`CE `, :ref:`CI-checks `, :ref:`Rector ` | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 0.8.4 | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | PHP Version | All | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Severity | Minor | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Instant (5 mins) | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Precision | Very high | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Examples | :ref:`case-magento-arrays-multipleidenticalkeys`, :ref:`case-mediawiki-arrays-multipleidenticalkeys` | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Community Edition `_, `Exakat Cloud `_ | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+