jenkins-bot has submitted this change and it was merged.

Change subject: BREAKING CHANGE: update mediawiki-codesniffer to 0.7.1
......................................................................


BREAKING CHANGE: update mediawiki-codesniffer to 0.7.1

Remove autoloading of LocalisationUpdate.php because it breaks
everything. Use wfLoadExtension( 'LocalisationUpdate' ); if you
are not using it already.

Remove exclude extensions, no extension dependencies in this repo.

Diff produced by running "composer fix" added in this patch.

Change-Id: I84f6f6058be8935d788d3ca8c9639bcb0dbc2ee9
---
M LocalisationUpdate.class.php
M QuickArrayReader.php
M Updater.php
M composer.json
M fetcher/FileSystemFetcher.php
M fetcher/GitHubFetcher.php
M fetcher/HttpFetcher.php
M finder/Finder.php
M reader/JSONReader.php
M reader/PHPReader.php
M tests/phpunit/UpdaterTest.php
M tests/phpunit/finder/FinderTest.php
M tests/phpunit/reader/JSONReaderTest.php
M tests/phpunit/reader/ReaderFactoryTest.php
14 files changed, 88 insertions(+), 92 deletions(-)

Approvals:
  KartikMistry: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/LocalisationUpdate.class.php b/LocalisationUpdate.class.php
index d826b5b..dec4b4e 100644
--- a/LocalisationUpdate.class.php
+++ b/LocalisationUpdate.class.php
@@ -31,7 +31,7 @@
                        return true;
                }
 
