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

Change subject: Use short array syntax - includes/*
......................................................................

Use short array syntax - includes/*

Done by phpcbf over composer fix

Change-Id: I257c0ac219c570263017f891359628be42b7cee9
---
M includes/ballots/ApprovalBallot.php
M includes/ballots/Ballot.php
M includes/ballots/ChooseBallot.php
M includes/ballots/PreferentialBallot.php
M includes/ballots/RadioRangeBallot.php
M includes/ballots/RadioRangeCommentBallot.php
M includes/talliers/CommentDumper.php
M includes/talliers/ElectionTallier.php
M includes/talliers/HistogramRangeTallier.php
M includes/talliers/PairwiseTallier.php
M includes/talliers/PluralityTallier.php
M includes/talliers/SchulzeTallier.php
M includes/talliers/Tallier.php
M includes/user/Auth.php
M includes/user/Voter.php
15 files changed, 186 insertions(+), 186 deletions(-)


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

diff --git a/includes/ballots/ApprovalBallot.php 
b/includes/ballots/ApprovalBallot.php
index eb93a2e..b33ea39 100644
--- a/includes/ballots/ApprovalBallot.php
+++ b/includes/ballots/ApprovalBallot.php
@@ -5,7 +5,7 @@
  */
 class SecurePoll_ApprovalBallot extends SecurePoll_Ballot {
        static function getTallyTypes() {
-               return array( 'plurality' );
+               return [ 'plurality' ];
        }
 
        /**
@@ -24,9 +24,9 @@
                        $oldValue = $wgRequest->getBool( $inputId );
                        $s .=
                                '<div class="securepoll-option-approval">' .
-                               Xml::check( $inputId, $oldValue, array( 'id' => 
$inputId ) ) .
+                               Xml::check( $inputId, $oldValue, [ 'id' => 
$inputId ] ) .
                                '&#160;' .
-                               Xml::tags( 'label', array( 'for' => $inputId ), 
$optionHTML ) .
+                               Xml::tags( 'label', [ 'for' => $inputId ], 
$optionHTML ) .
                                '&#160;' .
                                "</div>\n";
                }
@@ -53,7 +53,7 @@
        }
 
        function unpackRecord( $record ) {
-               $scores = array();
+               $scores = [];
                $itemLength = 2 * 8 + 7;
                for ( $offset = 0, $len = strlen( $record ); $offset < $len; 
$offset += $itemLength ) {
                        if ( !preg_match( 
'/Q([0-9A-F]{8})-A([0-9A-F]{8})-([yn])--/A',
@@ -70,8 +70,8 @@
                return $scores;
        }
 
-       function convertScores( $scores, $params = array() ) {
-               $result = array();
+       function convertScores( $scores, $params = [] ) {
+               $result = [];
                foreach ( $this->election->getQuestions() as $question ) {
                        $qid = $question->getId();
                        if ( !isset( $scores[$qid] ) ) {
diff --git a/includes/ballots/Ballot.php b/includes/ballots/Ballot.php
index 2a65f12..2e4e321 100644
--- a/includes/ballots/Ballot.php
+++ b/includes/ballots/Ballot.php
@@ -6,13 +6,13 @@
 abstract class SecurePoll_Ballot {
        public $election, $context;
 
-       private static $ballotTypes = array(
+       private static $ballotTypes = [
                'approval' => 'SecurePoll_ApprovalBallot',
                'preferential' => 'SecurePoll_PreferentialBallot',
                'choose' => 'SecurePoll_ChooseBallot',
                'radio-range' => 'SecurePoll_RadioRangeBallot',
                'radio-range-comment' => 'SecurePoll_RadioRangeCommentBallot',
-       );
+       ];
 
        /**
         * Get a list of names of tallying methods, which may be used to 
produce a
@@ -36,24 +36,24 @@
         * @return array
         */
        static function getCreateDescriptors() {
-               return array(
-                       'election' => array(
-                               'shuffle-questions' => array(
+               return [
+                       'election' => [
+                               'shuffle-questions' => [
                                        'label-message' => 
'securepoll-create-label-shuffle_questions',
                                        'type' => 'check',
                                        'hidelabel' => true,
                                        'SecurePoll_type' => 'property',
-                               ),
-                               'shuffle-options' => array(
+                               ],
+                               'shuffle-options' => [
                                        'label-message' => 
'securepoll-create-label-shuffle_options',
                                        'type' => 'check',
                                        'hidelabel' => true,
                                        'SecurePoll_type' => 'property',
-                               ),
-                       ),
-                       'question' => array(),
-                       'option' => array(),
-               );
+                               ],
+                       ],
+                       'question' => [],
+                       'option' => [],
+               ];
        }
 
        /**
@@ -71,7 +71,7 @@
         * @see SecurePoll_Election::getMessageNames()
         */
        function getMessageNames() {
-               return array();
+               return [];
        }
 
        /**
@@ -114,7 +114,7 @@
        /**
         * Convert a record to a string of some kind
         */
-       function convertRecord( $record, $options = array() ) {
+       function convertRecord( $record, $options = [] ) {
                $scores = $this->unpackRecord( $record );
                return $this->convertScores( $scores );
        }
@@ -122,7 +122,7 @@
        /**
         * Convert a score array to a string of some kind
         */
-       abstract function convertScores( $scores, $options = array() );
+       abstract function convertScores( $scores, $options = [] );
 
        /**
         * Create a ballot of the given type
@@ -185,9 +185,9 @@
                        $this->prevErrorIds = $status->sp_getIds();
                        $this->prevStatus = $status;
                } else {
-                       $this->prevErrorIds = array();
+                       $this->prevErrorIds = [];
                }
-               $this->usedErrorIds = array();
+               $this->usedErrorIds = [];
        }
 
        function errorLocationIndicator( $id ) {
@@ -196,7 +196,7 @@
                }
                $this->usedErrorIds[$id] = true;
                return
-                       Xml::element( 'img', array(
+                       Xml::element( 'img', [
                                'src' => $this->context->getResourceUrl( 
'warning-22.png' ),
                                'width' => 22,
                                'height' => 22,
@@ -204,7 +204,7 @@
                                'class' => 'securepoll-error-location',
                                'alt' => '',
                                'title' => 
$this->prevStatus->sp_getMessageText( $id )
-                       ) );
+                       ] );
        }
 
        /**
@@ -243,7 +243,7 @@
                $store = $this->context->getStore();
                $status = $store->callbackValidVotes(
                        $this->election->info['id'],
-                       array( $this, 'getCurrentVoteCallback' ),
+                       [ $this, 'getCurrentVoteCallback' ],
                        $voter->getId()
                );
                if ( !$status->isOK() ){
@@ -263,7 +263,7 @@
 
 class SecurePoll_BallotStatus extends Status {
        public $sp_context;
-       public $sp_ids = array();
+       public $sp_ids = [];
 
        function __construct( $context ) {
                $this->sp_context = $context;
@@ -271,11 +271,11 @@
 
        function sp_fatal( $message, $id /*, parameters... */ ) {
                $params = array_slice( func_get_args(), 2 );
-               $this->errors[] = array(
+               $this->errors[] = [
                        'type' => 'error',
                        'securepoll-id' => $id,
                        'message' => $message,
-                       'params' => $params );
+                       'params' => $params ];
                $this->sp_ids[$id] = true;
                $this->ok = false;
        }
@@ -295,14 +295,14 @@
                                $id = $error['securepoll-id'];
                                if ( isset( $usedIds[$id] ) ) {
                                        $s .= '<li>' .
-                                               Xml::openElement( 'a', array(
+                                               Xml::openElement( 'a', [
                                                        'href' => '#' . 
urlencode( "$id-location" ),
                                                        'class' => 
'securepoll-error-jump'
-                                               ) ) .
-                                               Xml::element( 'img', array(
+                                               ] ) .
+                                               Xml::element( 'img', [
                                                        'alt' => '',
                                                        'src' => 
$this->sp_context->getResourceUrl( 'down-16.png' ),
-                                               ) ) .
+                                               ] ) .
                                                '</a>' .
                                                htmlspecialchars( $text ) .
                                                "</li>\n";
diff --git a/includes/ballots/ChooseBallot.php 
b/includes/ballots/ChooseBallot.php
index 5daec53..ae6b7ab 100644
--- a/includes/ballots/ChooseBallot.php
+++ b/includes/ballots/ChooseBallot.php
@@ -11,18 +11,18 @@
         * @return array
         */
        static function getTallyTypes() {
-               return array( 'plurality' );
+               return [ 'plurality' ];
        }
 
        static function getCreateDescriptors() {
                $ret = parent::getCreateDescriptors();
-               $ret['option'] += array(
-                       'name' => array(
+               $ret['option'] += [
+                       'name' => [
                                'label-message' => 
'securepoll-create-label-option-name',
                                'type' => 'text',
                                'SecurePoll_type' => 'message',
-                       ),
-               );
+                       ],
+               ];
                return $ret;
        }
 
@@ -41,9 +41,9 @@
                        $radioId = "{$name}_opt{$optionId}";
                        $s .=
                                '<div class="securepoll-option-choose">' .
-                               Xml::radio( $name, $optionId, false, array( 
'id' => $radioId ) ) .
+                               Xml::radio( $name, $optionId, false, [ 'id' => 
$radioId ] ) .
                                '&#160;' .
-                               Xml::tags( 'label', array( 'for' => $radioId ), 
$optionHTML ) .
+                               Xml::tags( 'label', [ 'for' => $radioId ], 
$optionHTML ) .
                                "</div>\n";
                }
                return $s;
@@ -69,7 +69,7 @@
        }
 
        function unpackRecord( $record ) {
-               $result = array();
+               $result = [];
                $record = trim( $record );
                for ( $offset = 0, $len = strlen( $record ); $offset < $len; 
$offset += 18 ) {
                        if ( !preg_match( '/Q([0-9A-F]{8})A([0-9A-F]{8})/A', 
$record, $m, 0, $offset ) ) {
@@ -78,12 +78,12 @@
                        }
                        $qid = intval( base_convert( $m[1], 16, 10 ) );
                        $oid = intval( base_convert( $m[2], 16, 10 ) );
-                       $result[$qid] = array( $oid => 1 );
+                       $result[$qid] = [ $oid => 1 ];
                }
                return $result;
        }
 
