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

Change subject: Use short array syntax
......................................................................

Use short array syntax

Done by phpcbf over composer fix

Change-Id: I6ba21315abbe586ce4237be991daade483b259a4
---
M SecurePoll.i18n.php
M api/ApiStrikeVote.php
M includes/crypt/Crypt.php
M includes/entities/Election.php
M includes/entities/Entity.php
M includes/entities/Option.php
M includes/entities/Question.php
M includes/htmlform/HTMLFormRadioRangeColumnLabels.php
M includes/jobs/PopulateVoterListJob.php
M includes/main/Context.php
M includes/main/SecurePollContentHandler.php
M includes/main/SpecialSecurePoll.php
M includes/main/Store.php
M phpcs.xml
14 files changed, 247 insertions(+), 248 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SecurePoll 
refs/changes/75/358075/1

diff --git a/SecurePoll.i18n.php b/SecurePoll.i18n.php
index e2af401..b627ebd 100644
--- a/SecurePoll.i18n.php
+++ b/SecurePoll.i18n.php
@@ -10,10 +10,10 @@
  *
  * This shim maintains compatibility back to MediaWiki 1.17.
  */
-$messages = array();
+$messages = [];
 if ( !function_exists( 'wfJsonI18nShim310d2110c88636f7' ) ) {
        function wfJsonI18nShim310d2110c88636f7( $cache, $code, &$cachedData ) {
-               $codeSequence = array_merge( array( $code ), 
$cachedData['fallbackSequence'] );
+               $codeSequence = array_merge( [ $code ], 
$cachedData['fallbackSequence'] );
                foreach ( $codeSequence as $csCode ) {
                        $fileName = __DIR__ . "/i18n/$csCode.json";
                        if ( is_readable( $fileName ) ) {
diff --git a/api/ApiStrikeVote.php b/api/ApiStrikeVote.php
index efd9046..7e6cefc 100644
--- a/api/ApiStrikeVote.php
+++ b/api/ApiStrikeVote.php
@@ -44,7 +44,7 @@
                // if not logged in: fail
                $user = $this->getUser();
                if ( !$user->isLoggedIn() ) {
-                       if ( is_callable( array( $this, 'dieWithError' ) ) ) {
+                       if ( is_callable( [ $this, 'dieWithError' ] ) ) {
                                $this->dieWithError(
                                        
'apierror-securepoll-mustbeloggedin-strikevote', 'notloggedin'
                                );
@@ -61,16 +61,16 @@
                $db = $context->getDB();
                $table = $db->tableName( 'securepoll_elections' );
                $row = $db->selectRow(
-                       array( 'securepoll_votes', 'securepoll_elections' ),
+                       [ 'securepoll_votes', 'securepoll_elections' ],
                        "$table.*",
-                       array( 'vote_id' => $voteid, 'vote_election=el_entity' 
),
+                       [ 'vote_id' => $voteid, 'vote_election=el_entity' ],
                        __METHOD__
                );
 
                // if no vote: fail
                if ( !$row ) {
-                       if ( is_callable( array( $this, 'dieWithError' ) ) ) {
-                               $this->dieWithError( array( 
'apierror-securepoll-badvoteid', $voteid ), 'novote' );
+                       if ( is_callable( [ $this, 'dieWithError' ] ) ) {
+                               $this->dieWithError( [ 
'apierror-securepoll-badvoteid', $voteid ], 'novote' );
                        } else {
                                $this->dieUsage( "$voteid is not a valid vote 
id.", 'novote' );
                        }
@@ -81,7 +81,7 @@
                $subpage->election = $context->newElectionFromRow( $row );
                $status = $subpage->strike( $option, $voteid, $reason );
 
-               $result = array();
+               $result = [];
                if ( $status->isGood() ) {
                        $result['status'] = 'good';
                } else {
@@ -103,32 +103,32 @@
        }
 
        public function getAllowedParams() {
-               return array(
-                       'option' => array(
-                               ApiBase::PARAM_TYPE => array(
+               return [
+                       'option' => [
+                               ApiBase::PARAM_TYPE => [
                                        'strike',
                                        'unstrike'
-                               ),
+                               ],
                                ApiBase::PARAM_REQUIRED => true,
-                               ApiBase::PARAM_HELP_MSG_PER_VALUE => array(),
-                       ),
-                       'reason' => array(
+                               ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
+                       ],
+                       'reason' => [
                                ApiBase::PARAM_TYPE => 'string',
                                ApiBase::PARAM_REQUIRED => true,
-                       ),
-                       'voteid' => array(
+                       ],
+                       'voteid' => [
                                ApiBase::PARAM_TYPE => 'integer',
                                ApiBase::PARAM_REQUIRED => true,
-                       ),
-               );
+                       ],
+               ];
        }
 
        protected function getExamplesMessages() {
-               return array(
+               return [
                        
'action=strikevote&option=strike&reason=duplication&voteid=1&token=123ABC' =>
                                'apihelp-strikevote-example-strike',
                        
'action=strikevote&option=unstrike&reason=mistake&voteid=1&token=123ABC' =>
                                'apihelp-strikevote-example-unstrike',
-               );
+               ];
        }
 }
diff --git a/includes/crypt/Crypt.php b/includes/crypt/Crypt.php
index 7734665..c3ccf62 100644
--- a/includes/crypt/Crypt.php
+++ b/includes/crypt/Crypt.php
@@ -25,10 +25,10 @@
         */
        abstract function canDecrypt();
 
-       private static $cryptTypes = array(
+       private static $cryptTypes = [
                'none' => false,
                'gpg' => 'SecurePoll_GpgCrypt',
-       );
+       ];
 
        /**
         * Create an encryption object of the given type. Currently only "gpg" 
is
@@ -55,11 +55,11 @@
         * @return array
         */
        static function getCreateDescriptors() {
-               return array(
-                       'election' => array(),
-                       'question' => array(),
-                       'option' => array(),
-               );
+               return [
+                       'election' => [],
+                       'question' => [],
+                       'option' => [],
+               ];
        }
 }
 
@@ -82,35 +82,35 @@
                global $wgSecurePollGpgSignKey;
 
                $ret = SecurePoll_Crypt::getCreateDescriptors();
-               $ret['election'] += array(
-                       'gpg-encrypt-key' => array(
+               $ret['election'] += [
+                       'gpg-encrypt-key' => [
                                'label-message' => 
'securepoll-create-label-gpg_encrypt_key',
                                'type' => 'textarea',
                                'required' => true,
                                'SecurePoll_type' => 'property',
                                'rows' => 5,
                                'validation-callback' => 
'SecurePoll_GpgCrypt::checkEncryptKey',
-                       ),
-               );
+                       ],
+               ];
 
                if ( $wgSecurePollGpgSignKey ) {
-                       $ret['election'] += array(
-                               'gpg-sign-key' => array(
+                       $ret['election'] += [
+                               'gpg-sign-key' => [
                                        'type' => 'api',
                                        'default' => $wgSecurePollGpgSignKey,
                                        'SecurePoll_type' => 'property',
-                               ),
-                       );
+                               ],
+                       ];
                } else {
-                       $ret['election'] += array(
-                               'gpg-sign-key' => array(
+                       $ret['election'] += [
+                               'gpg-sign-key' => [
                                        'label-message' => 
'securepoll-create-label-gpg_sign_key',
                                        'type' => 'textarea',
                                        'SecurePoll_type' => 'property',
                                        'rows' => 5,
                                        'validation-callback' => 
'SecurePoll_GpgCrypt::checkSignKey',
-                               ),
-                       );
+                               ],
+                       ];
                }
 
                return $ret;
diff --git a/includes/entities/Election.php b/includes/entities/Election.php
index 08cb5a2..c7e7555 100644
--- a/includes/entities/Election.php
+++ b/includes/entities/Election.php
@@ -101,13 +101,13 @@
         * Get a list of localisable message names. See SecurePoll_Entity.
         */
        function getMessageNames() {
-               return array(
+               return [
                        'title',
                        'intro',
                        'jump-text',
                        'return-text',
                        'unqualified-error',
-               );
+               ];
        }
 
        /**
@@ -183,8 +183,8 @@
                $props = $params['properties'];
                $status = Status::newGood();
 
-               $lists = isset( $props['lists'] ) ? $props['lists'] : array();
-               $centralLists = isset( $props['central-lists'] ) ? 
$props['central-lists'] : array();
+               $lists = isset( $props['lists'] ) ? $props['lists'] : [];
+               $centralLists = isset( $props['central-lists'] ) ? 
$props['central-lists'] : [];
                $includeList = $this->getProperty( 'include-list' );
                $excludeList = $this->getProperty( 'exclude-list' );
 
@@ -241,7 +241,7 @@
 
                        // Groups
                        $needGroup = $this->getProperty( 'need-group' );
-                       $groups = isset( $props['groups'] ) ? $props['groups'] 
: array();
+                       $groups = isset( $props['groups'] ) ? $props['groups'] 
: [];
                        if ( $needGroup && !in_array( $needGroup, $groups ) ) {
                                $status->fatal( 'securepoll-not-in-group', 
$needGroup );
                        }
@@ -290,11 +290,11 @@
                $db = $this->context->getDB();
                $row = $db->selectRow(
                        'securepoll_votes',
-                       array( "1" ),
-                       array(
+                       [ "1" ],
+                       [
                                'vote_election' => $this->getId(),
                                'vote_voter' => $voter->getId(),
-                       ),
+                       ],
                        __METHOD__ );
                return $row !== false;
        }
@@ -315,7 +315,7 @@
        function getQuestions() {
                if ( $this->questions === null ) {
                        $info = $this->context->getStore()->getQuestionInfo( 
$this->getId() );
-                       $this->questions = array();
+                       $this->questions = [];
                        foreach ( $info as $questionInfo ) {
                                $this->questions[] = 
$this->context->newQuestion( $questionInfo );
                        }
@@ -380,12 +380,12 @@
                $db = $this->context->getDB();
                $res = $db->select(
                        'securepoll_votes',
-                       array( '*' ),
-                       array(
+                       [ '*' ],
+                       [
                                'vote_election' => $this->getId(),
                                'vote_current' => 1,
                                'vote_struck' => 0
-                       ),
+                       ],
                        __METHOD__
                );
                if ( $res->numRows() ) {
@@ -402,31 +402,31 @@
        /**
         * Get an XML snippet describing the configuration of this object
         */
-       function getConfXml( $params = array() ) {
+       function getConfXml( $params = [] ) {
                $s = "<configuration>\n" .
-                       Xml::element( 'title', array(), $this->title ) . "\n" .
-                       Xml::element( 'ballot', array(), $this->ballotType ) . 
"\n" .
-                       Xml::element( 'tally', array(), $this->tallyType ) . 
"\n" .
-                       Xml::element( 'primaryLang', array(), 
$this->primaryLang ) . "\n" .
-                       Xml::element( 'startDate', array(), wfTimestamp( 
TS_ISO_8601, $this->startDate ) ) . "\n" .
-                       Xml::element( 'endDate', array(), wfTimestamp( 
TS_ISO_8601, $this->endDate ) ) . "\n" .
+                       Xml::element( 'title', [], $this->title ) . "\n" .
+                       Xml::element( 'ballot', [], $this->ballotType ) . "\n" .
+                       Xml::element( 'tally', [], $this->tallyType ) . "\n" .
+                       Xml::element( 'primaryLang', [], $this->primaryLang ) . 
"\n" .
+                       Xml::element( 'startDate', [], wfTimestamp( 
TS_ISO_8601, $this->startDate ) ) . "\n" .
+                       Xml::element( 'endDate', [], wfTimestamp( TS_ISO_8601, 
$this->endDate ) ) . "\n" .
                        $this->getConfXmlEntityStuff( $params );
 
                // If we're making a jump dump, we need to add some extra 
properties, and
                // override the auth type
                if ( !empty( $params['jump'] ) ) {
                        $s .=
-                               Xml::element( 'auth', array(), 'local' ) . "\n" 
.
+                               Xml::element( 'auth', [], 'local' ) . "\n" .
                                Xml::element( 'property',
-                                       array( 'name' => 'jump-url' ),
+                                       [ 'name' => 'jump-url' ],
                                        
$this->context->getSpecialTitle()->getCanonicalUrl()
                                ) . "\n" .
                                Xml::element( 'property',
-                                       array( 'name' => 'jump-id' ),
+                                       [ 'name' => 'jump-id' ],
                                        $this->getId()
                                ) . "\n";
                } else {
-                       $s .= Xml::element( 'auth', array(), $this->authType ) 
. "\n";
+                       $s .= Xml::element( 'auth', [], $this->authType ) . 
"\n";
                }
 
                foreach ( $this->getQuestions() as $question ) {
@@ -439,15 +439,15 @@
        /**
         * Get property names which aren't included in an XML dump
         */
-       function getPropertyDumpBlacklist( $params = array() ) {
+       function getPropertyDumpBlacklist( $params = [] ) {
                if ( !empty( $params['jump'] ) ) {
-                       return array(
+                       return [
                                'gpg-encrypt-key',
                                'gpg-sign-key',
                                'gpg-decrypt-key'
-                       );
+                       ];
                } else {
-                       return array();
+                       return [];
                }
        }
 
diff --git a/includes/entities/Entity.php b/includes/entities/Entity.php
index 51d97e4..34ed062 100644
--- a/includes/entities/Entity.php
+++ b/includes/entities/Entity.php
@@ -14,7 +14,7 @@
        public $id;
        public $electionId;
        public $context;
-       public $messagesLoaded = array();
+       public $messagesLoaded = [];
        public $properties;
 
        /**
@@ -50,7 +50,7 @@
         */
        function getMessageNames() {
                # STUB
-               return array();
+               return [];
        }
 
        /**
@@ -78,7 +78,7 @@
         * @return array
         */
        function getChildren() {
-               return array();
+               return [];
        }
 
        /**
@@ -87,7 +87,7 @@
         * @return array
         */
        function getDescendants() {
-               $descendants = array();
+               $descendants = [];
                $children = $this->getChildren();
                foreach ( $children as $child ) {
                        $descendants[] = $child;
@@ -104,7 +104,7 @@
                if ( $lang === false ) {
                        $lang = reset( $this->context->languages );
                }
-               $ids = array( $this->getId() );
+               $ids = [ $this->getId() ];
                foreach ( $this->getDescendants() as $child ) {
                        $ids[] = $child->getId();
                }
@@ -118,11 +118,11 @@
         * automatically.
         */
        function loadProperties() {
-               $properties = $this->context->getStore()->getProperties( array( 
$this->getId() ) );
+               $properties = $this->context->getStore()->getProperties( [ 
$this->getId() ] );
                if ( count( $properties ) ) {
                        $this->properties = reset( $properties );
                } else {
-                       $this->properties = array();
+                       $this->properties = [];
                }
        }
 
@@ -190,7 +190,7 @@
         * and its descendants.
         */
        function getLangList() {
-               $ids = array( $this->getId() );
+               $ids = [ $this->getId() ];
                foreach ( $this->getDescendants() as $child ) {
                        $ids[] = $child->getId();
                }
@@ -228,7 +228,7 @@
        /**
         * Get configuration XML. Overridden by most subclasses.
         */
-       function getConfXml( $params = array() ) {
+       function getConfXml( $params = [] ) {
                return "<{$this->type}>\n" .
                        $this->getConfXmlEntityStuff( $params ) .
                        "</{$this->type}>\n";
@@ -237,12 +237,12 @@
        /**
         * Get an XML snippet giving the messages and properties
         */
-       function getConfXmlEntityStuff( $params = array() ) {
-               $s = Xml::element( 'id', array(), $this->getId() ) . "\n";
+       function getConfXmlEntityStuff( $params = [] ) {
+               $s = Xml::element( 'id', [], $this->getId() ) . "\n";
                $blacklist = $this->getPropertyDumpBlacklist( $params );
                foreach ( $this->getAllProperties() as $name => $value ) {
                        if ( !in_array( $name, $blacklist ) ) {
-                               $s .= Xml::element( 'property', array( 'name' 
=> $name ), $value ) . "\n";
+                               $s .= Xml::element( 'property', [ 'name' => 
$name ], $value ) . "\n";
                        }
                }
                if ( isset( $params['langs'] ) ) {
@@ -256,7 +256,7 @@
                                if ( $value !== false ) {
                                        $s .= Xml::element(
                                                        'message',
-                                                       array( 'name' => $name, 
'lang' => $lang ),
+                                                       [ 'name' => $name, 
'lang' => $lang ],
                                                        $value
                                                ) . "\n";
                                }
@@ -269,8 +269,8 @@
         * Get property names which aren't included in an XML dump.
         * Overloaded by Election.
         */
-       function getPropertyDumpBlacklist( $params = array() ) {
-               return array();
+       function getPropertyDumpBlacklist( $params = [] ) {
+               return [];
        }
 
 }
diff --git a/includes/entities/Option.php b/includes/entities/Option.php
index 6f68887..178fe31 100644
--- a/includes/entities/Option.php
+++ b/includes/entities/Option.php
@@ -19,6 +19,6 @@
         * translate subpage with a list of messages to localise.
         */
        function getMessageNames() {
-               return array( 'text' );
+               return [ 'text' ];
        }
 }
diff --git a/includes/entities/Question.php b/includes/entities/Question.php
index 66d4112..5e2a99d 100644
--- a/includes/entities/Question.php
+++ b/includes/entities/Question.php
@@ -16,7 +16,7 @@
         */
        function __construct( $context, $info ) {
                parent::__construct( $context, 'question', $info );
-               $this->options = array();
+               $this->options = [];
                foreach ( $info['options'] as $optionInfo ) {
                        $this->options[] = new SecurePoll_Option( $context, 
$optionInfo );
                }
@@ -27,7 +27,7 @@
         */
        function getMessageNames() {
                $ballot = $this->getElection()->getBallot();
-               return array_merge( $ballot->getMessageNames( $this ), array( 
'text' ) );
+               return array_merge( $ballot->getMessageNames( $this ), [ 'text' 
] );
 
        }
 
@@ -42,7 +42,7 @@
                return $this->options;
        }
 
-       function getConfXml( $params = array() ) {
+       function getConfXml( $params = [] ) {
                $s = "<question>\n" . $this->getConfXmlEntityStuff( $params );
                foreach ( $this->getOptions() as $option ) {
                        $s .= $option->getConfXml( $params );
diff --git a/includes/htmlform/HTMLFormRadioRangeColumnLabels.php 
b/includes/htmlform/HTMLFormRadioRangeColumnLabels.php
index 7058305..9e1c4fc 100644
--- a/includes/htmlform/HTMLFormRadioRangeColumnLabels.php
+++ b/includes/htmlform/HTMLFormRadioRangeColumnLabels.php
@@ -21,7 +21,7 @@
                        }
                }
 
-               $ret = array();
+               $ret = [];
                foreach ( $values as $k => $v ) {
                        if ( preg_match( '/^-?\d+$/', $k ) ) {
                                $key = ( $neg && $k > 0 ) ? "+$k" : $k;
@@ -62,14 +62,14 @@
                $inputs = '';
                foreach ( (array)$value as $k => $v ) {
                        $k = str_replace( 'column', '', $k );
-                       $labels .= Html::element( 'th', array( 
'data-securepoll-col-num' => $k ), $k );
-                       $inputs .= Html::rawElement( 'td', array( 
'data-securepoll-col-num' => $k ),
-                               Html::element( 'input', array(
+                       $labels .= Html::element( 'th', [ 
'data-securepoll-col-num' => $k ], $k );
+                       $inputs .= Html::rawElement( 'td', [ 
'data-securepoll-col-num' => $k ],
+                               Html::element( 'input', [
                                        'type' => 'text',
                                        'name' => "{$this->mName}[$k]",
                                        'size' => $size,
                                        'value' => $v,
-                               ) )
+                               ] )
                        );
                }
 
@@ -78,13 +78,13 @@
                        $attribs['class'] .= " $this->mClass";
                }
 
-               $html = Html::rawElement( 'table', array(
+               $html = Html::rawElement( 'table', [
                                'class' => $class,
                                'data-securepoll-col-name' => $this->mName,
                                'data-securepoll-input-size' => $size,
-                       ),
-                       Html::rawElement( 'tr', array( 'class' => 
'securepoll-label-row' ), $labels ) .
-                               Html::rawElement( 'tr', array( 'class' => 
'securepoll-input-row' ), $inputs )
+                       ],
+                       Html::rawElement( 'tr', [ 'class' => 
'securepoll-label-row' ], $labels ) .
+                               Html::rawElement( 'tr', [ 'class' => 
'securepoll-input-row' ], $inputs )
                );
 
                return $html;
diff --git a/includes/jobs/PopulateVoterListJob.php 
b/includes/jobs/PopulateVoterListJob.php
index d3fe3c8..6f17d35 100644
--- a/includes/jobs/PopulateVoterListJob.php
+++ b/includes/jobs/PopulateVoterListJob.php
@@ -7,24 +7,24 @@
  */
 class SecurePoll_PopulateVoterListJob extends Job {
        public static function pushJobsForElection( SecurePoll_Election 
$election ) {
-               static $props = array(
+               static $props = [
                        'need-list', 'list_populate',
                        'list_edits-before', 'list_edits-before-count', 
'list_edits-before-date',
                        'list_edits-between', 'list_edits-between-count',
                        'list_edits-startdate', 'list_edits-enddate',
                        'list_exclude-groups', 'list_include-groups',
-               );
-               static $listProps = array(
+               ];
+               static $listProps = [
                        'list_edits-startdate', 'list_edits-enddate',
                        'list_exclude-groups', 'list_include-groups',
-               );
+               ];
 
                $dbw = $election->context->getDB();
                $lbFactory = 
MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
 
                // First, fetch the current config and calculate a hash of it 
for
                // detecting changes
-               $params = array(
+               $params = [
                        'electionWiki' => wfWikiID(),
                        'electionId' => $election->getID(),
                        'list_populate' => '0',
@@ -33,15 +33,15 @@
                        'list_edits-between' => '',
                        'list_exclude-groups' => '',
                        'list_include-groups' => '',
-               );
+               ];
 
                $res = $dbw->select(
                        'securepoll_properties',
-                       array( 'pr_key', 'pr_value' ),
-                       array(
+                       [ 'pr_key', 'pr_value' ],
+                       [
                                'pr_entity' => $election->getID(),
                                'pr_key' => $props,
-                       )
+                       ]
                );
                foreach ( $res as $row ) {
                        $params[$row->pr_key] = $row->pr_value;
@@ -56,7 +56,7 @@
 
                foreach ( $listProps as $prop ) {
                        if ( $params[$prop] === '' ) {
-                               $params[$prop] = array();
+                               $params[$prop] = [];
                        } else {
                                $params[$prop] = explode( '|', $params[$prop] );
                        }
@@ -66,10 +66,10 @@
                $key = sha1( serialize( $params ) );
 
                // Now fill in the remaining params
-               $params += array(
+               $params += [
                        'jobKey' => $key,
                        'nextUserId' => 1,
-               );
+               ];
 
                // Get the list of wikis we need jobs on
                $wikis = $election->getProperty( 'wikis' );
@@ -79,12 +79,12 @@
                                $wikis[] = wfWikiID();
                        }
                } else {
-                       $wikis = array( wfWikiID() );
+                       $wikis = [ wfWikiID() ];
                }
 
                // Find the max user_id for each wiki, both to know when we're 
done
                // with that wiki's job and for the special page to calculate 
progress.
-               $maxIds = array();
+               $maxIds = [];
                $total = 0;
                foreach ( $wikis as $wiki ) {
                        $dbr = wfGetLB( $wiki )->getConnectionRef( DB_SLAVE, 
[], $wiki );
@@ -121,24 +121,24 @@
                // abort) and the progress figures.
                $dbw->replace(
                        'securepoll_properties',
-                       array( 'pr_entity', 'pr_key' ),
-                       array(
-                               array(
+                       [ 'pr_entity', 'pr_key' ],
+                       [
+                               [
                                        'pr_entity' => $election->getID(),
                                        'pr_key' => 'list_job-key',
                                        'pr_value' => $params['jobKey'],
-                               ),
-                               array(
+                               ],
+                               [
                                        'pr_entity' => $election->getID(),
                                        'pr_key' => 'list_total-count',
                                        'pr_value' => $total,
-                               ),
-                               array(
+                               ],
+                               [
                                        'pr_entity' => $election->getID(),
                                        'pr_key' => 'list_complete-count',
                                        'pr_value' => 0,
-                               ),
-                       )
+                               ],
+                       ]
                );
 
                foreach ( $wikis as $wiki ) {
@@ -159,7 +159,7 @@
                        $jobQueueGroup->push( new JobSpecification(
                                'securePollPopulateVoterList',
                                $params,
-                               array(),
+                               [],
                                $title
                        ) );
                }
@@ -185,7 +185,7 @@
                $lbFactory = 
MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
                try {
                        // Check if the job key changed, and abort if so.
-                       $dbwElection = wfGetDB( DB_MASTER, array(), 
$this->params['electionWiki'] );
+                       $dbwElection = wfGetDB( DB_MASTER, [], 
$this->params['electionWiki'] );
                        $dbwLocal = wfGetDB( DB_MASTER );
                        $jobKey = self::fetchJobKey( $dbwElection, 
$this->params['electionId'] );
                        if ( $jobKey !== $this->params['jobKey'] ) {
@@ -204,21 +204,21 @@
                                $res = $dbr->select(
                                        'revision',
                                        'rev_user',
-                                       array(
+                                       [
                                                "rev_user >= $min",
                                                "rev_user < $max",
                                                "rev_timestamp < $timestamp",
-                                       ),
+                                       ],
                                        __METHOD__,
-                                       array(
+                                       [
                                                'GROUP BY' => 'rev_user',
-                                               'HAVING' => array(
+                                               'HAVING' => [
                                                        'COUNT(*) >= ' . 
$dbr->addQuotes( $this->params['list_edits-before-count'] ),
-                                               )
-                                       )
+                                               ]
+                                       ]
                                );
 
-                               $list = array();
+                               $list = [];
                                foreach ( $res as $row ) {
                                        $list[] = $row->rev_user;
                                }
@@ -238,21 +238,21 @@
                                $res = $dbr->select(
                                        'revision',
                                        'rev_user',
-                                       array(
+                                       [
                                                "rev_user >= $min",
                                                "rev_user < $max",
                                                "rev_timestamp >= $timestamp1",
                                                "rev_timestamp < $timestamp2",
-                                       ),
+                                       ],
                                        __METHOD__,
-                                       array(
+                                       [
                                                'GROUP BY' => 'rev_user',
-                                               'HAVING' => array(
+                                               'HAVING' => [
                                                        'COUNT(*) >= ' . 
$dbr->addQuotes( $this->params['list_edits-between-count'] ),
-                                               )
-                                       )
+                                               ]
+                                       ]
                                );
-                               $list = array();
+                               $list = [];
                                foreach ( $res as $row ) {
                                        $list[] = $row->rev_user;
                                }
@@ -268,27 +268,27 @@
                        global $wgDisableUserGroupExpiry;
                        if ( $this->params['list_exclude-groups'] ) {
                                $res = $dbr->select(
-                                       array( 'user', 'user_groups' ),
+                                       [ 'user', 'user_groups' ],
                                        'user_id',
-                                       array(
+                                       [
                                                "user_id >= $min",
                                                "user_id < $max",
                                                'ug_user IS NULL',
-                                       ),
+                                       ],
                                        __METHOD__,
-                                       array(),
-                                       array(
-                                               'user_groups' => array( 'LEFT 
OUTER JOIN', array(
+                                       [],
+                                       [
+                                               'user_groups' => [ 'LEFT OUTER 
JOIN', [
                                                                'ug_user = 
user_id',
                                                                'ug_group' => 
$this->params['list_exclude-groups'],
                                                                ( !isset( 
$wgDisableUserGroupExpiry ) || $wgDisableUserGroupExpiry ) ?
                                                                        '1' :
                                                                        
'ug_expiry IS NULL OR ug_expiry >= ' . $dbr->addQuotes( $dbr->timestamp() ),
-                                                       )
-                                               ),
-                                       )
+                                                       ]
+                                               ],
+                                       ]
                                );
-                               $list = array();
+                               $list = [];
                                foreach ( $res as $row ) {
                                        $list[] = $row->user_id;
                                }
@@ -305,16 +305,16 @@
                                $res = $dbr->select(
                                        'user_groups',
                                        'ug_user',
-                                       array(
+                                       [
                                                "ug_user >= $min",
                                                "ug_user < $max",
                                                'ug_group' => 
$this->params['list_include-groups'],
                                                ( !isset( 
$wgDisableUserGroupExpiry ) || $wgDisableUserGroupExpiry ) ?
                                                        '1' :
                                                        'ug_expiry IS NULL OR 
ug_expiry >= ' . $dbr->addQuotes( $dbr->timestamp() ),
-                                       )
+                                       ]
                                );
-                               $list = array();
+                               $list = [];
                                foreach ( $res as $row ) {
                                        $list[] = $row->ug_user;
                                }
@@ -326,12 +326,12 @@
                                }
                        }
 
-                       $ins = array();
+                       $ins = [];
                        foreach ( $users as $user_id ) {
-                               $ins[] = array(
+                               $ins[] = [
                                        'li_name' => $this->params['need-list'],
                                        'li_member' => $user_id,
-                               );
+                               ];
                        }
 
                        // Flush any prior REPEATABLE-READ snapshots so the 
locking below works
@@ -353,26 +353,26 @@
 
                        $jobKey = self::fetchJobKey( $dbwElection, 
$this->params['electionId'] );
                        if ( $jobKey === $this->params['jobKey'] ) {
-                               $dbwLocal->delete( 'securepoll_lists', array(
+                               $dbwLocal->delete( 'securepoll_lists', [
                                        'li_name' => $this->params['need-list'],
                                        "li_member >= $min",
                                        "li_member < $max",
-                               ) );
+                               ] );
                                $dbwLocal->insert( 'securepoll_lists', $ins );
 
-                               $count = $dbwElection->selectField( 
'securepoll_properties', 'pr_value', array(
+                               $count = $dbwElection->selectField( 
'securepoll_properties', 'pr_value', [
                                        'pr_entity' => 
$this->params['electionId'],
                                        'pr_key' => 'list_complete-count',
-                               ) );
+                               ] );
                                $dbwElection->update(
                                        'securepoll_properties',
-                                       array(
+                                       [
                                                'pr_value' => $count + $max - 
$min,
-                                       ),
-                                       array(
+                                       ],
+                                       [
                                                'pr_entity' => 
$this->params['electionId'],
                                                'pr_key' => 
'list_complete-count',
-                                       )
+                                       ]
                                );
                        }
 
@@ -395,7 +395,7 @@
                        JobQueueGroup::singleton()->push( new JobSpecification(
                                'securePollPopulateVoterList',
                                $params,
-                               array(),
+                               [],
                                $this->title
                        ) );
                }
@@ -407,10 +407,10 @@
                return $db->selectField(
                        'securepoll_properties',
                        'pr_value',
-                       array(
+                       [
                                'pr_entity' => $electionId,
                                'pr_key' => 'list_job-key',
-                       )
+                       ]
                );
        }
 }
diff --git a/includes/main/Context.php b/includes/main/Context.php
index 6e50517..1bd6f08 100644
--- a/includes/main/Context.php
+++ b/includes/main/Context.php
@@ -17,18 +17,18 @@
  */
 class SecurePoll_Context {
        /** Language fallback sequence */
-       public $languages = array( 'en' );
+       public $languages = [ 'en' ];
 
        /** Message text cache */
-       public $messageCache = array();
+       public $messageCache = [];
 
        /** election cache */
-       public $electionCache = array();
+       public $electionCache = [];
 
        /**
         * Which messages are loaded. 2-d array: language and entity ID, value 
arbitrary.
         */
-       public $messagesLoaded = array();
+       public $messagesLoaded = [];
 
        /** ParserOptions instance used for message parsing */
        public $parserOptions;
@@ -88,13 +88,13 @@
        /** Set the store class */
        function setStoreClass( $class ) {
                $this->store = null;
-               $this->messageCache = $this->messagesLoaded = array();
+               $this->messageCache = $this->messagesLoaded = [];
                $this->storeClass = $class;
        }
 
        /** Set the store object. Overrides any previous store class. */
        function setStore( $store ) {
-               $this->messageCache = $this->messagesLoaded = array();
+               $this->messageCache = $this->messagesLoaded = [];
                $this->store = $store;
        }
 
@@ -110,7 +110,7 @@
         */
        function getElection( $id ) {
                if ( !isset( $this->electionCache[$id] ) ) {
-                       $info = $this->getStore()->getElectionInfo( array( $id 
) );
+                       $info = $this->getStore()->getElectionInfo( [ $id ] );
                        if ( $info ) {
                                $this->electionCache[$id] = $this->newElection( 
reset( $info ) );
                        } else {
@@ -126,7 +126,7 @@
         * @return SecurePoll_Election
         */
        function getElectionByTitle( $name ) {
-               $info = $this->getStore()->getElectionInfoByTitle( array( $name 
) );
+               $info = $this->getStore()->getElectionInfoByTitle( [ $name ] );
                if ( $info ) {
                        return $this->newElection( reset( $info ) );
                } else {
@@ -236,7 +236,7 @@
         */
        function getMessage( $lang, $id, $key ) {
                if ( !isset( $this->messagesLoaded[$lang][$id] ) ) {
-                       $this->getMessages( $lang, array( $id ) );
+                       $this->getMessages( $lang, [ $id ] );
                }
                if ( isset( $this->messageCache[$lang][$id][$key] ) ) {
                        return $this->messageCache[$lang][$id][$key];
diff --git a/includes/main/SecurePollContentHandler.php 
b/includes/main/SecurePollContentHandler.php
index 236ecfb..d830953 100644
--- a/includes/main/SecurePollContentHandler.php
+++ b/includes/main/SecurePollContentHandler.php
@@ -28,11 +28,11 @@
                if ( $subpage === '' ) {
                        $properties = $election->getAllProperties();
                        if ( $useBlacklist ) {
-                               $blacklist = array_flip( 
$election->getPropertyDumpBlacklist() ) + array(
+                               $blacklist = array_flip( 
$election->getPropertyDumpBlacklist() ) + [
                                        'gpg-encrypt-key' => true,
                                        'gpg-sign-key' => true,
                                        'gpg-decrypt-key' => true,
-                               );
+                               ];
                                foreach ( $properties as $k => $v ) {
                                        if ( isset( $blacklist[$k] ) ) {
                                                $properties[$k] = '<redacted>';
@@ -44,7 +44,7 @@
                                        $properties['list_complete-count']
                                );
                        }
-                       $data = array(
+                       $data = [
                                'id' => $election->getId(),
                                'title' => $election->title,
                                'ballot' => $election->ballotType,
@@ -54,8 +54,8 @@
                                'endDate' => wfTimestamp( TS_ISO_8601, 
$election->getEndDate() ),
                                'authType' => $election->authType,
                                'properties' => $properties,
-                               'questions' => array(),
-                       );
+                               'questions' => [],
+                       ];
 
                        foreach ( $election->getQuestions() as $question ) {
                                $properties = $question->getAllProperties();
@@ -67,11 +67,11 @@
                                                }
                                        }
                                }
-                               $q = array(
+                               $q = [
                                        'id' => $question->getId(),
                                        'properties' => $properties,
-                                       'options' => array(),
-                               );
+                                       'options' => [],
+                               ];
 
                                foreach ( $question->getOptions() as $option ) {
                                        $properties = 
$option->getAllProperties();
@@ -83,10 +83,10 @@
                                                        }
                                                }
                                        }
-                                       $o = array(
+                                       $o = [
                                                'id' => $option->getId(),
                                                'properties' => $properties,
-                                       );
+                                       ];
                                        $q['options'][] = $o;
                                }
 
@@ -94,12 +94,12 @@
                        }
                } elseif ( preg_match( '#^msg/(\S+)$#', $subpage, $m ) ) {
                        $lang = $m[1];
-                       $data = array(
+                       $data = [
                                'id' => $election->getId(),
                                'lang' => $lang,
-                               'messages' => array(),
-                               'questions' => array(),
-                       );
+                               'messages' => [],
+                               'questions' => [],
+                       ];
                        foreach ( $election->getMessageNames() as $name ) {
                                $value = $election->getRawMessage( $name, $lang 
);
                                if ( $value !== false ) {
@@ -108,11 +108,11 @@
                        }
 
                        foreach ( $election->getQuestions() as $question ) {
-                               $q = array(
+                               $q = [
                                        'id' => $question->getId(),
-                                       'messages' => array(),
-                                       'options' => array(),
-                               );
+                                       'messages' => [],
+                                       'options' => [],
+                               ];
                                foreach ( $question->getMessageNames() as $name 
) {
                                        $value = $question->getRawMessage( 
$name, $lang );
                                        if ( $value !== false ) {
@@ -121,10 +121,10 @@
                                }
 
                                foreach ( $question->getOptions() as $option ) {
-                                       $o = array(
+                                       $o = [
                                                'id' => $option->getId(),
-                                               'messages' => array(),
-                                       );
+                                               'messages' => [],
+                                       ];
                                        foreach ( $option->getMessageNames() as 
$name ) {
                                                $value = 
$option->getRawMessage( $name, $lang );
                                                if ( $value !== false ) {
@@ -155,7 +155,7 @@
                        false, FormatJson::ALL_OK );
                $title = Title::makeTitle( NS_SECUREPOLL, $election->getId() .
                        ( $subpage === '' ? '' : "/$subpage" ) );
-               return array( $title, ContentHandler::makeContent( $json, 
$title, 'SecurePoll' ) );
+               return [ $title, ContentHandler::makeContent( $json, $title, 
'SecurePoll' ) ];
        }
 
        public function canBeUsedOn( Title $title ) {
@@ -165,7 +165,7 @@
 
        public function getActionOverrides() {
                // Disable write actions
-               return array(
+               return [
                        'delete' => false,
                        'edit' => false,
                        'info' => false,
@@ -174,7 +174,7 @@
                        'rollback' => false,
                        'submit' => false,
                        'unprotect' => false,
-               );
+               ];
        }
 
        protected function getContentClass() {
diff --git a/includes/main/SpecialSecurePoll.php 
b/includes/main/SpecialSecurePoll.php
index 6a43704..e545ce7 100644
--- a/includes/main/SpecialSecurePoll.php
+++ b/includes/main/SpecialSecurePoll.php
@@ -6,7 +6,7 @@
  * this or of SpecialPage, they're subclassed from SecurePoll_ActionPage.
  */
 class SecurePoll_SpecialSecurePoll extends SpecialPage {
-       public static $pages = array(
+       public static $pages = [
                'create' => 'SecurePoll_CreatePage',
                'edit' => 'SecurePoll_CreatePage',
                'details' => 'SecurePoll_DetailsPage',
@@ -19,7 +19,7 @@
                'translate' => 'SecurePoll_TranslatePage',
                'vote' => 'SecurePoll_VotePage',
                'votereligibility' => 'SecurePoll_VoterEligibilityPage',
-       );
+       ];
 
        public $sp_context;
 
@@ -42,11 +42,11 @@
                $out = $this->getOutput();
 
                $this->setHeaders();
-               $out->addLink( array(
+               $out->addLink( [
                        'rel' => 'stylesheet',
                        'href' => 
"$wgExtensionAssetsPath/SecurePoll/resources/SecurePoll.css",
                        'type' => 'text/css'
-               ) );
+               ] );
                $out->addScriptFile( 
"$wgExtensionAssetsPath/SecurePoll/resources/SecurePoll.js" );
 
                $paramString = strval( $paramString );
diff --git a/includes/main/Store.php b/includes/main/Store.php
index 4896338..da9aa22 100644
--- a/includes/main/Store.php
+++ b/includes/main/Store.php
@@ -85,13 +85,13 @@
                $res = $db->select(
                        'securepoll_msgs',
                        '*',
-                       array(
+                       [
                                'msg_entity' => $ids,
                                'msg_lang' => $lang
-                       ),
+                       ],
                        __METHOD__
                );
-               $messages = array();
+               $messages = [];
                foreach ( $res as $row ) {
                        $messages[$row->msg_entity][$row->msg_key] = 
$row->msg_text;
                }
@@ -103,11 +103,11 @@
                $res = $db->select(
                        'securepoll_msgs',
                        'DISTINCT msg_lang',
-                       array(
+                       [
                                'msg_entity' => $ids
-                       ),
+                       ],
                        __METHOD__ );
-               $langs = array();
+               $langs = [];
                foreach ( $res as $row ) {
                        $langs[] = $row->msg_lang;
                }
@@ -119,9 +119,9 @@
                $res = $db->select(
                        'securepoll_properties',
                        '*',
-                       array( 'pr_entity' => $ids ),
+                       [ 'pr_entity' => $ids ],
                        __METHOD__ );
-               $properties = array();
+               $properties = [];
                foreach ( $res as $row ) {
                        $properties[$row->pr_entity][$row->pr_key] = 
$row->pr_value;
                }
@@ -134,9 +134,9 @@
                $res = $db->select(
                        'securepoll_elections',
                        '*',
-                       array( 'el_entity' => $ids ),
+                       [ 'el_entity' => $ids ],
                        __METHOD__ );
-               $infos = array();
+               $infos = [];
                foreach ( $res as $row ) {
                        $infos[$row->el_entity] = $this->decodeElectionRow( 
$row );
                }
@@ -149,9 +149,9 @@
                $res = $db->select(
                        'securepoll_elections',
                        '*',
-                       array( 'el_title' => $names ),
+                       [ 'el_title' => $names ],
                        __METHOD__ );
-               $infos = array();
+               $infos = [];
                foreach ( $res as $row ) {
                        $infos[$row->el_title] = $this->decodeElectionRow( $row 
);
                }
@@ -159,7 +159,7 @@
        }
 
        function decodeElectionRow( $row ) {
-               static $map = array(
+               static $map = [
                        'id' => 'el_entity',
                        'title' => 'el_title',
                        'ballot' => 'el_ballot',
@@ -169,9 +169,9 @@
                        'endDate' => 'el_end_date',
                        'auth' => 'el_auth_type',
                        'owner' => 'el_owner'
-               );
+               ];
 
-               $info = array();
+               $info = [];
                foreach ( $map as $key => $field ) {
                        if ( $key == 'startDate' || $key == 'endDate' ) {
                                $info[$key] = wfTimestamp( TS_MW, $row->$field 
);
@@ -189,54 +189,54 @@
        function getQuestionInfo( $electionId ) {
                $db = $this->getDB();
                $res = $db->select(
-                       array( 'securepoll_questions', 'securepoll_options' ),
+                       [ 'securepoll_questions', 'securepoll_options' ],
                        '*',
-                       array(
+                       [
                                'qu_election' => $electionId,
                                'op_question=qu_entity'
-                       ),
+                       ],
                        __METHOD__,
-                       array( 'ORDER BY' => 'qu_index, qu_entity' )
+                       [ 'ORDER BY' => 'qu_index, qu_entity' ]
                );
 
-               $questions = array();
-               $options = array();
+               $questions = [];
+               $options = [];
                $questionId = false;
                $electionId = false;
                foreach ( $res as $row ) {
                        if ( $questionId === false ) {
                        } elseif ( $questionId !== $row->qu_entity ) {
-                               $questions[] = array(
+                               $questions[] = [
                                        'id' => $questionId,
                                        'election' => $electionId,
                                        'options' => $options
-                               );
-                               $options = array();
+                               ];
+                               $options = [];
                        }
-                       $options[] = array(
+                       $options[] = [
                                'id' => $row->op_entity,
                                'election' => $row->op_election,
-                       );
+                       ];
                        $questionId = $row->qu_entity;
                        $electionId = $row->qu_election;
                }
                if ( $questionId !== false ) {
-                       $questions[] = array(
+                       $questions[] = [
                                'id' => $questionId,
                                'election' => $electionId,
                                'options' => $options
-                       );
+                       ];
                }
                return $questions;
        }
 
        function callbackValidVotes( $electionId, $callback, $voterId = null ) {
                $dbr = $this->getDB();
-               $where = array(
+               $where = [
                        'vote_election' => $electionId,
                        'vote_current' => 1,
                        'vote_struck' => 0
-               );
+               ];
                if ( $voterId !== null ){
                        $where['vote_voter'] = $voterId;
                }
@@ -261,7 +261,7 @@
                $res = $db->selectRow(
                        'securepoll_entity',
                        '*',
-                       array( 'en_id' => $id ),
+                       [ 'en_id' => $id ],
                        __METHOD__ );
                return $res
                        ? $res->en_type
@@ -282,7 +282,7 @@
         * Get an array containing all election IDs stored in this object
         */
        function getAllElectionIds() {
-               $electionIds = array();
+               $electionIds = [];
                foreach ( $this->entityInfo as $info ) {
                        if ( $info['type'] !== 'election' ) {
                                continue;
@@ -294,13 +294,13 @@
 
        function getMessages( $lang, $ids ) {
                if ( !isset( $this->messages[$lang] ) ) {
-                       return array();
+                       return [];
                }
                return array_intersect_key( $this->messages[$lang], array_flip( 
$ids ) );
        }
 
        function getLangList( $ids ) {
-               $langs = array();
+               $langs = [];
                foreach ( $this->messages as $lang => $langMessages ) {
                        foreach ( $ids as $id ) {
                                if ( isset( $langMessages[$id] ) ) {
@@ -372,8 +372,8 @@
        public $voteCallback, $voteElectionId, $voteCallbackStatus;
 
        /** Valid entity info keys by entity type. */
-       private static $entityInfoKeys = array(
-               'election' => array(
+       private static $entityInfoKeys = [
+               'election' => [
                        'id',
                        'title',
                        'ballot',
@@ -382,20 +382,20 @@
                        'startDate',
                        'endDate',
                        'auth'
-               ),
-               'question' => array( 'id', 'election' ),
-               'option' => array( 'id', 'election' ),
-       );
+               ],
+               'question' => [ 'id', 'election' ],
+               'option' => [ 'id', 'election' ],
+       ];
 
        /** The type of each entity child and its corresponding (plural) info 
element */
-       private static $childTypes = array(
-               'election' => array( 'question' => 'questions' ),
-               'question' => array( 'option' => 'options' ),
-               'option' => array()
-       );
+       private static $childTypes = [
+               'election' => [ 'question' => 'questions' ],
+               'question' => [ 'option' => 'options' ],
+               'option' => []
+       ];
 
        /** All entity types */
-       private static $entityTypes = array( 'election', 'question', 'option' );
+       private static $entityTypes = [ 'election', 'question', 'option' ];
 
        /**
         * Constructor. Note that readFile() must be called before any 
information
@@ -515,9 +515,9 @@
         */
        function readEntity( $entityType ) {
                $xr = $this->xmlReader;
-               $info = array( 'type' => $entityType );
-               $messages = array();
-               $properties = array();
+               $info = [ 'type' => $entityType ];
+               $messages = [];
+               $properties = [];
                if ( $xr->isEmptyElement ) {
                        wfDebug( __METHOD__.": unexpected empty element\n" );
                        $xr->read();
diff --git a/phpcs.xml b/phpcs.xml
index 1845afe..7b53421 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -2,7 +2,6 @@
 <ruleset>
        <rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
                <exclude name="Squiz.Classes.ValidClassName.NotCamelCaps"/>
-               <exclude name="Generic.Arrays.DisallowLongArraySyntax.Found"/>
        </rule>
        <rule ref="MediaWiki.NamingConventions.ValidGlobalName">
                <properties>

-- 
To view, visit https://gerrit.wikimedia.org/r/358075
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6ba21315abbe586ce4237be991daade483b259a4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SecurePoll
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <umherirrender_de...@web.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to