build: Updating mediawiki/mediawiki-codesniffer to 0.7.1

Also added "composer fix" command.

Change-Id: I6f3f29f03abb607fbca9cec6f140875f2a3468a0
This commit is contained in:
Kunal Mehta
2016-05-09 18:30:34 -07:00
parent 6089ea868d
commit 6b8c33e763
11 changed files with 98 additions and 96 deletions

View File

@@ -96,10 +96,10 @@ class UniversalLanguageSelectorHooks {
// If EventLogging integration is enabled, load the schema module // If EventLogging integration is enabled, load the schema module
// and the event logging functions module // and the event logging functions module
if ( $wgULSEventLogging ) { if ( $wgULSEventLogging ) {
$out->addModules( array( $out->addModules( [
'schema.UniversalLanguageSelector', 'schema.UniversalLanguageSelector',
'ext.uls.eventlogger', 'ext.uls.eventlogger',
) ); ] );
} }
// If the extension is enabled, basic features (API, language data) available. // If the extension is enabled, basic features (API, language data) available.
@@ -141,12 +141,12 @@ class UniversalLanguageSelectorHooks {
* Hook: ResourceLoaderTestModules * Hook: ResourceLoaderTestModules
*/ */
public static function addTestModules( array &$testModules, ResourceLoader $resourceLoader ) { public static function addTestModules( array &$testModules, ResourceLoader $resourceLoader ) {
$testModules['qunit']['ext.uls.tests'] = array( $testModules['qunit']['ext.uls.tests'] = [
'scripts' => array( 'tests/qunit/ext.uls.tests.js' ), 'scripts' => [ 'tests/qunit/ext.uls.tests.js' ],
'dependencies' => array( 'jquery.uls', 'ext.uls.init', 'ext.uls.preferences' ), 'dependencies' => [ 'jquery.uls', 'ext.uls.init', 'ext.uls.preferences' ],
'localBasePath' => __DIR__, 'localBasePath' => __DIR__,
'remoteExtPath' => 'UniversalLanguageSelector', 'remoteExtPath' => 'UniversalLanguageSelector',
); ];
return true; return true;
} }
@@ -169,14 +169,14 @@ class UniversalLanguageSelectorHooks {
// The element id will be 'pt-uls' // The element id will be 'pt-uls'
$langCode = $context->getLanguage()->getCode(); $langCode = $context->getLanguage()->getCode();
$personal_urls = array( $personal_urls = [
'uls' => array( 'uls' => [
'text' => Language::fetchLanguageName( $langCode ), 'text' => Language::fetchLanguageName( $langCode ),
'href' => '#', 'href' => '#',
'class' => 'uls-trigger autonym', 'class' => 'uls-trigger autonym',
'active' => true 'active' => true
) ]
) + $personal_urls; ] + $personal_urls;
return true; return true;
} }
@@ -340,19 +340,19 @@ class UniversalLanguageSelectorHooks {
} }
public static function onGetPreferences( $user, &$preferences ) { public static function onGetPreferences( $user, &$preferences ) {
$preferences['uls-preferences'] = array( $preferences['uls-preferences'] = [
'type' => 'api', 'type' => 'api',
); ];
// A link shown for accessing ULS language settings from preferences screen // A link shown for accessing ULS language settings from preferences screen
$preferences['languagesettings'] = array( $preferences['languagesettings'] = [
'type' => 'info', 'type' => 'info',
'raw' => true, 'raw' => true,
'section' => 'personal/i18n', 'section' => 'personal/i18n',
'default' => "<a id='uls-preferences-link' href='#'></a>", 'default' => "<a id='uls-preferences-link' href='#'></a>",
// The above link will have text set from javascript. Just to avoid // The above link will have text set from javascript. Just to avoid
// showing the link when javascript is disabled. // showing the link when javascript is disabled.
); ];
return true; return true;
} }
@@ -366,18 +366,18 @@ class UniversalLanguageSelectorHooks {
$wgHideInterlanguageLinks === false $wgHideInterlanguageLinks === false
) { ) {
$imagesDir = "$wgExtensionAssetsPath/UniversalLanguageSelector/resources/images"; $imagesDir = "$wgExtensionAssetsPath/UniversalLanguageSelector/resources/images";
$prefs['uls-compact-links'] = array( $prefs['uls-compact-links'] = [
'label-message' => 'uls-betafeature-label', 'label-message' => 'uls-betafeature-label',
'desc-message' => 'uls-betafeature-desc', 'desc-message' => 'uls-betafeature-desc',
'screenshot' => array( 'screenshot' => [
'ltr' => "$imagesDir/compact-links-ltr.png", 'ltr' => "$imagesDir/compact-links-ltr.png",
'rtl' => "$imagesDir/compact-links-rtl.png", 'rtl' => "$imagesDir/compact-links-rtl.png",
), ],
'info-link' => 'info-link' =>
'https://www.mediawiki.org/wiki/Universal_Language_Selector/Design/Interlanguage_links', 'https://www.mediawiki.org/wiki/Universal_Language_Selector/Design/Interlanguage_links',
'discussion-link' => 'discussion-link' =>
'https://www.mediawiki.org/wiki/Talk:Universal_Language_Selector/Design/Interlanguage_links', 'https://www.mediawiki.org/wiki/Talk:Universal_Language_Selector/Design/Interlanguage_links',
); ];
} }
} }
@@ -401,11 +401,11 @@ class UniversalLanguageSelectorHooks {
} }
// A dummy link, just to make sure that the section appears // A dummy link, just to make sure that the section appears
$template->data['language_urls'][] = array( $template->data['language_urls'][] = [
'href' => '#', 'href' => '#',
'text' => '', 'text' => '',
'class' => 'uls-p-lang-dummy', 'class' => 'uls-p-lang-dummy',
); ];
return true; return true;
} }
@@ -439,7 +439,7 @@ class UniversalLanguageSelectorHooks {
if ( if (
( (
( (
is_callable( array( $resourceLoader, 'isModuleRegistered' ) ) && is_callable( [ $resourceLoader, 'isModuleRegistered' ] ) &&
!$resourceLoader->isModuleRegistered( 'jquery.i18n' ) !$resourceLoader->isModuleRegistered( 'jquery.i18n' )
) )
|| ||
@@ -448,18 +448,18 @@ class UniversalLanguageSelectorHooks {
&& &&
!isset( $wgResourceModules[ 'jquery.i18n' ] ) !isset( $wgResourceModules[ 'jquery.i18n' ] )
) { ) {
$resourceLoader->register( array( $resourceLoader->register( [
'jquery.i18n' => array( 'jquery.i18n' => [
'scripts' => array( 'scripts' => [
'lib/jquery.i18n/jquery.i18n.js', 'lib/jquery.i18n/jquery.i18n.js',
'lib/jquery.i18n/jquery.i18n.messagestore.js', 'lib/jquery.i18n/jquery.i18n.messagestore.js',
'lib/jquery.i18n/jquery.i18n.parser.js', 'lib/jquery.i18n/jquery.i18n.parser.js',
'lib/jquery.i18n/jquery.i18n.emitter.js', 'lib/jquery.i18n/jquery.i18n.emitter.js',
'lib/jquery.i18n/jquery.i18n.emitter.bidi.js', 'lib/jquery.i18n/jquery.i18n.emitter.bidi.js',
'lib/jquery.i18n/jquery.i18n.language.js', 'lib/jquery.i18n/jquery.i18n.language.js',
), ],
'dependencies' => 'mediawiki.libs.pluralruleparser', 'dependencies' => 'mediawiki.libs.pluralruleparser',
'languageScripts' => array( 'languageScripts' => [
'bs' => 'lib/jquery.i18n/languages/bs.js', 'bs' => 'lib/jquery.i18n/languages/bs.js',
'dsb' => 'lib/jquery.i18n/languages/dsb.js', 'dsb' => 'lib/jquery.i18n/languages/dsb.js',
'fi' => 'lib/jquery.i18n/languages/fi.js', 'fi' => 'lib/jquery.i18n/languages/fi.js',
@@ -474,26 +474,26 @@ class UniversalLanguageSelectorHooks {
'ru' => 'lib/jquery.i18n/languages/ru.js', 'ru' => 'lib/jquery.i18n/languages/ru.js',
'sl' => 'lib/jquery.i18n/languages/sl.js', 'sl' => 'lib/jquery.i18n/languages/sl.js',
'uk' => 'lib/jquery.i18n/languages/uk.js', 'uk' => 'lib/jquery.i18n/languages/uk.js',
), ],
'targets' => array( 'desktop', 'mobile' ), 'targets' => [ 'desktop', 'mobile' ],
'localBasePath' => __DIR__, 'localBasePath' => __DIR__,
'remoteExtPath' => 'UniversalLanguageSelector', 'remoteExtPath' => 'UniversalLanguageSelector',
) ]
) ); ] );
} }
if ( $wgULSEventLogging ) { if ( $wgULSEventLogging ) {
$resourceLoader->register( array( $resourceLoader->register( [
'ext.uls.eventlogger' => array( 'ext.uls.eventlogger' => [
'scripts' => 'js/ext.uls.eventlogger.js', 'scripts' => 'js/ext.uls.eventlogger.js',
'dependencies' => array( 'dependencies' => [
'mediawiki.user', 'mediawiki.user',
'schema.UniversalLanguageSelector', 'schema.UniversalLanguageSelector',
), ],
'localBasePath' => __DIR__ . '/resources', 'localBasePath' => __DIR__ . '/resources',
'remoteExtPath' => 'UniversalLanguageSelector/resources', 'remoteExtPath' => 'UniversalLanguageSelector/resources',
), ],
) ); ] );
} }
return true; return true;

View File

@@ -33,29 +33,29 @@ class ApiLanguageSearch extends ApiBase {
} }
public function getAllowedParams() { public function getAllowedParams() {
return array( return [
'search' => array( 'search' => [
ApiBase::PARAM_REQUIRED => true ApiBase::PARAM_REQUIRED => true
), ],
'typos' => array( 'typos' => [
ApiBase::PARAM_REQUIRED => false, ApiBase::PARAM_REQUIRED => false,
ApiBase::PARAM_TYPE => 'integer', ApiBase::PARAM_TYPE => 'integer',
ApiBase::PARAM_DFLT => 1 ApiBase::PARAM_DFLT => 1
), ],
); ];
} }
/** /**
* @see ApiBase::getExamplesMessages() * @see ApiBase::getExamplesMessages()
*/ */
protected function getExamplesMessages() { protected function getExamplesMessages() {
return array( return [
'action=languagesearch&search=Te' 'action=languagesearch&search=Te'
=> 'apihelp-languagesearch-example-1', => 'apihelp-languagesearch-example-1',
'action=languagesearch&search=ഫി' 'action=languagesearch&search=ഫി'
=> 'apihelp-languagesearch-example-2', => 'apihelp-languagesearch-example-2',
'action=languagesearch&search=ഫി&typos=1' 'action=languagesearch&search=ഫി&typos=1'
=> 'apihelp-languagesearch-example-3', => 'apihelp-languagesearch-example-3',
); ];
} }
} }

View File

@@ -46,24 +46,24 @@ class ApiULSLocalization extends ApiBase {
} }
public function getAllowedParams() { public function getAllowedParams() {
return array( return [
'language' => array( 'language' => [
ApiBase::PARAM_REQUIRED => true, ApiBase::PARAM_REQUIRED => true,
ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_TYPE => 'string',
), ],
); ];
} }
/** /**
* @see ApiBase::getExamplesMessages() * @see ApiBase::getExamplesMessages()
*/ */
protected function getExamplesMessages() { protected function getExamplesMessages() {
return array( return [
'action=ulslocalization&language=ta' 'action=ulslocalization&language=ta'
=> 'apihelp-ulslocalization-example-1', => 'apihelp-ulslocalization-example-1',
'action=ulslocalization&language=hi' 'action=ulslocalization&language=hi'
=> 'apihelp-ulslocalization-example-2', => 'apihelp-ulslocalization-example-2',
); ];
} }
// Try to scare people away from using this externally // Try to scare people away from using this externally

View File

@@ -26,12 +26,15 @@
}, },
"require-dev": { "require-dev": {
"jakub-onderka/php-parallel-lint": "0.9.2", "jakub-onderka/php-parallel-lint": "0.9.2",
"mediawiki/mediawiki-codesniffer": "0.5.1" "mediawiki/mediawiki-codesniffer": "0.7.1"
}, },
"scripts": { "scripts": {
"test": [ "test": [
"parallel-lint . --exclude vendor", "parallel-lint . --exclude vendor",
"phpcs -p -s" "phpcs -p -s"
],
"fix": [
"phpcbf"
] ]
} }
} }

