.. _structures-fallthrough: .. _switch-fallthrough: Switch Fallthrough ++++++++++++++++++ A switch with fallthrough is prone to errors. A fallthrough happens when a case or default clause in a switch statement is not finished by a `break `_ (or equivalent); CWE report this as a security concern, unless well documented. A fallthrough may be used as a feature. Then, it is indistinguishable from an `error `_. When the case block is empty, this analysis doesn't report it : the case is then used as an alias. This analysis doesn't take into account comments about the fallthrough. .. code-block:: php See also `CWE-484: Omitted Break Statement in Switch `_ and `Rule: no-switch-case-fall-through `_. Connex PHP features ------------------- + `switch `_ + `fallthrough `_ Suggestions ___________ * Make separate code for each case. Always use break at the end of a case or default. Specs _____ +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ | Short name | Structures/Fallthrough | +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All `, :ref:`Changed Behavior `, :ref:`Inventory `, :ref:`Security ` | +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 0.12.14 | +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ | PHP Version | All | +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ | Severity | Minor | +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Instant (5 mins) | +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ | Precision | Very high | +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Exakat Cloud `_ | +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+