[TYPO3-core] Wrapper methods around globals?

Xavier Perseguers xavier at typo3.org
Wed Mar 19 11:50:26 CET 2014


Hi Francois,

> In a patch I submitted this morning [1], I added a wrapper method around
> $GLOBALS['BE_USER'], because it makes it much easier to work with such
> globals in an IDE, having type hinting and code completion. I did it
> because I saw other places in the Core using this way of doing this.
> 
> Now Kay Strobach thinks this should not be done for performance reasons.
> Do we have guidelines about this?
> 
> I'm perfectly willing to update my patch and remove that wrapper method,
> but I would first like to know if there's any consensus about this.

I think the wrapper method is indeed a very good idea. Now what Kay
suggested is to assign it to a local variable. This will 1) keep the
type hinting and IDE autocomplete mechanism and 2) prevent many "same"
calls which indeed slow down the code.

Cheers

-- 
Xavier Perseguers
TYPO3 CMS Team Member

TYPO3 .... inspiring people to share!
Get involved: http://typo3.org



More information about the TYPO3-team-core mailing list