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 | * @license GNU GPL v2+ |
||
9 | * @since 0.1 |
||
10 | * |
||
11 | * @author Leo Wallentin (Rotsee) |
||
12 | * @author James Hong Kong (Mwjames) |
||
13 | * @author Jeroen De Dauw |
||
14 | * @author Karsten Hoffmeyer (Kghbln) |
||
15 | */ |
||
16 | if ( !defined( 'MEDIAWIKI' ) ) { |
||
17 | die( 'This file is part of the SemanticMetaTags extension, it is not a valid entry point.' ); |
||
18 | } |
||
19 | |||
20 | if ( version_compare( $GLOBALS['wgVersion'], '1.20', '<' ) ) { |
||
21 | die( '<b>Error:</b> This version of Semantic Extra Special Properties requires MediaWiki 1.20 or above.' ); |
||
22 | } |
||
23 | |||
24 | if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) { |
||
25 | include_once( __DIR__ . '/vendor/autoload.php' ); |
||
26 | } |
||
27 | |||
28 | if ( !defined( 'SMW_VERSION' ) ) { |
||
29 | 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 />' ); |
||
30 | } |
||
31 | |||
32 | if ( version_compare( SMW_VERSION, '1.9', '<' ) ) { |
||
33 | die( '<b>Error:</b> This version of Semantic Extra Special Properties requires Semantic MediaWiki 1.9 or above.' ); |
||
34 | } |
||
35 | |||
36 | if ( defined( 'SESP_VERSION' ) ) { |
||
37 | // Do not initialize more than once. |
||
38 | return 1; |
||
39 | } |
||
40 | |||
41 | define( 'SESP_VERSION', '1.3.1' ); |
||
42 | |||
43 | /** |
||
44 | * @codeCoverageIgnore |
||
45 | */ |
||
46 | call_user_func( function () { |
||
47 | |||
48 | // Register extension info |
||
49 | $GLOBALS['wgExtensionCredits']['semantic'][] = array( |
||
50 | 'path' => __FILE__, |
||
51 | 'name' => 'Semantic Extra Special Properties', |
||
52 | 'author' => array( |
||
53 | '[https://github.com/rotsee Leo Wallentin]', |
||
54 | '[https://semantic-mediawiki.org/wiki/User:MWJames James Hong Kong]', |
||
55 | '...' |
||
56 | ), |
||
57 | 'version' => SESP_VERSION, |
||
58 | 'url' => 'https://www.mediawiki.org/wiki/Extension:SemanticExtraSpecialProperties', |
||
59 | 'descriptionmsg' => 'sesp-desc', |
||
60 | 'license-name' => 'GPL-2.0+' |
||
61 | ); |
||
62 | |||
63 | // Default setting |
||
64 | $GLOBALS['sespCacheType'] = CACHE_ANYTHING; |
||
65 | $GLOBALS['sespUseAsFixedTables'] = false; |
||
66 | $GLOBALS['sespSpecialProperties'] = array(); |
||
67 | $GLOBALS['wgSESPExcludeBots'] = false; |
||
68 | $GLOBALS['wgShortUrlPrefix'] = ''; |
||
69 | |||
70 | $GLOBALS['wgMessagesDirs']['semantic-extra-special-properties'] = __DIR__ . '/i18n'; |
||
71 | $GLOBALS['wgExtensionMessagesFiles']['semantic-extra-special-properties'] = __DIR__ . '/i18n/SemanticExtraSpecialProperties.i18n.php'; |
||
72 | |||
73 | // Finalize extension setup |
||
74 | $GLOBALS['wgExtensionFunctions'][] = function() { |
||
75 | |||
76 | $configuration = array( |
||
77 | 'wgDisableCounters' => $GLOBALS['wgDisableCounters'], |
||
78 | 'sespUseAsFixedTables' => $GLOBALS['sespUseAsFixedTables'], |
||
79 | 'sespSpecialProperties' => $GLOBALS['sespSpecialProperties'], |
||
80 | 'wgSESPExcludeBots' => $GLOBALS['wgSESPExcludeBots'], |
||
81 | 'wgShortUrlPrefix' => $GLOBALS['wgShortUrlPrefix'], |
||
82 | 'sespCacheType' => $GLOBALS['sespCacheType'] |
||
83 | ); |
||
84 | |||
85 | $hookRegistry = new HookRegistry( $configuration ); |
||
86 | $hookRegistry->register(); |
||
87 | }; |
||
88 | |||
89 | } ); |
||
90 |
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.