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 SESP\HookRegistry; |
||
4 | |||
5 | /** |
||
6 | * Extension SemanticExtraSpecialProperties - Adds some extra special properties to all pages. |
||
7 | * |
||
8 | * @see https://github.com/SemanticMediaWiki/SemanticExtraSpecialProperties |
||
9 | * |
||
10 | * @defgroup SemanticExtraSpecialProperties Semantic Extra Special Properties |
||
11 | */ |
||
12 | if ( !defined( 'MEDIAWIKI' ) ) { |
||
13 | die( 'This file is part of the SemanticExtraSpecialProperties extension, it is not a valid entry point.' ); |
||
14 | } |
||
15 | |||
16 | if ( version_compare( $GLOBALS['wgVersion'], '1.25', '<' ) ) { |
||
17 | die( '<b>Error:</b> This version of Semantic Extra Special Properties requires MediaWiki 1.25 or above.' ); |
||
18 | } |
||
19 | |||
20 | if ( !defined( 'SMW_VERSION' ) ) { |
||
21 | die( '<b>Error:</b> This version of Semantic Extra Special Properties requires <a href="http://semantic-mediawiki.org/wiki/Semantic_MediaWiki">Semantic MediaWiki</a> installed.<br />' ); |
||
22 | } |
||
23 | |||
24 | if ( defined( 'SESP_VERSION' ) ) { |
||
25 | // Do not initialize more than once. |
||
26 | return 1; |
||
27 | } |
||
28 | |||
29 | SemanticExtraSpecialProperties::initExtension(); |
||
30 | |||
31 | $GLOBALS['wgExtensionFunctions'][] = function() { |
||
32 | SemanticExtraSpecialProperties::onExtensionFunction(); |
||
33 | }; |
||
34 | |||
35 | /** |
||
36 | * @codeCoverageIgnore |
||
37 | */ |
||
38 | class SemanticExtraSpecialProperties { |
||
39 | |||
40 | /** |
||
41 | * @since 1.4 |
||
42 | */ |
||
43 | public static function initExtension() { |
||
44 | |||
45 | // Load DefaultSettings |
||
46 | require_once __DIR__ . '/DefaultSettings.php'; |
||
47 | |||
48 | define( 'SESP_VERSION', '1.4.0-alpha' ); |
||
49 | |||
50 | if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) { |
||
51 | include_once( __DIR__ . '/vendor/autoload.php' ); |
||
52 | } |
||
53 | |||
54 | // Register extension info |
||
55 | $GLOBALS['wgExtensionCredits']['semantic'][] = array( |
||
56 | 'path' => __FILE__, |
||
57 | 'name' => 'Semantic Extra Special Properties', |
||
58 | 'author' => array( |
||
59 | '[https://github.com/rotsee Leo Wallentin]', |
||
60 | '[https://www.semantic-mediawiki.org/wiki/User:MWJames James Hong Kong]', |
||
61 | '...' |
||
62 | ), |
||
63 | 'version' => SESP_VERSION, |
||
64 | 'url' => 'https://www.mediawiki.org/wiki/Extension:SemanticExtraSpecialProperties', |
||
65 | 'descriptionmsg' => 'sesp-desc', |
||
66 | 'license-name' => 'GPL-2.0+' |
||
67 | ); |
||
68 | |||
69 | $GLOBALS['wgMessagesDirs']['SemanticExtraSpecialProperties'] = __DIR__ . '/i18n'; |
||
70 | $GLOBALS['wgExtensionMessagesFiles']['SemanticExtraSpecialProperties'] = __DIR__ . '/i18n/SemanticExtraSpecialProperties.i18n.php'; |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * @since 1.4 |
||
75 | */ |
||
76 | public static function onExtensionFunction() { |
||
77 | |||
78 | $configuration = array( |
||
79 | 'wgDisableCounters' => $GLOBALS['wgDisableCounters'], |
||
80 | 'sespUseAsFixedTables' => $GLOBALS['sespUseAsFixedTables'], |
||
81 | 'sespSpecialProperties' => $GLOBALS['sespSpecialProperties'], |
||
82 | 'wgSESPExcludeBots' => $GLOBALS['wgSESPExcludeBots'], |
||
83 | 'wgShortUrlPrefix' => $GLOBALS['wgShortUrlPrefix'], |
||
84 | 'sespCacheType' => $GLOBALS['sespCacheType'] |
||
85 | ); |
||
86 | |||
87 | $hookRegistry = new HookRegistry( |
||
88 | $configuration |
||
89 | ); |
||
90 | |||
91 | $hookRegistry->register(); |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * @since 1.4 |
||
96 | * |
||
97 | * @return string|null |
||
98 | */ |
||
99 | public static function getVersion() { |
||
100 | return SESP_VERSION; |
||
101 | } |
||
102 | |||
103 | } |
||
104 |
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.