[TYPO3-core] CGL, the global keyword
Christoph Dörfel
christoph.doerfel at gmail.com
Wed Oct 16 13:06:19 CEST 2013
Hi
Use of the global keyword is not recommended (not strictly forbidden though) according to the CGL.We should always use $GLOBALS['variable'].
@see http://docs.typo3.org/TYPO3/CodingGuidelinesReference/PhpFileFormatting/PhpSyntaxFormatting/Index.html#global-variables
Now to my question: Why is that? Does it have some serious drawbacks?
Defining the global variables of a method right at the beginning of the code would give an overview of what's used later on.
Even if we keep the current CGL on the global keyword, we should think about method comments with the @global tag for global variables.
/**
* @global type $variable
* @global type $GLOBALS['variable']
*/
Thanks for your feedback and clarification on this topic
Christoph
More information about the TYPO3-team-core
mailing list