These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
2 | |||
3 | use SG\HookRegistry; |
||
4 | use SMW\ApplicationFactory; |
||
5 | |||
6 | /** |
||
7 | * A terminology markup extension with a Semantic MediaWiki backend |
||
8 | * |
||
9 | * @defgroup SemanticGlossary Semantic Glossary |
||
10 | * @author Stephan Gambke |
||
11 | */ |
||
12 | if ( !defined( 'MEDIAWIKI' ) ) { |
||
13 | die( 'This file is part of a MediaWiki extension, it is not a valid entry point.' ); |
||
14 | } |
||
15 | |||
16 | if ( defined( 'SG_VERSION' ) ) { |
||
17 | // Do not initialize more than once. |
||
18 | return 1; |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * The Semantic Glossary version |
||
23 | */ |
||
24 | define( 'SG_VERSION', '1.2.0-alpha' ); |
||
25 | |||
26 | if ( !defined( 'SMW_VERSION' ) ) { |
||
27 | die( 'Semantic Glossary depends on the Semantic MediaWiki extension. You need to install Semantic MediaWiki first.' ); |
||
28 | } |
||
29 | |||
30 | if ( !defined( 'LINGO_VERSION' ) ) { |
||
31 | die( 'Semantic Glossary depends on the Lingo extension. You need to install Lingo first.' ); |
||
32 | } |
||
33 | |||
34 | call_user_func( function () { |
||
35 | |||
36 | // register the extension |
||
37 | $GLOBALS[ 'wgExtensionCredits' ][ 'semantic' ][] = array( |
||
38 | 'path' => __FILE__, |
||
39 | 'name' => 'Semantic Glossary', |
||
40 | 'author' => array( '[http://www.mediawiki.org/wiki/User:F.trott Stephan Gambke]', 'James Hong Kong' ), |
||
41 | 'url' => 'https://www.mediawiki.org/wiki/Extension:Semantic_Glossary', |
||
42 | 'descriptionmsg' => 'semanticglossary-desc', |
||
43 | 'version' => SG_VERSION, |
||
44 | 'license-name' => 'GPL-2.0+' |
||
45 | ); |
||
46 | |||
47 | // set SemanticGlossaryBackend as the backend to access the glossary |
||
48 | $GLOBALS[ 'wgexLingoBackend' ] = 'SG\LingoBackendAdapter'; |
||
49 | |||
50 | // server-local path to this file |
||
51 | $dir = __DIR__; |
||
52 | |||
53 | // register message file |
||
54 | $GLOBALS[ 'wgMessagesDirs' ]['SemanticGlossary'] = $dir . '/i18n'; |
||
55 | $GLOBALS[ 'wgExtensionMessagesFiles' ]['SemanticGlossary'] = $dir . '/SemanticGlossary.i18n.php'; |
||
56 | |||
57 | $GLOBALS['wgExtensionFunctions'][] = function() { |
||
58 | |||
59 | $hookRegistry = new HookRegistry( |
||
60 | ApplicationFactory::getInstance()->getStore() |
||
61 | ); |
||
62 | |||
63 | $hookRegistry->register(); |
||
64 | }; |
||
65 | |||
66 | } ); |
||
67 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.