.. _constants-couldbeconstant: .. _could-be-constant: Could Be Constant +++++++++++++++++ Literals may be replaced by an existing constant. Constants makes the code easier to read, as they may bear a meaningful name. They also hide implementation values, with a readable name, such as ``const READABLE= true;``. Later, upgrading constant values is easier than scouring the code with a new literal. Not all literal can be replaced by a constant values : sometimes, literal may have the same literal value, but different meanings. Check with your application semantics before changing any literal with a constant. This analysis currently doesn't support arrays. This analysis also skips very common values, such as boolean, ``0`` and ``1``. This prevents too many false positive. .. code-block:: php Suggestions ___________ * Turn the literal into an existing constant Specs _____ +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Short name | Constants/CouldBeConstant | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All `, :ref:`Semantics ` | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 1.8.4 | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | PHP Version | All | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Severity | Minor | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Quick (30 mins) | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Precision | High | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Features | constant | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Exakat Cloud `_ | +--------------+-------------------------------------------------------------------------------------------------------------------------+