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 SMW\Scribunto\HookRegistry; |
||
4 | |||
5 | /** |
||
6 | * @see https://github.com/SemanticMediaWiki/SemanticScribunto/ |
||
7 | * |
||
8 | * @defgroup SemanticScribunto Semantic Scribunto |
||
9 | */ |
||
10 | if ( !defined( 'MEDIAWIKI' ) ) { |
||
11 | die( 'This file is part of the Semantic Scribunto extension, it is not a valid entry point.' ); |
||
12 | } |
||
13 | |||
14 | if ( version_compare( $GLOBALS[ 'wgVersion' ], '1.24', 'lt' ) ) { |
||
15 | die( '<b>Error:</b> This version of <a href="https://github.com/SemanticMediaWiki/SemanticScribunto/">Semantic Scribunto</a> is only compatible with MediaWiki 1.24 or above. You need to upgrade MediaWiki first.' ); |
||
16 | } |
||
17 | |||
18 | if ( defined( 'SMW_SCRIBUNTO_VERSION' ) ) { |
||
19 | // Do not initialize more than once. |
||
20 | return 1; |
||
21 | } |
||
22 | |||
23 | define( 'SMW_SCRIBUNTO_VERSION', '1.0.0-alpha' ); |
||
24 | |||
25 | /** |
||
26 | * @codeCoverageIgnore |
||
27 | */ |
||
28 | call_user_func( function () { |
||
29 | |||
30 | // Register extension info |
||
31 | $GLOBALS['wgExtensionCredits']['semantic'][] = array( |
||
32 | 'path' => __FILE__, |
||
33 | 'name' => 'Semantic Scribunto', |
||
34 | 'author' => array( 'James Hong Kong' ), |
||
35 | 'url' => 'https://github.com/SemanticMediaWiki/SemanticScribunto/', |
||
36 | 'descriptionmsg' => 'smw-scribunto-desc', |
||
37 | 'version' => SMW_SCRIBUNTO_VERSION, |
||
38 | 'license-name' => 'GPL-2.0+', |
||
39 | ); |
||
40 | |||
41 | // MW 1.26+ |
||
42 | if ( !function_exists( 'wfGlobalCacheKey' ) ) { |
||
43 | function wfGlobalCacheKey( /*...*/ ) { |
||
44 | $args = func_get_args(); |
||
45 | $key = 'global:' . implode( ':', $args ); |
||
46 | return strtr( $key, ' ', '_' ); |
||
47 | } |
||
48 | } |
||
49 | |||
50 | // Register message files |
||
51 | $GLOBALS['wgMessagesDirs']['smw-scribunto'] = __DIR__ . '/i18n'; |
||
52 | |||
53 | // Finalize extension setup |
||
54 | $GLOBALS['wgExtensionFunctions'][] = function() { |
||
55 | |||
56 | $hookRegistry = new HookRegistry(); |
||
57 | $hookRegistry->register(); |
||
58 | }; |
||
59 | |||
60 | } ); |
||
61 |
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.