[TYPO3-dev] Official coding guidelines of TYPO3
Dmitry Dulepov
dmitry.dulepov at gmail.com
Thu Apr 23 21:20:55 CEST 2009
Hi!
Andy Grunwald [wmdb] wrote:
> Thanks Dmitry for your fast answer.
> Is this a draft already or are this the final coding guidelines? Will
> there be changes in the near future?
This is a draft. There is one unsolved question and I think it holds the CGL from being approved.
> And i have some questions about the "PHP syntax formatting" section:
>
> 1. I find the following lines in the document:
>> Variables on the global scope may use upper case and underscore
> characters.
>> Examples:
>> $TYPO3_CONF_VARS
>> $TYPO3_DB
Keywords are "on global scope". Global scope is outside of the function (i.e. in ext_tables.php or in typo3conf/localconf.php).
> I´ve read (but i don`t know where) that is recommended to use
> $GLOBALS['TYPO3_DB'] instead of $TYPO3_DB, because you could remove
> those lines in different methods:
>
> function example(){
> global $TYPO3_DB, $LANG, ...;
> ...
> }
>
> Is this recommended and is there a "mistake" in this document or is my
> last sentence wrong?
Yes, inside functions we recommend to use $GLOBALS always (see page 12). However there are old functions with "global". We change them when we work with them but it is not a high priority task.
> 2. I find the following lines in the document:
>> The opening curly brace is always on the same line as the preceding
> construction. There must be a space (not a tab!) before the opening
> brace. The opening brace is always followed by a new line.
>
> Why there is no guideline for the following example (i cant find one)?:
>
> $variable = 5;
> OR
> $variable=5;
>
> In my opinion this is very important because the first version
> ($variable = 5;) is easier to read. The second advantage for the first
> version is that this is similar to the "String"-Guidelines (Page: 11 / 12):
>> $content = 'Hello ' . 'world!';
Good one! I will add it.
--
Dmitry Dulepov
In TYPO3 blog: http://dmitry-dulepov.com/article/have-fun-with-the-typoscript-error-hunt.html
LinkedIn: http://www.linkedin.com/in/dmitrydulepov
Twitter: http://twitter.com/dmitryd
Skype: liels_bugs
More information about the TYPO3-dev
mailing list