.. _structures-noneedforelse: .. _no-need-for-else: No Need For Else ++++++++++++++++ Else is not needed when the Then ends with a `break `_. A `break `_ may be the following keywords : `break `_, `continue `_, return, goto. Any of these send the execution somewhere in the code. The else block is then executed as the main sequence, only if the condition fails. .. code-block:: php See also `Object Calisthenics, rule # 2 `_. Connex PHP features ------------------- + `if-then `_ Suggestions ___________ * Remove else block, but keep the code Specs _____ +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Short name | Structures/NoNeedForElse | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All `, :ref:`Analyze `, :ref:`Changed Behavior ` | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 0.10.4 | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | PHP Version | All | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Severity | Minor | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Quick (30 mins) | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Precision | Very high | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Examples | :ref:`case-thelia-structures-noneedforelse`, :ref:`case-thinkphp-structures-noneedforelse` | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Exakat Cloud `_ | +--------------+-------------------------------------------------------------------------------------------------------------------------+