From 5d40cff293d6969785ef429ef32b572905e6fcf0 Mon Sep 17 00:00:00 2001 From: Daimona Eaytoy Date: Mon, 9 Sep 2019 11:11:50 +0200 Subject: [PATCH] maintenance: Explicitly declare all used properties All uses were checked with codesearch, and the visibility was chosen as strict as possible. Change-Id: I56666299cc04ccc418e05949422876583982eb3c --- maintenance/cleanupImages.php | 5 +++- maintenance/compareParsers.php | 12 ++++++++++ maintenance/dumpIterator.php | 6 +++-- maintenance/importDump.php | 10 ++++++++ maintenance/includes/BackupDumper.php | 29 +++++++++++++++++++++++ maintenance/mwdocgen.php | 20 ++++++++++++++++ maintenance/preprocessDump.php | 2 ++ maintenance/preprocessorFuzzTest.php | 7 ++++++ maintenance/rebuildImages.php | 24 +++++++++++++++++-- maintenance/recountCategories.php | 6 +++++ maintenance/renderDump.php | 2 ++ maintenance/storage/recompressTracked.php | 2 ++ 12 files changed, 120 insertions(+), 5 deletions(-) diff --git a/maintenance/cleanupImages.php b/maintenance/cleanupImages.php index 4d0c0e6729..69281810e6 100644 --- a/maintenance/cleanupImages.php +++ b/maintenance/cleanupImages.php @@ -42,6 +42,9 @@ class CleanupImages extends TableCleanup { 'callback' => 'processRow', ]; + /** @var LocalRepo|null */ + private $repo; + public function __construct() { parent::__construct(); $this->addDescription( 'Script to clean up broken, unparseable upload filenames' ); @@ -116,7 +119,7 @@ class CleanupImages extends TableCleanup { * @return string */ private function filePath( $name ) { - if ( !isset( $this->repo ) ) { + if ( $this->repo === null ) { $this->repo = RepoGroup::singleton()->getLocalRepo(); } diff --git a/maintenance/compareParsers.php b/maintenance/compareParsers.php index 3f5587832e..0d4b7b1c70 100644 --- a/maintenance/compareParsers.php +++ b/maintenance/compareParsers.php @@ -39,6 +39,18 @@ require_once __DIR__ . '/dumpIterator.php'; class CompareParsers extends DumpIterator { private $count = 0; + /** @var bool */ + private $saveFailed; + /** @var bool */ + private $stripParametersEnabled; + /** @var bool */ + private $showParsedOutput; + /** @var bool */ + private $showDiff; + /** @var ParserOptions */ + private $options; + /** @var int */ + private $failed; public function __construct() { parent::__construct(); diff --git a/maintenance/dumpIterator.php b/maintenance/dumpIterator.php index 751932d73f..20e94594eb 100644 --- a/maintenance/dumpIterator.php +++ b/maintenance/dumpIterator.php @@ -34,9 +34,10 @@ require_once __DIR__ . '/Maintenance.php'; * @ingroup Maintenance */ abstract class DumpIterator extends Maintenance { - private $count = 0; private $startTime; + /** @var string|bool|null */ + private $from; public function __construct() { parent::__construct(); @@ -60,6 +61,7 @@ abstract class DumpIterator extends Maintenance { $revision->setTitle( Title::newFromText( rawurldecode( basename( $this->getOption( 'file' ), '.txt' ) ) ) ); + $this->from = false; $this->handleRevision( $revision ); return; @@ -131,7 +133,7 @@ abstract class DumpIterator extends Maintenance { } $this->count++; - if ( isset( $this->from ) ) { + if ( $this->from !== false ) { if ( $this->from != $title ) { return; } diff --git a/maintenance/importDump.php b/maintenance/importDump.php index cda16fe3b3..d5f94ad8ab 100644 --- a/maintenance/importDump.php +++ b/maintenance/importDump.php @@ -43,6 +43,16 @@ class BackupReader extends Maintenance { public $imageBasePath = false; /** @var array|false */ public $nsFilter = false; + /** @var bool|resource */ + public $stderr; + /** @var callable|null */ + protected $importCallback; + /** @var callable|null */ + protected $logItemCallback; + /** @var callable|null */ + protected $uploadCallback; + /** @var int */ + protected $startTime; function __construct() { parent::__construct(); diff --git a/maintenance/includes/BackupDumper.php b/maintenance/includes/BackupDumper.php index 358dc21e13..6c1c083e99 100644 --- a/maintenance/includes/BackupDumper.php +++ b/maintenance/includes/BackupDumper.php @@ -49,6 +49,8 @@ abstract class BackupDumper extends Maintenance { public $dumpUploadFileContents = false; public $orderRevs = false; public $limitNamespaces = []; + /** @var bool|resource */ + public $stderr; protected $reportingInterval = 100; protected $pageCount = 0; @@ -65,6 +67,33 @@ abstract class BackupDumper extends Maintenance { protected $ID = 0; + /** @var int */ + protected $startTime; + /** @var int */ + protected $pageCountPart; + /** @var int */ + protected $revCountPart; + /** @var int */ + protected $maxCount; + /** @var int */ + protected $timeOfCheckpoint; + /** @var ExportProgressFilter */ + protected $egress; + /** @var string */ + protected $buffer; + /** @var array|false */ + protected $openElement; + /** @var bool */ + protected $atStart; + /** @var string|null */ + protected $thisRevModel; + /** @var string|null */ + protected $thisRevFormat; + /** @var string */ + protected $lastName; + /** @var string */ + protected $state; + /** * The dependency-injected database to use. * diff --git a/maintenance/mwdocgen.php b/maintenance/mwdocgen.php index 4a50cc5773..f600f13869 100644 --- a/maintenance/mwdocgen.php +++ b/maintenance/mwdocgen.php @@ -42,6 +42,26 @@ require_once __DIR__ . '/Maintenance.php'; * @ingroup Maintenance */ class MWDocGen extends Maintenance { + /** @var string */ + private $doxygen; + /** @var string */ + private $mwVersion; + /** @var string */ + private $output; + /** @var string */ + private $input; + /** @var string */ + private $inputFilter; + /** @var string */ + private $template; + /** @var string[] */ + private $excludes; + /** @var string[] */ + private $excludePatterns; + /** @var bool */ + private $doDot; + /** @var bool */ + private $doMan; /** * Prepare Maintenance class diff --git a/maintenance/preprocessDump.php b/maintenance/preprocessDump.php index 05b78d4847..fddac8a0e4 100644 --- a/maintenance/preprocessDump.php +++ b/maintenance/preprocessDump.php @@ -41,6 +41,8 @@ class PreprocessDump extends DumpIterator { /* Variables for dressing up as a parser */ public $mTitle = 'PreprocessDump'; public $mPPNodeCount = 0; + /** @var Preprocessor */ + public $mPreprocessor; public function getStripList() { $parser = MediaWikiServices::getInstance()->getParser(); diff --git a/maintenance/preprocessorFuzzTest.php b/maintenance/preprocessorFuzzTest.php index 39b2ff03e8..3a43ae8b5c 100644 --- a/maintenance/preprocessorFuzzTest.php +++ b/maintenance/preprocessorFuzzTest.php @@ -150,6 +150,13 @@ class PPFuzzTester { class PPFuzzTest { public $templates, $mainText, $title, $entryPoint, $output; + /** @var PPFuzzTester */ + private $parent; + /** @var string */ + public $nickname; + /** @var bool */ + public $fancySig; + /** * @param PPFuzzTester $tester */ diff --git a/maintenance/rebuildImages.php b/maintenance/rebuildImages.php index 3de0070859..df2ab042b1 100644 --- a/maintenance/rebuildImages.php +++ b/maintenance/rebuildImages.php @@ -41,12 +41,32 @@ use Wikimedia\Rdbms\IMaintainableDatabase; * @ingroup Maintenance */ class ImageBuilder extends Maintenance { - /** * @var IMaintainableDatabase */ protected $dbw; + /** @var bool */ + private $dryrun; + + /** @var LocalRepo|null */ + private $repo; + + /** @var int */ + private $updated; + + /** @var int */ + private $processed; + + /** @var int */ + private $count; + + /** @var int */ + private $startTime; + + /** @var string */ + private $table; + function __construct() { parent::__construct(); @@ -79,7 +99,7 @@ class ImageBuilder extends Maintenance { * @return LocalRepo */ function getRepo() { - if ( !isset( $this->repo ) ) { + if ( $this->repo === null ) { $this->repo = RepoGroup::singleton()->getLocalRepo(); } diff --git a/maintenance/recountCategories.php b/maintenance/recountCategories.php index 7e8f0636d5..8ec648ff39 100644 --- a/maintenance/recountCategories.php +++ b/maintenance/recountCategories.php @@ -36,6 +36,12 @@ use MediaWiki\MediaWikiServices; * @ingroup Maintenance */ class RecountCategories extends Maintenance { + /** @var string */ + private $mode; + + /** @var int */ + private $minimumId; + public function __construct() { parent::__construct(); $this->addDescription( <<<'TEXT' diff --git a/maintenance/renderDump.php b/maintenance/renderDump.php index cc5ae5961e..85795ca7a7 100644 --- a/maintenance/renderDump.php +++ b/maintenance/renderDump.php @@ -40,6 +40,8 @@ class DumpRenderer extends Maintenance { private $count = 0; private $outputDirectory, $startTime; + /** @var string */ + private $prefix; public function __construct() { parent::__construct(); diff --git a/maintenance/storage/recompressTracked.php b/maintenance/storage/recompressTracked.php index 0d506ef767..9f20e670ac 100644 --- a/maintenance/storage/recompressTracked.php +++ b/maintenance/storage/recompressTracked.php @@ -713,6 +713,8 @@ class CgzCopyTransaction { /** @var ConcatenatedGzipHistoryBlob|false */ public $cgz; public $referrers; + /** @var array */ + private $texts; /** * Create a transaction from a RecompressTracked object -- 2.20.1