.. _classes-classoverreach: .. _class-overreach: Class Overreach +++++++++++++++ An object of class A may reach any private or protected properties, constants or methods in another object of the same class. This is a PHP feature, though seldom known. This feature is also called class invasion. .. code-block:: php p + 1; } } echo (new A)->foo(new A); ?> See also `Visibility from other objects `_ and `spatie/invade `_. Connex PHP features ------------------- + `visibility `_ + `class-invasion `_ Suggestions ___________ * Use a getter to reach inside the other object private properties Specs _____ +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Short name | Classes/ClassOverreach | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All `, :ref:`Appinfo `, :ref:`Changed Behavior ` | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 2.2.2 | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | PHP Version | All | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Severity | Minor | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Slow (1 hour) | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Precision | Medium | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Exakat Cloud `_ | +--------------+-------------------------------------------------------------------------------------------------------------------------+