.. _classes-undeclaredstaticproperty: .. _wrong-access-style-to-property: Wrong Access Style to Property ++++++++++++++++++++++++++++++ Use the right syntax when reaching for a property. `Static `_ properties use the ``\:\:`` operator, and non-`static `_ properties use ``->``. Mistaking one of the other raise two different reactions from PHP : ``Access to undeclared `static `_ property`` is a fatal `error `_, while ``PHP Notice: Accessing `static `_ property aa\:\:$a as non `static `_`` is a notice. This analysis reports both `static `_ properties with a `->` access, and non-`static `_ properties with a `\:\:` access. .. code-block:: php a; // WRONG } } class b { public $b = 1; function foo() { echo $this->$b; // right echo b::$b; // WRONG } } ?> See also `Static Keyword `_. Related PHP errors ------------------- + `0 `_ + `1 `_ Connex PHP features ------------------- + `declaration `_ Suggestions ___________ * Match the property call with the definition * Make the property static Specs _____ +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Short name | Classes/UndeclaredStaticProperty | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All `, :ref:`Analyze `, :ref:`CE `, :ref:`CI-checks `, :ref:`Class Review ` | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 1.4.9 | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | PHP Version | All | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Severity | Critical | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Quick (30 mins) | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Precision | Very high | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Examples | :ref:`case-humo-gen-classes-undeclaredstaticproperty` | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Community Edition `_, `Exakat Cloud `_ | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+