-       function convertScores( $scores, $params = array() ) {
+       function convertScores( $scores, $params = [] ) {
                $s = '';
                foreach ( $this->election->getQuestions() as $question ) {
                        $qid = $question->getId();
diff --git a/includes/ballots/PreferentialBallot.php 
b/includes/ballots/PreferentialBallot.php
index cf68f18..2c62b08 100644
--- a/includes/ballots/PreferentialBallot.php
+++ b/includes/ballots/PreferentialBallot.php
@@ -9,19 +9,19 @@
  */
 class SecurePoll_PreferentialBallot extends SecurePoll_Ballot {
        static function getTallyTypes() {
-               return array( 'schulze' );
+               return [ 'schulze' ];
        }
 
        static function getCreateDescriptors() {
                $ret = parent::getCreateDescriptors();
-               $ret['election'] += array(
-                       'must-rank-all' => array(
+               $ret['election'] += [
+                       'must-rank-all' => [
                                'label-message' => 
'securepoll-create-label-must_rank_all',
                                'type' => 'check',
                                'hidelabel' => true,
                                'SecurePoll_type' => 'property',
-                       ),
-               );
+                       ],
+               ];
                return $ret;
        }
 
@@ -41,13 +41,13 @@
                        $oldValue = $wgRequest->getVal( $inputId, '' );
                        $s .=
                                '<div class="securepoll-option-preferential">' .
-                               Xml::input( $inputId, '3', $oldValue, array(
+                               Xml::input( $inputId, '3', $oldValue, [
                                        'id' => $inputId,
                                        'maxlength' => 3,
-                               ) ) .
+                               ] ) .
                                '&#160;' .
                                $this->errorLocationIndicator( $inputId ) .
-                               Xml::tags( 'label', array( 'for' => $inputId ), 
$optionHTML ) .
+                               Xml::tags( 'label', [ 'for' => $inputId ], 
$optionHTML ) .
                                '&#160;' .
                                "</div>\n";
                }
@@ -99,7 +99,7 @@
        }
 
        function unpackRecord( $record ) {
-               $ranks = array();
+               $ranks = [];
                $itemLength = 3*8 + 7;
                for ( $offset = 0, $len = strlen( $record ); $offset < $len; 
$offset += $itemLength ) {
                        if ( !preg_match( 
'/Q([0-9A-F]{8})-A([0-9A-F]{8})-R([0-9A-F]{8})--/A',
@@ -116,8 +116,8 @@
                return $ranks;
        }
 
-       function convertScores( $scores, $params = array() ) {
-               $result = array();
+       function convertScores( $scores, $params = [] ) {
+               $result = [];
                foreach ( $this->election->getQuestions() as $question ) {
                        $qid = $question->getId();
                        if ( !isset( $scores[$qid] ) ) {
diff --git a/includes/ballots/RadioRangeBallot.php 
b/includes/ballots/RadioRangeBallot.php
index 5f7e739..840fd07 100644
--- a/includes/ballots/RadioRangeBallot.php
+++ b/includes/ballots/RadioRangeBallot.php
@@ -20,85 +20,85 @@
        public $columnLabels, $minMax;
 
        static function getTallyTypes() {
-               return array( 'plurality', 'histogram-range' );
+               return [ 'plurality', 'histogram-range' ];
        }
 
        static function getCreateDescriptors() {
                $ret = parent::getCreateDescriptors();
-               $ret['election'] += array(
-                       'must-answer-all' => array(
+               $ret['election'] += [
+                       'must-answer-all' => [
                                'label-message' => 
'securepoll-create-label-must_answer_all',
                                'type' => 'check',
                                'hidelabel' => true,
                                'SecurePoll_type' => 'property',
-                       ),
-               );
-               $ret['question'] += array(
-                       array(
+                       ],
+               ];
+               $ret['question'] += [
+                       [
                                'type' => 'info',
                                'rawrow' => true,
                                'default' => '<table 
class="securepoll-layout-table"><tr><td>',
-                       ),
+                       ],
 
-                       'min-score' => array(
+                       'min-score' => [
                                'label-message' => 
'securepoll-create-label-min_score',
                                'type' => 'int',
                                'required' => true,
                                'SecurePoll_type' => 'property',
-                       ),
+                       ],
 
-                       array(
+                       [
                                'type' => 'info',
                                'rawrow' => true,
                                'default' => '</td><td>',
-                       ),
+                       ],
 
-                       'max-score' => array(
+                       'max-score' => [
                                'label-message' => 
'securepoll-create-label-max_score',
                                'type' => 'int',
                                'required' => true,
                                'SecurePoll_type' => 'property',
-                       ),
+                       ],
 
-                       array(
+                       [
                                'type' => 'info',
                                'rawrow' => true,
                                'default' => '</td><td>',
-                       ),
+                       ],
 
-                       'default-score' => array(
+                       'default-score' => [
                                'label-message' => 
'securepoll-create-label-default_score',
                                'type' => 'int',
                                'SecurePoll_type' => 'property',
-                       ),
+                       ],
 
-                       array(
+                       [
                                'type' => 'info',
                                'rawrow' => true,
                                'default' => '</td></tr></table>',
-                       ),
+                       ],
 
-                       'column-order' => array(
+                       'column-order' => [
                                'label-message' => 
'securepoll-create-label-column_order',
                                'type' => 'select',
-                               'options-messages' => array(
+                               'options-messages' => [
                                        
'securepoll-create-option-column_order-asc' => 'asc',
                                        
'securepoll-create-option-column_order-desc' => 'desc',
-                               ),
+                               ],
                                'SecurePoll_type' => 'property',
-                       ),
-                       'column-label-msgs' => array(
+                       ],
+                       'column-label-msgs' => [
                                'label-message' => 
'securepoll-create-label-column_label_msgs',
                                'type' => 'check',
                                'hidelabel' => true,
                                'SecurePoll_type' => 'property',
-                       ),
-                       'column-messages' => array(
-                               'hide-if' => array( '!==', 'column-label-msgs', 
'1' ),
+                       ],
+                       'column-messages' => [
+                               'hide-if' => [ '!==', 'column-label-msgs', '1' 
],
                                'class' => 
'SecurePoll_HTMLFormRadioRangeColumnLabels',
                                'SecurePoll_type' => 'messages',
-                       ),
-               );
+                       ],
+               ];
                return $ret;
        }
 
@@ -113,7 +113,7 @@
                if ( $max <= $min ) {
                        throw new MWException( __METHOD__.': min/max not 
configured' );
                }
-               return array( $min, $max );
+               return [ $min, $max ];
        }
 
        /**
@@ -157,7 +157,7 @@
         */
        function getColumnLabels( $question ) {
                // list( $min, $max ) = $this->getMinMax( $question );
-               $labels = array();
+               $labels = [];
                $useMessageLabels = $question->getProperty( 'column-label-msgs' 
);
                $scores = $this->getScoresLeftToRight( $question );
                if ( $useMessageLabels ) {
@@ -176,12 +176,12 @@
 
        function getMessageNames( $entity = null ) {
                if ( $entity === null || $entity->getType() !== 'question' ) {
-                       return array();
+                       return [];
                }
                if ( !$entity->getProperty( 'column-label-msgs' ) ) {
-                       return array();
+                       return [];
                }
-               $msgs = array();
+               $msgs = [];
                list( $min, $max ) = $this->getMinMax( $entity );
                for ( $score = $min; $score <= $max; $score++ ) {
                        $signedScore = $this->addSign( $entity, $score );
@@ -214,7 +214,7 @@
                        "<tr>\n" .
                        "<th>&#160;</th>\n";
                foreach ( $labels as $label ) {
-                       $s .= Html::rawElement( 'th', array(), $label ) . "\n";
+                       $s .= Html::rawElement( 'th', [], $label ) . "\n";
                }
                $s .= "</tr>\n";
                $defaultScore = $question->getProperty( 'default-score' );
@@ -226,15 +226,15 @@
                        $oldValue = $wgRequest->getVal( $inputId, $defaultScore 
);
                        $s .= "<tr class=\"securepoll-ballot-row\">\n" .
                                Xml::tags( 'td',
-                                       array( 'class' => 
'securepoll-ballot-optlabel' ),
+                                       [ 'class' => 
'securepoll-ballot-optlabel' ],
                                        $this->errorLocationIndicator( $inputId 
) . $optionHTML
                                );
 
                        foreach ( $labels as $score => $label ) {
                                $s .=
-                                       Xml::tags( 'td', array(),
+                                       Xml::tags( 'td', [],
                                                Xml::radio( $inputId, $score, 
!strcmp( $oldValue, $score ),
-                                                       array( 'title' => 
$label ) )
+                                                       [ 'title' => $label ] )
                                        ) . "\n";
                        }
                        $s .= "</tr>\n";
@@ -292,9 +292,9 @@
        }
 
        function unpackRecord( $record ) {
-               $scores = array();
+               $scores = [];
                $itemLength = 8 + 8 + 11 + 7;
-               $questions = array();
+               $questions = [];
                foreach ( $this->election->getQuestions() as $question ) {
                        $questions[$question->getId()] = $question;
                }
@@ -322,8 +322,8 @@
                return $scores;
        }
 
-       function convertScores( $scores, $params = array() ) {
-               $result = array();
+       function convertScores( $scores, $params = [] ) {
+               $result = [];
                foreach ( $this->election->getQuestions() as $question ) {
                        $qid = $question->getId();
                        if ( !isset( $scores[$qid] ) ) {
diff --git a/includes/ballots/RadioRangeCommentBallot.php 
b/includes/ballots/RadioRangeCommentBallot.php
index 8949b8e..e9b3748 100644
--- a/includes/ballots/RadioRangeCommentBallot.php
+++ b/includes/ballots/RadioRangeCommentBallot.php
@@ -15,9 +15,9 @@
 
                // Add the comments boxes.
                $form .= Html::textarea( 'securepoll_comments_native', '',
-                       array( 'rows' => 10, 'cols' => 20 ) );
+                       [ 'rows' => 10, 'cols' => 20 ] );
                $form .= Html::textarea( 'securepoll_comments_en', '',
-                       array( 'rows' => 10, 'cols' => 20 ) );
+                       [ 'rows' => 10, 'cols' => 20 ] );
 
                return $form;
        }
@@ -49,9 +49,9 @@
         * Copy and modify from parent function, complex to refactor.
         */
        function unpackRecord( $record ) {
-               $scores = array();
+               $scores = [];
                $itemLength = 8 + 8 + 11 + 7;
-               $questions = array();
+               $questions = [];
                foreach ( $this->election->getQuestions() as $question ) {
                        $questions[$question->getId()] = $question;
                }
@@ -83,7 +83,7 @@
                }
 
                // Read comments
-               $scores['comment'] = array();
+               $scores['comment'] = [];
 
                $scores['comment']['native'] = $this->readComment( $record, 
$offset );
 
diff --git a/includes/talliers/CommentDumper.php 
b/includes/talliers/CommentDumper.php
index 3f677e4..7a6c649 100644
--- a/includes/talliers/CommentDumper.php
+++ b/includes/talliers/CommentDumper.php
@@ -52,7 +52,7 @@
                        return Status::newGood();
                }
 
-               $output = array( $comments['native'], $comments['en'] );
+               $output = [ $comments['native'], $comments['en'] ];
 
                ksort( $output );
 
diff --git a/includes/talliers/ElectionTallier.php 
b/includes/talliers/ElectionTallier.php
index 4faaea6..e1f1d8c 100644
--- a/includes/talliers/ElectionTallier.php
+++ b/includes/talliers/ElectionTallier.php
@@ -29,7 +29,7 @@
                $this->crypt = $this->election->getCrypt();
                $this->ballot = $this->election->getBallot();
                $questions = $this->election->getQuestions();
-               $this->talliers = array();
+               $this->talliers = [];
                $tallyType = $this->election->getTallyType();
                foreach ( $questions as $question ) {
                        $tallier = $this->context->newTallier( $tallyType, 
$this, $question );
@@ -39,7 +39,7 @@
                        $this->talliers[$question->getId()] = $tallier;
                }
 
-               $status = $store->callbackValidVotes( $this->election->getId(), 
array( $this, 'addRecord' ) );
+               $status = $store->callbackValidVotes( $this->election->getId(), 
[ $this, 'addRecord' ] );
                if ( !$status->isOK() ) {
                        return $status;
                }
diff --git a/includes/talliers/HistogramRangeTallier.php 
b/includes/talliers/HistogramRangeTallier.php
index efcef4b..4e217cf 100644
--- a/includes/talliers/HistogramRangeTallier.php
+++ b/includes/talliers/HistogramRangeTallier.php
@@ -1,9 +1,9 @@
 <?php
 
 class SecurePoll_HistogramRangeTallier extends SecurePoll_Tallier {
-       public $histogram = array();
-       public $sums = array();
-       public $counts = array();
+       public $histogram = [];
+       public $sums = [];
+       public $counts = [];
        public $averages;
        public $minScore, $maxScore;
 
@@ -33,7 +33,7 @@
        }
 
        function finishTally() {
-               $this->averages = array();
+               $this->averages = [];
                foreach ( $this->sums as $oid => $sum ) {
                        if ( $this->counts[$oid] === 0 ) {
                                $this->averages[$oid] = 'N/A';
@@ -46,10 +46,10 @@
 
        function getHtmlResult() {
                $ballot = $this->election->getBallot();
-               if ( !is_callable( array( $ballot, 'getColumnLabels' ) ) ) {
+               if ( !is_callable( [ $ballot, 'getColumnLabels' ] ) ) {
                        throw new MWException( __METHOD__.': ballot type not 
supported by this tallier' );
                }
-               $optionLabels = array();
+               $optionLabels = [];
                foreach ( $this->question->getOptions() as $option ) {
                        $optionLabels[$option->getId()] = 
$option->parseMessageInline( 'text' );
                }
@@ -59,20 +59,20 @@
                        "<tr>\n" .
                        "<th>&#160;</th>\n";
                foreach ( $labels as $label ) {
-                       $s .= Xml::element( 'th', array(), $label ) . "\n";
+                       $s .= Xml::element( 'th', [], $label ) . "\n";
                }
-               $s .= Xml::element( 'th', array(), wfMessage( 
'securepoll-average-score' )->text() );
+               $s .= Xml::element( 'th', [], wfMessage( 
'securepoll-average-score' )->text() );
                $s .= "</tr>\n";
 
                foreach ( $this->averages as $oid => $average ) {
                        $s .= "<tr>\n" .
-                               Xml::tags( 'td', array( 'class' => 
'securepoll-results-row-heading' ),
+                               Xml::tags( 'td', [ 'class' => 
'securepoll-results-row-heading' ],
                                        $optionLabels[$oid] ) .
                                "\n";
                        foreach ( $labels as $score => $label ) {
-                               $s .= Xml::element( 'td', array(), 
$this->histogram[$oid][$score] ) . "\n";
+                               $s .= Xml::element( 'td', [], 
$this->histogram[$oid][$score] ) . "\n";
                        }
-                       $s .= Xml::element( 'td', array(), $average ) . "\n";
+                       $s .= Xml::element( 'td', [], $average ) . "\n";
                        $s .= "</tr>\n";
                }
                $s .= "</table>\n";
diff --git a/includes/talliers/PairwiseTallier.php 
b/includes/talliers/PairwiseTallier.php
index 691975d..c36dab4 100644
--- a/includes/talliers/PairwiseTallier.php
+++ b/includes/talliers/PairwiseTallier.php
@@ -5,19 +5,19 @@
  * Tested via SecurePoll_SchulzeTallier.
  */
 abstract class SecurePoll_PairwiseTallier extends SecurePoll_Tallier {
-       public $optionIds = array();
-       public $victories = array();
+       public $optionIds = [];
+       public $victories = [];
        public $abbrevs;
-       public $rowLabels = array();
+       public $rowLabels = [];
 
        function __construct( $context, $electionTallier, $question ) {
                parent::__construct( $context, $electionTallier, $question );
-               $this->optionIds = array();
+               $this->optionIds = [];
                foreach ( $question->getOptions() as $option ) {
                        $this->optionIds[] = $option->getId();
                }
 
-               $this->victories = array();
+               $this->victories = [];
                foreach ( $this->optionIds as $i ) {
                        foreach ( $this->optionIds as $j ) {
                                $this->victories[$i][$j] = 0;
@@ -43,7 +43,7 @@
 
        function getOptionAbbreviations() {
                if ( is_null( $this->abbrevs ) ) {
-                       $abbrevs = array();
+                       $abbrevs = [];
                        foreach ( $this->question->getOptions() as $option ) {
                                $text = $option->getMessage( 'text' );
                                $parts = explode( ' ', $text );
@@ -71,7 +71,7 @@
 
        function getRowLabels( $format = 'html' ) {
                if ( !isset( $this->rowLabels[$format] ) ) {
-                       $rowLabels = array();
+                       $rowLabels = [];
                        $abbrevs = $this->getOptionAbbreviations();
                        foreach ( $this->question->getOptions() as $option ) {
                                if ( $format == 'html' ) {
@@ -100,14 +100,14 @@
 
                # Header row
                foreach ( $rankedIds as $oid ) {
-                       $s .= Xml::tags( 'th', array(), $abbrevs[$oid] ) . "\n";
+                       $s .= Xml::tags( 'th', [], $abbrevs[$oid] ) . "\n";
                }
                $s .= "</tr>\n";
 
                foreach ( $rankedIds as $oid1 ) {
                        # Header column
                        $s .= "<tr>\n";
-                       $s .= Xml::tags( 'td', array( 'class' => 
'securepoll-results-row-heading' ),
+                       $s .= Xml::tags( 'td', [ 'class' => 
'securepoll-results-row-heading' ],
                                $rowLabels[$oid1] );
                        # Rest of the matrix
                        foreach ( $rankedIds as $oid2 ) {
@@ -119,7 +119,7 @@
                                if ( is_array( $value ) ) {
                                        $value = '(' . implode( ', ', $value ) 
. ')';
                                }
-                               $s .= Xml::element( 'td', array(), $value ) . 
"\n";
+                               $s .= Xml::element( 'td', [], $value ) . "\n";
                        }
                        $s .= "</tr>\n";
                }
@@ -133,7 +133,7 @@
                $rowLabels = $this->getRowLabels( 'text' );
 
                # Calculate column widths
-               $colWidths = array();
+               $colWidths = [];
                foreach ( $abbrevs as $id => $abbrev ) {
                        if ( strlen( $abbrev ) < $minWidth ) {
                                $colWidths[$id] = $minWidth;
diff --git a/includes/talliers/PluralityTallier.php 
b/includes/talliers/PluralityTallier.php
index 8d9dd31..f196efb 100644
--- a/includes/talliers/PluralityTallier.php
+++ b/includes/talliers/PluralityTallier.php
@@ -4,7 +4,7 @@
  * Tallier that supports choose-one, approval and range voting
  */
 class SecurePoll_PluralityTallier extends SecurePoll_Tallier {
-       public $tally = array();
+       public $tally = [];
 
        /**
         * @param  $context SecurePoll_Context
@@ -80,7 +80,7 @@
        }
 
        function getRanks() {
-               $ranks = array();
+               $ranks = [];
                $currentRank = 1;
                $oids = array_keys( $this->tally );
                $scores = array_values( $this->tally );
diff --git a/includes/talliers/SchulzeTallier.php 
b/includes/talliers/SchulzeTallier.php
index bd46625..07e40b5 100644
--- a/includes/talliers/SchulzeTallier.php
+++ b/includes/talliers/SchulzeTallier.php
@@ -23,7 +23,7 @@
 
                # First the path strength matrix is populated with the "direct" 
victory count in each
                # direction, i.e. the number of people who preferenced A over 
B, and B over A.
-               $strengths = array();
+               $strengths = [];
                foreach ( $this->optionIds as $oid1 ) {
                        foreach ( $this->optionIds as $oid2 ) {
                                if ( $oid1 === $oid2 ) {
@@ -33,10 +33,10 @@
                                $v21 = $victories[$oid2][$oid1];
                                if ( $v12 > $v21 ) {
                                        # Direct victory
-                                       $strengths[$oid1][$oid2] = array( $v12, 
$v21 );
+                                       $strengths[$oid1][$oid2] = [ $v12, $v21 
];
                                } else {
                                        # Direct loss
-                                       $strengths[$oid1][$oid2] = array( 0, 0 
);
+                                       $strengths[$oid1][$oid2] = [ 0, 0 ];
                                }
                        }
                }
@@ -72,7 +72,7 @@
 
        function convertStrengthMatrixToRanks( $strengths ) {
                $unusedIds = $this->optionIds;
-               $ranks = array();
+               $ranks = [];
                $currentRank = 1;
 
                while ( count( $unusedIds ) ) {
diff --git a/includes/talliers/Tallier.php b/includes/talliers/Tallier.php
index c53eeb5..4503597 100644
--- a/includes/talliers/Tallier.php
+++ b/includes/talliers/Tallier.php
@@ -14,11 +14,11 @@
 
        abstract function finishTally();
 
-       public static $tallierTypes = array(
+       public static $tallierTypes = [
                'plurality' => 'SecurePoll_PluralityTallier',
                'schulze' => 'SecurePoll_SchulzeTallier',
                'histogram-range' => 'SecurePoll_HistogramRangeTallier',
-       );
+       ];
 
        /**
         * @param $context
@@ -49,11 +49,11 @@
         * @return array
         */
        static function getCreateDescriptors() {
-               return array(
-                       'election' => array(),
-                       'question' => array(),
-                       'option' => array(),
-               );
+               return [
+                       'election' => [],
+                       'question' => [],
+                       'option' => [],
+               ];
        }
 
        /**
@@ -88,8 +88,8 @@
 
                        $option = $this->optionsById[$oid];
                        $s .= "<tr>" .
-                               Xml::element( 'td', array(), $rank ) .
-                               Xml::openElement( 'td', array() ) .
+                               Xml::element( 'td', [], $rank ) .
+                               Xml::openElement( 'td', [] ) .
                                $option->parseMessage( 'text', false ) .
                                Xml::closeElement( 'td' ) .
                                "</tr>\n";
diff --git a/includes/user/Auth.php b/includes/user/Auth.php
index 2042f8d..92ea666 100644
--- a/includes/user/Auth.php
+++ b/includes/user/Auth.php
@@ -10,10 +10,10 @@
        /**
         * List of available authorization modules (subclasses)
         */
-       private static $authTypes = array(
+       private static $authTypes = [
                'local' => 'SecurePoll_LocalAuth',
                'remote-mw' => 'SecurePoll_RemoteMWAuth',
-       );
+       ];
 
        /**
         * Create an auth object of the given type
@@ -39,7 +39,7 @@
         * @return array
         */
        static function getCreateDescriptors() {
-               return array();
+               return [];
        }
 
        function __construct( $context ) {
@@ -117,14 +117,14 @@
                $dbw->startAtomic( __METHOD__ );
                $row = $dbw->selectRow(
                        'securepoll_voters', '*',
-                       array(
+                       [
                                'voter_name' => $params['name'],
                                'voter_election' => $params['electionId'],
                                'voter_domain' => $params['domain'],
                                'voter_url' => $params['url']
-                       ),
+                       ],
                        __METHOD__,
-                       array( 'FOR UPDATE' )
+                       [ 'FOR UPDATE' ]
                );
                if ( $row ) {
                        $user = $this->context->newVoterFromRow( $row );
@@ -215,12 +215,12 @@
         */
        function getUserParams( $user ) {
                global $wgServer;
-               $params = array(
+               $params = [
                        'name' => $user->getName(),
                        'type' => 'local',
                        'domain' => preg_replace( '!.*/(.*)$!', '$1', $wgServer 
),
                        'url' => $user->getUserPage()->getCanonicalURL(),
-                       'properties' => array(
+                       'properties' => [
                                'wiki' => wfWikiID(),
                                'blocked' => $user->isBlocked(),
                                'central-block-count' => 
$this->getCentralBlockCount( $user ),
@@ -231,10 +231,10 @@
                                'lists' => $this->getLists( $user ),
                                'central-lists' => $this->getCentralLists( 
$user ),
                                'registration' => $user->getRegistration(),
-                       )
-               );
+                       ]
+               ];
 
-               Hooks::run( 'SecurePoll_GetUserParams', array( $this, $user, 
&$params ) );
+               Hooks::run( 'SecurePoll_GetUserParams', [ $this, $user, 
&$params ] );
                return $params;
        }
 
@@ -247,11 +247,11 @@
                $dbr = $this->context->getDB();
                $res = $dbr->select(
                        'securepoll_lists',
-                       array( 'li_name' ),
-                       array( 'li_member' => $user->getId() ),
+                       [ 'li_name' ],
+                       [ 'li_member' => $user->getId() ],
                        __METHOD__
                );
-               $lists = array();
+               $lists = [];
                foreach ( $res as $row ) {
                        $lists[] = $row->li_name;
                }
@@ -265,20 +265,20 @@
         */
        function getCentralLists( $user ) {
                if ( !class_exists( 'CentralAuthUser' ) ) {
-                       return array();
+                       return [];
                }
                $centralUser = CentralAuthUser::getInstance( $user );
                if ( !$centralUser->isAttached() ) {
-                       return array();
+                       return [];
                }
                $dbc = CentralAuthUser::getCentralSlaveDB();
                $res = $dbc->select(
                        'securepoll_lists',
-                       array( 'li_name' ),
-                       array( 'li_member' => $centralUser->getId() ),
+                       [ 'li_name' ],
+                       [ 'li_member' => $centralUser->getId() ],
                        __METHOD__
                );
-               $lists = array();
+               $lists = [];
                foreach ( $res as $row ) {
                        $lists[] = $row->li_name;
                }
@@ -315,14 +315,14 @@
  */
 class SecurePoll_RemoteMWAuth extends SecurePoll_Auth {
        static function getCreateDescriptors() {
-               return array(
-                       'script-path' => array(
+               return [
+                       'script-path' => [
                                'label-message' => 
'securepoll-create-label-remote_mw_script_path',
                                'type' => 'url',
                                'required' => true,
                                'SecurePoll_type' => 'property',
-                       ),
-               );
+                       ],
+               ];
        }
 
        /**
@@ -333,9 +333,9 @@
        function requestLogin( $election ) {
                global $wgRequest, $wgSecurePollScript, $wgConf;
 
-               $urlParamNames = array( 'id', 'token', 'wiki', 'site', 'lang', 
'domain' );
-               $vars = array();
-               $params = array();
+               $urlParamNames = [ 'id', 'token', 'wiki', 'site', 'lang', 
'domain' ];
+               $vars = [];
+               $params = [];
                foreach ( $urlParamNames as $name ) {
                        $value = $wgRequest->getVal( $name );
                        if ( !preg_match( '/^[\w.-]*$/', $value ) ) {
@@ -379,14 +379,14 @@
                        $url .= '/';
                }
                $url .= $wgSecurePollScript . '?' .
-                       wfArrayToCgi( array(
+                       wfArrayToCgi( [
                                'token' => $params['token'],
                                'id' => $params['id']
-                       ) );
+                       ] );
 
                // Use the default SSL certificate file
                // Necessary on some versions of cURL, others do this by default
-               $curlParams = array( CURLOPT_CAINFO => 
'/etc/ssl/certs/ca-certificates.crt' );
+               $curlParams = [ CURLOPT_CAINFO => 
'/etc/ssl/certs/ca-certificates.crt' ];
 
                $value = Http::get( $url, 20, $curlParams );
 
diff --git a/includes/user/Voter.php b/includes/user/Voter.php
index 0aef482..d3cf09d 100644
--- a/includes/user/Voter.php
+++ b/includes/user/Voter.php
@@ -6,11 +6,11 @@
  */
 class SecurePoll_Voter {
        public $id, $electionId, $name, $domain, $wiki, $type, $url;
-       public $properties = array();
+       public $properties = [];
 
-       private static $paramNames = array(
+       private static $paramNames = [
                'id', 'electionId', 'name', 'domain', 'wiki', 'type', 'url', 
'properties'
-       );
+       ];
 
        /**
         * Create a voter from the given associative array of parameters
@@ -30,7 +30,7 @@
         */
        static function newFromId( $context, $id ) {
                $db = $context->getDB();
-               $row = $db->selectRow( 'securepoll_voters', '*', array( 
'voter_id' => $id ), __METHOD__ );
+               $row = $db->selectRow( 'securepoll_voters', '*', [ 'voter_id' 
=> $id ], __METHOD__ );
                if ( !$row ) {
                        return false;
                }
@@ -41,7 +41,7 @@
         * Create a voter from a DB result row
         */
        static function newFromRow( $context, $row ) {
-               return new self( $context, array(
+               return new self( $context, [
                        'id' => $row->voter_id,
                        'electionId' => $row->voter_election,
                        'name' => $row->voter_name,
@@ -49,7 +49,7 @@
                        'type' => $row->voter_type,
                        'url' => $row->voter_url,
                        'properties' => self::decodeProperties( 
$row->voter_properties )
-               ) );
+               ] );
        }
 
        /**
@@ -62,7 +62,7 @@
        static function createVoter( $context, $params ) {
                $db = $context->getDB();
                $id = $db->nextSequenceValue( 'voters_voter_id' );
-               $row = array(
+               $row = [
                        'voter_id' => $id,
                        'voter_election' => $params['electionId'],
                        'voter_name' => $params['name'],
@@ -70,7 +70,7 @@
                        'voter_domain' => $params['domain'],
                        'voter_url' => $params['url'],
                        'voter_properties' => self::encodeProperties( 
$params['properties'] )
-               );
+               ];
                $db->insert( 'securepoll_voters', $row, __METHOD__ );
                $params['id'] = $db->insertId();
                return new self( $context, $params );
@@ -148,7 +148,7 @@
         */
        static function decodeProperties( $blob ) {
                if ( strval( $blob ) == '' ) {
-                       return array();
+                       return [];
                } else {
                        return unserialize( $blob );
                }
@@ -184,21 +184,21 @@
                $dbw = $this->context->getDB();
                # Insert the log record
                $dbw->insert( 'securepoll_cookie_match',
-                       array(
+                       [
                                'cm_election' => $this->getElectionId(),
                                'cm_voter_1' => $this->getId(),
                                'cm_voter_2' => $voterId,
                                'cm_timestamp' => wfTimestampNow( TS_DB )
-                       ),
+                       ],
                        __METHOD__ );
 
                # Update the denormalized fields
                $dbw->update( 'securepoll_votes',
-                       array( 'vote_cookie_dup' => 1 ),
-                       array(
+                       [ 'vote_cookie_dup' => 1 ],
+                       [
                                'vote_election' => $this->getElectionId(),
-                               'vote_voter' => array( $this->getId(), $voterId 
)
-                       ),
+                               'vote_voter' => [ $this->getId(), $voterId ]
+                       ],
                        __METHOD__ );
        }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I257c0ac219c570263017f891359628be42b7cee9
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