aboutsummaryrefslogtreecommitdiffstats
path: root/maintenance
diff options
context:
space:
mode:
authorUmherirrender <umherirrender_de.wp@web.de>2025-03-30 18:45:31 +0200
committerUmherirrender <umherirrender_de.wp@web.de>2025-03-31 19:47:36 +0000
commitbe3115a12e20ed3fc9a6d74e2ab81d6d50922c4f (patch)
treefa70d85c8ab777d575ee0bc6f1cfd4c0d20fc62d /maintenance
parent33f585f0842fae65ab9215247a2773f2b48893b0 (diff)
downloadmediawikicore-be3115a12e20ed3fc9a6d74e2ab81d6d50922c4f.tar.gz
mediawikicore-be3115a12e20ed3fc9a6d74e2ab81d6d50922c4f.zip
maintenance: Use type declaration on undocumented private functions
Change-Id: I2c1bc3b4e0ee782076ddaeae133672b730d345d9
Diffstat (limited to 'maintenance')
-rw-r--r--maintenance/SqliteMaintenance.php2
-rw-r--r--maintenance/benchmarks/benchmarkJsonCodec.php2
-rw-r--r--maintenance/benchmarks/benchmarkSettings.php2
-rw-r--r--maintenance/benchmarks/benchmarkTidy.php2
-rw-r--r--maintenance/checkDependencies.php8
-rw-r--r--maintenance/cleanupImages.php11
-rw-r--r--maintenance/cleanupPreferences.php3
-rw-r--r--maintenance/cleanupWatchlist.php2
-rw-r--r--maintenance/compareParsers.php4
-rw-r--r--maintenance/convertExtensionToRegistration.php2
-rw-r--r--maintenance/deleteAutoPatrolLogs.php4
-rw-r--r--maintenance/deleteOldRevisions.php2
-rw-r--r--maintenance/dumpUploads.php4
-rw-r--r--maintenance/getConfiguration.php2
-rw-r--r--maintenance/importDump.php12
-rw-r--r--maintenance/importImages.php2
-rw-r--r--maintenance/includes/MaintenanceParameters.php2
-rw-r--r--maintenance/includes/MaintenanceRunner.php4
-rw-r--r--maintenance/includes/SevenZipStream.php2
-rw-r--r--maintenance/includes/TextPassDumper.php4
-rw-r--r--maintenance/install.php2
-rw-r--r--maintenance/language/generateCollationData.php2
-rw-r--r--maintenance/language/generateUcfirstOverrides.php2
-rw-r--r--maintenance/language/importExtensionMessages.php10
-rw-r--r--maintenance/mcc.php2
-rw-r--r--maintenance/migrateExternallinks.php2
-rw-r--r--maintenance/migrateFileTables.php2
-rw-r--r--maintenance/migrateLinksTable.php2
-rw-r--r--maintenance/populateChangeTagDef.php2
-rw-r--r--maintenance/purgePage.php2
-rw-r--r--maintenance/rebuildImages.php11
-rw-r--r--maintenance/storage/checkStorage.php6
-rw-r--r--maintenance/storage/moveToExternal.php8
-rw-r--r--maintenance/storage/recompressTracked.php2
-rw-r--r--maintenance/storage/trackBlobs.php4
-rwxr-xr-xmaintenance/update.php2
-rw-r--r--maintenance/updateSearchIndex.php2
37 files changed, 71 insertions, 68 deletions
diff --git a/maintenance/SqliteMaintenance.php b/maintenance/SqliteMaintenance.php
index da9a3ab59485..609c4cc18387 100644
--- a/maintenance/SqliteMaintenance.php
+++ b/maintenance/SqliteMaintenance.php
@@ -109,7 +109,7 @@ class SqliteMaintenance extends Maintenance {
}
}
- private function backup( DBConnRef $dbw, $fileName ) {
+ private function backup( DBConnRef $dbw, string $fileName ) {
$this->output( "Backing up database:\n Locking..." );
$dbw->query( 'BEGIN IMMEDIATE TRANSACTION', __METHOD__ );
$ourFile = $dbw->__call( 'getDbFilePath', [] );
diff --git a/maintenance/benchmarks/benchmarkJsonCodec.php b/maintenance/benchmarks/benchmarkJsonCodec.php
index 7ab1d0bd67b4..d5ec449955fe 100644
--- a/maintenance/benchmarks/benchmarkJsonCodec.php
+++ b/maintenance/benchmarks/benchmarkJsonCodec.php
@@ -76,7 +76,7 @@ class BenchmarkJsonCodec extends Benchmarker {
] );
}
- private function loadData( $file ) {
+ private function loadData( string $file ) {
if ( str_ends_with( $file, '.php' ) ) {
$data = include $file;
if ( !$data ) {
diff --git a/maintenance/benchmarks/benchmarkSettings.php b/maintenance/benchmarks/benchmarkSettings.php
index 2f49284c0860..66b12df55e82 100644
--- a/maintenance/benchmarks/benchmarkSettings.php
+++ b/maintenance/benchmarks/benchmarkSettings.php
@@ -46,7 +46,7 @@ class BenchmarkSettings extends Benchmarker {
$this->addDescription( 'Benchmark loading settings files.' );
}
- private function newSettingsBuilder() {
+ private function newSettingsBuilder(): SettingsBuilder {
$extReg = new ExtensionRegistry();
$configBuilder = new ArrayConfigBuilder();
$phpIniSink = new NullIniSink();
diff --git a/maintenance/benchmarks/benchmarkTidy.php b/maintenance/benchmarks/benchmarkTidy.php
index c193ee5dcc28..6ed3b3ccf58d 100644
--- a/maintenance/benchmarks/benchmarkTidy.php
+++ b/maintenance/benchmarks/benchmarkTidy.php
@@ -41,7 +41,7 @@ class BenchmarkTidy extends Benchmarker {
$this->benchmark( $html );
}
- private function benchmark( $html ) {
+ private function benchmark( string $html ) {
$services = $this->getServiceContainer();
$contLang = $services->getContentLanguage();
$tidy = $services->getTidy();
diff --git a/maintenance/checkDependencies.php b/maintenance/checkDependencies.php
index 69a646382d71..25fd10eb070e 100644
--- a/maintenance/checkDependencies.php
+++ b/maintenance/checkDependencies.php
@@ -86,7 +86,7 @@ class CheckDependencies extends Maintenance {
}
}
- private function loadThing( &$dependencies, $name, $extensions, $skins ) {
+ private function loadThing( array &$dependencies, string $name, array $extensions, array $skins ) {
$extDir = $this->getConfig()->get( MainConfigNames::ExtensionDirectory );
$styleDir = $this->getConfig()->get( MainConfigNames::StyleDirectory );
$queue = [];
@@ -154,8 +154,8 @@ class CheckDependencies extends Maintenance {
$this->addToDependencies( $dependencies, $extensions, $skins, $name );
}
- private function addToDependencies( &$dependencies, $extensions, $skins,
- $why = null, $status = null, $message = null
+ private function addToDependencies( array &$dependencies, array $extensions, array $skins,
+ ?string $why = null, ?string $status = null, ?string $message = null
) {
$mainRegistry = ExtensionRegistry::getInstance();
$iter = [ 'extensions' => $extensions, 'skins' => $skins ];
@@ -186,7 +186,7 @@ class CheckDependencies extends Maintenance {
}
}
- private function formatForHumans( $dependencies ) {
+ private function formatForHumans( array $dependencies ): string {
$text = '';
foreach ( $dependencies as $type => $things ) {
$text .= ucfirst( $type ) . "\n" . str_repeat( '=', strlen( $type ) ) . "\n";
diff --git a/maintenance/cleanupImages.php b/maintenance/cleanupImages.php
index b4634e12cb05..d471e97039cf 100644
--- a/maintenance/cleanupImages.php
+++ b/maintenance/cleanupImages.php
@@ -28,6 +28,7 @@
use MediaWiki\FileRepo\LocalRepo;
use MediaWiki\Parser\Sanitizer;
use MediaWiki\Title\Title;
+use Wikimedia\Rdbms\IReadableDatabase;
// @codeCoverageIgnoreStart
require_once __DIR__ . '/TableCleanup.php';
@@ -137,7 +138,7 @@ class CleanupImages extends TableCleanup {
return $this->repo->getRootDirectory() . '/' . $this->repo->getHashPath( $name ) . $name;
}
- private function imageExists( $name, $db ) {
+ private function imageExists( string $name, IReadableDatabase $db ): bool {
return (bool)$db->newSelectQueryBuilder()
->select( '1' )
->from( 'image' )
@@ -146,7 +147,7 @@ class CleanupImages extends TableCleanup {
->fetchField();
}
- private function pageExists( $name, $db ) {
+ private function pageExists( string $name, IReadableDatabase $db ): bool {
return (bool)$db->newSelectQueryBuilder()
->select( '1' )
->from( 'page' )
@@ -158,7 +159,7 @@ class CleanupImages extends TableCleanup {
->fetchField();
}
- private function pokeFile( $orig, $new ) {
+ private function pokeFile( string $orig, string $new ) {
$path = $this->filePath( $orig );
if ( !file_exists( $path ) ) {
$this->output( "missing file: $path\n" );
@@ -232,12 +233,12 @@ class CleanupImages extends TableCleanup {
}
}
- private function appendTitle( $name, $suffix ) {
+ private function appendTitle( string $name, string $suffix ): string {
return preg_replace( '/^(.*)(\..*?)$/',
"\\1$suffix\\2", $name );
}
- private function buildSafeTitle( $name ) {
+ private function buildSafeTitle( string $name ) {
$x = preg_replace_callback(
'/([^' . Title::legalChars() . ']|~)/',
[ $this, 'hexChar' ],
diff --git a/maintenance/cleanupPreferences.php b/maintenance/cleanupPreferences.php
index 0b4707b4411c..afd85bd4fe7c 100644
--- a/maintenance/cleanupPreferences.php
+++ b/maintenance/cleanupPreferences.php
@@ -32,6 +32,7 @@ use MediaWiki\MainConfigNames;
use MediaWiki\Maintenance\Maintenance;
use MediaWiki\User\Options\UserOptionsLookup;
use Wikimedia\Rdbms\IExpression;
+use Wikimedia\Rdbms\IReadableDatabase;
use Wikimedia\Rdbms\LikeValue;
/**
@@ -99,7 +100,7 @@ class CleanupPreferences extends Maintenance {
}
}
- private function deleteByWhere( $dbr, $startMessage, $where ) {
+ private function deleteByWhere( IReadableDatabase $dbr, string $startMessage, array $where ) {
$this->output( $startMessage . "...\n" );
$dryRun = $this->hasOption( 'dry-run' );
diff --git a/maintenance/cleanupWatchlist.php b/maintenance/cleanupWatchlist.php
index 61ef59bb2e36..f9a9dba53e65 100644
--- a/maintenance/cleanupWatchlist.php
+++ b/maintenance/cleanupWatchlist.php
@@ -80,7 +80,7 @@ class CleanupWatchlist extends TableCleanup {
$this->progress( 0 );
}
- private function removeWatch( $row ) {
+ private function removeWatch( \stdClass $row ): int {
if ( !$this->dryrun && $this->hasOption( 'fix' ) ) {
$dbw = $this->getPrimaryDB();
$dbw->newDeleteQueryBuilder()
diff --git a/maintenance/compareParsers.php b/maintenance/compareParsers.php
index 4e97cc03815d..09a683090c7e 100644
--- a/maintenance/compareParsers.php
+++ b/maintenance/compareParsers.php
@@ -123,7 +123,7 @@ class CompareParsers extends DumpIterator {
}
}
- private function stripParameters( $text ) {
+ private function stripParameters( string $text ): string {
if ( !$this->stripParametersEnabled ) {
return $text;
}
@@ -191,7 +191,7 @@ class CompareParsers extends DumpIterator {
}
}
- private static function checkParserLocally( $parserName ) {
+ private static function checkParserLocally( string $parserName ) {
/* Look for the parser in a file appropriately named in the current folder */
if ( !class_exists( $parserName ) && file_exists( "$parserName.php" ) ) {
global $wgAutoloadClasses;
diff --git a/maintenance/convertExtensionToRegistration.php b/maintenance/convertExtensionToRegistration.php
index 3c2f5c2975f8..bed732a5092a 100644
--- a/maintenance/convertExtensionToRegistration.php
+++ b/maintenance/convertExtensionToRegistration.php
@@ -226,7 +226,7 @@ class ConvertExtensionToRegistration extends Maintenance {
}
}
- private function stripPath( $val, $dir ) {
+ private function stripPath( string $val, string $dir ): string {
if ( $val === $dir ) {
$val = '';
} elseif ( strpos( $val, $dir ) === 0 ) {
diff --git a/maintenance/deleteAutoPatrolLogs.php b/maintenance/deleteAutoPatrolLogs.php
index 00e5a5908c39..35949641e414 100644
--- a/maintenance/deleteAutoPatrolLogs.php
+++ b/maintenance/deleteAutoPatrolLogs.php
@@ -100,7 +100,7 @@ class DeleteAutoPatrolLogs extends Maintenance {
}
}
- private function getRows( $fromId ) {
+ private function getRows( ?int $fromId ): array {
$dbr = $this->getReplicaDB();
$before = $this->getOption( 'before', false );
@@ -127,7 +127,7 @@ class DeleteAutoPatrolLogs extends Maintenance {
->fetchFieldValues();
}
- private function getRowsOld( $fromId ) {
+ private function getRowsOld( ?int $fromId ): ?array {
$dbr = $this->getReplicaDB();
$batchSize = $this->getBatchSize();
$before = $this->getOption( 'before', false );
diff --git a/maintenance/deleteOldRevisions.php b/maintenance/deleteOldRevisions.php
index ff62cdf24b86..0aeca0ae6531 100644
--- a/maintenance/deleteOldRevisions.php
+++ b/maintenance/deleteOldRevisions.php
@@ -46,7 +46,7 @@ class DeleteOldRevisions extends Maintenance {
$this->doDelete( $this->hasOption( 'delete' ), $this->getArgs( 'page_id' ) );
}
- private function doDelete( $delete = false, $pageIds = [] ) {
+ private function doDelete( bool $delete = false, array $pageIds = [] ) {
# Data should come off the master, wrapped in a transaction
$dbw = $this->getPrimaryDB();
$this->beginTransaction( $dbw, __METHOD__ );
diff --git a/maintenance/dumpUploads.php b/maintenance/dumpUploads.php
index c476fa594e0c..901da886a543 100644
--- a/maintenance/dumpUploads.php
+++ b/maintenance/dumpUploads.php
@@ -115,7 +115,7 @@ By default, outputs relative paths against the parent directory of $wgUploadDire
}
}
- private function outputItem( $name, $shared ) {
+ private function outputItem( string $name, bool $shared ) {
$file = $this->getServiceContainer()->getRepoGroup()->findFile( $name );
if ( $file && $this->filterItem( $file, $shared ) ) {
$filename = $file->getLocalRefPath();
@@ -126,7 +126,7 @@ By default, outputs relative paths against the parent directory of $wgUploadDire
}
}
- private function filterItem( $file, $shared ) {
+ private function filterItem( File $file, bool $shared ): bool {
return $shared || $file->isLocal();
}
}
diff --git a/maintenance/getConfiguration.php b/maintenance/getConfiguration.php
index 22fcc8b3b8ec..52b27a8a15d3 100644
--- a/maintenance/getConfiguration.php
+++ b/maintenance/getConfiguration.php
@@ -187,7 +187,7 @@ class GetConfiguration extends Maintenance {
return trim( $ret, "\n" );
}
- private function isAllowedVariable( $value ) {
+ private function isAllowedVariable( $value ): bool {
if ( is_array( $value ) ) {
foreach ( $value as $v ) {
if ( !$this->isAllowedVariable( $v ) ) {
diff --git a/maintenance/importDump.php b/maintenance/importDump.php
index ee3ff3ff1999..e7a6ee26d763 100644
--- a/maintenance/importDump.php
+++ b/maintenance/importDump.php
@@ -159,7 +159,7 @@ TEXT
$this->nsFilter = array_unique( array_map( [ $this, 'getNsIndex' ], $namespaces ) );
}
- private function getNsIndex( $namespace ) {
+ private function getNsIndex( string $namespace ): int {
$contLang = $this->getServiceContainer()->getContentLanguage();
$result = $contLang->getNsIndex( $namespace );
if ( $result !== false ) {
@@ -249,7 +249,7 @@ TEXT
}
}
- private function report( $final = false ) {
+ private function report( bool $final = false ) {
if ( $final xor ( $this->pageCount % $this->reportingInterval == 0 ) ) {
$this->showReport();
}
@@ -275,11 +275,11 @@ TEXT
$this->waitForReplication();
}
- private function progress( $string ) {
+ private function progress( string $string ) {
fwrite( $this->stderr, $string . "\n" );
}
- private function importFromFile( $filename ) {
+ private function importFromFile( string $filename ): bool {
if ( preg_match( '/\.gz$/', $filename ) ) {
$filename = 'compress.zlib://' . $filename;
} elseif ( preg_match( '/\.bz2$/', $filename ) ) {
@@ -296,7 +296,7 @@ TEXT
return $this->importFromHandle( $file );
}
- private function importFromStdin() {
+ private function importFromStdin(): bool {
$file = fopen( 'php://stdin', 'rt' );
if ( self::posix_isatty( $file ) ) {
$this->maybeHelp( true );
@@ -305,7 +305,7 @@ TEXT
return $this->importFromHandle( $file );
}
- private function importFromHandle( $handle ) {
+ private function importFromHandle( $handle ): bool {
$this->startTime = microtime( true );
$user = User::newSystemUser( User::MAINTENANCE_SCRIPT_USER, [ 'steal' => true ] );
diff --git a/maintenance/importImages.php b/maintenance/importImages.php
index c9a831dec084..aab6d5215d9b 100644
--- a/maintenance/importImages.php
+++ b/maintenance/importImages.php
@@ -523,7 +523,7 @@ class ImportImages extends Maintenance {
return html_entity_decode( $matches[1] );
}
- private function getFileUserFromSourceWiki( $wiki_host, $file ) {
+ private function getFileUserFromSourceWiki( string $wiki_host, string $file ) {
$url = $wiki_host . '/api.php?action=query&format=xml&titles=File:'
. rawurlencode( $file ) . '&prop=imageinfo&&iiprop=user';
$body = $this->getServiceContainer()->getHttpRequestFactory()->get( $url, [], __METHOD__ );
diff --git a/maintenance/includes/MaintenanceParameters.php b/maintenance/includes/MaintenanceParameters.php
index 8d5855dc7904..a03b76935958 100644
--- a/maintenance/includes/MaintenanceParameters.php
+++ b/maintenance/includes/MaintenanceParameters.php
@@ -635,7 +635,7 @@ class MaintenanceParameters {
return implode( '', $output );
}
- private function formatHelpItems( array $items, $heading, $descWidth, $tab ) {
+ private function formatHelpItems( array $items, string $heading, int $descWidth, string $tab ): string {
if ( $items === [] ) {
return '';
}
diff --git a/maintenance/includes/MaintenanceRunner.php b/maintenance/includes/MaintenanceRunner.php
index 625fac947a9f..43f3441267d4 100644
--- a/maintenance/includes/MaintenanceRunner.php
+++ b/maintenance/includes/MaintenanceRunner.php
@@ -64,7 +64,7 @@ class MaintenanceRunner {
$this->addDefaultParams();
}
- private function getConfig() {
+ private function getConfig(): Config {
if ( $this->config === null ) {
$this->config = $this->getServiceContainer()->getMainConfig();
}
@@ -222,7 +222,7 @@ class MaintenanceRunner {
}
}
- private static function isAbsolutePath( $path ) {
+ private static function isAbsolutePath( string $path ): bool {
if ( str_starts_with( $path, '/' ) ) {
return true;
}
diff --git a/maintenance/includes/SevenZipStream.php b/maintenance/includes/SevenZipStream.php
index a133c5f01832..d1dd4520468f 100644
--- a/maintenance/includes/SevenZipStream.php
+++ b/maintenance/includes/SevenZipStream.php
@@ -50,7 +50,7 @@ class SevenZipStream {
}
}
- private function stripPath( $path ) {
+ private function stripPath( string $path ): string {
$prefix = 'mediawiki.compress.7z://';
return substr( $path, strlen( $prefix ) );
diff --git a/maintenance/includes/TextPassDumper.php b/maintenance/includes/TextPassDumper.php
index 0b82b17944ee..2703116d3614 100644
--- a/maintenance/includes/TextPassDumper.php
+++ b/maintenance/includes/TextPassDumper.php
@@ -376,7 +376,7 @@ TEXT
$this->timeExceeded = true;
}
- private function checkIfTimeExceeded() {
+ private function checkIfTimeExceeded(): bool {
if ( $this->maxTimeAllowed
&& ( $this->lastTime - $this->timeOfCheckpoint > $this->maxTimeAllowed )
) {
@@ -1042,7 +1042,7 @@ TEXT
}
}
- private function isValidTextId( $id ) {
+ private function isValidTextId( string $id ): bool {
if ( preg_match( '/:/', $id ) ) {
return $id !== 'tt:0';
} elseif ( preg_match( '/^\d+$/', $id ) ) {
diff --git a/maintenance/install.php b/maintenance/install.php
index 2a4234e96167..85dc6c012e3c 100644
--- a/maintenance/install.php
+++ b/maintenance/install.php
@@ -230,7 +230,7 @@ class CommandLineInstaller extends Maintenance {
return true;
}
- private function generateStrongPassword() {
+ private function generateStrongPassword(): string {
$strongPassword = '';
$strongPasswordLength = 20;
$strongPasswordChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+-={}|;:,.<>?';
diff --git a/maintenance/language/generateCollationData.php b/maintenance/language/generateCollationData.php
index a9047f73f986..ba55d34683be 100644
--- a/maintenance/language/generateCollationData.php
+++ b/maintenance/language/generateCollationData.php
@@ -117,7 +117,7 @@ class GenerateCollationData extends Maintenance {
$uxr->readChars( [ $this, 'charCallback' ] );
}
- private function charCallback( $data ) {
+ private function charCallback( array $data ) {
// Skip non-printable characters,
// but do not skip a normal space (U+0020) since
// people like to use that as a fake no header symbol.
diff --git a/maintenance/language/generateUcfirstOverrides.php b/maintenance/language/generateUcfirstOverrides.php
index d6698eec9a27..7be7ca05edb7 100644
--- a/maintenance/language/generateUcfirstOverrides.php
+++ b/maintenance/language/generateUcfirstOverrides.php
@@ -74,7 +74,7 @@ class GenerateUcfirstOverrides extends Maintenance {
);
}
- private function loadJson( $filename ) {
+ private function loadJson( string $filename ) {
$data = file_get_contents( $filename );
if ( $data === false ) {
$msg = sprintf( "Could not load data from file '%s'\n", $filename );
diff --git a/maintenance/language/importExtensionMessages.php b/maintenance/language/importExtensionMessages.php
index c5ebd5b7df00..2d11e19a7a4a 100644
--- a/maintenance/language/importExtensionMessages.php
+++ b/maintenance/language/importExtensionMessages.php
@@ -60,7 +60,7 @@ class ImportExtensionMessages extends Maintenance {
$this->extensionDir = $config->get( MainConfigNames::ExtensionDirectory );
}
- private function getMessagesDirs( $extData ) {
+ private function getMessagesDirs( array $extData ): array {
if ( isset( $extData['MessagesDirs'] ) ) {
$messagesDirs = [];
foreach ( $extData['MessagesDirs'] as $dirs ) {
@@ -78,7 +78,7 @@ class ImportExtensionMessages extends Maintenance {
return $messagesDirs;
}
- private function processDir( $dir ) {
+ private function processDir( string $dir ) {
$path = $this->extensionDir . "/{$this->extName}/$dir";
foreach ( new DirectoryIterator( $path ) as $file ) {
@@ -91,7 +91,7 @@ class ImportExtensionMessages extends Maintenance {
}
}
- private function processFile( $lang, $extI18nPath ) {
+ private function processFile( string $lang, string $extI18nPath ) {
$extJson = file_get_contents( $extI18nPath );
if ( $extJson === false ) {
$this->error( "Unable to read i18n file \"$extI18nPath\"" );
@@ -126,7 +126,7 @@ class ImportExtensionMessages extends Maintenance {
$this->setCoreData( $lang, $coreData );
}
- private function getCoreData( $lang ) {
+ private function getCoreData( string $lang ) {
if ( !isset( $this->coreDataCache[$lang] ) ) {
$corePath = MW_INSTALL_PATH . "/languages/i18n/$lang.json";
// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
@@ -142,7 +142,7 @@ class ImportExtensionMessages extends Maintenance {
return $this->coreDataCache[$lang];
}
- private function setCoreData( $lang, $data ) {
+ private function setCoreData( string $lang, $data ) {
if ( !isset( $this->coreDataCache[$lang] ) ) {
// Non-existent file, do not create
return;
diff --git a/maintenance/mcc.php b/maintenance/mcc.php
index 99766423f96e..8b23ca428fcd 100644
--- a/maintenance/mcc.php
+++ b/maintenance/mcc.php
@@ -185,7 +185,7 @@ class Mcc extends Maintenance {
} while ( !$quit );
}
- private function mccGetHelp( $command ) {
+ private function mccGetHelp( $command ): string {
$output = '';
$commandList = [
'get' => 'grabs something',
diff --git a/maintenance/migrateExternallinks.php b/maintenance/migrateExternallinks.php
index 21f8cf5f6468..683c063af1cb 100644
--- a/maintenance/migrateExternallinks.php
+++ b/maintenance/migrateExternallinks.php
@@ -70,7 +70,7 @@ class MigrateExternallinks extends LoggedUpdateMaintenance {
return true;
}
- private function handleBatch( $lowId ) {
+ private function handleBatch( int $lowId ): int {
$batchSize = $this->getBatchSize();
// range is inclusive, let's subtract one.
$highId = $lowId + $batchSize - 1;
diff --git a/maintenance/migrateFileTables.php b/maintenance/migrateFileTables.php
index d40205927344..c48a7c0352ce 100644
--- a/maintenance/migrateFileTables.php
+++ b/maintenance/migrateFileTables.php
@@ -141,7 +141,7 @@ class MigrateFileTables extends Maintenance {
. "$totalRowsInserted rows have been inserted into filerevision table.\n" );
}
- private function handleFile( stdClass $row ) {
+ private function handleFile( stdClass $row ): int {
$repo = $this->getServiceContainer()->getRepoGroup()
->newCustomLocalRepo();
$dbw = $this->getPrimaryDB();
diff --git a/maintenance/migrateLinksTable.php b/maintenance/migrateLinksTable.php
index 5eb0e2c20819..43e29d3aa695 100644
--- a/maintenance/migrateLinksTable.php
+++ b/maintenance/migrateLinksTable.php
@@ -94,7 +94,7 @@ class MigrateLinksTable extends LoggedUpdateMaintenance {
return true;
}
- private function handlePageBatch( $lowPageId, $mapping, $table ) {
+ private function handlePageBatch( int $lowPageId, array $mapping, string $table ) {
$batchSize = $this->getBatchSize();
$targetColumn = $mapping[$table]['target_id'];
$pageIdColumn = $mapping[$table]['page_id'];
diff --git a/maintenance/populateChangeTagDef.php b/maintenance/populateChangeTagDef.php
index aa8b36cd491d..f75b3b64938c 100644
--- a/maintenance/populateChangeTagDef.php
+++ b/maintenance/populateChangeTagDef.php
@@ -187,7 +187,7 @@ class PopulateChangeTagDef extends LoggedUpdateMaintenance {
}
}
- private function backpopulateChangeTagPerTag( $tagName, $tagId ) {
+ private function backpopulateChangeTagPerTag( string $tagName, int $tagId ) {
$dbr = $this->getReplicaDB();
$dbw = $this->getPrimaryDB();
$sleep = (int)$this->getOption( 'sleep', 0 );
diff --git a/maintenance/purgePage.php b/maintenance/purgePage.php
index 1f533bef1f30..8053e9366530 100644
--- a/maintenance/purgePage.php
+++ b/maintenance/purgePage.php
@@ -51,7 +51,7 @@ class PurgePage extends Maintenance {
}
}
- private function purge( $titleText ) {
+ private function purge( string $titleText ) {
$title = Title::newFromText( $titleText );
if ( $title === null ) {
diff --git a/maintenance/rebuildImages.php b/maintenance/rebuildImages.php
index fc506efe63a3..7983cbcdf8dd 100644
--- a/maintenance/rebuildImages.php
+++ b/maintenance/rebuildImages.php
@@ -40,6 +40,7 @@ use MediaWiki\Maintenance\Maintenance;
use MediaWiki\Specials\SpecialUpload;
use MediaWiki\User\User;
use Wikimedia\Rdbms\IMaintainableDatabase;
+use Wikimedia\Rdbms\SelectQueryBuilder;
/**
* Maintenance script to update image metadata records.
@@ -128,7 +129,7 @@ class ImageBuilder extends Maintenance {
$this->table = $table;
}
- private function progress( $updated ) {
+ private function progress( int $updated ) {
$this->updated += $updated;
$this->processed++;
if ( $this->processed % 100 != 0 ) {
@@ -155,7 +156,7 @@ class ImageBuilder extends Maintenance {
flush();
}
- private function buildTable( $table, $queryBuilder, $callback ) {
+ private function buildTable( string $table, SelectQueryBuilder $queryBuilder, callable $callback ) {
$count = $this->dbw->newSelectQueryBuilder()
->select( 'count(*)' )
->from( $table )
@@ -181,7 +182,7 @@ class ImageBuilder extends Maintenance {
$this->buildTable( 'image', FileSelectQueryBuilder::newForFile( $this->getReplicaDB() ), $callback );
}
- private function imageCallback( $row ) {
+ private function imageCallback( \stdClass $row ): bool {
// Create a File object from the row
// This will also upgrade it
$file = $this->getRepo()->newFileFromRow( $row );
@@ -194,7 +195,7 @@ class ImageBuilder extends Maintenance {
[ $this, 'oldimageCallback' ] );
}
- private function oldimageCallback( $row ) {
+ private function oldimageCallback( \stdClass $row ): bool {
// Create a File object from the row
// This will also upgrade it
if ( $row->oi_archive_name == '' ) {
@@ -225,7 +226,7 @@ class ImageBuilder extends Maintenance {
}
}
- private function addMissingImage( $filename, $fullpath ) {
+ private function addMissingImage( string $filename, string $fullpath ) {
$timestamp = $this->dbw->timestamp( $this->getRepo()->getFileTimestamp( $fullpath ) );
$services = $this->getServiceContainer();
diff --git a/maintenance/storage/checkStorage.php b/maintenance/storage/checkStorage.php
index 54add8a7334a..384ab296a1b1 100644
--- a/maintenance/storage/checkStorage.php
+++ b/maintenance/storage/checkStorage.php
@@ -400,7 +400,7 @@ class CheckStorage extends Maintenance {
}
}
- private function addError( $type, $msg, $ids ) {
+ private function addError( string $type, string $msg, $ids ) {
if ( is_array( $ids ) && count( $ids ) == 1 ) {
$ids = reset( $ids );
}
@@ -423,7 +423,7 @@ class CheckStorage extends Maintenance {
$this->errors[$type] += array_fill_keys( $revIds, true );
}
- private function checkExternalConcatBlobs( $externalConcatBlobs ) {
+ private function checkExternalConcatBlobs( array $externalConcatBlobs ) {
if ( !count( $externalConcatBlobs ) ) {
return;
}
@@ -465,7 +465,7 @@ class CheckStorage extends Maintenance {
}
}
- private function restoreText( $revIds, $xml ) {
+ private function restoreText( array $revIds, string $xml ) {
global $wgDBname;
$tmpDir = wfTempDir();
diff --git a/maintenance/storage/moveToExternal.php b/maintenance/storage/moveToExternal.php
index 8f66c7061c07..b27e33014700 100644
--- a/maintenance/storage/moveToExternal.php
+++ b/maintenance/storage/moveToExternal.php
@@ -129,7 +129,7 @@ class MoveToExternal extends Maintenance {
return $this->doMoveToExternal();
}
- private function doMoveToExternal() {
+ private function doMoveToExternal(): bool {
$success = true;
$dbr = $this->getReplicaDB();
@@ -253,7 +253,7 @@ class MoveToExternal extends Maintenance {
return $success;
}
- private function compress( $text, $flags ) {
+ private function compress( string $text, array $flags ): array {
if ( $this->gzip && !in_array( 'gzip', $flags ) ) {
$flags[] = 'gzip';
$text = gzdeflate( $text );
@@ -261,7 +261,7 @@ class MoveToExternal extends Maintenance {
return [ $text, $flags ];
}
- private function resolveLegacyEncoding( $text, $flags ) {
+ private function resolveLegacyEncoding( string $text, array $flags ): array {
if ( $this->legacyEncoding !== null
&& !in_array( 'utf-8', $flags )
&& !in_array( 'utf8', $flags )
@@ -290,7 +290,7 @@ class MoveToExternal extends Maintenance {
return [ $text, $flags ];
}
- private function resolveStubs( $stubIDs ) {
+ private function resolveStubs( array $stubIDs ) {
if ( $this->dryRun ) {
print "Note: resolving stubs in dry run mode is expected to fail, " .
"because the main blobs have not been moved to external storage.\n";
diff --git a/maintenance/storage/recompressTracked.php b/maintenance/storage/recompressTracked.php
index 691cc43426c7..b6f39493704d 100644
--- a/maintenance/storage/recompressTracked.php
+++ b/maintenance/storage/recompressTracked.php
@@ -174,7 +174,7 @@ class RecompressTracked {
}
}
- private function logToFile( $msg, $file ) {
+ private function logToFile( string $msg, string $file ) {
$header = '[' . date( 'd\TH:i:s' ) . '] ' . wfHostname() . ' ' . posix_getpid();
if ( $this->childId !== false ) {
$header .= "({$this->childId})";
diff --git a/maintenance/storage/trackBlobs.php b/maintenance/storage/trackBlobs.php
index 8f6d83ee5320..5eef62f9cd75 100644
--- a/maintenance/storage/trackBlobs.php
+++ b/maintenance/storage/trackBlobs.php
@@ -111,7 +111,7 @@ class TrackBlobs extends Maintenance {
$dbw->sourceFile( __DIR__ . '/blob_tracking.sql' );
}
- private function getTextClause() {
+ private function getTextClause(): IExpression {
if ( !$this->textClause ) {
$dbr = $this->getReplicaDB();
$conds = [];
@@ -128,7 +128,7 @@ class TrackBlobs extends Maintenance {
return $this->textClause;
}
- private function interpretPointer( $text ) {
+ private function interpretPointer( string $text ) {
if ( !preg_match( '!^DB://(\w+)/(\d+)(?:/([0-9a-fA-F]+)|)$!', $text, $m ) ) {
return false;
}
diff --git a/maintenance/update.php b/maintenance/update.php
index 4a748ba55138..209fc691447b 100755
--- a/maintenance/update.php
+++ b/maintenance/update.php
@@ -261,7 +261,7 @@ class UpdateMediaWiki extends Maintenance {
parent::validateParamsAndArgs();
}
- private function formatWarnings( array $warnings ) {
+ private function formatWarnings( array $warnings ): string {
$text = '';
foreach ( $warnings as $warning ) {
$warning = wordwrap( $warning, 75, "\n " );
diff --git a/maintenance/updateSearchIndex.php b/maintenance/updateSearchIndex.php
index 21ca64d5d67c..fbec1c183144 100644
--- a/maintenance/updateSearchIndex.php
+++ b/maintenance/updateSearchIndex.php
@@ -89,7 +89,7 @@ class UpdateSearchIndex extends Maintenance {
}
}
- private function doUpdateSearchIndex( $start, $end ) {
+ private function doUpdateSearchIndex( string $start, string $end ) {
global $wgDisableSearchUpdate;
$wgDisableSearchUpdate = false;