| Conditions | 12 |
| Paths | 130 |
| Total Lines | 68 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 66 | public static function onExtensionFunction() { |
||
| 67 | |||
| 68 | if ( !defined( 'SMW_VERSION' ) ) { |
||
| 69 | if ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ) { |
||
| 70 | die( "\nThe 'Semantic Extra Special Properties' extension requires 'Semantic MediaWiki' to be installed and enabled.\n" ); |
||
| 71 | } else { |
||
| 72 | die( '<b>Error:</b> The <a href="https://github.com/SemanticMediaWiki/SemanticExtraSpecialProperties/">Semantic Extra Special Properties</a> extension requires <a href="https://www.semantic-mediawiki.org/wiki/Semantic_MediaWiki">Semantic MediaWiki</a> to be installed and enabled.<br />' ); |
||
| 73 | } |
||
| 74 | } |
||
| 75 | |||
| 76 | // Cover legacy settings |
||
| 77 | $deprecationNotices = []; |
||
| 78 | |||
| 79 | if ( isset( $GLOBALS['sespUseAsFixedTables'] ) ) { |
||
| 80 | $GLOBALS['sespgUseFixedTables'] = $GLOBALS['sespUseAsFixedTables']; |
||
| 81 | $deprecationNotices['replacement']['sespUseAsFixedTables'] = 'sespgUseFixedTables'; |
||
| 82 | } |
||
| 83 | |||
| 84 | if ( isset( $GLOBALS['sespPropertyDefinitionFile'] ) ) { |
||
| 85 | $GLOBALS['sespgDefinitionsFile'] = $GLOBALS['sespPropertyDefinitionFile']; |
||
| 86 | $deprecationNotices['replacement']['sespPropertyDefinitionFile'] = 'sespgDefinitionsFile'; |
||
| 87 | } |
||
| 88 | |||
| 89 | if ( isset( $GLOBALS['sespLocalPropertyDefinitions'] ) ) { |
||
| 90 | $GLOBALS['sespgLocalDefinitions'] = $GLOBALS['sespLocalPropertyDefinitions']; |
||
| 91 | $deprecationNotices['replacement']['sespLocalPropertyDefinitions'] = 'sespgLocalDefinitions'; |
||
| 92 | } |
||
| 93 | |||
| 94 | if ( isset( $GLOBALS['sespSpecialProperties'] ) ) { |
||
| 95 | $GLOBALS['sespgEnabledPropertyList'] = $GLOBALS['sespSpecialProperties']; |
||
| 96 | $deprecationNotices['replacement']['sespSpecialProperties'] = 'sespgEnabledPropertyList'; |
||
| 97 | } |
||
| 98 | |||
| 99 | if ( isset( $GLOBALS['sespLabelCacheVersion'] ) ) { |
||
| 100 | $GLOBALS['sespgLabelCacheVersion'] = $GLOBALS['sespLabelCacheVersion']; |
||
| 101 | $deprecationNotices['replacement']['sespLabelCacheVersion'] = 'sespgLabelCacheVersion'; |
||
| 102 | } |
||
| 103 | |||
| 104 | if ( isset( $GLOBALS['wgSESPExcludeBots'] ) ) { |
||
| 105 | $GLOBALS['sespgExcludeBotEdits'] = $GLOBALS['wgSESPExcludeBots']; |
||
| 106 | $deprecationNotices['replacement']['wgSESPExcludeBots'] = 'sespgExcludeBotEdits'; |
||
| 107 | } |
||
| 108 | |||
| 109 | // Allow deprecated settings to appear on the `Special:SemanticMediaWiki` |
||
| 110 | // "Deprecation notices" section |
||
| 111 | if ( $deprecationNotices !== [] && !isset( $GLOBALS['smwgDeprecationNotices']['sesp'] ) ) { |
||
| 112 | $GLOBALS['smwgDeprecationNotices']['sesp'] = [ 'replacement' => $deprecationNotices['replacement'] ]; |
||
| 113 | } |
||
| 114 | |||
| 115 | $config = [ |
||
| 116 | 'sespgUseFixedTables' => $GLOBALS['sespgUseFixedTables'], |
||
| 117 | 'sespgEnabledPropertyList' => $GLOBALS['sespgEnabledPropertyList'], |
||
| 118 | 'sespgExcludeBotEdits' => $GLOBALS['sespgExcludeBotEdits'], |
||
| 119 | 'sespgDefinitionsFile' => $GLOBALS['sespgDefinitionsFile'], |
||
| 120 | 'sespgLocalDefinitions' => $GLOBALS['sespgLocalDefinitions'], |
||
| 121 | 'sespgLabelCacheVersion' => $GLOBALS['sespgLabelCacheVersion'], |
||
| 122 | |||
| 123 | // Non-SESP settings |
||
| 124 | 'wgDisableCounters' => $GLOBALS['wgDisableCounters'] ?? null, |
||
| 125 | 'wgShortUrlPrefix' => $GLOBALS['wgShortUrlPrefix'], |
||
| 126 | ]; |
||
| 127 | |||
| 128 | $hookRegistry = new HookRegistry( |
||
| 129 | $config |
||
| 130 | ); |
||
| 131 | |||
| 132 | $hookRegistry->register(); |
||
| 133 | } |
||
| 134 | |||
| 150 |