@@ -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 ], |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | } |
89 | 89 | |
90 | 90 | public function provideData() { |
91 | - $data = []; |
|
91 | + $data = [ ]; |
|
92 | 92 | |
93 | 93 | $xmlFileProvider = new XmlFileProvider( __DIR__ . '/../Fixture/articleAnnotation' ); |
94 | 94 | $files = $xmlFileProvider->getFiles(); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | $testCase = [ |
106 | 106 | 0 => substr( $file, strlen( __DIR__ . '/../Fixture/articleAnnotation' ) ), |
107 | 107 | 1 => trim( $decoded[ 'text' ] ), |
108 | - 2 => [], |
|
108 | + 2 => [ ], |
|
109 | 109 | 3 => trim( $decoded[ 'expected' ] ) . "\n", |
110 | 110 | ]; |
111 | 111 | |
@@ -114,12 +114,12 @@ discard block |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | foreach ( $decoded[ 'glossary-entry' ] as $entry ) { |
117 | - $testCase[ 2 ][] = [ $entry[ 'term' ], $entry[ 'definition' ], $entry[ 'link' ], $entry[ 'style' ] ]; |
|
117 | + $testCase[ 2 ][ ] = [ $entry[ 'term' ], $entry[ 'definition' ], $entry[ 'link' ], $entry[ 'style' ] ]; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | \MediaWiki\restoreWarnings(); |
121 | 121 | |
122 | - $data[] = $testCase; |
|
122 | + $data[ ] = $testCase; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | return $data; |
@@ -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, |
@@ -47,14 +47,14 @@ discard block |
||
47 | 47 | const ELEMENT_LINK = 3; |
48 | 48 | const ELEMENT_STYLE = 4; |
49 | 49 | |
50 | - const ELEMENT_FIELDCOUNT = 5; // number of fields stored for each element; (last field's index) + 1 |
|
50 | + const ELEMENT_FIELDCOUNT = 5; // number of fields stored for each element; (last field's index) + 1 |
|
51 | 51 | |
52 | 52 | const LINK_TEMPLATE_ID = 'LingoLink'; |
53 | 53 | |
54 | 54 | private $formattedTerm = null; |
55 | 55 | private $formattedDefinitions = null; |
56 | 56 | |
57 | - private $mDefinitions = []; |
|
57 | + private $mDefinitions = [ ]; |
|
58 | 58 | private $mTerm = null; |
59 | 59 | |
60 | 60 | private $hasBeenDisplayed = false; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @param array $definition |
75 | 75 | */ |
76 | 76 | public function addDefinition( &$definition ) { |
77 | - $this->mDefinitions[] = $definition + array_fill( 0, self::ELEMENT_FIELDCOUNT, null ); |
|
77 | + $this->mDefinitions[ ] = $definition + array_fill( 0, self::ELEMENT_FIELDCOUNT, null ); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | $descriptor = $this->getDescriptorFromLinkTarget( $linkTarget ); |
130 | 130 | |
131 | 131 | if ( $descriptor === null ) { |
132 | - $this->mDefinitions = []; |
|
132 | + $this->mDefinitions = [ ]; |
|
133 | 133 | $this->addErrorMessageForInvalidLink( $linkTarget ); |
134 | 134 | return $this->buildFormattedTermAsTooltip( $doc ); |
135 | 135 | } |
@@ -177,20 +177,20 @@ discard block |
||
177 | 177 | // set style |
178 | 178 | $classes = [ 'mw-lingo-term' ]; |
179 | 179 | |
180 | - $classes[] = $this->mDefinitions[ 0 ][ self::ELEMENT_STYLE ]; |
|
180 | + $classes[ ] = $this->mDefinitions[ 0 ][ self::ELEMENT_STYLE ]; |
|
181 | 181 | |
182 | 182 | if ( array_key_exists( 'title', $descriptor ) && $descriptor[ 'title' ] instanceof Title ) { |
183 | 183 | |
184 | - if ( !$descriptor['title']->isKnown() ) { |
|
185 | - $classes[] = 'new'; |
|
184 | + if ( !$descriptor[ 'title' ]->isKnown() ) { |
|
185 | + $classes[ ] = 'new'; |
|
186 | 186 | } |
187 | 187 | |
188 | - if ( $descriptor['title']->isExternal() ) { |
|
189 | - $classes[] = 'extiw'; |
|
188 | + if ( $descriptor[ 'title' ]->isExternal() ) { |
|
189 | + $classes[ ] = 'extiw'; |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | } else { |
193 | - $classes[] = 'ext'; |
|
193 | + $classes[ ] = 'ext'; |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | return array_filter( $classes ); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @since 2.0.2 |
43 | 43 | */ |
44 | 44 | public static function initExtension() { |
45 | - $GLOBALS[ 'wgExtensionFunctions' ][] = function () { |
|
45 | + $GLOBALS[ 'wgExtensionFunctions' ][ ] = function() { |
|
46 | 46 | $parser = LingoParser::getInstance(); |
47 | 47 | |
48 | 48 | $backend = new $GLOBALS[ 'wgexLingoBackend' ](); |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | |
52 | 52 | \Hooks::register( 'ContentAlterParserOutput', [ $parser, 'parse' ] ); |
53 | 53 | |
54 | - \Hooks::register( 'GetDoubleUnderscoreIDs', function ( array &$doubleUnderscoreIDs ) { |
|
55 | - $doubleUnderscoreIDs[] = 'noglossary'; |
|
54 | + \Hooks::register( 'GetDoubleUnderscoreIDs', function( array &$doubleUnderscoreIDs ) { |
|
55 | + $doubleUnderscoreIDs[ ] = 'noglossary'; |
|
56 | 56 | return true; |
57 | 57 | } ); |
58 | 58 | |
59 | - \Hooks::register( 'ParserFirstCallInit', function ( \Parser $parser ) { |
|
60 | - $parser->setHook( 'noglossary', function ( $input, array $args, \Parser $parser, \PPFrame $frame ) { |
|
59 | + \Hooks::register( 'ParserFirstCallInit', function( \Parser $parser ) { |
|
60 | + $parser->setHook( 'noglossary', function( $input, array $args, \Parser $parser, \PPFrame $frame ) { |
|
61 | 61 | $output = $parser->recursiveTagParse( $input, $frame ); |
62 | 62 | return '<span class="noglossary">' . $output . '</span>'; |
63 | 63 | } ); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | return true; |
66 | 66 | } ); |
67 | 67 | |
68 | - \Hooks::register( 'SpecialPageBeforeExecute', function ( \SpecialPage $specialPage, $subPage ) { |
|
68 | + \Hooks::register( 'SpecialPageBeforeExecute', function( \SpecialPage $specialPage, $subPage ) { |
|
69 | 69 | if ( $specialPage instanceof \SpecialVersion ) { |
70 | 70 | foreach ( $GLOBALS[ 'wgExtensionCredits' ][ 'parserhook' ] as $index => $description ) { |
71 | 71 | if ( $GLOBALS[ 'wgExtensionCredits' ][ 'parserhook' ][ $index ][ 'name' ] === 'Lingo' ) { |