[TYPO3-core] $GLOBALS vs globals

Ernesto Baschny [cron IT] ernst at cron-it.de
Thu Oct 26 12:22:46 CEST 2006


Martin Kutschker schrieb am 26.10.2006 11:45:

> I use global whenever I use them same variable more than once or
> twice. Eg spelling $GLOBALS['TSFE'] ten times is tiresome and not
> even easy to read.

In my view it is exactly the opposite: It enhances the readability of
the code, because you can know exactly what variable you are acessing
here and it will be much easier later to identify dependencies on
certain globals.

Writing them could be a matter of copy&paste or some other helper
methods. I think we should not spare characters just to be able to type
them faster, the code should be readable and understandable.

> I do not favour a codig style that forbids "global" altogether.

I would favor such a style.

> Maybe in TYPO3 5.0 we can use singletons and do not use globals at
> all, but please don to not force us to use $GLOBALS['TSFE'],
> $GLOBALS['TCA'] every single time.

TYPO3 5.0 is a different story, $GLOBALS should only be used at a
minimum, but I think we should aim for that "minor" change in 4.1. What
do others think?

Cheers,
Ernesto



More information about the TYPO3-team-core mailing list