Thiemo Mättig (WMDE) has uploaded a new change for review.

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

Change subject: Fix method signatures in all maintenance scripts
......................................................................

Fix method signatures in all maintenance scripts

This patch focuses on cleaning up method signatures. Sometimes this
means adding missing or fixing incomplete PHPDoc tags. Sometimes this
means refining the signature, more precisely:
* adding missing type hints,
* removing a return from a method that isn't supposed to do so,
* removing "= null" if a parameter isn't allowed to be null.

This is split from I0b2be11 to make it easier to review.

Change-Id: Ic96148297f8ad1910e394cedd8b24119fd1eace9
---
M repo/maintenance/dumpJson.php
M repo/maintenance/importInterlang.php
M repo/maintenance/importProperties.php
M repo/maintenance/populateChangesSubscription.php
M repo/maintenance/pruneChanges.php
M repo/maintenance/rebuildEntityPerPage.php
M repo/maintenance/rebuildItemsPerSite.php
M repo/maintenance/rebuildPropertyInfo.php
M repo/maintenance/rebuildTermsSearchKey.php
9 files changed, 67 insertions(+), 37 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/01/187101/1

diff --git a/repo/maintenance/dumpJson.php b/repo/maintenance/dumpJson.php
index 75e90a2..9a158f1 100644
--- a/repo/maintenance/dumpJson.php
+++ b/repo/maintenance/dumpJson.php
@@ -19,6 +19,7 @@
 use Wikibase\Repo\IO\EntityIdReader;
 use Wikibase\Repo\IO\LineReader;
 use Wikibase\Repo\Store\EntityIdPager;
+use Wikibase\Repo\Store\EntityPerPage;
 use Wikibase\Repo\Store\SQL\EntityPerPageIdPager;
 use Wikibase\Repo\WikibaseRepo;
 
@@ -52,7 +53,7 @@
        private $entityPerPage;
 
        /**
-        * @var bool|resource
+        * @var resource|bool
         */
        private $logFileHandle = false;
 
@@ -112,9 +113,9 @@
        /**
         * Opens the given file for use by logMessage().
         *
-        * @param $file
+        * @param string $file
         *
-        * @throws \MWException
+        * @throws MWException
         */
        private function openLogFile( $file ) {
                $this->closeLogFile();
@@ -127,7 +128,7 @@
                $this->logFileHandle = fopen( $file, 'a' );
 
                if ( !$this->logFileHandle ) {
-                       throw new \MWException( 'Failed to open log file: ' . 
$file );
+                       throw new MWException( 'Failed to open log file: ' . 
$file );
                }
        }
 
@@ -170,7 +171,7 @@
                $output = fopen( $outFile, 'w' ); //TODO: Allow injection of an 
OutputStream
 
                if ( !$output ) {
-                       throw new \MWException( 'Failed to open ' . $outFile . 
'!' );
+                       throw new MWException( 'Failed to open ' . $outFile . 
'!' );
                }
 
                if ( $this->hasOption( 'list-file' ) ) {
@@ -213,12 +214,12 @@
        }
 
        /**
-        * @param null|string $entityType
+        * @param string|null $entityType
         * @param ExceptionHandler $exceptionReporter
         *
         * @return EntityIdPager a stream of EntityId objects
         */