-               $codeSequence = array_merge( array( $code ), 
$cache['fallbackSequence'] );
+               $codeSequence = array_merge( [ $code ], 
$cache['fallbackSequence'] );
                foreach ( $codeSequence as $csCode ) {
                        $fileName = "$dir/" . self::getFilename( $csCode );
                        $cache['deps'][] = new FileDependency( $fileName );
diff --git a/QuickArrayReader.php b/QuickArrayReader.php
index 65b6227..c96bab4 100644
--- a/QuickArrayReader.php
+++ b/QuickArrayReader.php
@@ -7,23 +7,23 @@
  * Still an order of magnitude slower than eval().
  */
 class QuickArrayReader {
-       private $vars = array();
+       private $vars = [];
 
        /**
         * @param $string string
         */
        function __construct( $string ) {
-               $scalarTypes = array(
+               $scalarTypes = [
                        T_LNUMBER => true,
                        T_DNUMBER => true,
                        T_STRING => true,
                        T_CONSTANT_ENCAPSED_STRING => true,
-               );
-               $skipTypes = array(
+               ];
+               $skipTypes = [
                        T_WHITESPACE => true,
                        T_COMMENT => true,
                        T_DOC_COMMENT => true,
-               );
+               ];
                $tokens = token_get_all( $string );
                $count = count( $tokens );
                for ( $i = 0; $i < $count; ) {
@@ -75,7 +75,7 @@
                                                if ( $tokens[$i] !== '(' ) {
                                                        throw $this->except( 
$tokens[$i], '(' );
                                                }
-                                               $buildval = array();
+                                               $buildval = [];
                                                do {
                                                        while ( isset( 
$skipTypes[$tokens[++$i][0]] ) ) {
                                                        }
@@ -169,7 +169,7 @@
                        // appended to the token; without it we ended up 
reading in the
                        // extra quote on the end!
                        return strtr( substr( trim( $str ), 1, -1 ),
-                               array( '\\\'' => '\'', '\\\\' => '\\' ) );
+                               [ '\\\'' => '\'', '\\\\' => '\\' ] );
                }
 
                wfSuppressWarnings();
diff --git a/Updater.php b/Updater.php
index 6055f5d..456c9bc 100644
--- a/Updater.php
+++ b/Updater.php
@@ -38,7 +38,7 @@
 
                // This assumes all other keys are used as variables
                // in the pattern. For example name -> %NAME%.
-               $keys = array();
+               $keys = [];
                foreach ( array_keys( $info ) as $key ) {
                        $keys[] = '%' . strtoupper( $key ) . '%';
                }
@@ -55,7 +55,7 @@
         * @return array List of translations indexed by language code.
         */
        public function readMessages( ReaderFactory $readerFactory, array 
$files ) {
-               $messages = array();
+               $messages = [];
 
                foreach ( $files as $filename => $contents ) {
                        $reader = $readerFactory->getReader( $filename );
@@ -68,7 +68,7 @@
 
                        foreach ( $parsed as $code => $langMessages ) {
                                if ( !isset( $messages[$code] ) ) {
-                                       $messages[$code] = array();
+                                       $messages[$code] = [];
                                }
                                $messages[$code] = array_merge( 
$messages[$code], $langMessages );
                        }
@@ -89,8 +89,8 @@
         * @param array [$blacklist] Array of message keys to ignore, keys as 
as array keys.
         * @return array
         */
-       public function findChangedTranslations( $origin, $remote, $blacklist = 
array() ) {
-               $changed = array();
+       public function findChangedTranslations( $origin, $remote, $blacklist = 
[] ) {
+               $changed = [];
                foreach ( $remote as $key => $value ) {
                        if ( isset( $blacklist[$key] ) ) {
                                continue;
@@ -116,7 +116,7 @@
                if ( $this->isDirectory( $path ) ) {
                        $files = $fetcher->fetchDirectory( $path );
                } else {
-                       $files = array( $path => $fetcher->fetchFile( $path ) );
+                       $files = [ $path => $fetcher->fetchFile( $path ) ];
                }
 
                // Remove files which were not found
@@ -132,13 +132,13 @@
 
                $components = $finder->getComponents();
 
-               $updatedMessages = array();
+               $updatedMessages = [];
 
                foreach ( $components as $key => $info ) {
                        $originFiles = $this->fetchFiles( $fetcherFactory, 
$info['orig'] );
                        $remoteFiles = $this->fetchFiles( $fetcherFactory, 
$this->expandRemotePath( $info, $repos ) );
 
-                       if ( $remoteFiles === array() ) {
+                       if ( $remoteFiles === [] ) {
                                // Small optimization: if nothing to compare 
with, skip
                                continue;
                        }
@@ -165,7 +165,7 @@
                        // message: string in all languages; translation: 
string in one language.
                        foreach ( $remoteMessages as $language => 
$remoteTranslations ) {
                                // Check for completely new languages
-                               $originTranslations = array();
+                               $originTranslations = [];
                                if ( isset( $originMessages[$language] ) ) {
                                        $originTranslations = 
$originMessages[$language];
                                }
@@ -177,12 +177,12 @@
                                );
 
                                // Avoid empty arrays
-                               if ( $updatedTranslations === array() ) {
+                               if ( $updatedTranslations === [] ) {
                                        continue;
                                }
 
                                if ( !isset( $updatedMessages[$language] ) ) {
-                                       $updatedMessages[$language] = array();
+                                       $updatedMessages[$language] = [];
                                }
 
                                // In case of conflicts, which should not 
exist, this prefers the
diff --git a/composer.json b/composer.json
index a7798c3..d8c530d 100644
--- a/composer.json
+++ b/composer.json
@@ -31,18 +31,14 @@
                "forum": 
"https://www.mediawiki.org/wiki/Extension_talk:LocalisationUpdate";,
                "wiki": 
"https://www.mediawiki.org/wiki/Extension:LocalisationUpdate";
        },
-       "autoload": {
-               "files": [
-                       "LocalisationUpdate.php"
-               ]
-       },
        "require-dev": {
                "jakub-onderka/php-parallel-lint": "0.9.2",
                "mediawiki/mediawiki-codesniffer": "0.7.1"
        },
        "scripts": {
+               "fix": "phpcbf",
                "test": [
-                       "parallel-lint . --exclude vendor --exclude extensions",
+                       "parallel-lint . --exclude vendor",
                        "phpcs -p -s"
                ],
                "fix": [
diff --git a/fetcher/FileSystemFetcher.php b/fetcher/FileSystemFetcher.php
index 9ed84b5..6d21586 100644
--- a/fetcher/FileSystemFetcher.php
+++ b/fetcher/FileSystemFetcher.php
@@ -26,7 +26,7 @@
                // Remove the protocol prefix
                $pattern = preg_replace( '~^file://~', '', $pattern );
 
-               $data = array();
+               $data = [];
                foreach ( glob( $pattern ) as $file ) {
                        if ( is_readable( $file ) ) {
                                $data["file://$file"] = file_get_contents( 
$file );
diff --git a/fetcher/GitHubFetcher.php b/fetcher/GitHubFetcher.php
index 03ef531..5bc7d4f 100644
--- a/fetcher/GitHubFetcher.php
+++ b/fetcher/GitHubFetcher.php
@@ -27,7 +27,7 @@
                        throw new \Exception( "Unable to get directory listing 
for {$m['org']}/{$m['repo']}" );
                }
 
-               $files = array();
+               $files = [];
                $json = \FormatJson::decode( $json, true );
                foreach ( $json as $fileinfo ) {
                        $fileurl = dirname( $pattern ) . '/' . 
$fileinfo['name'];
diff --git a/fetcher/HttpFetcher.php b/fetcher/HttpFetcher.php
index 27e6512..42b0f03 100644
--- a/fetcher/HttpFetcher.php
+++ b/fetcher/HttpFetcher.php
@@ -20,7 +20,7 @@
         * implementation of this.
         */
        public function fetchDirectory( $pattern ) {
-               $files = array();
+               $files = [];
 
                $languages = \Language::fetchLanguageNames( null, 'mwfile' );
 
diff --git a/finder/Finder.php b/finder/Finder.php
index f59ec2c..20ba937 100644
--- a/finder/Finder.php
+++ b/finder/Finder.php
@@ -27,15 +27,15 @@
         * @return array
         */
        public function getComponents() {
-               $components = array();
+               $components = [];
 
                // For older versions of Mediawiki, pull json updates even 
though its still using php
                if ( !isset( $this->json['core'] ) ) {
-                       $components['core'] = array(
+                       $components['core'] = [
                                'repo' => 'mediawiki',
                                'orig' => 
"file://{$this->core}/languages/messages/Messages*.php",
                                'path' => 'languages/messages/i18n/*.json',
-                       );
+                       ];
                }
 
                foreach ( $this->json as $key => $value ) {
@@ -44,13 +44,13 @@
 
                        foreach ( (array)$value as $subkey => $subvalue ) {
                                // Mediawiki core files
-                               $matches = array();
+                               $matches = [];
                                if ( preg_match( 
'~/(?P<path>(?:includes|languages|resources)/.*)$~', $subvalue, $matches ) ) {
-                                       $components["$key-$subkey"] = array(
+                                       $components["$key-$subkey"] = [
                                                'repo' => 'mediawiki',
                                                'orig' => 
"file://$value/*.json",
                                                'path' => 
"{$matches['path']}/*.json",
-                                       );
+                                       ];
                                        continue;
                                }
 
@@ -71,18 +71,18 @@
                }
 
                foreach ( $this->php as $key => $value ) {
-                       $matches = array();
+                       $matches = [];
                        $ok = preg_match( 
'~/extensions/(?P<name>[^/]+)/(?P<path>.*\.i18n\.php)$~', $value, $matches );
                        if ( !$ok ) {
                                continue;
                        }
 
-                       $components[$key] = array(
+                       $components[$key] = [
                                'repo' => 'extension',
                                'name' => $matches['name'],
                                'orig' => "file://$value",
                                'path' => $matches['path'],
-                       );
+                       ];
                }
 
                return $components;
@@ -95,15 +95,15 @@
         */
        private function getItem( $dir, $subvalue ) {
                // This ignores magic, alias etc. non message files
-               $matches = array();
+               $matches = [];
                if ( !preg_match( "~/$dir/(?P<name>[^/]+)/(?P<path>.*)$~", 
$subvalue, $matches ) ) {
                        return null;
                }
 
-               return array(
+               return [
                        'name' => $matches['name'],
                        'orig' => "file://$subvalue/*.json",
                        'path' => "{$matches['path']}/*.json",
-               );
+               ];
        }
 }
diff --git a/reader/JSONReader.php b/reader/JSONReader.php
index 7df4070..fdc4e1d 100644
--- a/reader/JSONReader.php
+++ b/reader/JSONReader.php
@@ -23,7 +23,7 @@
                unset( $messages['@metadata'] );
 
                if ( $this->code ) {
-                       return array( $this->code => $messages );
+                       return [ $this->code => $messages ];
                }
 
                // Assuming that the array is keyed by language codes
diff --git a/reader/PHPReader.php b/reader/PHPReader.php
index 649f4a0..f314744 100644
--- a/reader/PHPReader.php
+++ b/reader/PHPReader.php
@@ -21,7 +21,7 @@
        public function parse( $contents ) {
                if ( strpos( $contents, '$messages' ) === false ) {
                        // This happens for some core languages that only have 
a fallback.
-                       return array();
+                       return [];
                }
 
                $php = $this->cleanupFile( $contents );
@@ -29,7 +29,7 @@
                $messages = $reader->getVar( 'messages' );
 
                if ( $this->code ) {
-                       return array( $this->code => $messages );
+                       return [ $this->code => $messages ];
                }
 
                // Assuming that the array is keyed by language codes
@@ -47,7 +47,7 @@
                $contents = preg_replace( '/\r\n?/', "\n", $contents );
 
                // We only want message arrays.
-               $results = array();
+               $results = [];
                preg_match_all( '/\$messages(?:.*\s)*?\);/', $contents, 
$results );
 
                // But we want them all in one string.
diff --git a/tests/phpunit/UpdaterTest.php b/tests/phpunit/UpdaterTest.php
index d4afc52..d315403 100644
--- a/tests/phpunit/UpdaterTest.php
+++ b/tests/phpunit/UpdaterTest.php
@@ -24,13 +24,13 @@
 
        public function testExpandRemotePath() {
                $updater = new Updater();
-               $repos = array( 'main' => 'file:///repos/%NAME%/%SOME-VAR%' );
+               $repos = [ 'main' => 'file:///repos/%NAME%/%SOME-VAR%' ];
 
-               $info = array(
+               $info = [
                        'repo' => 'main',
                        'name' => 'product',
                        'some-var' => 'file',
-               );
+               ];
                $this->assertEquals(
                        'file:///repos/product/file',
                        $updater->expandRemotePath( $info, $repos ),
@@ -41,8 +41,8 @@
        public function testReadMessages() {
                $updater = $updater = new Updater();
 
-               $input = array( 'file' => 'Hello World!' );
-               $output = array( 'en' => array( 'key' => $input['file'] ) );
+               $input = [ 'file' => 'Hello World!' ];
+               $output = [ 'en' => [ 'key' => $input['file'] ] ];
 
                $reader = $this->getMock( 'LocalisationUpdate\Reader' );
                $reader
@@ -63,19 +63,19 @@
        public function testFindChangedTranslations() {
                $updater = $updater = new Updater();
 
-               $origin = array(
+               $origin = [
                        'A' => '1',
                        'C' => '3',
                        'D' => '4',
-               );
-               $remote = array(
+               ];
+               $remote = [
                        'A' => '1', // No change key
                        'B' => '2', // New key
                        'C' => '33', // Changed key
                        'D' => '44', // Blacklisted key
-               );
-               $blacklist = array( 'D' => 0 );
-               $expected = array( 'B' => '2', 'C' => '33' );
+               ];
+               $blacklist = [ 'D' => 0 ];
+               $expected = [ 'B' => '2', 'C' => '33' ];
                $observed = $updater->findChangedTranslations( $origin, 
$remote, $blacklist );
                $this->assertEquals( $expected, $observed, 'Changed and new 
keys returned' );
        }
diff --git a/tests/phpunit/finder/FinderTest.php 
b/tests/phpunit/finder/FinderTest.php
index b767bf6..1b7d786 100644
--- a/tests/phpunit/finder/FinderTest.php
+++ b/tests/phpunit/finder/FinderTest.php
@@ -10,73 +10,73 @@
 class FinderTest extends \PHPUnit_Framework_TestCase {
        public function testGetComponents() {
                $finder = new Finder(
-                       array(
+                       [
                                'TranslateSearch' => 
'/IP/extensions/Translate/TranslateSearch.i18n.php',
                                'Babel' => 
'/IP/extensions/Babel/Babel.i18n.php',
-                       ),
-                       array(
+                       ],
+                       [
                                'Babel' => '/IP/extensions/Babel/i18n',
-                               'Door' => array(
+                               'Door' => [
                                        'core' => 
'/IP/extensions/Door/i18n/core',
                                        'extra' => 
'/IP/extensions/Door/i18n/extra',
-                               ),
+                               ],
                                'Vector' => '/IP/skins/Vector/i18n',
-                       ),
+                       ],
                        '/IP'
                );
                $observed = $finder->getComponents();
 
-               $expected = array(
+               $expected = [
                        'repo' => 'mediawiki',
                        'orig' => "file:///IP/languages/messages/Messages*.php",
                        'path' => 'languages/messages/i18n/*.json',
-               );
+               ];
 
                $this->assertArrayHasKey( 'core', $observed );
                $this->assertEquals( $expected, $observed['core'], 'Core php 
file' );
 
-               $expected = array(
+               $expected = [
                        'repo' => 'extension',
                        'name' => 'Translate',
                        'orig' => 
'file:///IP/extensions/Translate/TranslateSearch.i18n.php',
                        'path' => 'TranslateSearch.i18n.php'
-               );
+               ];
                $this->assertArrayHasKey( 'TranslateSearch', $observed );
                $this->assertEquals( $expected, $observed['TranslateSearch'], 
'PHP only extension' );
 
-               $expected = array(
+               $expected = [
                        'repo' => 'extension',
                        'name' => 'Babel',
                        'orig' => 'file:///IP/extensions/Babel/i18n/*.json',
                        'path' => 'i18n/*.json'
-               );
+               ];
                $this->assertArrayHasKey( 'Babel-0', $observed );
                $this->assertEquals( $expected, $observed['Babel-0'], 'PHP&JSON 
extension' );
 
-               $expected = array(
+               $expected = [
                        'repo' => 'extension',
                        'name' => 'Door',
                        'orig' => 'file:///IP/extensions/Door/i18n/core/*.json',
                        'path' => 'i18n/core/*.json'
-               );
+               ];
                $this->assertArrayHasKey( 'Door-core', $observed );
                $this->assertEquals( $expected, $observed['Door-core'], 
'Multidir json extension' );
 
-               $expected = array(
+               $expected = [
                        'repo' => 'extension',
                        'name' => 'Door',
                        'orig' => 
'file:///IP/extensions/Door/i18n/extra/*.json',
                        'path' => 'i18n/extra/*.json'
-               );
+               ];
                $this->assertArrayHasKey( 'Door-extra', $observed );
                $this->assertEquals( $expected, $observed['Door-extra'], 
'Multidir json extension' );
 
-               $expected = array(
+               $expected = [
                        'repo' => 'skin',
                        'name' => 'Vector',
                        'orig' => 'file:///IP/skins/Vector/i18n/*.json',
                        'path' => 'i18n/*.json'
-               );
+               ];
                $this->assertArrayHasKey( 'Vector-0', $observed );
                $this->assertEquals( $expected, $observed['Vector-0'], 'Json 
skin' );
        }
diff --git a/tests/phpunit/reader/JSONReaderTest.php 
b/tests/phpunit/reader/JSONReaderTest.php
index 06d4cd6..bd5c049 100644
--- a/tests/phpunit/reader/JSONReaderTest.php
+++ b/tests/phpunit/reader/JSONReaderTest.php
@@ -18,22 +18,22 @@
        }
 
        public function parseProvider() {
-               return array(
-                       array(
+               return [
+                       [
                                '{}',
-                               array(),
+                               [],
                                'empty file',
-                       ),
-                       array(
+                       ],
+                       [
                                '{"key":"value"}',
-                               array( 'key' => 'value' ),
+                               [ 'key' => 'value' ],
                                'file with one string',
-                       ),
-                       array(
+                       ],
+                       [
                                
'{"@metadata":{"authors":["Nike"]},"key":"value2"}',
-                               array( 'key' => 'value2' ),
+                               [ 'key' => 'value2' ],
                                '@metadata is ignored',
-                       )
-               );
+                       ]
+               ];
        }
 }
diff --git a/tests/phpunit/reader/ReaderFactoryTest.php 
b/tests/phpunit/reader/ReaderFactoryTest.php
index 9cb1a8f..feeb68c 100644
--- a/tests/phpunit/reader/ReaderFactoryTest.php
+++ b/tests/phpunit/reader/ReaderFactoryTest.php
@@ -19,22 +19,22 @@
        }
 
        public function getReaderProvider() {
-               return array(
-                       array(
+               return [
+                       [
                                'languages/messages/MessagesFi.php',
                                'LocalisationUpdate\PHPReader',
                                'core php file',
-                       ),
-                       array(
+                       ],
+                       [
                                'extensions/Translate/Translate.i18n.php',
                                'LocalisationUpdate\PHPReader',
                                'extension php file',
-                       ),
-                       array(
+                       ],
+                       [
                                'extension/Translate/i18n/core/de.json',
                                'LocalisationUpdate\JSONReader',
                                'extension json file',
-                       ),
-               );
+                       ],
+               ];
        }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/287315
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I84f6f6058be8935d788d3ca8c9639bcb0dbc2ee9
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/LocalisationUpdate
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <[email protected]>
Gerrit-Reviewer: KartikMistry <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Santhosh <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to