.. _functions-nobooleanasdefault: .. _no-boolean-as-default: No Boolean As Default +++++++++++++++++++++ Default values should always be set up with a constant name. Class constants and constants improve readability when calling the methods or comparing values and statuses. .. code-block:: php See also `FlagArgument `_ and `Clean code: The curse of a boolean parameter `_. Connex PHP features ------------------- + `boolean `_ + `default-value `_ Suggestions ___________ * Use constants or class constants to give value to a boolean literal * When constants have been defined, use them when calling the code * Split the method into two methods, one for each case Specs _____ +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Short name | Functions/NoBooleanAsDefault | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All `, :ref:`Analyze ` | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 0.10.0 | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | PHP Version | All | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Severity | Minor | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Quick (30 mins) | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Precision | High | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Examples | :ref:`case-openconf-functions-nobooleanasdefault` | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Exakat Cloud `_ | +--------------+-------------------------------------------------------------------------------------------------------------------------+