diff --git a/.gitignore b/.gitignore index e6095c8a..f815f0d4 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ vendor/ # You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file # composer.lock +composer.lock diff --git a/RelatedArticles.i18n.magic.php b/RelatedArticles.i18n.magic.php index acce4f1a..c39d5929 100644 --- a/RelatedArticles.i18n.magic.php +++ b/RelatedArticles.i18n.magic.php @@ -1,7 +1,7 @@ array( 0, 'related' ), -); +$magicWords['en'] = [ + 'related' => [ 0, 'related' ], +]; diff --git a/composer.json b/composer.json index 083767ba..33ad1e19 100644 --- a/composer.json +++ b/composer.json @@ -1,12 +1,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" ] } } diff --git a/includes/FooterHooks.php b/includes/FooterHooks.php index a913846f..b3ca93c9 100644 --- a/includes/FooterHooks.php +++ b/includes/FooterHooks.php @@ -69,7 +69,7 @@ class FooterHooks { BetaFeatures::isFeatureEnabled( $out->getUser(), 'read-more' ) ) ) { - $out->addModules( array( 'ext.relatedArticles.readMore.bootstrap' ) ); + $out->addModules( [ 'ext.relatedArticles.readMore.bootstrap' ] ); } } @@ -121,13 +121,13 @@ class FooterHooks { * @return boolean */ public static function onResourceLoaderRegisterModules( ResourceLoader &$resourceLoader ) { - $dependencies = array( + $dependencies = [ "mediawiki.user", "mediawiki.util" - ); - $scripts = array( + ]; + $scripts = [ "resources/ext.relatedArticles.readMore/index.js" - ); + ]; if ( class_exists( 'EventLogging' ) ) { $dependencies[] = "mediawiki.viewport"; @@ -137,30 +137,30 @@ class FooterHooks { $resourceLoader->register( "ext.relatedArticles.readMore", - array( + [ "dependencies" => $dependencies, "scripts" => $scripts, - "styles" => array( + "styles" => [ "resources/ext.relatedArticles.readMore/readMore.less" - ), - "skinStyles" => array( + ], + "skinStyles" => [ "default" => "resources/ext.relatedArticles.readMore/readMore.default.less", - "monobook" => array( + "monobook" => [ "resources/ext.relatedArticles.readMore/readMore.default.less", "resources/ext.relatedArticles.readMore/readMore.monobook.less" - ), + ], "minerva" => "resources/ext.relatedArticles.readMore/readMore.minerva.less" - ), - "messages" => array( + ], + "messages" => [ "relatedarticles-read-more-heading" - ), - "targets" => array( + ], + "targets" => [ "desktop", "mobile" - ), + ], "localBasePath" => __DIR__ . "/..", "remoteExtPath" => "RelatedArticles" - ) + ] ); return true; @@ -184,16 +184,16 @@ class FooterHooks { if ( $showReadMore ) { $wgExtensionAssetsPath = $config->get( 'ExtensionAssetsPath' ); - $preferences['read-more'] = array( + $preferences['read-more'] = [ 'label-message' => 'relatedarticles-read-more-beta-feature-title', 'desc-message' => 'relatedarticles-read-more-beta-feature-description', - 'screenshot' => array( + 'screenshot' => [ 'ltr' => "$wgExtensionAssetsPath/RelatedArticles/images/BetaFeatures/wb-readmore-beta-ltr.svg", 'rtl' => "$wgExtensionAssetsPath/RelatedArticles/images/BetaFeatures/wb-readmore-beta-rtl.svg", - ), + ], 'info-link' => 'https://www.mediawiki.org/wiki/Reading/Web/Projects/Read_more', 'discussion-link' => 'https://www.mediawiki.org/wiki/Talk:Reading/Web/Projects/Read_more', - ); + ]; } diff --git a/includes/Hooks.php b/includes/Hooks.php index a8158fb6..ac8fac98 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -40,7 +40,7 @@ class Hooks { $parserOutput = $parser->getOutput(); $relatedPages = $parserOutput->getExtensionData( 'RelatedArticles' ); if ( !$relatedPages ) { - $relatedPages = array(); + $relatedPages = []; } $args = func_get_args(); array_shift( $args ); @@ -68,7 +68,7 @@ class Hooks { public static function onParserClearState( Parser &$parser ) { $parserOutput = $parser->getOutput(); - $parserOutput->setExtensionData( 'RelatedArticles', array() ); + $parserOutput->setExtensionData( 'RelatedArticles', [] ); // FIXME: Remove in 30 days (T115698) $parserOutput->unsetProperty( 'RelatedArticles' ); @@ -121,20 +121,20 @@ class Hooks { * @return bool */ public static function onResourceLoaderTestModules( &$modules, &$rl ) { - $boilerplate = array( + $boilerplate = [ 'localBasePath' => __DIR__ . '/../tests/qunit/', 'remoteExtPath' => 'RelatedArticles/tests/qunit', - 'targets' => array( 'desktop', 'mobile' ), - ); + 'targets' => [ 'desktop', 'mobile' ], + ]; - $modules['qunit']['ext.relatedArticles.readMore.gateway.tests'] = $boilerplate + array( - 'scripts' => array( + $modules['qunit']['ext.relatedArticles.readMore.gateway.tests'] = $boilerplate + [ + 'scripts' => [ 'ext.relatedArticles.readMore.gateway/test_RelatedPagesGateway.js', - ), - 'dependencies' => array( + ], + 'dependencies' => [ 'ext.relatedArticles.readMore.gateway', - ), - ); + ], + ]; return true; } } diff --git a/includes/SidebarHooks.php b/includes/SidebarHooks.php index 5bdd938c..dc1ec849 100644 --- a/includes/SidebarHooks.php +++ b/includes/SidebarHooks.php @@ -34,11 +34,11 @@ class SidebarHooks { $relatedPagesUrls = self::getRelatedPagesUrls( $relatedPages ); // build relatedarticles
text
, and class
entries.
*/
private static function getRelatedPagesUrls( array $relatedPages ) {
- $relatedPagesUrls = array();
+ $relatedPagesUrls = [];
foreach ( $relatedPages as $page ) {
// Tribute to Evan
@@ -133,11 +133,11 @@ class SidebarHooks {
$title = Title::newFromText( $page );
if ( $title ) {
- $relatedPagesUrls[] = array(
+ $relatedPagesUrls[] = [
'href' => $title->getLocalURL(),
'text' => $altText ?: $title->getPrefixedText(),
'class' => 'interwiki-relart'
- );
+ ];
}
};
diff --git a/tests/phpunit/HooksTest.php b/tests/phpunit/HooksTest.php
index d34e9d3f..2297bed4 100644
--- a/tests/phpunit/HooksTest.php
+++ b/tests/phpunit/HooksTest.php
@@ -12,7 +12,7 @@ class HooksTest extends PHPUnit_Framework_TestCase {
public function test_onParserClearState() {
$parser = new Parser();
$parserOutput = $parser->mOutput = new ParserOutput();
- $relatedPages = array( 'Maybeshewill' );
+ $relatedPages = [ 'Maybeshewill' ];
$parserOutput->setExtensionData( 'RelatedArticles', $relatedPages );
$parserOutput->setProperty( 'RelatedArticles', $relatedPages );
@@ -20,7 +20,7 @@ class HooksTest extends PHPUnit_Framework_TestCase {
Hooks::onParserClearState( $parser );
$this->assertEquals(
- array(),
+ [],
$parserOutput->getExtensionData( 'RelatedArticles' ),
'It clears the list of related pages.'
);