From d8329fdbb13dc60f87c3a8ba606d0258d349c94c Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Mon, 9 May 2016 16:59:15 -0700 Subject: [PATCH] build: Updating mediawiki/mediawiki-codesniffer to 0.7.1 Also added "composer fix" command. Change-Id: I3de1f2562898b76b56f5e7aa36b61088331ff52c --- .gitignore | 1 + RelatedArticles.i18n.magic.php | 8 +++---- composer.json | 5 +++- includes/FooterHooks.php | 42 +++++++++++++++++----------------- includes/Hooks.php | 22 +++++++++--------- includes/SidebarHooks.php | 28 +++++++++++------------ tests/phpunit/HooksTest.php | 4 ++-- 7 files changed, 57 insertions(+), 53 deletions(-) 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
  • 's - $relatedPages = array(); + $relatedPages = []; foreach ( (array) $relatedPagesUrls as $url ) { $relatedPages[] = - Html::rawElement( 'li', array( 'class' => htmlspecialchars( $url['class'] ) ), - Html::element( 'a', array( 'href' => htmlspecialchars( $url['href'] ) ), + Html::rawElement( 'li', [ 'class' => htmlspecialchars( $url['class'] ) ], + Html::element( 'a', [ 'href' => htmlspecialchars( $url['href'] ) ], $url['text'] ) ); @@ -46,7 +46,7 @@ class SidebarHooks { // build complete html $bar[$skin->msg( 'relatedarticles-title' )->text()] = - Html::rawElement( 'ul', array(), + Html::rawElement( 'ul', [], implode( '', $relatedPages ) ); @@ -74,11 +74,11 @@ class SidebarHooks { $relatedPagesUrls = self::getRelatedPagesUrls( $relatedPages ); // build relatedarticles
  • 's - $relatedPages = array(); + $relatedPages = []; foreach ( (array) $relatedPagesUrls as $url ) { $relatedPages[] = - Html::rawElement( 'li', array( 'class' => htmlspecialchars( $url['class'] ) ), - Html::element( 'a', array( 'href' => htmlspecialchars( $url['href'] ) ), + Html::rawElement( 'li', [ 'class' => htmlspecialchars( $url['class'] ) ], + Html::element( 'a', [ 'href' => htmlspecialchars( $url['href'] ) ], $url['text'] ) ); @@ -89,13 +89,13 @@ class SidebarHooks { Html::closeElement( 'ul' ) . Html::closeElement( 'div' ) . Html::closeElement( 'div' ) . - Html::openElement( 'div', array( + Html::openElement( 'div', [ 'class' => 'portal', 'role' => 'navigation', 'id' => 'p-relatedarticles', - ) ) . - Html::element( 'h3', array(), wfMessage( 'relatedarticles-title' )->text() ) . - Html::openElement( 'div', array( 'class' => 'body' ) ) . + ] ) . + Html::element( 'h3', [], wfMessage( 'relatedarticles-title' )->text() ) . + Html::openElement( 'div', [ 'class' => 'body' ] ) . Html::openElement( 'ul' ) . implode( '', $relatedPages ); @@ -118,7 +118,7 @@ class SidebarHooks { * 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.' );