@@ -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 ]; |
@@ -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' ] = [ |
@@ -54,12 +54,12 @@ |
||
| 54 | 54 | $data = json_decode( json_encode( $defined_vars[ 'magicWords' ] ) ); |
| 55 | 55 | |
| 56 | 56 | $validator = new \JsonSchema\Validator(); |
| 57 | - $validator->check( $data, (object)[ '$ref' => |
|
| 57 | + $validator->check( $data, (object) [ '$ref' => |
|
| 58 | 58 | 'file://' . realpath( __DIR__ . '/../Fixture/magicWordsSchema.json' ) ] ); |
| 59 | 59 | |
| 60 | 60 | // format error message |
| 61 | 61 | $errors = implode( '', array_map( |
| 62 | - function ( $error ) { |
|
| 62 | + function( $error ) { |
|
| 63 | 63 | return "* [{$error[ 'property' ]}] {$error[ 'message' ]}\n"; |
| 64 | 64 | }, |
| 65 | 65 | $validator->getErrors() |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function testCanConstruct() { |
| 55 | 55 | $term = 'someTerm'; |
| 56 | - $definition = []; |
|
| 56 | + $definition = [ ]; |
|
| 57 | 57 | $element = new Element( $term, $definition ); |
| 58 | 58 | |
| 59 | 59 | $this->assertInstanceOf( '\Lingo\Element', $element ); |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | public function testGetFormattedTerm_2() { |
| 101 | 101 | // Setup |
| 102 | 102 | $term = 'someTerm'; |
| 103 | - $definition = []; |
|
| 103 | + $definition = [ ]; |
|
| 104 | 104 | $element = new Element( $term, $definition ); |
| 105 | 105 | |
| 106 | 106 | $GLOBALS[ 'wgexLingoDisplayOnce' ] = true; |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | $element = new Element( $term, $definition ); |
| 144 | 144 | |
| 145 | - $expectedAttributes = [ 'class' => [ 'mw-lingo-term', 'new' ], 'title' => wfMessage( 'red-link-title', $title )->text() ]; |
|
| 145 | + $expectedAttributes = [ 'class' => [ 'mw-lingo-term', 'new' ], 'title' => wfMessage( 'red-link-title', $title )->text() ]; |
|
| 146 | 146 | |
| 147 | 147 | $GLOBALS[ 'wgexLingoDisplayOnce' ] = false; |
| 148 | 148 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | $element = new Element( $term, $definition ); |
| 180 | 180 | |
| 181 | - $expectedAttributes = [ 'class' => [ 'mw-lingo-term' ], 'title' => $title ]; |
|
| 181 | + $expectedAttributes = [ 'class' => [ 'mw-lingo-term' ], 'title' => $title ]; |
|
| 182 | 182 | |
| 183 | 183 | $GLOBALS[ 'wgexLingoDisplayOnce' ] = false; |
| 184 | 184 | |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | * @param string[] $expectedAttributes |
| 477 | 477 | * @param array $unexpectedAttributes |
| 478 | 478 | */ |
| 479 | - protected function checkTermIsDomElement( $node, $tagName, $text, $expectedAttributes = [], $unexpectedAttributes = [] ) { |
|
| 479 | + protected function checkTermIsDomElement( $node, $tagName, $text, $expectedAttributes = [ ], $unexpectedAttributes = [ ] ) { |
|
| 480 | 480 | $nodeText = $this->doc->saveHTML( $node ); |
| 481 | 481 | |
| 482 | 482 | $this->assertInstanceOf( 'DOMElement', $node ); |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | |
| 488 | 488 | $classes = array_flip( array_filter( explode( ' ', $node->getAttribute( 'class' ) ) ) ); |
| 489 | 489 | |
| 490 | - foreach ( (array)$expectedAttributes[ 'class' ] as $expectedClass ) { |
|
| 490 | + foreach ( (array) $expectedAttributes[ 'class' ] as $expectedClass ) { |
|
| 491 | 491 | $this->assertTrue( array_key_exists( $expectedClass, $classes ) ); |
| 492 | 492 | } |
| 493 | 493 | |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | <<<'TESTTEXT' |
| 186 | 186 | ;CIP:Common image point |
| 187 | 187 | ;CMP:Common midpoint |
| 188 | -TESTTEXT |
|
| 188 | +testtext |
|
| 189 | 189 | , |
| 190 | 190 | [ |
| 191 | 191 | [ 'CMP', 'Common midpoint', null, null ], |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | :Common image point |
| 201 | 201 | ;CMP |
| 202 | 202 | :Common midpoint |
| 203 | -TESTTEXT |
|
| 203 | +testtext |
|
| 204 | 204 | , |
| 205 | 205 | [ |
| 206 | 206 | [ 'CMP', 'Common midpoint', null, null ], |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | ;CIP |
| 215 | 215 | ;CMP |
| 216 | 216 | :Common midpoint |
| 217 | -TESTTEXT |
|
| 217 | +testtext |
|
| 218 | 218 | , |
| 219 | 219 | [ |
| 220 | 220 | [ 'CMP', 'Common midpoint', null, null ], |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | ;CIP |
| 229 | 229 | :Common image point |
| 230 | 230 | :Common midpoint |
| 231 | -TESTTEXT |
|
| 231 | +testtext |
|
| 232 | 232 | , |
| 233 | 233 | [ |
| 234 | 234 | [ 'CIP', 'Common image point', null, null ], |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | ;CMP |
| 244 | 244 | :Common image point |
| 245 | 245 | :Common midpoint |
| 246 | -TESTTEXT |
|
| 246 | +testtext |
|
| 247 | 247 | , |
| 248 | 248 | [ |
| 249 | 249 | [ 'CMP', 'Common image point', null, null ], |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | Sed ut perspiciatis unde; omnis iste natus error: sit voluptatem accusantium... |
| 268 | 268 | |
| 269 | 269 | ;NMO:Normal move-out |
| 270 | -TESTTEXT |
|
| 270 | +testtext |
|
| 271 | 271 | , |
| 272 | 272 | [ |
| 273 | 273 | [ 'NMO', 'Normal move-out', null, null ], |
@@ -70,6 +70,6 @@ |
||
| 70 | 70 | $config = isReadablePath( "$extDirectory/phpunit.xml.dist" ); |
| 71 | 71 | $mw = isReadablePath( dirname( dirname( $extDirectory ) ) . "/tests/phpunit/phpunit.php" ); |
| 72 | 72 | |
| 73 | -echo "php {$mw} -c {$config} " . implode( ' ', addArguments( $GLOBALS['argv'] ) ) . "\n\n"; |
|
| 73 | +echo "php {$mw} -c {$config} " . implode( ' ', addArguments( $GLOBALS[ 'argv' ] ) ) . "\n\n"; |
|
| 74 | 74 | |
| 75 | -passthru( "php {$mw} -c {$config} " . implode( ' ', addArguments( $GLOBALS['argv'] ) ) ); |
|
| 75 | +passthru( "php {$mw} -c {$config} " . implode( ' ', addArguments( $GLOBALS[ 'argv' ] ) ) ); |
|
@@ -72,8 +72,8 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function next() { |
| 74 | 74 | static $term = null; |
| 75 | - static $definitions = []; |
|
| 76 | - static $ret = []; |
|
| 75 | + static $definitions = [ ]; |
|
| 76 | + static $ret = [ ]; |
|
| 77 | 77 | |
| 78 | 78 | $this->collectDictionaryLines(); |
| 79 | 79 | |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | // wipe the data if it's a totally new term definition |
| 111 | 111 | if ( !empty( $term ) && count( $definitions ) > 0 ) { |
| 112 | - $definitions = []; |
|
| 112 | + $definitions = [ ]; |
|
| 113 | 113 | $term = null; |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - $definitions[] = trim( $chunks[ 1 ] ); |
|
| 116 | + $definitions[ ] = trim( $chunks[ 1 ] ); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // found a new term? |
@@ -130,10 +130,10 @@ discard block |
||
| 130 | 130 | * @return array |
| 131 | 131 | */ |
| 132 | 132 | protected function queueDefinitions( $definitions, $term ) { |
| 133 | - $ret = []; |
|
| 133 | + $ret = [ ]; |
|
| 134 | 134 | |
| 135 | 135 | foreach ( $definitions as $definition ) { |
| 136 | - $ret[] = [ |
|
| 136 | + $ret[ ] = [ |
|
| 137 | 137 | Element::ELEMENT_TERM => $term, |
| 138 | 138 | Element::ELEMENT_DEFINITION => $definition, |
| 139 | 139 | Element::ELEMENT_LINK => null, |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | public function provideData() { |
| 93 | - $data = []; |
|
| 93 | + $data = [ ]; |
|
| 94 | 94 | |
| 95 | 95 | $xmlFileProvider = new XmlFileProvider( __DIR__ . '/../Fixture/articleAnnotation' ); |
| 96 | 96 | $files = $xmlFileProvider->getFiles(); |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | $testCase = [ |
| 108 | 108 | 0 => substr( $file, strlen( __DIR__ . '/../Fixture/articleAnnotation' ) ), |
| 109 | 109 | 1 => trim( $decoded[ 'text' ] ), |
| 110 | - 2 => [], |
|
| 110 | + 2 => [ ], |
|
| 111 | 111 | 3 => trim( $decoded[ 'expected' ] ) . "\n", |
| 112 | 112 | ]; |
| 113 | 113 | |
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | foreach ( $decoded[ 'glossary-entry' ] as $entry ) { |
| 119 | - $testCase[ 2 ][] = [ $entry[ 'term' ], $entry[ 'definition' ], $entry[ 'link' ], $entry[ 'style' ] ]; |
|
| 119 | + $testCase[ 2 ][ ] = [ $entry[ 'term' ], $entry[ 'definition' ], $entry[ 'link' ], $entry[ 'style' ] ]; |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | \Wikimedia\restoreWarnings(); |
| 123 | 123 | |
| 124 | - $data[] = $testCase; |
|
| 124 | + $data[ ] = $testCase; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | return $data; |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | } else { |
| 155 | 155 | |
| 156 | 156 | wfDebug( "Cache miss: Lingo tree not found in cache.\n" ); |
| 157 | - $this->mLingoTree =& $this->buildLingo(); |
|
| 157 | + $this->mLingoTree = & $this->buildLingo(); |
|
| 158 | 158 | wfDebug( "Cached lingo tree.\n" ); |
| 159 | 159 | } |
| 160 | 160 | |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | } else { |
| 167 | 167 | wfDebug( "Caching of lingo tree disabled.\n" ); |
| 168 | - $this->mLingoTree =& $this->buildLingo(); |
|
| 168 | + $this->mLingoTree = & $this->buildLingo(); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | } |
@@ -201,10 +201,10 @@ discard block |
||
| 201 | 201 | // Parse text identical to options used in includes/api/ApiParse.php |
| 202 | 202 | $params = $this->mApiParams; |
| 203 | 203 | $text = is_null( $params ) ? $parser->getOutput()->getText() : $parser->getOutput()->getText( [ |
| 204 | - 'allowTOC' => !$params['disabletoc'], |
|
| 205 | - 'enableSectionEditLinks' => !$params['disableeditsection'], |
|
| 206 | - 'wrapperDivClass' => $params['wrapoutputclass'], |
|
| 207 | - 'deduplicateStyles' => !$params['disablestylededuplication'], |
|
| 204 | + 'allowTOC' => !$params[ 'disabletoc' ], |
|
| 205 | + 'enableSectionEditLinks' => !$params[ 'disableeditsection' ], |
|
| 206 | + 'wrapperDivClass' => $params[ 'wrapoutputclass' ], |
|
| 207 | + 'deduplicateStyles' => !$params[ 'disablestylededuplication' ], |
|
| 208 | 208 | ] ); |
| 209 | 209 | |
| 210 | 210 | if ( $text === null || $text === '' ) { |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | // Iterate all HTML text matches |
| 236 | 236 | $numberOfTextElements = $textElements->length; |
| 237 | 237 | |
| 238 | - $definitions = []; |
|
| 238 | + $definitions = [ ]; |
|
| 239 | 239 | |
| 240 | 240 | for ( $textElementIndex = 0; $textElementIndex < $numberOfTextElements; $textElementIndex++ ) { |
| 241 | 241 | $textElement = $textElements->item( $textElementIndex ); |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | continue; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - $matches = []; |
|
| 247 | + $matches = [ ]; |
|
| 248 | 248 | preg_match_all( |
| 249 | 249 | $this->regex, |
| 250 | 250 | $textElement->nodeValue, |