@@ -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 ]; |
@@ -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' ] = [ |
@@ -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, |
@@ -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 ); |