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