.. _structures-variablemaybenonglobal: .. _declare-global-early: Declare Global Early ++++++++++++++++++++ `Static `_ and global keywords should be used as early as possible in a method. Performance wise, it is better to call ``global`` or ``static`` only before using the variable. Human-wise, it is recommended to put ``global`` or ``static`` at the beginning of the method, for better readability. .. code-block:: php See also `Using static variables `_ and `The global keyword `_. Suggestions ___________ * Use static and global at the beginning of the method * Move static and global to the first usage of the variable * Remove any access to the variable before static and global Specs _____ +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Short name | Structures/VariableMayBeNonGlobal | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All ` | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 1.5.3 | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | PHP Version | All | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Severity | Minor | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Instant (5 mins) | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Precision | Very high | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Features | static-variable, global-variable | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Exakat Cloud `_ | +--------------+-------------------------------------------------------------------------------------------------------------------------+