Semantic MediaWiki and related extensions
|
Semantic MediaWiki and many of its extensions stick to a strict naming conventions and code styles based on the MediaWiki coding conventions. The guidelines can often be adopted to other extensions by just changing the prefix SMW
.
PSR-4
guideline in naming and using namespaces for classes where SMW
is the top-vendor identifier,src
folder follow the PSR-4
layoutincludes
folder have no or very rudimentary test coverage and do not follow PSR-4
. Once a class meets certain criteria (one of which is sufficient test coverage among others) it is expected to be moved into the src
folder with the objective to remove includes
in the future.UTF8
(this is absolutely crucial)The `` annotation for a class indicates a solely restricted use within the SMW-core code base and even though a class might provide public access methods, it SHOULD NOT be expected that the class itself or its methods will be available during or after a specific release cycle.
In general, all names are written using the CamelCase style, although methodNames and variableNames typically start with lower case letters. Private methods are not required to follow the convention.
Classes
use a namespace that starts with "SMW". Class definitions that are encapsulated in methods do not have a prefix. Another exception are classes for '''Specials''' which should be named after the special, as is common in MediaWiki.Functions
that are accessible globally require the "smwf" prefixVariables
are prefixed with "smwg" if declared globally. Variables in a class do not have a special prefix. Local variables in functions typically use the camelCase style or _
if any separation is needed.Constants
are written ALL_CAPS with underscores as internal separator, and are to be prefixed with "SMW_" when used globally (e.g. in "define('SMW_FOO', 1)"), class constants are free from this convention.In general, code layout is guided by the MediaWiki coding conventions. Please be sure to read this document.
$this
inside of a static method)In general, all names are written CamelCase, although methodNames and variableNames typically start with lower case letters.
Resources.php
@since
to indicate the version in which the function or field was added. Also do this for hooks.and