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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -20,7 +20,7 @@ class ResourceLoaderULSJsonMessageModule extends ResourceLoaderModule {
* @return string[] Module names.
*/
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';
}
$params = array( $code, ULSJsonMessageLoader::getMessages( $code ) );
$params = [ $code, ULSJsonMessageLoader::getMessages( $code ) ];
return Xml::encodeJsCall( 'mw.uls.loadLocalization', $params );
}

View File

@@ -23,7 +23,7 @@
* Resource loader module for providing MediaWiki language names.
*/
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.
@@ -32,7 +32,7 @@ class ResourceLoaderULSModule extends ResourceLoaderModule {
* @return array
*/
protected function getData( $languageCode ) {
$vars = array();
$vars = [];
$vars['wgULSLanguages'] = Language::fetchLanguageNames(
$languageCode,
'mwfile'
@@ -49,7 +49,7 @@ class ResourceLoaderULSModule extends ResourceLoaderModule {
$languageCode = $context->getLanguage();
$out = '';
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;
@@ -85,10 +85,10 @@ class ResourceLoaderULSModule extends ResourceLoaderModule {
return $result['timestamp'];
}
$timestamp = wfTimestamp();
$cache->set( $key, array(
$cache->set( $key, [
'hash' => $hash,
'timestamp' => $timestamp,
) );
] );
return $timestamp;
}

View File

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

View File

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