-       private function makeIdStream( $entityType = null, ExceptionHandler 
$exceptionReporter = null ) {
+       private function makeIdStream( $entityType, ExceptionHandler 
$exceptionReporter ) {
                $listFile = $this->getOption( 'list-file' );
 
                if ( $listFile !== null ) {
@@ -231,7 +232,7 @@
        }
 
        /**
-        * @param $entityType
+        * @param string|null $entityType
         *
         * @return EntityIdPager
         */
@@ -241,17 +242,17 @@
        }
 
        /**
-        * @param $listFile
+        * @param string $listFile
         * @param ExceptionHandler $exceptionReporter
         *
         * @throws MWException
         * @return EntityIdPager
         */
-       private function makeIdFileStream( $listFile, ExceptionHandler 
$exceptionReporter = null ) {
+       private function makeIdFileStream( $listFile, ExceptionHandler 
$exceptionReporter ) {
                $input = fopen( $listFile, 'r' );
 
                if ( !$input ) {
-                       throw new \MWException( "Failed to open ID file: 
$input" );
+                       throw new MWException( "Failed to open ID file: $input" 
);
                }
 
                $stream = new EntityIdReader( new LineReader( $input ), new 
BasicEntityIdParser() );
diff --git a/repo/maintenance/importInterlang.php 
b/repo/maintenance/importInterlang.php
index 5dcff04..b9ee573 100644
--- a/repo/maintenance/importInterlang.php
+++ b/repo/maintenance/importInterlang.php
@@ -24,20 +24,35 @@
 
 class importInterlang extends Maintenance {
 
+       /**
+        * @var bool
+        */
        private $verbose = false;
+
+       /**
+        * @var bool
+        */
        private $ignore_errors = false;
+
+       /**
+        * @var int
+        */
        private $skip = 0;
+
+       /**
+        * @var int
+        */
        private $only = 0;
 
        /**
-        * @var User|null
+        * @var User
         */
-       private $user = null;
+       private $user;
 
        /**
-        * @var EntityStore|null
+        * @var EntityStore
         */
-       private $store = null;
+       private $store;
 
        public function __construct() {
                $this->mDescription = "Import interlanguage links in 
Wikidata.\n\nThe links may be created by extractInterlang.sql";
@@ -130,11 +145,12 @@
        }
 
        /**
-        * @param Array $links An associative array of interlanguage links, 
mapping site IDs to page titles on that site.
+        * @param string[] $links Associative array of interlanguage links, 
mapping language codes to
+        * page titles on that site.
         *
         * @return bool true if the item was created, false otherwise
         */
-       private function createItem( $links ) {
+       private function createItem( array $links ) {
                $item = Item::newEmpty();
 
                foreach ( $links as $lang => $title ) {
diff --git a/repo/maintenance/importProperties.php 
b/repo/maintenance/importProperties.php
index c598a0f..677597a 100644
--- a/repo/maintenance/importProperties.php
+++ b/repo/maintenance/importProperties.php
@@ -25,20 +25,36 @@
 require_once $basePath . '/maintenance/Maintenance.php';
 
 class importProperties extends Maintenance {
+
+       /**
+        * @var bool
+        */
        private $verbose = false;
+
+       /**
+        * @var bool
+        */
        private $ignore_errors = false;
+
+       /**
+        * @var int
+        */
        private $skip = 0;
+
+       /**
+        * @var int
+        */
        private $only = 0;
 
        /**
-        * @var User|null
+        * @var User
         */
-       private $user = null;
+       private $user;
 
        /**
-        * @var EntityStore|null
+        * @var EntityStore
         */
-       private $store = null;
+       private $store;
 
        public function __construct() {
                $this->mDescription = "Import properties in Wikidata.";
@@ -126,11 +142,12 @@
        }
 
        /**
-        * @param Array $data An associative array of interlanguage links, 
mapping site IDs to page titles on that site.
+        * @param string[] $data Associative array of interlanguage links, 
mapping language codes to
+        * page titles on that site.
         *
         * @return bool true if the item was created, false otherwise
         */
-       private function createProperty( $data ) {
+       private function createProperty( array $data ) {
                $property = Property::newFromType( 'wikibase-item' );
 
                foreach ( $data as $lang => $title ) {
diff --git a/repo/maintenance/populateChangesSubscription.php 
b/repo/maintenance/populateChangesSubscription.php
index 37ced39..2060f36 100644
--- a/repo/maintenance/populateChangesSubscription.php
+++ b/repo/maintenance/populateChangesSubscription.php
@@ -83,7 +83,7 @@
        /**
         * Outputs a message vis the output() method.
         *
-        * @param $msg
+        * @param string $msg
         */
        public function report( $msg ) {
                $this->output( "$msg\n" );
diff --git a/repo/maintenance/pruneChanges.php 
b/repo/maintenance/pruneChanges.php
index e40170d..1d56aa6 100644
--- a/repo/maintenance/pruneChanges.php
+++ b/repo/maintenance/pruneChanges.php
@@ -96,7 +96,7 @@
        /**
         * Calculates the timestamp up to which changes can be pruned.
         *
-        * @return int timstamp up to which changes can be pruned (as unix 
period)
+        * @return int Timestamp up to which changes can be pruned (as Unix 
period).
         */
        private function getCutoffTimestamp() {
                $until = time() - $this->keepSeconds;
@@ -126,7 +126,7 @@
        /**
         * Prunes all changes older than $until from the changes table.
         *
-        * @param $until
+        * @param int $until
         *
         * @return int the number of changes deleted.
         */
diff --git a/repo/maintenance/rebuildEntityPerPage.php 
b/repo/maintenance/rebuildEntityPerPage.php
index 8e96c66..7e65cd5 100644
--- a/repo/maintenance/rebuildEntityPerPage.php
+++ b/repo/maintenance/rebuildEntityPerPage.php
@@ -34,7 +34,7 @@
        /**
         * @see LoggedUpdateMaintenance::doDBUpdates
         *
-        * @return boolean
+        * @return bool
         */
        public function doDBUpdates() {
                if ( !defined( 'WB_VERSION' ) ) {
@@ -74,7 +74,7 @@
         *
         * @since 0.4
         *
-        * @param $msg
+        * @param string $msg
         */
        public function report( $msg ) {
                $this->output( "$msg\n" );
diff --git a/repo/maintenance/rebuildItemsPerSite.php 
b/repo/maintenance/rebuildItemsPerSite.php
index d8f49b3..9af7e7c 100644
--- a/repo/maintenance/rebuildItemsPerSite.php
+++ b/repo/maintenance/rebuildItemsPerSite.php
@@ -33,8 +33,6 @@
 
        /**
         * @see Maintenance::execute
-        *
-        * @return boolean
         */
        public function execute() {
                if ( !defined( 'WB_VERSION' ) ) {
@@ -65,8 +63,6 @@
 
                // Now <s>kill</s> fix the table
                $builder->rebuild( $stream );
-
-               return true;
        }
 
        /**
@@ -74,7 +70,7 @@
         *
         * @since 0.4
         *
-        * @param $msg
+        * @param string $msg
         */
        public function report( $msg ) {
                $this->output( "$msg\n" );
diff --git a/repo/maintenance/rebuildPropertyInfo.php 
b/repo/maintenance/rebuildPropertyInfo.php
index 1218534..eb8f718 100644
--- a/repo/maintenance/rebuildPropertyInfo.php
+++ b/repo/maintenance/rebuildPropertyInfo.php
@@ -33,7 +33,7 @@
        /**
         * @see LoggedUpdateMaintenance::doDBUpdates
         *
-        * @return boolean
+        * @return bool
         */
        public function doDBUpdates() {
                if ( !defined( 'WB_VERSION' ) ) {
@@ -78,7 +78,7 @@
         *
         * @since 0.4
         *
-        * @param $msg
+        * @param string $msg
         */
        public function report( $msg ) {
                $this->output( "$msg\n" );
diff --git a/repo/maintenance/rebuildTermsSearchKey.php 
b/repo/maintenance/rebuildTermsSearchKey.php
index 86c186e..1eb1fec 100644
--- a/repo/maintenance/rebuildTermsSearchKey.php
+++ b/repo/maintenance/rebuildTermsSearchKey.php
@@ -33,7 +33,7 @@
        /**
         * @see LoggedUpdateMaintenance::doDBUpdates
         *
-        * @return boolean
+        * @return bool
         */
        public function doDBUpdates() {
                if ( !defined( 'WB_VERSION' ) ) {
@@ -75,7 +75,7 @@
         *
         * @since 0.4
         *
-        * @param $msg
+        * @param string $msg
         */
        public function report( $msg ) {
                $this->output( "$msg\n" );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic96148297f8ad1910e394cedd8b24119fd1eace9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>

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

Reply via email to