@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public static function initExtension() { |
| 45 | 45 | |
| 46 | - $GLOBALS[ 'wgExtensionFunctions' ][] = function () { |
|
| 46 | + $GLOBALS[ 'wgExtensionFunctions' ][ ] = function() { |
|
| 47 | 47 | |
| 48 | 48 | $parser = LingoParser::getInstance(); |
| 49 | 49 | |
@@ -53,14 +53,14 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | \Hooks::register( 'ParserBeforeTidy', [ $parser, 'parse' ] ); |
| 55 | 55 | |
| 56 | - \Hooks::register('GetDoubleUnderscoreIDs', function ( array &$doubleUnderscoreIDs ) { |
|
| 57 | - $doubleUnderscoreIDs[] = 'noglossary'; |
|
| 56 | + \Hooks::register( 'GetDoubleUnderscoreIDs', function( array &$doubleUnderscoreIDs ) { |
|
| 57 | + $doubleUnderscoreIDs[ ] = 'noglossary'; |
|
| 58 | 58 | return true; |
| 59 | 59 | } ); |
| 60 | 60 | |
| 61 | - \Hooks::register( 'ParserFirstCallInit', function ( \Parser $parser ) { |
|
| 61 | + \Hooks::register( 'ParserFirstCallInit', function( \Parser $parser ) { |
|
| 62 | 62 | |
| 63 | - $parser->setHook( 'noglossary', function ( $input, array $args, \Parser $parser, \PPFrame $frame ) { |
|
| 63 | + $parser->setHook( 'noglossary', function( $input, array $args, \Parser $parser, \PPFrame $frame ) { |
|
| 64 | 64 | $output = $parser->recursiveTagParse( $input, $frame ); |
| 65 | 65 | return '<span class="noglossary">' . $output . '</span>'; |
| 66 | 66 | } ); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | return true; |
| 69 | 69 | } ); |
| 70 | 70 | |
| 71 | - \Hooks::register( 'SpecialPageBeforeExecute', function ( \SpecialPage $specialPage, $subPage ) { |
|
| 71 | + \Hooks::register( 'SpecialPageBeforeExecute', function( \SpecialPage $specialPage, $subPage ) { |
|
| 72 | 72 | |
| 73 | 73 | if ( $specialPage instanceof \SpecialVersion ) { |
| 74 | 74 | foreach ( $GLOBALS[ 'wgExtensionCredits' ][ 'parserhook' ] as $index => $description ) { |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | const TREE_VERSION = 2; |
| 54 | 54 | |
| 55 | - private $mTree = []; |
|
| 56 | - private $mList = []; |
|
| 55 | + private $mTree = [ ]; |
|
| 56 | + private $mList = [ ]; |
|
| 57 | 57 | private $mMinLength = 1000; |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | $this->mList[ $term ]->addDefinition( $definition ); |
| 72 | 72 | } else { |
| 73 | 73 | |
| 74 | - $matches = []; |
|
| 74 | + $matches = [ ]; |
|
| 75 | 75 | preg_match_all( LingoParser::getInstance()->regex, $term, $matches ); |
| 76 | 76 | |
| 77 | 77 | $element = $this->addElement( $matches[ 0 ], $term, $definition ); |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | while ( ( $step = array_shift( $path ) ) !== null ) { |
| 98 | 98 | |
| 99 | 99 | if ( !isset( $tree[ $step ] ) ) { |
| 100 | - $tree[ $step ] = []; |
|
| 100 | + $tree[ $step ] = [ ]; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | $tree = &$tree[ $step ]; |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | public function next() { |
| 76 | 76 | |
| 77 | 77 | static $term = null; |
| 78 | - static $definitions = []; |
|
| 79 | - static $ret = []; |
|
| 78 | + static $definitions = [ ]; |
|
| 79 | + static $ret = [ ]; |
|
| 80 | 80 | |
| 81 | 81 | $this->collectDictionaryLines(); |
| 82 | 82 | |
@@ -113,11 +113,11 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | // wipe the data if it's a totally new term definition |
| 115 | 115 | if ( !empty( $term ) && count( $definitions ) > 0 ) { |
| 116 | - $definitions = []; |
|
| 116 | + $definitions = [ ]; |
|
| 117 | 117 | $term = null; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - $definitions[] = trim( $chunks[ 1 ] ); |
|
| 120 | + $definitions[ ] = trim( $chunks[ 1 ] ); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | // found a new term? |
@@ -134,10 +134,10 @@ discard block |
||
| 134 | 134 | * @return array |
| 135 | 135 | */ |
| 136 | 136 | protected function queueDefinitions( $definitions, $term ) { |
| 137 | - $ret = []; |
|
| 137 | + $ret = [ ]; |
|
| 138 | 138 | |
| 139 | 139 | foreach ( $definitions as $definition ) { |
| 140 | - $ret[] = [ |
|
| 140 | + $ret[ ] = [ |
|
| 141 | 141 | Element::ELEMENT_TERM => $term, |
| 142 | 142 | Element::ELEMENT_DEFINITION => $definition, |
| 143 | 143 | Element::ELEMENT_LINK => null, |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | class MessageLog { |
| 43 | 43 | |
| 44 | - private $mMessages = []; |
|
| 44 | + private $mMessages = [ ]; |
|
| 45 | 45 | private $mParser = null; |
| 46 | 46 | |
| 47 | 47 | const MESSAGE_ERROR = 1; |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * @param int $severity |
| 54 | 54 | */ |
| 55 | 55 | public function addMessage( $message, $severity = self::MESSAGE_NOTICE ) { |
| 56 | - $this->mMessages[] = [ $message, $severity ]; |
|
| 56 | + $this->mMessages[ ] = [ $message, $severity ]; |
|
| 57 | 57 | |
| 58 | 58 | // log errors and warnings in debug log |
| 59 | 59 | if ( $severity == self::MESSAGE_WARNING || |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * @param $message |
| 68 | 68 | */ |
| 69 | 69 | public function addError( $message ) { |
| 70 | - $this->mMessages[] = [ $message, self::MESSAGE_ERROR ]; |
|
| 70 | + $this->mMessages[ ] = [ $message, self::MESSAGE_ERROR ]; |
|
| 71 | 71 | wfDebug( "Error: $message\n" ); |
| 72 | 72 | } |
| 73 | 73 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * @param $message |
| 76 | 76 | */ |
| 77 | 77 | public function addWarning( $message ) { |
| 78 | - $this->mMessages[] = [ $message, self::MESSAGE_WARNING ]; |
|
| 78 | + $this->mMessages[ ] = [ $message, self::MESSAGE_WARNING ]; |
|
| 79 | 79 | wfDebug( "Warning: $message\n" ); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @param $message |
| 84 | 84 | */ |
| 85 | 85 | public function addNotice( $message ) { |
| 86 | - $this->mMessages[] = [ $message, self::MESSAGE_NOTICE ]; |
|
| 86 | + $this->mMessages[ ] = [ $message, self::MESSAGE_NOTICE ]; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | * @ingroup Extensions |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -$magicWords = []; |
|
| 9 | +$magicWords = [ ]; |
|
| 10 | 10 | |
| 11 | 11 | /** English (English) */ |
| 12 | 12 | $magicWords[ 'en' ] = [ |
@@ -48,14 +48,14 @@ discard block |
||
| 48 | 48 | const ELEMENT_LINK = 3; |
| 49 | 49 | const ELEMENT_STYLE = 4; |
| 50 | 50 | |
| 51 | - const ELEMENT_FIELDCOUNT = 5; // number of fields stored for each element; (last field's index) + 1 |
|
| 51 | + const ELEMENT_FIELDCOUNT = 5; // number of fields stored for each element; (last field's index) + 1 |
|
| 52 | 52 | |
| 53 | 53 | const LINK_TEMPLATE_ID = 'LingoLink'; |
| 54 | 54 | |
| 55 | 55 | private $formattedTerm = null; |
| 56 | 56 | private $formattedDefinitions = null; |
| 57 | 57 | |
| 58 | - private $mDefinitions = []; |
|
| 58 | + private $mDefinitions = [ ]; |
|
| 59 | 59 | private $mTerm = null; |
| 60 | 60 | |
| 61 | 61 | private $hasBeenDisplayed = false; |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | * @param array $definition |
| 80 | 80 | */ |
| 81 | 81 | public function addDefinition( &$definition ) { |
| 82 | - $this->mDefinitions[] = array_pad( $definition, self::ELEMENT_FIELDCOUNT, null ); |
|
| 82 | + $this->mDefinitions[ ] = array_pad( $definition, self::ELEMENT_FIELDCOUNT, null ); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -206,18 +206,18 @@ discard block |
||
| 206 | 206 | // part here. |
| 207 | 207 | |
| 208 | 208 | // set style |
| 209 | - $classes = []; |
|
| 209 | + $classes = [ ]; |
|
| 210 | 210 | |
| 211 | 211 | if ( $this->mDefinitions[ 0 ][ self::ELEMENT_STYLE ] !== null ) { |
| 212 | - $classes[] = $this->mDefinitions[ 0 ][ self::ELEMENT_STYLE ]; |
|
| 212 | + $classes[ ] = $this->mDefinitions[ 0 ][ self::ELEMENT_STYLE ]; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | if ( !$target->isKnown() ) { |
| 216 | - $classes[] = 'new'; |
|
| 216 | + $classes[ ] = 'new'; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | if ( $target->isExternal() ) { |
| 220 | - $classes[] = 'extiw'; |
|
| 220 | + $classes[ ] = 'extiw'; |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | if ( count( $classes ) > 0 ) { |
@@ -264,16 +264,16 @@ discard block |
||
| 264 | 264 | protected function buildFormattedDefinitions() { |
| 265 | 265 | |
| 266 | 266 | // Wrap definition in a <div> tag |
| 267 | - $divDefinitions = []; |
|
| 268 | - $divDefinitions[] = '<div class="mw-lingo-tooltip-tip ' . $this->mDefinitions[ 0 ][ self::ELEMENT_STYLE ] . '" id="' . $this->getId() . '" >'; |
|
| 267 | + $divDefinitions = [ ]; |
|
| 268 | + $divDefinitions[ ] = '<div class="mw-lingo-tooltip-tip ' . $this->mDefinitions[ 0 ][ self::ELEMENT_STYLE ] . '" id="' . $this->getId() . '" >'; |
|
| 269 | 269 | |
| 270 | 270 | foreach ( $this->mDefinitions as $definition ) { |
| 271 | 271 | |
| 272 | - $divDefinitions[] = '<div class="mw-lingo-tooltip-definition">'; |
|
| 272 | + $divDefinitions[ ] = '<div class="mw-lingo-tooltip-definition">'; |
|
| 273 | 273 | |
| 274 | - $divDefinitions[] = '<div class="mw-lingo-tooltip-text ' . $this->mDefinitions[ 0 ][ self::ELEMENT_STYLE ] . "\">\n"; |
|
| 275 | - $divDefinitions[] = $definition[ self::ELEMENT_DEFINITION ]; |
|
| 276 | - $divDefinitions[] = "\n" . '</div>'; |
|
| 274 | + $divDefinitions[ ] = '<div class="mw-lingo-tooltip-text ' . $this->mDefinitions[ 0 ][ self::ELEMENT_STYLE ] . "\">\n"; |
|
| 275 | + $divDefinitions[ ] = $definition[ self::ELEMENT_DEFINITION ]; |
|
| 276 | + $divDefinitions[ ] = "\n" . '</div>'; |
|
| 277 | 277 | |
| 278 | 278 | if ( $definition[ self::ELEMENT_LINK ] ) { |
| 279 | 279 | |
@@ -284,14 +284,14 @@ discard block |
||
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | if ( $url !== null ) { |
| 287 | - $divDefinitions[] = '<div class="mw-lingo-tooltip-link">[' . $url . ' <nowiki/>]</div>'; |
|
| 287 | + $divDefinitions[ ] = '<div class="mw-lingo-tooltip-link">[' . $url . ' <nowiki/>]</div>'; |
|
| 288 | 288 | } |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - $divDefinitions[] = '</div>'; |
|
| 291 | + $divDefinitions[ ] = '</div>'; |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - $divDefinitions[] = "\n" . '</div>'; |
|
| 294 | + $divDefinitions[ ] = "\n" . '</div>'; |
|
| 295 | 295 | |
| 296 | 296 | $this->formattedDefinitions = join( $divDefinitions ); |
| 297 | 297 | } |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | } else { |
| 167 | 167 | |
| 168 | 168 | wfDebug( "Cache miss: Lingo tree not found in cache.\n" ); |
| 169 | - $this->mLingoTree =& $this->buildLingo(); |
|
| 169 | + $this->mLingoTree = & $this->buildLingo(); |
|
| 170 | 170 | wfDebug( "Cached lingo tree.\n" ); |
| 171 | 171 | } |
| 172 | 172 | |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | } else { |
| 179 | 179 | wfDebug( "Caching of lingo tree disabled.\n" ); |
| 180 | - $this->mLingoTree =& $this->buildLingo(); |
|
| 180 | + $this->mLingoTree = & $this->buildLingo(); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | } |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | $numberOfTextElements = $textElements->length; |
| 251 | 251 | $changedDoc = false; |
| 252 | 252 | |
| 253 | - $definitions = []; |
|
| 253 | + $definitions = [ ]; |
|
| 254 | 254 | |
| 255 | 255 | for ( $textElementIndex = 0; $textElementIndex < $numberOfTextElements; $textElementIndex++ ) { |
| 256 | 256 | $textElement = $textElements->item( $textElementIndex ); |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | continue; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - $matches = []; |
|
| 262 | + $matches = [ ]; |
|
| 263 | 263 | preg_match_all( |
| 264 | 264 | $this->regex, |
| 265 | 265 | $textElement->nodeValue, |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | continue; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - $wordDescriptors = &$matches[ 0 ]; // See __construct() for definition of "word" |
|
| 274 | + $wordDescriptors = &$matches[ 0 ]; // See __construct() for definition of "word" |
|
| 275 | 275 | $numberOfWordDescriptors = count( $wordDescriptors ); |
| 276 | 276 | |
| 277 | 277 | $parentNode = &$textElement->parentNode; |
@@ -289,12 +289,12 @@ discard block |
||
| 289 | 289 | |
| 290 | 290 | if ( $skippedWords > 0 ) { // skipped some text, insert it as is |
| 291 | 291 | |
| 292 | - $start = $wordDescriptors[$wordDescriptorIndex][self::WORD_OFFSET]; |
|
| 293 | - $length = $wordDescriptors[$wordDescriptorIndex + $skippedWords][self::WORD_OFFSET] - $start; |
|
| 292 | + $start = $wordDescriptors[ $wordDescriptorIndex ][ self::WORD_OFFSET ]; |
|
| 293 | + $length = $wordDescriptors[ $wordDescriptorIndex + $skippedWords ][ self::WORD_OFFSET ] - $start; |
|
| 294 | 294 | |
| 295 | 295 | $parentNode->insertBefore( |
| 296 | 296 | $doc->createTextNode( |
| 297 | - substr( $textElement->nodeValue, $start, $length) |
|
| 297 | + substr( $textElement->nodeValue, $start, $length ) |
|
| 298 | 298 | ), |
| 299 | 299 | $textElement |
| 300 | 300 | ); |
@@ -315,11 +315,11 @@ discard block |
||
| 315 | 315 | // Only change element if found term before |
| 316 | 316 | if ( $changedElem === true ) { |
| 317 | 317 | |
| 318 | - $start = $wordDescriptors[$wordDescriptorIndex][self::WORD_OFFSET]; |
|
| 318 | + $start = $wordDescriptors[ $wordDescriptorIndex ][ self::WORD_OFFSET ]; |
|
| 319 | 319 | |
| 320 | 320 | $parentNode->insertBefore( |
| 321 | 321 | $doc->createTextNode( |
| 322 | - substr( $textElement->nodeValue, $start) |
|
| 322 | + substr( $textElement->nodeValue, $start ) |
|
| 323 | 323 | ), |
| 324 | 324 | $textElement |
| 325 | 325 | ); |