.. _classes-nonppp: .. _forgotten-visibility: Forgotten Visibility ++++++++++++++++++++ Some classes elements (property, method, constant) are missing their explicit visibility. By default, it is public. It should at least be mentioned as public, or may be reviewed as protected or private. Class constants support also visibility since PHP 7.1. final, `static `_ and abstract are not counted as visibility. Only public, private and protected. The PHP 4 var keyword is counted as undefined. Traits, classes and interfaces are checked. .. code-block:: php See also `Visibility `_ and `Understanding The Concept Of Visibility In Object Oriented PHP `_. Connex PHP features ------------------- + `visibility `_ Suggestions ___________ * Always add explicit visibility to methods and constants in a class * Always add explicit visibility to properties in a class, after PHP 7.4 Specs _____ +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Short name | Classes/NonPpp | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All `, :ref:`Analyze `, :ref:`CE `, :ref:`CI-checks ` | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 0.8.4 | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | PHP Version | All | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Severity | Minor | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Instant (5 mins) | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Precision | Very high | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | ClearPHP | `always-have-visibility `__ | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Examples | :ref:`case-fuelcms-classes-nonppp`, :ref:`case-livezilla-classes-nonppp` | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Community Edition `_, `Exakat Cloud `_ | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+