.. _structures-maxlevelofidentation: .. _max-level-of-nesting: Max Level Of Nesting ++++++++++++++++++++ Avoid nesting structures too deep, as it hurts readability. Nesting structures are : if/then, switch, for, foreach, while, do...while. Ternary operator, try/catch are not considered a nesting structures. Closures, and more generally, functions definitions are counted separatedly. This analysis checks for 4 levels of nesting, by default. This may be changed by configuration. .. code-block:: php +----------+---------+---------+---------------------------------------------------------------------+ | Name | Default | Type | Description | +----------+---------+---------+---------------------------------------------------------------------+ | maxLevel | 4 | integer | Maximum level of nesting for control flow structures in one scope. | +----------+---------+---------+---------------------------------------------------------------------+ See also `Indentation and Spacing in PHP `. Connex PHP features ------------------- + `indentation `_ Suggestions ___________ * Refactor code to avoid nesting * Export some nested blocks to an external method or function Specs _____ +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Short name | Structures/MaxLevelOfIdentation | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All `, :ref:`Analyze `, :ref:`Changed Behavior ` | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 1.9.3 | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | PHP Version | All | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Severity | Minor | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Quick (30 mins) | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Precision | Very high | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Exakat Cloud `_ | +--------------+-------------------------------------------------------------------------------------------------------------------------+