Umherirrender has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/356214 )

Change subject: Add phpcs and make pass
......................................................................

Add phpcs and make pass

Change-Id: Ifb275bdb77363d527fbecaeec78928916684b182
---
M GlobalUserPage.body.php
M GlobalUserPage.hooks.php
M GlobalUserPage.i18n.magic.php
M GlobalUserPage.php
M GlobalUserPageCacheInvalidator.php
M GlobalUserPagePage.php
M composer.json
A phpcs.xml
8 files changed, 38 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalUserPage 
refs/changes/14/356214/1

diff --git a/GlobalUserPage.body.php b/GlobalUserPage.body.php
index 1538cdd..722f685 100644
--- a/GlobalUserPage.body.php
+++ b/GlobalUserPage.body.php
@@ -80,11 +80,11 @@
         */
        private function loadModules( OutputPage $out, array $parsedOutput ) {
                $rl = $out->getResourceLoader();
-               $map = array(
+               $map = [
                        'modules' => 'addModules',
                        'modulestyles' => 'addModuleStyles',
                        'modulescripts' => 'addModuleScripts',
-               );
+               ];
                foreach ( $map as $type => $func ) {
                        foreach ( $parsedOutput[$type] as $module ) {
                                if ( $rl->isModuleRegistered( $module ) ) {
@@ -118,7 +118,6 @@
                if ( self::$displayCache->has( $text ) ) {
                        return self::$displayCache->get( $text );
                }
-
 
                $user = User::newFromName( $title->getText() );
                $user->load( User::READ_NORMAL );
@@ -167,14 +166,14 @@
 
                global $wgGlobalUserPageDBname;
                $lb = wfGetLB( $wgGlobalUserPageDBname );
-               $dbr = $lb->getConnectionRef( DB_REPLICA, array(), 
$wgGlobalUserPageDBname );
+               $dbr = $lb->getConnectionRef( DB_REPLICA, [], 
$wgGlobalUserPageDBname );
                $row = $dbr->selectRow(
                        [ 'page', 'page_props' ],
                        [ 'page_touched', 'pp_propname' ],
-                       array(
+                       [
                                'page_namespace' => NS_USER,
                                'page_title' => 
$user->getUserPage()->getDBkey(),
-                       ),
+                       ],
                        __METHOD__,
                        [],
                        [ 'page_props' =>
@@ -295,7 +294,7 @@
        protected function parseWikiText( Title $title, $langCode ) {
                $unLocalizedName = MWNamespace::getCanonicalName( NS_USER ) . 
':' . $title->getText();
                $wikitext = '{{:' . $unLocalizedName . '}}';
-               $params = array(
+               $params = [
                        'action' => 'parse',
                        'title' => $unLocalizedName,
                        'text' => $wikitext,
@@ -304,7 +303,7 @@
                        'uselang' => $langCode,
                        'prop' => 'text|modules|jsconfigvars',
                        'formatversion' => 2
-               );
+               ];
                $data = $this->mPage->makeAPIRequest( $params );
                return $data !== false ? $data['parse'] : false;
        }
@@ -315,8 +314,8 @@
        public static function getEnabledWikis() {
                static $list = null;
                if ( $list === null ) {
-                       $list = array();
-                       if ( Hooks::run( 'GlobalUserPageWikis', array( &$list ) 
) ) {
+                       $list = [];
+                       if ( Hooks::run( 'GlobalUserPageWikis', [ &$list ] ) ) {
                                // Fallback if no hook override
                                global $wgLocalDatabases;
                                $list = $wgLocalDatabases;
diff --git a/GlobalUserPage.hooks.php b/GlobalUserPage.hooks.php
index 27d524b..d504b40 100644
--- a/GlobalUserPage.hooks.php
+++ b/GlobalUserPage.hooks.php
@@ -10,11 +10,11 @@
         */
        public static function onGetPreferences( User $user, &$preferences ) {
                if ( class_exists( 'GlobalPreferences' ) && 
GlobalPreferences::onGlobalPrefsPage() ) {
-                       $preferences['globaluserpage'] = array(
+                       $preferences['globaluserpage'] = [
                                'type' => 'toggle',
                                'label-message' => 'globaluserpage-preferences',
                                'section' => 'personal/info', // not the best 
place for it, but eh
-                       );
+                       ];
                }
 
                return true;
@@ -96,7 +96,7 @@
        public static function onPageContentInsertComplete( WikiPage $page ) {
                $title = $page->getTitle();
                if ( self::isGlobalUserPage( $title ) ) {
-                       $inv = new GlobalUserPageCacheInvalidator( 
$title->getText(), array( 'links' ) );
+                       $inv = new GlobalUserPageCacheInvalidator( 
$title->getText(), [ 'links' ] );
                        $inv->invalidate();
                }
 
diff --git a/GlobalUserPage.i18n.magic.php b/GlobalUserPage.i18n.magic.php
index 869cbf3..c02e0c1 100644
--- a/GlobalUserPage.i18n.magic.php
+++ b/GlobalUserPage.i18n.magic.php
@@ -1,8 +1,7 @@
 <?php
 
-$magicWords = array();
+$magicWords = [];
 
-$magicWords['en'] = array(
-       'noglobal' => array( 1, '__NOGLOBAL__' ),
-);
-
+$magicWords['en'] = [
+       'noglobal' => [ 1, '__NOGLOBAL__' ],
+];
diff --git a/GlobalUserPage.php b/GlobalUserPage.php
index 1428a3a..59a15a5 100644
--- a/GlobalUserPage.php
+++ b/GlobalUserPage.php
@@ -5,7 +5,8 @@
        // Keep i18n globals so mergeMessageFileList.php doesn't break
        $wgMessagesDirs['GlobalUserPage'] = __DIR__ . '/i18n';
        /* wfWarn(
-               'Deprecated PHP entry point used for GlobalUserPage extension. 
Please use wfLoadExtension instead, ' .
+               'Deprecated PHP entry point used for GlobalUserPage extension. 
' .
+               'Please use wfLoadExtension instead, ' .
                'see https://www.mediawiki.org/wiki/Extension_registration for 
more details.'
        ); */
        return true;
diff --git a/GlobalUserPageCacheInvalidator.php 
b/GlobalUserPageCacheInvalidator.php
index 6edf5aa..9f3bfa4 100644
--- a/GlobalUserPageCacheInvalidator.php
+++ b/GlobalUserPageCacheInvalidator.php
@@ -15,7 +15,7 @@
         */
        private $options;
 
-       public function __construct( $username, array $options = array() ) {
+       public function __construct( $username, array $options = [] ) {
                $this->username = $username;
                $this->options = $options;
        }
@@ -30,10 +30,10 @@
 
                JobQueueGroup::singleton()->push( new 
GlobalUserPageLocalJobSubmitJob(
                        Title::newFromText( 'User:' . $this->username ),
-                       array(
+                       [
                                'username' => $this->username,
                                'touch' => in_array( 'links', $this->options ),
-                       )
+                       ]
                ) );
        }
 }
diff --git a/GlobalUserPagePage.php b/GlobalUserPagePage.php
index 60d4ef6..2766639 100644
--- a/GlobalUserPagePage.php
+++ b/GlobalUserPagePage.php
@@ -71,13 +71,13 @@
                $key = 'globaluserpage:url:' . md5( $this->getUsername() );
                $data = $this->cache->get( $key );
                if ( $data === false ) {
-                       $params = array(
+                       $params = [
                                'action' => 'query',
                                'titles' => 'User:' . $this->getUsername(),
                                'prop' => 'info',
                                'inprop' => 'url',
                                'formatversion' => '2',
-                       );
+                       ];
                        $resp = $this->makeAPIRequest( $params );
                        if ( $resp === false ) {
                                // Don't cache upon failure
@@ -104,7 +104,7 @@
                wfDebugLog( 'GlobalUserPage', "Making a request to $url" );
                $req = MWHttpRequest::factory(
                        $url,
-                       array( 'timeout' => $this->config->get( 
'GlobalUserPageTimeout' ) )
+                       [ 'timeout' => $this->config->get( 
'GlobalUserPageTimeout' ) ]
                );
                $status = $req->execute();
                if ( !$status->isOK() ) {
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/356214
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifb275bdb77363d527fbecaeec78928916684b182
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GlobalUserPage
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to