Globals and Top-Level Functions

Jump to: navigation, search

Since Manual:Global variables discourages the use of globals, this Manual:Coding conventions should encourage the use of static class members and functions in lieu of globals and top-level functions. Instead of

$wgVersion;
$wgTitle;
 
function wfFuncname() { ... }

it could encourage

class SomeClass {
    public static $version;
    public static $title;
 
    public static function funcname() { ... }
}
Sledged (talk) 19:23, 5 March 2008 (UTC)07:08, 5 December 2011

As far as I can see the current coding conventions doesn't encourage use of global variabels and functions, it merely documents how to name them if you decide to create a global function or variable.

In the same section it also says how class method names and field names should be named.

Manual:Coding_conventions#PHP_Naming.

Krinkle23:40, 5 December 2011