Issue Task Rejected

#52878Use the "global" keyword instead of $GLOBALS

Christoph Dörfel 10/16/13, 09:31 updated 10/16/13, 10:57

Description

When working with global variables (inside functions) use the global keyword to refer to that variable instead of accessing the $GLOBALS array directly.

Bonus: Add tag in method comment for nice code completion in an IDE

/**
 * @global type $variable
 */

Why?
- Makes code easier to read (at least for me).
- You have an overview of all the global variables used in a function
- Code completion in an IDE

How?
Go through the entire core, find all $GLOBALS[variable], write global $variable; to the beginning of the method, add global type $variable@ to the method comment, replace all occurrences of $GLOBALS[variable] with $variable.

This could be integrated into the coding guidelines imho.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.