.. _classes-couldbeprivateconstante: .. _could-be-private-class-constant: Could Be Private Class Constant +++++++++++++++++++++++++++++++ Class constant may use ``private`` visibility. Since PHP 7.1, constants may also have a public/protected/private visibility. This restrict their usage to anywhere, class and children or class. As a general rule, it is recommended to make constant ``private`` by default, and to relax this restriction as needed. PHP makes them public by default. Constant shall stay ``public`` when the code has to be compatible with PHP 7.0 and older. They also have to be public in the case of component : some of those constants have to be used by external actors, in order to configure the component. .. code-block:: php See also `Class Constants `_. Connex PHP features ------------------- + `visibility `_ Specs _____ +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Short name | Classes/CouldBePrivateConstante | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All `, :ref:`Changed Behavior `, :ref:`Class Review ` | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 0.12.10 | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | PHP Version | All | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Severity | Minor | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Quick (30 mins) | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Precision | Very high | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Examples | :ref:`case-phinx-classes-couldbeprivateconstante` | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Exakat Cloud `_ | +--------------+--------------------------------------------------------------------------------------------------------------------------+