jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/357393 )
Change subject: Add phpcs and make pass
......................................................................
Add phpcs and make pass
Change-Id: I0c817a6613658e29a16a656e63c6ff20e6936585
---
M BasePageFilter.php
M CategoryPageFilter.php
M CategoryPageSuggester.php
M Hooks.php
M MoreLikePageSuggester.php
M PageSuggesterFactory.php
M RedisCategorySync.php
M TaskRecommendationsExperimentV1.php
M composer.json
A phpcs.xml
10 files changed, 64 insertions(+), 54 deletions(-)
Approvals:
jenkins-bot: Verified
Jforrester: Looks good to me, approved
diff --git a/BasePageFilter.php b/BasePageFilter.php
index 9e3a20b..e1ac2e5 100644
--- a/BasePageFilter.php
+++ b/BasePageFilter.php
@@ -6,9 +6,9 @@
use User;
/**
- Approve or reject a given page for suitability with GettingStarted.
- Base filter shared for all task types
-*/
+ * Approve or reject a given page for suitability with GettingStarted.
+ * Base filter shared for all task types
+ */
class BasePageFilter {
/** @var User */
protected $user;
@@ -34,11 +34,11 @@
$articleID = $title->getArticleID();
$excludedCategories = self::getExcludedCategories();
$dbr = wfGetDB( DB_SLAVE );
- foreach( $excludedCategories as $cat ) {
- $res = $dbr->selectRow( 'categorylinks', '1', array(
+ foreach ( $excludedCategories as $cat ) {
+ $res = $dbr->selectRow( 'categorylinks', '1', [
'cl_from' => $articleID,
'cl_to' => $cat,
- ), __METHOD__ );
+ ], __METHOD__ );
if ( $res !== false ) {
return true;
@@ -55,8 +55,8 @@
// TODO (phuedx 2014-02-010) Create a collection class
// for categories, which could be generalised in the
// future, i.e. CategoryCollection.
- self::$excludedCategories = array();
- foreach( $wgGettingStartedExcludedCategories as
$rawCategory ) {
+ self::$excludedCategories = [];
+ foreach ( $wgGettingStartedExcludedCategories as
$rawCategory ) {
// Canonicalize the category name.
$title = Title::newFromText( $rawCategory );
if ( !$title || !$title->inNamespace(
NS_CATEGORY ) ) {
diff --git a/CategoryPageFilter.php b/CategoryPageFilter.php
index 687566b..5fa458e 100644
--- a/CategoryPageFilter.php
+++ b/CategoryPageFilter.php
@@ -5,9 +5,9 @@
use Title;
/**
- Approve or reject a given page for suitability with GettingStarted.
- For use in conjunction with CategoryPageSuggester
-*/
+ * Approve or reject a given page for suitability with GettingStarted.
+ * For use in conjunction with CategoryPageSuggester
+ */
class CategoryPageFilter extends BasePageFilter {
const MAX_PAGE_LENGTH = 10000;
diff --git a/CategoryPageSuggester.php b/CategoryPageSuggester.php
index cec6bae..1835f2d 100644
--- a/CategoryPageSuggester.php
+++ b/CategoryPageSuggester.php
@@ -27,21 +27,21 @@
if ( !$this->redisConnection ) {
wfDebugLog( 'GettingStarted', "Unable to acquire redis
connection. Returning early.\n" );
- return array();
+ return [];
}
try {
$randomArticleIDs =
$this->redisConnection->sRandMember( $key, $count );
} catch ( RedisException $e ) {
wfDebugLog( 'GettingStarted', 'Redis exception: ' .
$e->getMessage() . ". Returning early.\n" );
- return array();
+ return [];
}
if ( is_array( $randomArticleIDs ) ) {
return \Title::newFromIDs( $randomArticleIDs );
} else {
wfDebugLog( 'GettingStarted', 'Redis returned a
non-array value, possibly an error.' );
- return array();
+ return [];
}
}
diff --git a/Hooks.php b/Hooks.php
index 960f355..e01c992 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -35,10 +35,10 @@
const USER_TOKEN_COOKIE_NAME = '-gettingStartedUserId';
- protected static $COOKIE_OPTIONS = array(
+ protected static $COOKIE_OPTIONS = [
'prefix' => '',
'path' => '/',
- );
+ ];
const INTRO_OPTION = 'gettingstarted-task-toolbar-show-intro';
@@ -68,7 +68,7 @@
$cookie = $request->getCookie( self::OPENTASK_COOKIE_NAME, '' );
$tasks = FormatJson::decode( $cookie, true );
if ( !is_array( $tasks ) ) {
- $tasks = array();
+ $tasks = [];
}
self::$openTask = $tasks;
@@ -101,9 +101,9 @@
* or it's separate (e.g. 'returnto')
*/
protected static function getUnprefixedGettingStartedTask( WebRequest
$request, Title $title ) {
- $fullTask = self::getPageTask( $request, $title);
+ $fullTask = self::getPageTask( $request, $title );
if ( $fullTask !== null ) {
- $matches = array();
+ $matches = [];
$matchReturn = preg_match( '/^gettingstarted-(.*)$/',
$fullTask, $matches );
if ( $matchReturn === 1 ) {
return $matches[1];
@@ -197,14 +197,14 @@
}
}
- $vars['wgGettingStarted'] = array(
- 'toolbar' => array(
+ $vars['wgGettingStarted'] = [
+ 'toolbar' => [
'taskName' => $taskName,
'description' => $task[
'toolbarDescription' ],
'tryAnotherTitle' => $task[
'toolbarTryAnotherTitle' ],
'showIntro' => $showIntro,
- ),
- );
+ ],
+ ];
}
return true;
@@ -224,9 +224,9 @@
$categoryCount = count( $wgGettingStartedCategoriesForTaskTypes
);
- $vars['wgGettingStartedConfig'] = array(
+ $vars['wgGettingStartedConfig'] = [
'hasCategories' => ( $categoryCount > 0 ),
- );
+ ];
return true;
}
@@ -287,14 +287,14 @@
if ( self::shouldLoadToolbar( $out, $user ) ) {
// Uses addModuleStyles since no-JS code must load it
this way
// and this avoids double-loading.
- $out->addModuleStyles( array(
+ $out->addModuleStyles( [
'mediawiki.ui.button',
- ) );
- $out->addModules( array(
+ ] );
+ $out->addModules( [
'ext.guidedTour.tour.gettingstartedtasktoolbarintro',
'ext.guidedTour.tour.gettingstartedtasktoolbar',
'ext.gettingstarted.taskToolbar',
- )
+ ]
);
}
@@ -302,7 +302,6 @@
// TODO (mattflaschen, 2013-10-05): If we're not going
to show
// anything, we probably shouldn't add this module for
performance
// reasons.
- //
// We could move the "no show" logic to
isPostCreateReturn (with a
// suitable name), then decide what to do about
// redirect-page-impression (maybe log on the server,
or get rid of it?)
@@ -333,9 +332,9 @@
public static function onGetPreferences( User $user, array
&$preferences ) {
// Show tour and fade in navbar and help button
- $preferences[self::INTRO_OPTION] = array(
+ $preferences[self::INTRO_OPTION] = [
'type' => 'api',
- );
+ ];
return true;
}
@@ -433,7 +432,6 @@
return true;
}
-
/**
* While experiement is running add Task suggestions link
* for logged in users who have made an edit
@@ -451,14 +449,14 @@
$experiment->isFlyoutEnabled() &&
$wgUser->getEditCount() > 0
) {
- $recommendations = array(
- 'recommendations' => array(
+ $recommendations = [
+ 'recommendations' => [
'text' => wfMessage(
'gettingstarted-lightbulb-recommendations-personal-tool' )
->text(),
'href' => '#recommendations',
'class' =>
'mw-gettingstarted-personal-tool-recommendations',
- )
- );
+ ]
+ ];
$personal_urls = $recommendations + $personal_urls;
$skinTemplate->getOutput()->addModuleStyles(
'ext.gettingstarted.lightbulb.personalTools'
diff --git a/MoreLikePageSuggester.php b/MoreLikePageSuggester.php
index 58b504f..9161eca 100644
--- a/MoreLikePageSuggester.php
+++ b/MoreLikePageSuggester.php
@@ -27,14 +27,14 @@
global $wgSearchTypeAlternatives;
$query = 'morelike:' . $this->baseTitle->getPrefixedDBkey();
- $params = array(
+ $params = [
'action' => 'query',
'list' => 'search',
'srnamespace' => NS_MAIN,
'srlimit' => $count,
'sroffset' => $offset,
'srsearch' => $query,
- );
+ ];
if ( $wgSearchTypeAlternatives !== null &&
count( $wgSearchTypeAlternatives ) > 0 ) {
@@ -53,9 +53,9 @@
$searchApiCall->execute();
$searchResults =
(array)$searchApiCall->getResult()->getResultData(
- array( 'query', 'search' ), array( 'Strip' => 'base' )
+ [ 'query', 'search' ], [ 'Strip' => 'base' ]
);
- $titles = array();
+ $titles = [];
foreach ( $searchResults as $searchResult ) {
$titles[] = Title::newFromText( $searchResult['title']
);
}
diff --git a/PageSuggesterFactory.php b/PageSuggesterFactory.php
index 7872e49..6b661a7 100644
--- a/PageSuggesterFactory.php
+++ b/PageSuggesterFactory.php
@@ -37,7 +37,7 @@
$category = \Category::newFromTitle( $sanitizedTitle );
return new CategoryPageSuggester( $redis, $category );
- } else if ( class_exists( 'CirrusSearch' ) &&
+ } elseif ( class_exists( 'CirrusSearch' ) &&
$taskName === 'morelike' &&
$sourceTitle !== null ) {
diff --git a/RedisCategorySync.php b/RedisCategorySync.php
index d5cfed8..a8efd66 100644
--- a/RedisCategorySync.php
+++ b/RedisCategorySync.php
@@ -27,10 +27,10 @@
public static $categories;
/** @var array: arrays of [Category, int] additions to process. **/
- public static $additions = array();
+ public static $additions = [];
/** @var array: arrays of [Category, int] removals to process. **/
- public static $removals = array();
+ public static $removals = [];
/** @var bool: whether or not an update callback has been registered.
**/
public static $callbackSet = false;
@@ -78,7 +78,7 @@
public static function makeCategoryKey( Category $category ) {
global $wgDBname;
return join( ':',
- array( 'RedisCategorySync', 'Category', $wgDBname, md5(
$category->getName() ) )
+ [ 'RedisCategorySync', 'Category', $wgDBname, md5(
$category->getName() ) ]
);
}
@@ -91,7 +91,7 @@
global $wgGettingStartedCategoriesForTaskTypes;
if ( self::$categories === null ) {
- self::$categories = array();
+ self::$categories = [];
foreach ( $wgGettingStartedCategoriesForTaskTypes as
$rawCategory ) {
// Canonicalize the category name.
$title = Title::newFromText( $rawCategory );
@@ -127,7 +127,7 @@
*/
public static function onCategoryAfterPageAdded( Category $category,
WikiPage $page ) {
if ( self::isUpdateRelevant( $category, $page ) ) {
- self::$additions[] = array( $category, $page->getId() );
+ self::$additions[] = [ $category, $page->getId() ];
self::setCallback();
}
return true;
@@ -139,7 +139,7 @@
*/
public static function onCategoryAfterPageRemoved( Category $category,
WikiPage $page ) {
if ( self::isUpdateRelevant( $category, $page ) ) {
- self::$removals[] = array( $category, $page->getId() );
+ self::$removals[] = [ $category, $page->getId() ];
self::setCallback();
}
return true;
@@ -162,10 +162,10 @@
$categories = self::getCategories();
foreach ( $categories as $rawCategory ) {
- self::$removals[] = array(
+ self::$removals[] = [
Category::newFromName( $rawCategory ),
$id
- );
+ ];
}
self::setCallback();
return true;
diff --git a/TaskRecommendationsExperimentV1.php
b/TaskRecommendationsExperimentV1.php
index 3858204..b1e490c 100644
--- a/TaskRecommendationsExperimentV1.php
+++ b/TaskRecommendationsExperimentV1.php
@@ -10,12 +10,12 @@
*/
class TaskRecommendationsExperimentV1 {
- private static $buckets = array(
+ private static $buckets = [
'control',
'post-edit',
'flyout',
'both',
- );
+ ];
private $bucket;
diff --git a/composer.json b/composer.json
index 686b65b..b8f68fb 100644
--- a/composer.json
+++ b/composer.json
@@ -1,11 +1,14 @@
{
"require-dev": {
"jakub-onderka/php-parallel-lint": "0.9.2",
- "jakub-onderka/php-console-highlighter": "0.3.2"
+ "jakub-onderka/php-console-highlighter": "0.3.2",
+ "mediawiki/mediawiki-codesniffer": "0.7.2"
},
"scripts": {
+ "fix": "phpcbf",
"test": [
- "parallel-lint . --exclude vendor"
+ "parallel-lint . --exclude vendor",
+ "phpcs -p -s"
]
}
}
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 0000000..4ffde0b
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ruleset>
+ <rule ref="vendor/mediawiki/mediawiki-codesniffer/MediaWiki"/>
+ <file>.</file>
+ <arg name="extensions" value="php,php5,inc"/>
+ <arg name="encoding" value="UTF-8"/>
+ <exclude-pattern>vendor</exclude-pattern>
+ <exclude-pattern>node_modules</exclude-pattern>
+</ruleset>
--
To view, visit https://gerrit.wikimedia.org/r/357393
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0c817a6613658e29a16a656e63c6ff20e6936585
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GettingStarted
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Mattflaschen <[email protected]>
Gerrit-Reviewer: Phuedx <[email protected]>
Gerrit-Reviewer: Swalling <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits