[TYPO3-dev] Official coding guidelines of TYPO3

Peter Russ peter.russ at 4many.net
Fri Apr 24 19:01:47 CEST 2009


--- Original Nachricht ---
Absender:   Franz Holzinger
Datum:       24.04.2009 18:15:
> Hello,
> 
> Dmitry Dulepov a écrit :
>>> The CGL says: "Use of global is not recommended. Always use
>>> $GLOBALS['variable']."
>>>
>>> But why do you recommend the longer way to use $GLOBALS['TYPO3_CONF_VARS
>>> '] instead of $TYPO3_CONF_VARS? Maybe it is because 'global'
>>> declarations might not work in some cases.
>>> It is easier to write and read if the variable names are shorter.
>>
>> It is because sometimes people forget to write "global $WHATEVER" or 
>> accidentally delete it and it causes hard to catch errors.
>>
>> What would you prefer: shorter code or smaller chances of errors?
> 
> I prefer shorter code. This is easier to read and understand. A deletion 
> of a line might always cause errors.
> Developers will learn to insert the global statements they need.
> 
[...]

Isn't the $GLOBALS approach PHP cgl?
This I prefer also it's longer to write or read. But the statement makes 
it very clear where the var comes from.

Futher there is the requirement for naming to start vars, functions, etc 
with lowercase. Vars in uppercase I would only allow for PHP predefined 
stuff.

+1 for $GLOBALS as you can use it when ever it is required
-1 globals .... because you always have to check.

Peter


-- 
Fiat lux! Docendo discimus.
_____________________________
uon GbR

http://www.uon.li
http://www.xing.com/profile/Peter_Russ




More information about the TYPO3-dev mailing list