@@ -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; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @param array $definition |
77 | 77 | */ |
78 | 78 | public function addDefinition( &$definition ) { |
79 | - $this->mDefinitions[] = $definition + array_fill( 0, self::ELEMENT_FIELDCOUNT, null ) ; |
|
79 | + $this->mDefinitions[ ] = $definition + array_fill( 0, self::ELEMENT_FIELDCOUNT, null ); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $descriptor = $this->getDescriptorFromLinkTarget( $linkTarget ); |
135 | 135 | |
136 | 136 | if ( $descriptor === null ) { |
137 | - $this->mDefinitions = []; |
|
137 | + $this->mDefinitions = [ ]; |
|
138 | 138 | $this->addErrorMessageForInvalidLink( $linkTarget ); |
139 | 139 | return $this->buildFormattedTermAsTooltip( $doc ); |
140 | 140 | } |
@@ -184,20 +184,20 @@ discard block |
||
184 | 184 | // set style |
185 | 185 | $classes = [ 'mw-lingo-term' ]; |
186 | 186 | |
187 | - $classes[] = $this->mDefinitions[ 0 ][ self::ELEMENT_STYLE ]; |
|
187 | + $classes[ ] = $this->mDefinitions[ 0 ][ self::ELEMENT_STYLE ]; |
|
188 | 188 | |
189 | 189 | if ( array_key_exists( 'title', $descriptor ) && $descriptor[ 'title' ] instanceof Title ) { |
190 | 190 | |
191 | - if ( !$descriptor['title']->isKnown() ) { |
|
192 | - $classes[] = 'new'; |
|
191 | + if ( !$descriptor[ 'title' ]->isKnown() ) { |
|
192 | + $classes[ ] = 'new'; |
|
193 | 193 | } |
194 | 194 | |
195 | - if ( $descriptor['title']->isExternal() ) { |
|
196 | - $classes[] = 'extiw'; |
|
195 | + if ( $descriptor[ 'title' ]->isExternal() ) { |
|
196 | + $classes[ ] = 'extiw'; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | } else { |
200 | - $classes[] = 'ext'; |
|
200 | + $classes[ ] = 'ext'; |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | return array_filter( $classes ); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | } else { |
156 | 156 | |
157 | 157 | wfDebug( "Cache miss: Lingo tree not found in cache.\n" ); |
158 | - $this->mLingoTree =& $this->buildLingo(); |
|
158 | + $this->mLingoTree = & $this->buildLingo(); |
|
159 | 159 | wfDebug( "Cached lingo tree.\n" ); |
160 | 160 | } |
161 | 161 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | |
167 | 167 | } else { |
168 | 168 | wfDebug( "Caching of lingo tree disabled.\n" ); |
169 | - $this->mLingoTree =& $this->buildLingo(); |
|
169 | + $this->mLingoTree = & $this->buildLingo(); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | // Iterate all HTML text matches |
232 | 232 | $numberOfTextElements = $textElements->length; |
233 | 233 | |
234 | - $definitions = []; |
|
234 | + $definitions = [ ]; |
|
235 | 235 | |
236 | 236 | for ( $textElementIndex = 0; $textElementIndex < $numberOfTextElements; $textElementIndex++ ) { |
237 | 237 | $textElement = $textElements->item( $textElementIndex ); |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | continue; |
241 | 241 | } |
242 | 242 | |
243 | - $matches = []; |
|
243 | + $matches = [ ]; |
|
244 | 244 | preg_match_all( |
245 | 245 | $this->regex, |
246 | 246 | $textElement->nodeValue, |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | public function testCanConstruct() { |
54 | 54 | |
55 | 55 | $term = 'someTerm'; |
56 | - $definition = []; |
|
56 | + $definition = [ ]; |
|
57 | 57 | $element = new Element( $term, $definition ); |
58 | 58 | |
59 | 59 | $this->assertInstanceOf( '\Lingo\Element', $element ); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $GLOBALS[ 'wgexLingoDisplayOnce' ] = false; |
80 | 80 | |
81 | - $expectedAttributes = ['class' => [ 'mw-lingo-term' ], 'data-lingo-term-id' => '8ade40e10f35a32fbb1e06a4b54751d0' ]; |
|
81 | + $expectedAttributes = [ 'class' => [ 'mw-lingo-term' ], 'data-lingo-term-id' => '8ade40e10f35a32fbb1e06a4b54751d0' ]; |
|
82 | 82 | |
83 | 83 | // Run |
84 | 84 | $node = $element->getFormattedTerm( $this->doc ); |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | |
103 | 103 | // Setup |
104 | 104 | $term = 'someTerm'; |
105 | - $definition = []; |
|
105 | + $definition = [ ]; |
|
106 | 106 | $element = new Element( $term, $definition ); |
107 | 107 | |
108 | 108 | $GLOBALS[ 'wgexLingoDisplayOnce' ] = true; |
109 | 109 | |
110 | - $expectedAttributes = ['class' => 'mw-lingo-term', 'data-lingo-term-id' => '8ade40e10f35a32fbb1e06a4b54751d0' ]; |
|
110 | + $expectedAttributes = [ 'class' => 'mw-lingo-term', 'data-lingo-term-id' => '8ade40e10f35a32fbb1e06a4b54751d0' ]; |
|
111 | 111 | |
112 | 112 | // Run |
113 | 113 | $node = $element->getFormattedTerm( $this->doc ); |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | |
147 | 147 | $element = new Element( $term, $definition ); |
148 | 148 | |
149 | - $expectedAttributes = [ 'class' => [ 'mw-lingo-term', 'new' ], 'title' => wfMessage( 'red-link-title', $title )->text()]; |
|
149 | + $expectedAttributes = [ 'class' => [ 'mw-lingo-term', 'new' ], 'title' => wfMessage( 'red-link-title', $title )->text() ]; |
|
150 | 150 | |
151 | 151 | $GLOBALS[ 'wgexLingoDisplayOnce' ] = false; |
152 | 152 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | |
184 | 184 | $element = new Element( $term, $definition ); |
185 | 185 | |
186 | - $expectedAttributes = [ 'class' => [ 'mw-lingo-term' ], 'title' => $title ]; |
|
186 | + $expectedAttributes = [ 'class' => [ 'mw-lingo-term' ], 'title' => $title ]; |
|
187 | 187 | |
188 | 188 | $GLOBALS[ 'wgexLingoDisplayOnce' ] = false; |
189 | 189 | |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | * @param string[] $expectedAttributes |
491 | 491 | * @param array $unexpectedAttributes |
492 | 492 | */ |
493 | - protected function checkTermIsDomElement( $node, $tagName, $text, $expectedAttributes = [], $unexpectedAttributes = [] ) { |
|
493 | + protected function checkTermIsDomElement( $node, $tagName, $text, $expectedAttributes = [ ], $unexpectedAttributes = [ ] ) { |
|
494 | 494 | $nodeText = $this->doc->saveHTML( $node ); |
495 | 495 | |
496 | 496 | $this->assertInstanceOf( 'DOMElement', $node ); |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | $classes = array_flip( array_filter( explode( ' ', $node->getAttribute( 'class' ) ) ) ); |
503 | 503 | |
504 | 504 | foreach ( (array) $expectedAttributes[ 'class' ] as $expectedClass ) { |
505 | - $this->assertTrue( array_key_exists( $expectedClass , $classes ) ); |
|
505 | + $this->assertTrue( array_key_exists( $expectedClass, $classes ) ); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | unset( $expectedAttributes[ 'class' ] ); |