Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 22 additions & 23 deletions DataValuesJavaScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
Expand All @@ -42,6 +42,7 @@
*
* @param array &$testModules
* @param \ResourceLoader &$resourceLoader
*
* @return boolean
*/
$GLOBALS['wgHooks']['ResourceLoaderTestModules'][] = function(
Expand All @@ -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 );

Expand Down
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"irc": "irc://irc.freenode.net/wikidata"
},
"require": {
"php": ">=5.5.9",
"composer/installers": ">=1.0.1"
},
"require-dev": {
Expand All @@ -37,8 +38,9 @@
]
},
"scripts": {
"phpcs": [
"vendor/bin/phpcs . -sp"
"test": [
"@validate --no-interaction",
"phpcs -p -s"
]
}
}
35 changes: 16 additions & 19 deletions lib/resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
),
),

);

],
],
];
} );
6 changes: 3 additions & 3 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<ruleset name="DataValuesJavaScript">
<rule ref="vendor/wikibase/wikibase-codesniffer/Wikibase">
<exclude name="Generic.Arrays.DisallowLongArraySyntax" />
</rule>
<rule ref="./vendor/wikibase/wikibase-codesniffer/Wikibase" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it needed/better to change this line like this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest I don't know. But I have seen Umherirrender adding this ./ to all phpcs.xml files, and I believe being consistent is important.


<file>.</file>
</ruleset>
54 changes: 26 additions & 28 deletions src/resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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,
Expand All @@ -76,5 +75,4 @@
);

return $modules;

} );
55 changes: 26 additions & 29 deletions src/valueFormatters/resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
),
),

);

],
],
];
} );
Loading