Ladsgroup has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/271241

Change subject: Support codesniffer 0.6.0
......................................................................

Support codesniffer 0.6.0

+ Changing all old arrays to new model

Change-Id: I930a1c57c9866c7bde06206829b9d32ade24812f
---
M composer.json
M includes/Api.php
M includes/Cache.php
M includes/Hooks.php
M includes/Scoring.php
M maintenance/CheckModelVersions.php
M maintenance/PopulateDatabase.php
M maintenance/PurgeScoreCache.php
8 files changed, 53 insertions(+), 52 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ORES 
refs/changes/41/271241/1

diff --git a/composer.json b/composer.json
index 11e4acd..2363941 100644
--- a/composer.json
+++ b/composer.json
@@ -1,9 +1,10 @@
 {
        "require-dev": {
                "jakub-onderka/php-parallel-lint": "0.9.2",
-               "mediawiki/mediawiki-codesniffer": "0.5.1"
+               "mediawiki/mediawiki-codesniffer": "0.6.0"
        },
        "scripts": {
+               "fix": "phpcbf",
                "test": [
                        "parallel-lint . --exclude vendor",
                        "phpcs -p"
diff --git a/includes/Api.php b/includes/Api.php
index f4ca69f..1a0f787 100644
--- a/includes/Api.php
+++ b/includes/Api.php
@@ -14,7 +14,7 @@
        /**
         * @return string Base URL plus your wiki's `scores` API path.
         */
-       public static function getUrl( $param = array() ) {
+       public static function getUrl( $param = [] ) {
                global $wgOresBaseUrl, $wgOresWikiId;
 
                if ( $wgOresWikiId ) {
@@ -34,7 +34,7 @@
         *
         * @throws RuntimeException
         */
-       public static function request( $params = array() ) {
+       public static function request( $params = [] ) {
                $logger = LoggerFactory::getInstance( 'ORES' );
 
                $url = Api::getUrl();
diff --git a/includes/Cache.php b/includes/Cache.php
index c002938..133e6b7 100644
--- a/includes/Cache.php
+++ b/includes/Cache.php
@@ -9,9 +9,9 @@
        protected $classMap;
 
        public function __construct() {
-               $this->classMap = array( 'true' => 1, 'false' => 0,
+               $this->classMap = [ 'true' => 1, 'false' => 0,
                        'B' => 0, 'C' => 1, 'FA' => 2, 'GA' => 3,
-                       'Start' => 4, 'Stub' => 5 );
+                       'Start' => 4, 'Stub' => 5 ];
        }
        /**
         * Save scores to the database
@@ -22,7 +22,7 @@
         */
        public function storeScores( $scores ) {
                // Map to database fields.
-               $dbData = array();
+               $dbData = [];
                foreach ( $scores as $revision => $revisionData ) {
                        foreach ( $revisionData as $model => $modelOutputs ) {
                                if ( isset( $modelOutputs['error'] ) ) {
@@ -44,13 +44,13 @@
                                        if ( $class === 0 ) {
                                                continue;
                                        }
-                                       $dbData[] = array(
+                                       $dbData[] = [
                                                'oresc_rev' => $revision,
                                                'oresc_model' => $modelId,
                                                'oresc_class' => $class,
                                                'oresc_probability' => 
$probability,
                                                'oresc_is_predicted' => ( 
$ores_is_predicted ),
-                                       );
+                                       ];
                                }
                        }
                }
@@ -74,11 +74,11 @@
                $dbr = \wfGetDB( DB_SLAVE );
                $dbw = \wfGetDB( DB_MASTER );
 
-               $join_conds = array( 'ores_model' =>
-                       array( 'LEFT JOIN', 'oresm_id = oresc_model' ) );
-               $conditions = array(
+               $join_conds = [ 'ores_model' =>
+                       [ 'LEFT JOIN', 'oresm_id = oresc_model' ] ];
+               $conditions = [
                        'oresm_name' => $model,
-               );
+               ];
                if ( !$isEverything ) {
                        $conditions[] = 'oresm_is_current != 1';
                }
@@ -88,12 +88,12 @@
                                'oresc_rev',
                                $conditions,
                                __METHOD__,
-                               array( 'LIMIT' => $batchSize ),
+                               [ 'LIMIT' => $batchSize ],
                                $join_conds
                        );
                        if ( $ids ) {
                                $dbw->delete( 'ores_classification',
-                                       array( 'oresc_rev' => $ids ),
+                                       [ 'oresc_rev' => $ids ],
                                        __METHOD__
                                );
                                wfWaitForSlaves();
@@ -113,7 +113,7 @@
 
                $modelId = \wfGetDB( DB_SLAVE )->selectField( 'ores_model',
                        'oresm_id',
-                       array( 'oresm_name' => $model, 'oresm_is_current' => 1 
),
+                       [ 'oresm_name' => $model, 'oresm_is_current' => 1 ],
                        __METHOD__
                );
                if ( $modelId === false ) {
@@ -127,7 +127,7 @@
        public function getModels() {
                $models = \wfGetDB( DB_SLAVE )->selectFieldValues( 'ores_model',
                        'oresm_name',
-                       array(),
+                       [],
                        __METHOD__
                );
                return $models;
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 97bbef2..80195f1 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -44,9 +44,9 @@
                if ( $rc->getAttribute( 'rc_type' ) === RC_EDIT ) {
                        $logger = LoggerFactory::getInstance( 'ORES' );
                        $logger->debug( 'Processing edit' );
-                       $job = new FetchScoreJob( $rc->getTitle(), array(
+                       $job = new FetchScoreJob( $rc->getTitle(), [
                                'revid' => $rc->getAttribute( 'rc_this_oldid' ),
-                       ) );
+                       ] );
                        JobQueueGroup::singleton()->push( $job );
                        $logger->debug( 'Job pushed...' );
                }
@@ -66,10 +66,10 @@
                        return true;
                }
 
-               $filters['hidenondamaging'] = array(
+               $filters['hidenondamaging'] = [
                        'msg' => 'ores-damaging-filter',
                        'default' => false,
-               );
+               ];
 
                return true;
        }
@@ -100,17 +100,17 @@
                $tables[] = 'ores_model';
 
                $fields[] = 'oresc_probability';
-               $join_conds['ores_classification'] = array( 'LEFT JOIN',
+               $join_conds['ores_classification'] = [ 'LEFT JOIN',
                        'rc_this_oldid = oresc_rev ' .
-                       'AND oresc_is_predicted = 1 AND oresc_class = 1' );
+                       'AND oresc_is_predicted = 1 AND oresc_class = 1' ];
 
                // Add user-based threshold
                $fields[] = $threshold . ' AS ores_threshold';
 
-               $join_conds['ores_model'] = array( 'LEFT JOIN',
+               $join_conds['ores_model'] = [ 'LEFT JOIN',
                        'oresc_model = oresm_id AND oresm_name = \'damaging\' ' 
.
                        'AND oresm_is_current = 1'
-               );
+               ];
 
                if ( $opts->getValue( 'hidenondamaging' ) ) {
                        // Filter out non-damaging edits.
@@ -175,7 +175,7 @@
         * @return bool
         */
        public static function onOldChangesListRecentChangesLine( ChangesList 
&$changesList, &$s,
-               $rc, &$classes = array()
+               $rc, &$classes = []
        ) {
                if ( self::oresEnabled( $changesList->getUser() ) === false ) {
                        return true;
@@ -250,18 +250,18 @@
                if ( self::oresEnabled( $user ) === false ) {
                        return true;
                }
-               $options = array();
+               $options = [];
                foreach ( $wgOresDamagingThresholds as $case => $value ) {
                        $text = \wfMessage( 'ores-damaging-' . $case )->parse();
                        $options[$text] = $case;
                }
-               $preferences['oresDamagingPref'] = array(
+               $preferences['oresDamagingPref'] = [
                        'type' => 'select',
                        'label-message' => 'ores-pref-damaging',
                        'section' => 'rc/ores',
                        'options' => $options,
                        'help-message' => 'ores-help-damaging-pref',
-               );
+               ];
                return true;
        }
 
@@ -282,16 +282,16 @@
        public static function onGetBetaFeaturePreferences( $user, &$prefs ) {
                global $wgExtensionAssetsPath;
 
-               $prefs['ores-enabled'] = array(
+               $prefs['ores-enabled'] = [
                        'label-message' => 'ores-beta-feature-message',
                        'desc-message' => 'ores-beta-feature-description',
-                       'screenshot' => array(
+                       'screenshot' => [
                                'ltr' => 
"$wgExtensionAssetsPath/ORES/images/ORES-beta-features-ltr.png",
                                'rtl' => 
"$wgExtensionAssetsPath/ORES/images/ORES-beta-features-rtl.png",
-                       ),
+                       ],
                        'info-link' => 
'https://www.mediawiki.org/wiki/Extension:ORES',
                        'discussion-link' => 
'https://www.mediawiki.org/wiki/Extension_talk:ORES',
-               );
+               ];
        }
 
        /**
diff --git a/includes/Scoring.php b/includes/Scoring.php
index d9d0c71..021e5df 100644
--- a/includes/Scoring.php
+++ b/includes/Scoring.php
@@ -16,10 +16,10 @@
                        $models = $wgOresModels;
                }
 
-               $wireData = Api::request( array(
+               $wireData = Api::request( [
                        'models' => implode( '|', (array) $models ),
                        'revids' => implode( '|', (array) $revisions ),
-               ) );
+               ] );
                return $wireData;
        }
 
diff --git a/maintenance/CheckModelVersions.php 
b/maintenance/CheckModelVersions.php
index 59b7427..10a54ee 100644
--- a/maintenance/CheckModelVersions.php
+++ b/maintenance/CheckModelVersions.php
@@ -24,22 +24,22 @@
                foreach ( $models as $name => $info ) {
                        \wfGetDB( DB_MASTER )->replace( 'ores_model',
                                'oresm_version',
-                               array(
+                               [
                                        'oresm_name' => $name,
                                        'oresm_version' => $info['version'],
                                        'oresm_is_current' => 1,
-                               ),
+                               ],
                                __METHOD__
                        );
 
                        \wfGetDB( DB_MASTER )->update( 'ores_model',
-                               array(
+                               [
                                        'oresm_is_current' => 0,
-                               ),
-                               array(
+                               ],
+                               [
                                        'oresm_name' => $name,
                                        'oresm_version != ' . \wfGetDB( 
DB_SLAVE )->addQuotes( $info['version'] ),
-                               ),
+                               ],
                                __METHOD__
                        );
                }
diff --git a/maintenance/PopulateDatabase.php b/maintenance/PopulateDatabase.php
index 2b7d4f0..e92ce7a 100644
--- a/maintenance/PopulateDatabase.php
+++ b/maintenance/PopulateDatabase.php
@@ -43,14 +43,14 @@
 
                $latestRcId = 0;
                $dbr = wfGetDB( DB_SLAVE );
-               $join_conds = array( 'ores_classification' =>
-                       array( 'LEFT JOIN', array( 'oresc_rev = rc_this_oldid' 
) )
-               );
+               $join_conds = [ 'ores_classification' =>
+                       [ 'LEFT JOIN', [ 'oresc_rev = rc_this_oldid' ] ]
+               ];
 
                $count = 0;
                while ( $count < $this->revisionLimit ) {
 
-                       $conditions = array( 'oresc_id IS NULL', 'rc_type' => 0 
);
+                       $conditions = [ 'oresc_id IS NULL', 'rc_type' => 0 ];
                        if ( $wgOresExcludeBots === true ) {
                                $conditions['rc_bot'] = 0;
                        }
@@ -58,25 +58,25 @@
                                $conditions[] = 'rc_id < ' . $dbr->addQuotes( 
$latestRcId );
                        }
 
-                       $res = $dbr->select( array( 'recentchanges', 
'ores_classification' ),
-                               array( 'rc_id', 'rc_this_oldid' ),
+                       $res = $dbr->select( [ 'recentchanges', 
'ores_classification' ],
+                               [ 'rc_id', 'rc_this_oldid' ],
                                $conditions,
                                __METHOD__,
-                               array( 'ORDER BY' => 'rc_id DESC',
-                                       'LIMIT' => $this->batchSize ),
+                               [ 'ORDER BY' => 'rc_id DESC',
+                                       'LIMIT' => $this->batchSize ],
                                $join_conds
                        );
 
-                       $pack = array();
+                       $pack = [];
                        foreach ( $res as $row ) {
                                $pack[] = $row->rc_this_oldid;
                                if ( count( $pack ) % 50 === 0 ) {
                                        $this->processScores( $pack, $scoring, 
$cache );
-                                       $pack = array();
+                                       $pack = [];
                                }
                                $latestRcId = $row->rc_id;
                        }
-                       if ( $pack !== array() ) {
+                       if ( $pack !== [] ) {
                                $this->processScores( $pack, $scoring, $cache );
                        }
 
diff --git a/maintenance/PurgeScoreCache.php b/maintenance/PurgeScoreCache.php
index ca4907e..9059076 100644
--- a/maintenance/PurgeScoreCache.php
+++ b/maintenance/PurgeScoreCache.php
@@ -24,7 +24,7 @@
 
        public function execute() {
                if ( $this->hasOption( 'model' ) ) {
-                       $models = array( $this->getOption( 'model' ) );
+                       $models = [ $this->getOption( 'model' ) ];
                } else {
                        $models = Cache::instance()->getModels();
                }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I930a1c57c9866c7bde06206829b9d32ade24812f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ORES
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgr...@gmail.com>

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

Reply via email to