View File

@@ -33,8 +33,8 @@ class LanguageNameIndexer extends Maintenance {
public function execute() { public function execute() {
$languages = Language::fetchLanguageNames( null, 'all' ); $languages = Language::fetchLanguageNames( null, 'all' );
$all = array(); $all = [];
$buckets = array(); $buckets = [];
foreach ( $languages as $code => $name ) { foreach ( $languages as $code => $name ) {
$all[$code][strtolower( $name )] = true; $all[$code][strtolower( $name )] = true;
$langnames = LanguageNames::getNames( $code, 0, 2 ); $langnames = LanguageNames::getNames( $code, 0, 2 );

View File

@@ -34,12 +34,12 @@ class LanguageNameSearch {
$index = self::getIndex( $searchKey ); $index = self::getIndex( $searchKey );
if ( !isset( self::$languagenames[$index] ) ) { if ( !isset( self::$languagenames[$index] ) ) {
return array(); return [];
} }
$bucket = self::$languagenames[$index]; $bucket = self::$languagenames[$index];
$results = array(); $results = [];
foreach ( $bucket as $name => $code ) { foreach ( $bucket as $name => $code ) {
// Prefix search // Prefix search
if ( strrpos( $name, $searchKey, -strlen( $name ) ) !== false if ( strrpos( $name, $searchKey, -strlen( $name ) ) !== false
@@ -63,7 +63,7 @@ class LanguageNameSearch {
* @return integer Code point of first letter of string * @return integer Code point of first letter of string
*/ */
public static function getCodepoint( $str ) { public static function getCodepoint( $str ) {
$values = array(); $values = [];
$lookingFor = 1; $lookingFor = 1;
$strLen = strlen( $str ); $strLen = strlen( $str );
$number = 0; $number = 0;
@@ -121,7 +121,7 @@ class LanguageNameSearch {
} }
$prevRow = range( 0, $length2 ); $prevRow = range( 0, $length2 );
for ( $i = 0; $i < $length1; $i++ ) { for ( $i = 0; $i < $length1; $i++ ) {
$currentRow = array(); $currentRow = [];
$currentRow[0] = $i + 1; $currentRow[0] = $i + 1;
$c1 = mb_substr( $str1, $i, 1, 'UTF-8' ); $c1 = mb_substr( $str1, $i, 1, 'UTF-8' );
for ( $j = 0; $j < $length2; $j++ ) { for ( $j = 0; $j < $length2; $j++ ) {

View File

@@ -17,8 +17,8 @@ class FontRepoCompiler {
public function getRepository() { public function getRepository() {
$files = $this->getFilesFromPath( $this->fsPath ); $files = $this->getFilesFromPath( $this->fsPath );
$fonts = array(); $fonts = [];
$languages = array(); $languages = [];
foreach ( $files as $file ) { foreach ( $files as $file ) {
$conf = $this->parseFile( $file ); $conf = $this->parseFile( $file );
@@ -36,14 +36,13 @@ class FontRepoCompiler {
ksort( $languages ); ksort( $languages );
ksort( $fonts ); ksort( $fonts );
return array( return [
'base' => $this->webPath, 'base' => $this->webPath,
'languages' => $languages, 'languages' => $languages,
'fonts' => $fonts 'fonts' => $fonts
); ];
} }
public function getFilesFromPath( $fspath ) { public function getFilesFromPath( $fspath ) {
return glob( "$fspath/*/font.ini" ); return glob( "$fspath/*/font.ini" );
} }
@@ -54,7 +53,7 @@ class FontRepoCompiler {
public function getLanguages( array $font ) { public function getLanguages( array $font ) {
if ( !isset( $font['languages'] ) ) { if ( !isset( $font['languages'] ) ) {
return array(); return [];
} }
$languages = explode( ',', $font['languages'] ); $languages = explode( ',', $font['languages'] );
@@ -68,7 +67,7 @@ class FontRepoCompiler {
$code = str_replace( '*', '', $rcode ); $code = str_replace( '*', '', $rcode );
if ( !isset( $languages[$code] ) ) { if ( !isset( $languages[$code] ) ) {
$languages[$code] = array( 'system' ); $languages[$code] = [ 'system' ];
} }
if ( strpos( $rcode, '*' ) !== false ) { if ( strpos( $rcode, '*' ) !== false ) {
@@ -83,7 +82,7 @@ class FontRepoCompiler {
} }
public function getFontInfo( $font, $fontpath, &$version ) { public function getFontInfo( $font, $fontpath, &$version ) {
$info = array(); $info = [];
$fontdir = basename( $fontpath ); $fontdir = basename( $fontpath );
$version = $info['version'] = isset( $font['version'] ) ? $font['version'] : $version; $version = $info['version'] = isset( $font['version'] ) ? $font['version'] : $version;

View File

@@ -20,7 +20,7 @@ class ResourceLoaderULSJsonMessageModule extends ResourceLoaderModule {
* @return string[] Module names. * @return string[] Module names.
*/ */
public function getDependencies( ResourceLoaderContext $context = null ) { public function getDependencies( ResourceLoaderContext $context = null ) {
return array( 'ext.uls.i18n' ); return [ 'ext.uls.i18n' ];
} }
/** /**
@@ -57,7 +57,7 @@ class ResourceLoaderULSJsonMessageModule extends ResourceLoaderModule {
$code = 'en'; $code = 'en';
} }
$params = array( $code, ULSJsonMessageLoader::getMessages( $code ) ); $params = [ $code, ULSJsonMessageLoader::getMessages( $code ) ];
return Xml::encodeJsCall( 'mw.uls.loadLocalization', $params ); return Xml::encodeJsCall( 'mw.uls.loadLocalization', $params );
} }

View File

@@ -23,7 +23,7 @@
* Resource loader module for providing MediaWiki language names. * Resource loader module for providing MediaWiki language names.
*/ */
class ResourceLoaderULSModule extends ResourceLoaderModule { class ResourceLoaderULSModule extends ResourceLoaderModule {
protected $targets = array( 'desktop', 'mobile' ); protected $targets = [ 'desktop', 'mobile' ];
/** /**
* Get all the dynamic data for the content language to an array. * Get all the dynamic data for the content language to an array.
@@ -32,7 +32,7 @@ class ResourceLoaderULSModule extends ResourceLoaderModule {
* @return array * @return array
*/ */
protected function getData( $languageCode ) { protected function getData( $languageCode ) {
$vars = array(); $vars = [];
$vars['wgULSLanguages'] = Language::fetchLanguageNames( $vars['wgULSLanguages'] = Language::fetchLanguageNames(
$languageCode, $languageCode,
'mwfile' 'mwfile'
@@ -49,7 +49,7 @@ class ResourceLoaderULSModule extends ResourceLoaderModule {
$languageCode = $context->getLanguage(); $languageCode = $context->getLanguage();
$out = ''; $out = '';
foreach ( $this->getData( $languageCode ) as $key => $value ) { foreach ( $this->getData( $languageCode ) as $key => $value ) {
$out .= Xml::encodeJsCall( 'mw.config.set', array( $key, $value ) ); $out .= Xml::encodeJsCall( 'mw.config.set', [ $key, $value ] );
} }
return $out; return $out;
@@ -85,10 +85,10 @@ class ResourceLoaderULSModule extends ResourceLoaderModule {
return $result['timestamp']; return $result['timestamp'];
} }
$timestamp = wfTimestamp(); $timestamp = wfTimestamp();
$cache->set( $key, array( $cache->set( $key, [
'hash' => $hash, 'hash' => $hash,
'timestamp' => $timestamp, 'timestamp' => $timestamp,
) ); ] );
return $timestamp; return $timestamp;
} }

View File

@@ -27,7 +27,7 @@ class ULSJsonMessageLoader {
* @return string[] * @return string[]
*/ */
public static function getFilenames( $language ) { public static function getFilenames( $language ) {
$filenames = array(); $filenames = [];
$languages = Language::getFallbacksFor( $language ); $languages = Language::getFallbacksFor( $language );
// Prepend the requested language code // Prepend the requested language code
@@ -57,7 +57,7 @@ class ULSJsonMessageLoader {
* @return array * @return array
*/ */
public static function getMessages( $language ) { public static function getMessages( $language ) {
$contents = array(); $contents = [];
foreach ( self::getFilenames( $language ) as $filename ) { foreach ( self::getFilenames( $language ) as $filename ) {
$contents += self::loadI18nFile( $filename ); $contents += self::loadI18nFile( $filename );

View File

@@ -28,39 +28,39 @@ class LanguageSearchTest extends PHPUnit_Framework_TestCase {
} }
public function searchDataProvider() { public function searchDataProvider() {
return array( return [
array( 'ഹിന്ദി', array( [ 'ഹിന്ദി', [
'hi' => 'ഹിന്ദി' 'hi' => 'ഹിന്ദി'
) ]
), ],
array( 'മല', array( [ 'മല', [
'ml' => 'മലയാളം', 'ml' => 'മലയാളം',
'mg' => 'മലഗാസി', 'mg' => 'മലഗാസി',
'ms' => 'മലെയ്', 'ms' => 'മലെയ്',
) ]
), ],
array( 'Φινλαν', array( [ 'Φινλαν', [
'fi' => 'Φινλανδικά', 'fi' => 'Φινλανδικά',
) ]
), ],
array( 'blah', array() [ 'blah', []
), ],
array( 'الفرنسية', array( [ 'الفرنسية', [
'fr' => 'الفرنسية', 'fr' => 'الفرنسية',
'fr-ca' => 'الفرنسية الكندية', 'fr-ca' => 'الفرنسية الكندية',
'fr-ch' => 'الفرنسية السويسرية', 'fr-ch' => 'الفرنسية السويسرية',
'frm' => 'الفرنسية الوسطى', 'frm' => 'الفرنسية الوسطى',
'fro' => 'الفرنسية القديمة', 'fro' => 'الفرنسية القديمة',
) ]
), ],
array( 'മലയളം', array( [ 'മലയളം', [
'ml' => 'മലയാളം', 'ml' => 'മലയാളം',
) ]
), ],
array( 'finish', array( [ 'finish', [
'fi' => 'finnish' 'fi' => 'finnish'
) ]
), ],
); ];
} }
} }