From bb361e995f1d667d2907f04799c9a1981e2494f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thiemo=20M=C3=A4ttig?= Date: Mon, 17 Jul 2017 09:59:18 +0200 Subject: [PATCH] Use short array syntax in all PHP files --- DataValuesJavaScript.php | 45 +++++++++++++------------ composer.json | 6 ++-- lib/resources.php | 35 +++++++++----------- phpcs.xml | 6 ++-- src/resources.php | 54 +++++++++++++++--------------- src/valueFormatters/resources.php | 55 +++++++++++++++---------------- src/valueParsers/resources.php | 55 +++++++++++++++---------------- 7 files changed, 123 insertions(+), 133 deletions(-) diff --git a/DataValuesJavaScript.php b/DataValuesJavaScript.php index 538f00f..ac53600 100644 --- a/DataValuesJavaScript.php +++ b/DataValuesJavaScript.php @@ -14,23 +14,23 @@ require_once __DIR__ . '/vendor/autoload.php'; } -$GLOBALS['wgExtensionCredits']['datavalues'][] = array( +$GLOBALS['wgExtensionCredits']['datavalues'][] = [ 'path' => __DIR__, 'name' => 'DataValues JavaScript', 'version' => DATA_VALUES_JAVASCRIPT_VERSION, - 'author' => array( + 'author' => [ '[https://www.mediawiki.org/wiki/User:Danwe Daniel Werner]', '[http://www.snater.com H. Snater]', '[https://www.mediawiki.org/wiki/User:Jeroen_De_Dauw Jeroen De Dauw]', - ), + ], 'url' => 'https://github.com/wmde/DataValuesJavascript', 'description' => 'JavaScript related to the DataValues library', 'license-name' => 'GPL-2.0+' -); +]; // Resource Loader module registration $GLOBALS['wgResourceModules'] = array_merge( - isset( $GLOBALS['wgResourceModules'] ) ? $GLOBALS['wgResourceModules'] : array(), + isset( $GLOBALS['wgResourceModules'] ) ? $GLOBALS['wgResourceModules'] : [], include __DIR__ . '/lib/resources.php', include __DIR__ . '/src/resources.php' ); @@ -42,6 +42,7 @@ * * @param array &$testModules * @param \ResourceLoader &$resourceLoader + * * @return boolean */ $GLOBALS['wgHooks']['ResourceLoaderTestModules'][] = function( @@ -51,36 +52,34 @@ preg_match( '+' . preg_quote( DIRECTORY_SEPARATOR ) . '(?:vendor|extensions)' . preg_quote( DIRECTORY_SEPARATOR ) . '.*+', __DIR__, $remoteExtPath ); - $moduleTemplate = array( + $moduleTemplate = [ 'localBasePath' => __DIR__ . '/tests', 'remoteExtPath' => '..' . $remoteExtPath[0] . DIRECTORY_SEPARATOR . 'tests', - ); + ]; - $testModuleTemplates = array( - - 'valueFormatters.tests' => $moduleTemplate + array( - 'scripts' => array( + $testModuleTemplates = [ + 'valueFormatters.tests' => $moduleTemplate + [ + 'scripts' => [ 'src/valueFormatters/valueFormatters.tests.js', - ), - 'dependencies' => array( + ], + 'dependencies' => [ 'dataValues.DataValue', 'util.inherit', 'valueFormatters', - ), - ), + ], + ], - 'valueParsers.tests' => $moduleTemplate + array( - 'scripts' => array( + 'valueParsers.tests' => $moduleTemplate + [ + 'scripts' => [ 'src/valueParsers/valueParsers.tests.js', - ), - 'dependencies' => array( + ], + 'dependencies' => [ 'dataValues.DataValue', 'util.inherit', 'valueParsers', - ), - ), - - ); + ], + ], + ]; $testModules['qunit'] = array_merge( $testModules['qunit'], $testModuleTemplates ); diff --git a/composer.json b/composer.json index 55b1890..bf1c5af 100644 --- a/composer.json +++ b/composer.json @@ -26,6 +26,7 @@ "irc": "irc://irc.freenode.net/wikidata" }, "require": { + "php": ">=5.5.9", "composer/installers": ">=1.0.1" }, "require-dev": { @@ -37,8 +38,9 @@ ] }, "scripts": { - "phpcs": [ - "vendor/bin/phpcs . -sp" + "test": [ + "@validate --no-interaction", + "phpcs -p -s" ] } } diff --git a/lib/resources.php b/lib/resources.php index 4855088..dd876e9 100644 --- a/lib/resources.php +++ b/lib/resources.php @@ -10,33 +10,30 @@ preg_match( '+' . preg_quote( DIRECTORY_SEPARATOR ) . '(?:vendor|extensions)' . preg_quote( DIRECTORY_SEPARATOR ) . '.*+', __DIR__, $remoteExtPath ); - $moduleTemplate = array( + $moduleTemplate = [ 'localBasePath' => __DIR__, 'remoteExtPath' => '..' . $remoteExtPath[0] - ); + ]; - return array( - - 'globeCoordinate.js' => $moduleTemplate + array( - 'scripts' => array( + return [ + 'globeCoordinate.js' => $moduleTemplate + [ + 'scripts' => [ 'globeCoordinate/globeCoordinate.js', 'globeCoordinate/globeCoordinate.Formatter.js', 'globeCoordinate/globeCoordinate.GlobeCoordinate.js', - ), - ), + ], + ], - 'qunit.parameterize' => $moduleTemplate + array( - 'scripts' => array( + 'qunit.parameterize' => $moduleTemplate + [ + 'scripts' => [ 'qunit.parameterize/qunit.parameterize.js', - ), - ), + ], + ], - 'util.inherit' => $moduleTemplate + array( - 'scripts' => array( + 'util.inherit' => $moduleTemplate + [ + 'scripts' => [ 'util/util.inherit.js', - ), - ), - - ); - + ], + ], + ]; } ); diff --git a/phpcs.xml b/phpcs.xml index f168382..4128010 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,6 +1,6 @@ - - - + + + . diff --git a/src/resources.php b/src/resources.php index 9a3cc7e..72b55b0 100644 --- a/src/resources.php +++ b/src/resources.php @@ -10,31 +10,30 @@ preg_match( '+' . preg_quote( DIRECTORY_SEPARATOR ) . '(?:vendor|extensions)' . preg_quote( DIRECTORY_SEPARATOR ) . '.*+', __DIR__, $remoteExtPath ); - $moduleTemplate = array( + $moduleTemplate = [ 'localBasePath' => __DIR__, 'remoteExtPath' => '..' . $remoteExtPath[0], - ); - - $modules = array( + ]; - 'dataValues' => $moduleTemplate + array( - 'scripts' => array( + $modules = [ + 'dataValues' => $moduleTemplate + [ + 'scripts' => [ 'dataValues.js', - ), - ), + ], + ], - 'dataValues.DataValue' => $moduleTemplate + array( - 'scripts' => array( + 'dataValues.DataValue' => $moduleTemplate + [ + 'scripts' => [ 'DataValue.js', - ), - 'dependencies' => array( + ], + 'dependencies' => [ 'dataValues', 'util.inherit', - ), - ), + ], + ], - 'dataValues.values' => $moduleTemplate + array( - 'scripts' => array( + 'dataValues.values' => $moduleTemplate + [ + 'scripts' => [ // Note: The order here is relevant, scripts should be places after the ones they // depend on. 'values/BoolValue.js', @@ -48,26 +47,26 @@ 'values/QuantityValue.js', 'values/UnknownValue.js', 'values/UnDeserializableValue.js', - ), - 'dependencies' => array( + ], + 'dependencies' => [ 'dataValues.DataValue', 'dataValues.TimeValue', 'globeCoordinate.js', // required by GlobeCoordinateValue 'util.inherit', - ), - ), + ], + ], - 'dataValues.TimeValue' => $moduleTemplate + array( - 'scripts' => array( + 'dataValues.TimeValue' => $moduleTemplate + [ + 'scripts' => [ 'values/TimeValue.js', - ), - 'dependencies' => array( + ], + 'dependencies' => [ 'dataValues.DataValue', 'util.inherit', - ), - ), + ], + ], - ); + ]; $modules = array_merge( $modules, @@ -76,5 +75,4 @@ ); return $modules; - } ); diff --git a/src/valueFormatters/resources.php b/src/valueFormatters/resources.php index ed13dcb..633eb2e 100644 --- a/src/valueFormatters/resources.php +++ b/src/valueFormatters/resources.php @@ -9,50 +9,47 @@ preg_match( '+' . preg_quote( DIRECTORY_SEPARATOR ) . '(?:vendor|extensions)' . preg_quote( DIRECTORY_SEPARATOR ) . '.*+', __DIR__, $remoteExtPath ); - $moduleTemplate = array( + $moduleTemplate = [ 'localBasePath' => __DIR__, 'remoteExtPath' => '..' . $remoteExtPath[0], - ); + ]; - return array( - - 'valueFormatters' => $moduleTemplate + array( - 'scripts' => array( + return [ + 'valueFormatters' => $moduleTemplate + [ + 'scripts' => [ 'valueFormatters.js', - ), - ), + ], + ], - 'valueFormatters.ValueFormatter' => $moduleTemplate + array( - 'scripts' => array( + 'valueFormatters.ValueFormatter' => $moduleTemplate + [ + 'scripts' => [ 'formatters/ValueFormatter.js', - ), - 'dependencies' => array( + ], + 'dependencies' => [ 'util.inherit', 'valueFormatters', - ), - ), + ], + ], - 'valueFormatters.ValueFormatterStore' => $moduleTemplate + array( - 'scripts' => array( + 'valueFormatters.ValueFormatterStore' => $moduleTemplate + [ + 'scripts' => [ 'ValueFormatterStore.js', - ), - 'dependencies' => array( + ], + 'dependencies' => [ 'valueFormatters', - ), - ), + ], + ], - 'valueFormatters.formatters' => $moduleTemplate + array( - 'scripts' => array( + 'valueFormatters.formatters' => $moduleTemplate + [ + 'scripts' => [ 'formatters/NullFormatter.js', 'formatters/StringFormatter.js', - ), - 'dependencies' => array( + ], + 'dependencies' => [ 'dataValues.values', 'util.inherit', 'valueFormatters.ValueFormatter', - ), - ), - - ); - + ], + ], + ]; } ); diff --git a/src/valueParsers/resources.php b/src/valueParsers/resources.php index b5a9265..07a6808 100644 --- a/src/valueParsers/resources.php +++ b/src/valueParsers/resources.php @@ -10,53 +10,50 @@ preg_match( '+' . preg_quote( DIRECTORY_SEPARATOR ) . '(?:vendor|extensions)' . preg_quote( DIRECTORY_SEPARATOR ) . '.*+', __DIR__, $remoteExtPath ); - $moduleTemplate = array( + $moduleTemplate = [ 'localBasePath' => __DIR__, 'remoteExtPath' => '..' . $remoteExtPath[0], - ); + ]; - return array( - - 'valueParsers' => $moduleTemplate + array( - 'scripts' => array( + return [ + 'valueParsers' => $moduleTemplate + [ + 'scripts' => [ 'valueParsers.js', - ), - ), + ], + ], - 'valueParsers.ValueParser' => $moduleTemplate + array( - 'scripts' => array( + 'valueParsers.ValueParser' => $moduleTemplate + [ + 'scripts' => [ 'parsers/ValueParser.js', - ), - 'dependencies' => array( + ], + 'dependencies' => [ 'util.inherit', 'valueParsers', - ), - ), + ], + ], - 'valueParsers.ValueParserStore' => $moduleTemplate + array( - 'scripts' => array( + 'valueParsers.ValueParserStore' => $moduleTemplate + [ + 'scripts' => [ 'ValueParserStore.js', - ), - 'dependencies' => array( + ], + 'dependencies' => [ 'valueParsers', - ), - ), + ], + ], - 'valueParsers.parsers' => $moduleTemplate + array( - 'scripts' => array( + 'valueParsers.parsers' => $moduleTemplate + [ + 'scripts' => [ 'parsers/BoolParser.js', 'parsers/FloatParser.js', 'parsers/IntParser.js', 'parsers/NullParser.js', 'parsers/StringParser.js', - ), - 'dependencies' => array( + ], + 'dependencies' => [ 'dataValues.values', 'util.inherit', 'valueParsers.ValueParser', - ), - ), - - ); - + ], + ], + ]; } );