diff options
Diffstat (limited to 'includes')
56 files changed, 106 insertions, 96 deletions
diff --git a/includes/Category/Category.php b/includes/Category/Category.php index 494befbaa621..38d849d22772 100644 --- a/includes/Category/Category.php +++ b/includes/Category/Category.php @@ -572,7 +572,7 @@ class Category { return false; } - private function addWhereonCategoryName( SelectQueryBuilder $queryBuilder, $name ) { + private function addWhereonCategoryName( SelectQueryBuilder $queryBuilder, string $name ) { if ( $this->migrationStage & SCHEMA_COMPAT_READ_OLD ) { $queryBuilder->where( [ 'cl_to' => $name ] ); } else { diff --git a/includes/DomainEvent/EventIngressBase.php b/includes/DomainEvent/EventIngressBase.php index effbca05d4a5..fb4d65ee0002 100644 --- a/includes/DomainEvent/EventIngressBase.php +++ b/includes/DomainEvent/EventIngressBase.php @@ -110,7 +110,7 @@ abstract class EventIngressBase implements InitializableDomainEventSubscriber { DomainEventSource $eventSource, string $eventType, string $suffix - ) { + ): bool { $method = "handle{$eventType}Event{$suffix}"; if ( !method_exists( $this, $method ) ) { return false; diff --git a/includes/ExternalLinks/LinkFilter.php b/includes/ExternalLinks/LinkFilter.php index 43781cf8c43e..e47b5751a194 100644 --- a/includes/ExternalLinks/LinkFilter.php +++ b/includes/ExternalLinks/LinkFilter.php @@ -287,7 +287,7 @@ class LinkFilter { return $index; } - private static function reverseDomain( $domain ) { + private static function reverseDomain( string $domain ): string { if ( substr( $domain, 0, 3 ) === 'V6.' ) { $ipv6 = str_replace( '.', ':', trim( substr( $domain, 3 ), '.' ) ); if ( IPUtils::isValid( $ipv6 ) ) { diff --git a/includes/Html/ListToggle.php b/includes/Html/ListToggle.php index f06fc14d70e1..baafb9b77103 100644 --- a/includes/Html/ListToggle.php +++ b/includes/Html/ListToggle.php @@ -43,7 +43,7 @@ class ListToggle { $output->addModuleStyles( 'mediawiki.checkboxtoggle.styles' ); } - private function checkboxLink( $checkboxType ) { + private function checkboxLink( string $checkboxType ): string { return Html::element( // CSS classes: mw-checkbox-all, mw-checkbox-none, mw-checkbox-invert 'a', [ 'class' => 'mw-checkbox-' . $checkboxType, 'role' => 'button', 'tabindex' => 0 ], diff --git a/includes/Notification/NotificationService.php b/includes/Notification/NotificationService.php index 15f4b2dadc03..a90bcb978535 100644 --- a/includes/Notification/NotificationService.php +++ b/includes/Notification/NotificationService.php @@ -49,7 +49,7 @@ class NotificationService { $this->specs = $specs; } - private function getHandlers() { + private function getHandlers(): array { if ( $this->handlersByType === [] ) { foreach ( $this->specs as $spec ) { $obj = $this->objectFactory->createObject( $spec, [ 'assertClass' => NotificationHandler::class ] ); diff --git a/includes/Output/OutputPage.php b/includes/Output/OutputPage.php index 196c1f4572d9..0a33bb608ccd 100644 --- a/includes/Output/OutputPage.php +++ b/includes/Output/OutputPage.php @@ -3062,7 +3062,7 @@ class OutputPage extends ContextSource { return json_encode( $output, JSON_UNESCAPED_SLASHES ); } - private function getFeaturePolicyReportOnly() { + private function getFeaturePolicyReportOnly(): string { $config = $this->getConfig(); $features = $config->get( MainConfigNames::FeaturePolicyReportOnly ); @@ -3754,7 +3754,7 @@ class OutputPage extends ContextSource { return $this->debugMode; } - private function getRlClientContext() { + private function getRlClientContext(): RL\Context { if ( !$this->rlClientContext ) { $query = ResourceLoader::makeLoaderQuery( [], // modules; not relevant diff --git a/includes/Permissions/RateLimiter.php b/includes/Permissions/RateLimiter.php index 18aeda7e6de7..20b009478351 100644 --- a/includes/Permissions/RateLimiter.php +++ b/includes/Permissions/RateLimiter.php @@ -342,7 +342,7 @@ class RateLimiter { return !$allowed; } - private function canBypass( string $action ) { + private function canBypass( string $action ): bool { return $this->rateLimits[$action]['&can-bypass'] ?? true; } diff --git a/includes/RenameUser/RenameUser.php b/includes/RenameUser/RenameUser.php index 4b022b0ad4b3..8f27fe501b85 100644 --- a/includes/RenameUser/RenameUser.php +++ b/includes/RenameUser/RenameUser.php @@ -270,7 +270,9 @@ class RenameUser { return Status::newGood(); } - private function movePagesAndSubPages( User $performer, Title $oldTitle, Title $newTitle, bool $suppressRedirect ) { + private function movePagesAndSubPages( + User $performer, Title $oldTitle, Title $newTitle, bool $suppressRedirect + ): Status { $status = Status::newGood(); $movePage = $this->movePageFactory->newMovePage( diff --git a/includes/Revision/RevisionRenderer.php b/includes/Revision/RevisionRenderer.php index 999768829f88..8d28ca3641bf 100644 --- a/includes/Revision/RevisionRenderer.php +++ b/includes/Revision/RevisionRenderer.php @@ -181,7 +181,7 @@ class RevisionRenderer { return $renderedRevision; } - private function getSpeculativeRevId( $dbIndex ) { + private function getSpeculativeRevId( int $dbIndex ): int { // Use a separate primary DB connection in order to see the latest data, by avoiding // stale data from REPEATABLE-READ snapshots. $flags = ILoadBalancer::CONN_TRX_AUTOCOMMIT; @@ -194,7 +194,7 @@ class RevisionRenderer { ->caller( __METHOD__ )->fetchField(); } - private function getSpeculativePageId( $dbIndex ) { + private function getSpeculativePageId( int $dbIndex ): int { // Use a separate primary DB connection in order to see the latest data, by avoiding // stale data from REPEATABLE-READ snapshots. $flags = ILoadBalancer::CONN_TRX_AUTOCOMMIT; diff --git a/includes/Revision/RevisionStore.php b/includes/Revision/RevisionStore.php index dbd884e78f1e..ac17a3b85b1c 100644 --- a/includes/Revision/RevisionStore.php +++ b/includes/Revision/RevisionStore.php @@ -624,9 +624,9 @@ class RevisionStore implements RevisionFactory, RevisionLookup, LoggerAwareInter UserIdentity $user, CommentStoreComment $comment, PageIdentity $page, - $pageId, - $parentId - ) { + int $pageId, + int $parentId + ): RevisionRecord { $slotRoles = $rev->getSlotRoles(); $revisionRow = $this->insertRevisionRowOn( @@ -1438,7 +1438,7 @@ class RevisionStore implements RevisionFactory, RevisionLookup, LoggerAwareInter return $this->constructSlotRecords( $revId, $res, $queryFlags, $page ); } - private function loadSlotRecordsFromDb( $revId, $queryFlags, PageIdentity $page ): array { + private function loadSlotRecordsFromDb( int $revId, int $queryFlags, PageIdentity $page ): array { $revQuery = $this->getSlotsQueryInfo( [ 'content' ] ); $db = $this->getDBConnectionRefForQueryFlags( $queryFlags ); diff --git a/includes/Settings/Source/ReflectionSchemaSource.php b/includes/Settings/Source/ReflectionSchemaSource.php index 7937847a4bad..6ec18bd550e5 100644 --- a/includes/Settings/Source/ReflectionSchemaSource.php +++ b/includes/Settings/Source/ReflectionSchemaSource.php @@ -163,14 +163,14 @@ class ReflectionSchemaSource implements Stringable, SettingsSource { return 'class ' . $this->class; } - private function normalizeComment( string $doc ) { + private function normalizeComment( string $doc ): string { $doc = preg_replace( '/^\s*\/\*+\s*|\s*\*+\/\s*$/', '', $doc ); $doc = preg_replace( '/^\s*\**$/m', " ", $doc ); $doc = preg_replace( '/^\s*\**[ \t]?/m', '', $doc ); return $doc; } - private function normalizeDynamicDefault( string $name, $spec ) { + private function normalizeDynamicDefault( string $name, $spec ): array { if ( $spec === true ) { $spec = [ 'callback' => [ $this->class, "getDefault{$name}" ] ]; } diff --git a/includes/SiteStats/SiteStatsInit.php b/includes/SiteStats/SiteStatsInit.php index c83330793b64..ffa0bfad12d1 100644 --- a/includes/SiteStats/SiteStatsInit.php +++ b/includes/SiteStats/SiteStatsInit.php @@ -69,7 +69,7 @@ class SiteStatsInit { return $this->edits; } - private function countTableRows( string $tableName ) { + private function countTableRows( string $tableName ): int { return (int)$this->dbr->newSelectQueryBuilder() ->select( 'COUNT(*)' ) ->from( $tableName ) @@ -178,7 +178,7 @@ class SiteStatsInit { } } - private function getShardedValue( $value, $noShards, $rowId ) { + private function getShardedValue( int $value, int $noShards, int $rowId ): int { $remainder = $value % $noShards; $quotient = (int)( ( $value - $remainder ) / $noShards ); // Add the reminder to the first row diff --git a/includes/Storage/DerivedPageDataUpdater.php b/includes/Storage/DerivedPageDataUpdater.php index f299e5180342..e8e596230585 100644 --- a/includes/Storage/DerivedPageDataUpdater.php +++ b/includes/Storage/DerivedPageDataUpdater.php @@ -748,7 +748,7 @@ class DerivedPageDataUpdater implements LoggerAwareInterface, PreparedUpdate { ->getContentHandler( $this->getRawSlot( $role )->getModel() ); } - private function usePrimary() { + private function usePrimary(): bool { // TODO: can we just set a flag to true in prepareContent()? return $this->wikiPage->wasLoadedFrom( IDBAccessObject::READ_LATEST ); } @@ -1032,7 +1032,7 @@ class DerivedPageDataUpdater implements LoggerAwareInterface, PreparedUpdate { return $this->renderedRevision; } - private function assertHasPageState( $method ) { + private function assertHasPageState( string $method ) { if ( !$this->pageState ) { throw new LogicException( 'Must call grabCurrentRevision() or prepareContent() ' @@ -1041,7 +1041,7 @@ class DerivedPageDataUpdater implements LoggerAwareInterface, PreparedUpdate { } } - private function assertPrepared( $method ) { + private function assertPrepared( string $method ) { if ( !$this->revision ) { throw new LogicException( 'Must call prepareContent() or prepareUpdate() before calling ' . $method @@ -1049,7 +1049,7 @@ class DerivedPageDataUpdater implements LoggerAwareInterface, PreparedUpdate { } } - private function assertHasRevision( $method ) { + private function assertHasRevision( string $method ) { if ( !$this->revision->getId() ) { throw new LogicException( 'Must call prepareUpdate() before calling ' . $method diff --git a/includes/Storage/NameTableStoreFactory.php b/includes/Storage/NameTableStoreFactory.php index b2f936eed2e0..64c7ef0e6391 100644 --- a/includes/Storage/NameTableStoreFactory.php +++ b/includes/Storage/NameTableStoreFactory.php @@ -40,7 +40,7 @@ class NameTableStoreFactory { /** @var LoggerInterface */ private $logger; - private static function getTableInfo() { + private static function getTableInfo(): array { if ( self::$info ) { return self::$info; } diff --git a/includes/Storage/PageUpdater.php b/includes/Storage/PageUpdater.php index 0ca376c3ba4f..4d5347833bce 100644 --- a/includes/Storage/PageUpdater.php +++ b/includes/Storage/PageUpdater.php @@ -1674,7 +1674,7 @@ class PageUpdater implements PageUpdateCauses { RevisionRecord $newRevisionRecord, CommentStoreComment $summary, array $hints = [] - ) { + ): AtomicSectionUpdate { return new AtomicSectionUpdate( $dbw, __METHOD__, @@ -1716,14 +1716,14 @@ class PageUpdater implements PageUpdateCauses { return $this->slotRoleRegistry->getAllowedRoles( $this->getPage() ); } - private function ensureRoleAllowed( $role ) { + private function ensureRoleAllowed( string $role ) { $allowedRoles = $this->getAllowedSlotRoles(); if ( !in_array( $role, $allowedRoles ) ) { throw new PageUpdateException( "Slot role `$role` is not allowed." ); } } - private function ensureRoleNotRequired( $role ) { + private function ensureRoleNotRequired( string $role ) { $requiredRoles = $this->getRequiredSlotRoles(); if ( in_array( $role, $requiredRoles ) ) { throw new PageUpdateException( "Slot role `$role` is required." ); diff --git a/includes/Storage/SqlBlobStore.php b/includes/Storage/SqlBlobStore.php index 15d6730ac594..348c55f8d7cf 100644 --- a/includes/Storage/SqlBlobStore.php +++ b/includes/Storage/SqlBlobStore.php @@ -461,7 +461,7 @@ class SqlBlobStore implements BlobStore { return [ $result, $errors ]; } - private static function getDBOptions( $bitfield ) { + private static function getDBOptions( int $bitfield ): array { if ( DBAccessObjectUtils::hasFlags( $bitfield, IDBAccessObject::READ_LATEST_IMMUTABLE ) ) { $index = DB_REPLICA; // override READ_LATEST if set $fallbackIndex = DB_PRIMARY; diff --git a/includes/actions/HistoryAction.php b/includes/actions/HistoryAction.php index a998bb4909d7..7e0439d199b6 100644 --- a/includes/actions/HistoryAction.php +++ b/includes/actions/HistoryAction.php @@ -424,7 +424,7 @@ class HistoryAction extends FormlessAction { $feed->outFooter(); } - private function feedEmpty() { + private function feedEmpty(): FeedItem { return new FeedItem( $this->msg( 'nohistory' )->inContentLanguage()->text(), $this->msg( 'history-feed-empty' )->inContentLanguage()->parseAsBlock(), diff --git a/includes/actions/McrUndoAction.php b/includes/actions/McrUndoAction.php index d838ad7ac149..7b42ec71c16a 100644 --- a/includes/actions/McrUndoAction.php +++ b/includes/actions/McrUndoAction.php @@ -286,7 +286,7 @@ class McrUndoAction extends FormAction { return $newRev; } - private function generateDiffOrPreview() { + private function generateDiffOrPreview(): string { $newRev = $this->getNewRevision(); if ( $newRev->hasSameContent( $this->curRev ) ) { throw new ErrorPageError( 'mcrundofailed', 'undo-nochange' ); diff --git a/includes/actions/pagers/HistoryPager.php b/includes/actions/pagers/HistoryPager.php index 3a7268edaabd..5eee82db7d59 100644 --- a/includes/actions/pagers/HistoryPager.php +++ b/includes/actions/pagers/HistoryPager.php @@ -308,7 +308,7 @@ class HistoryPager extends ReverseChronologicalPager { return $s; } - private function getRevisionButton( $name, $msg, $class ) { + private function getRevisionButton( string $name, string $msg, string $class ): string { $this->preventClickjacking = true; $element = Html::element( 'button', diff --git a/includes/block/DatabaseBlockStore.php b/includes/block/DatabaseBlockStore.php index d8c8d71e12d9..a718a1c2692f 100644 --- a/includes/block/DatabaseBlockStore.php +++ b/includes/block/DatabaseBlockStore.php @@ -1528,7 +1528,7 @@ class DatabaseBlockStore { : false; } - private function getAutoblockReason( DatabaseBlock $parentBlock ) { + private function getAutoblockReason( DatabaseBlock $parentBlock ): string { return wfMessage( 'autoblocker', $parentBlock->getTargetName(), diff --git a/includes/cache/GenderCache.php b/includes/cache/GenderCache.php index ec5a31d74dd1..c2328423b658 100644 --- a/includes/cache/GenderCache.php +++ b/includes/cache/GenderCache.php @@ -158,7 +158,7 @@ class GenderCache { } } - private static function normalizeUsername( $username ) { + private static function normalizeUsername( string $username ): string { // Strip off subpages $indexSlash = strpos( $username, '/' ); if ( $indexSlash !== false ) { diff --git a/includes/collation/CustomUppercaseCollation.php b/includes/collation/CustomUppercaseCollation.php index d6bacd0d43bb..22c04411cac5 100644 --- a/includes/collation/CustomUppercaseCollation.php +++ b/includes/collation/CustomUppercaseCollation.php @@ -92,7 +92,7 @@ class CustomUppercaseCollation extends NumericUppercaseCollation { parent::__construct( $languageFactory, $digitTransformLang ); } - private function convertToPua( $string ) { + private function convertToPua( string $string ): string { return str_replace( $this->alphabet, $this->puaSubset, $string ); } diff --git a/includes/collation/IcuCollation.php b/includes/collation/IcuCollation.php index 06e80812be87..b1418bd39249 100644 --- a/includes/collation/IcuCollation.php +++ b/includes/collation/IcuCollation.php @@ -326,7 +326,7 @@ class IcuCollation extends Collation { return $sortLetter; } - private function getPrimarySortKey( $string ) { + private function getPrimarySortKey( string $string ): string { return $this->primaryCollator->getSortKey( $string ); } diff --git a/includes/composer/PhpUnitSplitter/PhpUnitXmlManager.php b/includes/composer/PhpUnitSplitter/PhpUnitXmlManager.php index a85c86349a9d..bac35f6649f9 100644 --- a/includes/composer/PhpUnitSplitter/PhpUnitXmlManager.php +++ b/includes/composer/PhpUnitSplitter/PhpUnitXmlManager.php @@ -93,7 +93,7 @@ class PhpUnitXmlManager { return ( new PhpUnitTestFileScanner( $this->rootDir ) )->scanForFiles(); } - private static function extractNamespaceFromFile( $filename ): array { + private static function extractNamespaceFromFile( string $filename ): array { $contents = file_get_contents( $filename ); $matches = []; if ( preg_match( '/^namespace\s+([^\s;]+)/m', $contents, $matches ) ) { diff --git a/includes/deferred/LinksUpdate/CategoryLinksTable.php b/includes/deferred/LinksUpdate/CategoryLinksTable.php index 3a06391e824c..151566c9f408 100644 --- a/includes/deferred/LinksUpdate/CategoryLinksTable.php +++ b/includes/deferred/LinksUpdate/CategoryLinksTable.php @@ -243,7 +243,7 @@ class CategoryLinksTable extends TitleLinksTable { return $this->existingLinks; } - private function getSavedTimestamps() { + private function getSavedTimestamps(): array { if ( $this->savedTimestamps === null ) { $this->fetchExistingLinks(); } diff --git a/includes/deferred/LinksUpdate/PagePropsTable.php b/includes/deferred/LinksUpdate/PagePropsTable.php index bcd0a93c957f..ea42853e1b6b 100644 --- a/includes/deferred/LinksUpdate/PagePropsTable.php +++ b/includes/deferred/LinksUpdate/PagePropsTable.php @@ -104,7 +104,7 @@ class PagePropsTable extends LinksTable { && $this->encodeValue( $this->newProps[$name] ) === $this->encodeValue( $value ); } - private function encodeValue( $value ) { + private function encodeValue( $value ): string { if ( is_bool( $value ) ) { return (string)(int)$value; } elseif ( $value === null ) { diff --git a/includes/editpage/Constraint/UserRateLimitConstraint.php b/includes/editpage/Constraint/UserRateLimitConstraint.php index d21409a95a84..8f35dd5879d0 100644 --- a/includes/editpage/Constraint/UserRateLimitConstraint.php +++ b/includes/editpage/Constraint/UserRateLimitConstraint.php @@ -52,7 +52,7 @@ class UserRateLimitConstraint implements IEditConstraint { $this->newContentModel = $newContentModel; } - private function limit( string $action, int $inc = 1 ) { + private function limit( string $action, int $inc = 1 ): bool { return $this->limiter->limit( $this->subject, $action, $inc ); } diff --git a/includes/editpage/PreloadedContentBuilder.php b/includes/editpage/PreloadedContentBuilder.php index 61c9a81464bb..ab0a124eb66e 100644 --- a/includes/editpage/PreloadedContentBuilder.php +++ b/includes/editpage/PreloadedContentBuilder.php @@ -220,7 +220,7 @@ class PreloadedContentBuilder { Content $content, PageReference $title, array $preloadParams = [] - ) { + ): Content { return $this->contentTransformer->preloadTransform( $content, $title, diff --git a/includes/import/WikiImporter.php b/includes/import/WikiImporter.php index 8868c4cc8ffc..5dcf0e599550 100644 --- a/includes/import/WikiImporter.php +++ b/includes/import/WikiImporter.php @@ -979,7 +979,7 @@ class WikiImporter { } } - private function handleContent() { + private function handleContent(): array { $this->debug( "Enter content handler" ); $contentInfo = []; diff --git a/includes/jobqueue/jobs/CategoryMembershipChangeJob.php b/includes/jobqueue/jobs/CategoryMembershipChangeJob.php index 2e25cd883f83..0fe85621cf64 100644 --- a/includes/jobqueue/jobs/CategoryMembershipChangeJob.php +++ b/includes/jobqueue/jobs/CategoryMembershipChangeJob.php @@ -240,7 +240,7 @@ class CategoryMembershipChangeJob extends Job { private function getExplicitCategoriesChanges( WikiPage $page, RevisionRecord $newRev, ?RevisionRecord $oldRev = null - ) { + ): array { // Inject the same timestamp for both revision parses to avoid seeing category changes // due to time-based parser functions. Inject the same page title for the parses too. // Note that REPEATABLE-READ makes template/file pages appear unchanged between parses. diff --git a/includes/jobqueue/jobs/RefreshLinksJob.php b/includes/jobqueue/jobs/RefreshLinksJob.php index b6647c55a290..ed54a1bbc034 100644 --- a/includes/jobqueue/jobs/RefreshLinksJob.php +++ b/includes/jobqueue/jobs/RefreshLinksJob.php @@ -574,7 +574,7 @@ class RefreshLinksJob extends Job { private function canUseParserOutputFromCache( ParserOutput $cachedOutput, RevisionRecord $currentRevision - ) { + ): bool { // As long as the cache rev ID matches the current rev ID and it reflects // the job's triggering change, then it is usable. return $cachedOutput->getCacheRevisionId() == $currentRevision->getId() diff --git a/includes/language/converters/CrhConverter.php b/includes/language/converters/CrhConverter.php index f3c10215ca17..7a8ae1edd95f 100644 --- a/includes/language/converters/CrhConverter.php +++ b/includes/language/converters/CrhConverter.php @@ -255,7 +255,7 @@ class CrhConverter extends LanguageConverterSpecific { } } - private function regsConverter( $text, $toVariant ) { + private function regsConverter( string $text, string $toVariant ): string { if ( $text == '' ) { return $text; } diff --git a/includes/language/converters/MniConverter.php b/includes/language/converters/MniConverter.php index 20a421ae9c1a..495d0b716c3a 100644 --- a/includes/language/converters/MniConverter.php +++ b/includes/language/converters/MniConverter.php @@ -140,12 +140,12 @@ class MniConverter extends LanguageConverterSpecific { self::NUMERALS + self::MTEI_TO_BENG_MAP_EXTRA; - private function isBeginning( $position, $text ) { + private function isBeginning( int $position, string $text ): bool { $at_first = $position === 0; return $at_first || preg_match( self::NON_WORD_CHARACTER_PATTERN, $text[$position - 1] ); } - private function isEndOfWord( $char ) { + private function isEndOfWord( string $char ): bool { if ( $char === self::PERIOD ) { return true; } @@ -153,7 +153,7 @@ class MniConverter extends LanguageConverterSpecific { return count( $matches ) > 0; } - private function mteiToBengali( $text ) { + private function mteiToBengali( string $text ): iterable { $chars = mb_str_split( $text ); $l = count( $chars ); $i = 0; diff --git a/includes/language/dependency/MainConfigDependency.php b/includes/language/dependency/MainConfigDependency.php index 6735ad22aec1..d6126256fae8 100644 --- a/includes/language/dependency/MainConfigDependency.php +++ b/includes/language/dependency/MainConfigDependency.php @@ -17,6 +17,8 @@ * * @file */ + +use MediaWiki\Config\Config; use MediaWiki\MediaWikiServices; /** @@ -35,7 +37,7 @@ class MainConfigDependency extends CacheDependency { $this->value = $this->getConfig()->get( $this->name ); } - private function getConfig() { + private function getConfig(): Config { return MediaWikiServices::getInstance()->getMainConfig(); } diff --git a/includes/languages/data/CrhExceptions.php b/includes/languages/data/CrhExceptions.php index 8ae58937a801..1538a7a4959e 100644 --- a/includes/languages/data/CrhExceptions.php +++ b/includes/languages/data/CrhExceptions.php @@ -29,7 +29,7 @@ class CrhExceptions { /** @var string[] */ private array $uc2lc = []; - private function initLcUc( $lcChars, $ucChars, $reinit = false ) { + private function initLcUc( string $lcChars, string $ucChars, bool $reinit = false ) { # bail if we've already done this, unless we are re-initializing if ( !$reinit && $this->lc2uc && $this->uc2lc ) { return; @@ -49,19 +49,21 @@ class CrhExceptions { $this->uc2lc = array_combine( array_values( $myUc ), array_values( $myLc ) ); } - private function myLc( $string ) { + private function myLc( string $string ): string { return strtr( $string, $this->uc2lc ); } - private function myUc( $string ) { + private function myUc( string $string ): string { return strtr( $string, $this->lc2uc ); } - private function myUcWord( $string ) { + private function myUcWord( string $string ): string { return $this->myUc( mb_substr( $string, 0, 1 ) ) . $this->myLc( mb_substr( $string, 1 ) ); } - private function addMappings( $mapArray, &$A2B, &$B2A, $exactCase = false, $prePat = '', $postPat = '' ) { + private function addMappings( + array $mapArray, array &$A2B, array &$B2A, bool $exactCase = false, string $prePat = '', string $postPat = '' + ) { foreach ( $mapArray as $WordA => $WordB ) { if ( !$exactCase ) { $ucA = $this->myUc( $WordA ); diff --git a/includes/linker/LinkRenderer.php b/includes/linker/LinkRenderer.php index d7aa984dbeb8..27e5411afe26 100644 --- a/includes/linker/LinkRenderer.php +++ b/includes/linker/LinkRenderer.php @@ -189,7 +189,7 @@ class LinkRenderer { } } - private function runBeginHook( $target, &$text, &$extraAttribs, &$query ) { + private function runBeginHook( $target, &$text, array &$extraAttribs, array &$query ) { $ret = null; if ( !$this->hookRunner->onHtmlPageLinkRendererBegin( // @phan-suppress-next-line PhanTypeMismatchArgument Type mismatch on pass-by-ref args diff --git a/includes/logging/ProtectLogFormatter.php b/includes/logging/ProtectLogFormatter.php index 1848bb487877..cf27a53bb216 100644 --- a/includes/logging/ProtectLogFormatter.php +++ b/includes/logging/ProtectLogFormatter.php @@ -223,7 +223,7 @@ class ProtectLogFormatter extends LogFormatter { return $protectDescription; } - private function formatExpiry( $expiry ) { + private function formatExpiry( string $expiry ): string { if ( wfIsInfinity( $expiry ) ) { return $this->context->msg( 'protect-expiry-indefinite' )->text(); } diff --git a/includes/logging/RightsLogFormatter.php b/includes/logging/RightsLogFormatter.php index a88d4569d7e0..c96b9a1c4537 100644 --- a/includes/logging/RightsLogFormatter.php +++ b/includes/logging/RightsLogFormatter.php @@ -309,7 +309,7 @@ class RightsLogFormatter extends LogFormatter { return $uiLanguage->semicolonList( $formattedChanges ); } - private function formatRightsListExpiryChanged( $groups ) { + private function formatRightsListExpiryChanged( array $groups ): string { $list = []; foreach ( $groups as $group => [ $oldExpiry, $newExpiry ] ) { @@ -354,7 +354,7 @@ class RightsLogFormatter extends LogFormatter { return $uiLanguage->listToText( $list ); } - private function formatRightsList( $groups ) { + private function formatRightsList( array $groups ): string { $uiLanguage = $this->context->getLanguage(); // separate arrays of temporary and permanent memberships $tempList = $permList = []; @@ -377,7 +377,7 @@ class RightsLogFormatter extends LogFormatter { return $uiLanguage->listToText( array_merge( $tempList, $permList ) ); } - private function formatDate( $date ) { + private function formatDate( string $date ): array { $uiLanguage = $this->context->getLanguage(); $uiUser = $this->context->getUser(); @@ -465,7 +465,7 @@ class RightsLogFormatter extends LogFormatter { return $ret; } - private function makeGroupArray( $group ) { + private function makeGroupArray( $group ): array { // Migrate old group params from string to array if ( $group === '' ) { $group = []; diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 0a8d43c3ac07..d63d84924a83 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -2557,7 +2557,7 @@ class WikiPage implements Stringable, Page, PageRecord { } private static function queueBacklinksJobs( - Title $title, $mainSlotChanged, $maybeRedirectChanged, $causeAction + Title $title, bool $mainSlotChanged, bool $maybeRedirectChanged, string $causeAction ) { $services = MediaWikiServices::getInstance(); $backlinkCache = $services->getBacklinkCacheFactory()->getBacklinkCache( $title ); diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 15530b79d3d1..a1eecf1ad725 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -2376,7 +2376,7 @@ class Parser { return $ret; } - private static function normalizeUrlComponent( $component, $unsafe ) { + private static function normalizeUrlComponent( string $component, string $unsafe ): string { $callback = static function ( $matches ) use ( $unsafe ) { $char = urldecode( $matches[0] ); $ord = ord( $char ); @@ -6236,18 +6236,18 @@ class Parser { return $this->mOutput->getPageProperty( 'defaultsort' ) ?? ''; } - private static function getSectionNameFromStrippedText( $text ) { + private static function getSectionNameFromStrippedText( string $text ): string { $text = Sanitizer::normalizeSectionNameWhitespace( $text ); $text = Sanitizer::decodeCharReferences( $text ); $text = self::normalizeSectionName( $text ); return $text; } - private static function makeAnchor( $sectionName ) { + private static function makeAnchor( string $sectionName ): string { return '#' . Sanitizer::escapeIdForLink( $sectionName ); } - private function makeLegacyAnchor( $sectionName ) { + private function makeLegacyAnchor( string $sectionName ): string { $fragmentMode = $this->svcOptions->get( MainConfigNames::FragmentMode ); if ( isset( $fragmentMode[1] ) && $fragmentMode[1] === 'legacy' ) { // ForAttribute() and ForLink() are the same for legacy encoding diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index 576c40314e87..119a16f93e6c 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -2197,7 +2197,7 @@ class ParserOutput extends CacheTime implements ContentMetadataCollector { return $value; } - private static function getTimes( $clock = null ): array { + private static function getTimes( ?string $clock = null ): array { $ret = []; if ( !$clock || $clock === 'wall' ) { $ret['wall'] = microtime( true ); diff --git a/includes/parser/Preprocessor_Hash.php b/includes/parser/Preprocessor_Hash.php index e37b8a78c5d5..11cfcba54d48 100644 --- a/includes/parser/Preprocessor_Hash.php +++ b/includes/parser/Preprocessor_Hash.php @@ -804,7 +804,7 @@ class Preprocessor_Hash extends Preprocessor { return [ [ 'root', $stack->rootAccum ] ]; } - private static function addLiteral( array &$accum, $text ) { + private static function addLiteral( array &$accum, string $text ) { $n = count( $accum ); if ( $n && is_string( $accum[$n - 1] ) ) { $accum[$n - 1] .= $text; diff --git a/includes/recentchanges/ChangesListFilter.php b/includes/recentchanges/ChangesListFilter.php index 38e85953333b..004992964459 100644 --- a/includes/recentchanges/ChangesListFilter.php +++ b/includes/recentchanges/ChangesListFilter.php @@ -449,7 +449,7 @@ abstract class ChangesListFilter { return false; } - private function hasConflictWithGroup( ChangesListFilterGroup $group ) { + private function hasConflictWithGroup( ChangesListFilterGroup $group ): bool { return in_array( $group, $this->getConflictingGroups() ); } @@ -476,7 +476,7 @@ abstract class ChangesListFilter { return false; } - private function hasConflictWithFilter( ChangesListFilter $filter ) { + private function hasConflictWithFilter( ChangesListFilter $filter ): bool { return in_array( $filter, $this->getConflictingFilters() ); } diff --git a/includes/recentchanges/RCCacheEntryFactory.php b/includes/recentchanges/RCCacheEntryFactory.php index a4ac492d1792..2353074a9e9d 100644 --- a/includes/recentchanges/RCCacheEntryFactory.php +++ b/includes/recentchanges/RCCacheEntryFactory.php @@ -166,7 +166,7 @@ class RCCacheEntryFactory { return $clink; } - private function getLogLink( $logType ) { + private function getLogLink( string $logType ): string { $logtitle = SpecialPage::getTitleFor( 'Log', $logType ); $logpage = new LogPage( $logType ); $logname = $logpage->getName()->text(); diff --git a/includes/recentchanges/RecentChange.php b/includes/recentchanges/RecentChange.php index af0865502a85..130cff0bc915 100644 --- a/includes/recentchanges/RecentChange.php +++ b/includes/recentchanges/RecentChange.php @@ -1275,7 +1275,7 @@ class RecentChange implements Taggable { return ChangesList::showCharacterDifference( $old, $new ); } - private static function checkIPAddress( $ip ) { + private static function checkIPAddress( string $ip ): string { global $wgRequest; if ( $ip ) { diff --git a/includes/registration/ExtensionRegistry.php b/includes/registration/ExtensionRegistry.php index ef4aff930736..d0fb664617eb 100644 --- a/includes/registration/ExtensionRegistry.php +++ b/includes/registration/ExtensionRegistry.php @@ -270,7 +270,7 @@ class ExtensionRegistry implements DomainEventSubscriber { return $this->cache; } - private function makeCacheKey( BagOStuff $cache, $component, ...$extra ) { + private function makeCacheKey( BagOStuff $cache, string $component, string ...$extra ): string { // Allow reusing cached ExtensionRegistry metadata between wikis (T274648) return $cache->makeGlobalKey( "registration-$component", diff --git a/includes/revisiondelete/RevisionDeleteUser.php b/includes/revisiondelete/RevisionDeleteUser.php index 9cb7a5ff0c5f..f10782be59b7 100644 --- a/includes/revisiondelete/RevisionDeleteUser.php +++ b/includes/revisiondelete/RevisionDeleteUser.php @@ -141,7 +141,9 @@ class RevisionDeleteUser { return true; } - private static function buildSetBitDeletedField( $field, $op, $value, IDatabase $dbw ) { + private static function buildSetBitDeletedField( + string $field, string $op, $value, IDatabase $dbw + ): array { return [ $field => new RawSQLValue( $op === '&' ? $dbw->bitAnd( $field, $value ) : $dbw->bitOr( $field, $value ) diff --git a/includes/search/BaseSearchResultSet.php b/includes/search/BaseSearchResultSet.php index 59b633c84903..39e314003c82 100644 --- a/includes/search/BaseSearchResultSet.php +++ b/includes/search/BaseSearchResultSet.php @@ -41,7 +41,7 @@ abstract class BaseSearchResultSet implements ISearchResultSet { $this->bcIterator()->rewind(); } - private function bcIterator() { + private function bcIterator(): ArrayIterator { if ( $this->bcIterator === null ) { // @phan-suppress-next-line PhanTypeMismatchProperty Expected $this->bcIterator = 'RECURSION'; diff --git a/includes/search/PrefixSearch.php b/includes/search/PrefixSearch.php index c40b703d958c..def316096de9 100644 --- a/includes/search/PrefixSearch.php +++ b/includes/search/PrefixSearch.php @@ -138,7 +138,9 @@ abstract class PrefixSearch { $this->handleResultFromHook( $srchres, $namespaces, $search, $limit, $offset ) ); } - private function handleResultFromHook( $srchres, $namespaces, $search, $limit, $offset ) { + private function handleResultFromHook( + array $srchres, array $namespaces, string $search, int $limit, int $offset + ): array { if ( $offset === 0 ) { // Only perform exact db match if offset === 0 // This is still far from perfect but at least we avoid returning the diff --git a/includes/search/SearchMySQL.php b/includes/search/SearchMySQL.php index ddbab89c4ac0..554450511061 100644 --- a/includes/search/SearchMySQL.php +++ b/includes/search/SearchMySQL.php @@ -143,7 +143,7 @@ class SearchMySQL extends SearchDatabase { ]; } - private function regexTerm( $string, $wildcard ) { + private function regexTerm( string $string, ?string $wildcard ): string { $regex = preg_quote( $string, '/' ); if ( MediaWikiServices::getInstance()->getContentLanguage()->hasWordBreaks() ) { if ( $wildcard ) { diff --git a/includes/search/SearchSqlite.php b/includes/search/SearchSqlite.php index 5e4bd83be001..ea89e166ed00 100644 --- a/includes/search/SearchSqlite.php +++ b/includes/search/SearchSqlite.php @@ -143,7 +143,7 @@ class SearchSqlite extends SearchDatabase { return " $field MATCH $searchon "; } - private function regexTerm( $string, $wildcard ) { + private function regexTerm( string $string, string $wildcard ): string { $regex = preg_quote( $string, '/' ); if ( MediaWikiServices::getInstance()->getContentLanguage()->hasWordBreaks() ) { if ( $wildcard ) { @@ -280,7 +280,7 @@ class SearchSqlite extends SearchDatabase { "WHERE page_id=$searchindex.rowid AND $match"; } - private function getCountQuery( $filteredTerm, $fulltext ) { + private function getCountQuery( string $filteredTerm, bool $fulltext ): string { $match = $this->parseQuery( $filteredTerm, $fulltext ); $dbr = $this->dbProvider->getReplicaDatabase(); $page = $dbr->tableName( 'page' ); diff --git a/includes/session/UserInfo.php b/includes/session/UserInfo.php index a55725625624..ece85e03dca0 100644 --- a/includes/session/UserInfo.php +++ b/includes/session/UserInfo.php @@ -59,7 +59,7 @@ final class UserInfo implements Stringable { /** @var User|null */ private $user = null; - private function __construct( ?User $user, $verified ) { + private function __construct( ?User $user, bool $verified ) { $userNameUtils = MediaWikiServices::getInstance()->getUserNameUtils(); if ( $user && $user->isAnon() && !$userNameUtils->isUsable( $user->getName() ) ) { $this->verified = true; diff --git a/includes/skins/components/SkinComponentTempUserBanner.php b/includes/skins/components/SkinComponentTempUserBanner.php index d8404801a7b8..3d3f26409b85 100644 --- a/includes/skins/components/SkinComponentTempUserBanner.php +++ b/includes/skins/components/SkinComponentTempUserBanner.php @@ -44,7 +44,7 @@ class SkinComponentTempUserBanner implements SkinComponent { $this->userpageUrl = $user->getUserPage()->getFullURL(); } - private function createLoginLink() { + private function createLoginLink(): string { return Html::element( 'a', [ 'href' => $this->loginUrl, @@ -55,7 +55,7 @@ class SkinComponentTempUserBanner implements SkinComponent { $this->localizer->msg( 'pt-login' )->text() ); } - private function createAccountLink() { + private function createAccountLink(): string { return Html::element( 'a', [ 'href' => $this->createAccountUrl, @@ -67,7 +67,7 @@ class SkinComponentTempUserBanner implements SkinComponent { ); } - private function renderBannerHTML() { + private function renderBannerHTML(): string { return Html::rawElement( 'div', [ 'class' => 'mw-temp-user-banner' ], Html::rawElement( 'p', [], $this->localizer->msg( 'temp-user-banner-description' )->escaped() . diff --git a/includes/tidy/RemexCompatMunger.php b/includes/tidy/RemexCompatMunger.php index a0faf73925df..90fc912823ce 100644 --- a/includes/tidy/RemexCompatMunger.php +++ b/includes/tidy/RemexCompatMunger.php @@ -134,7 +134,7 @@ class RemexCompatMunger implements TreeHandler { $this->serializer->endDocument( $pos ); } - private function getParentForInsert( $preposition, $refElement ) { + private function getParentForInsert( int $preposition, ?Element $refElement ): array { if ( $preposition === TreeBuilder::ROOT ) { return [ $this->serializer->getRootNode(), null ]; } elseif ( $preposition === TreeBuilder::BEFORE ) { @@ -210,7 +210,7 @@ class RemexCompatMunger implements TreeHandler { $length, $sourceStart, $sourceLength ); } - private function trace( $msg ) { + private function trace( string $msg ) { if ( $this->trace ) { wfDebug( "[RCM] $msg" ); } diff --git a/includes/user/TempUser/ScrambleMapping.php b/includes/user/TempUser/ScrambleMapping.php index fa2d29084834..86395fba892e 100644 --- a/includes/user/TempUser/ScrambleMapping.php +++ b/includes/user/TempUser/ScrambleMapping.php @@ -92,7 +92,7 @@ class ScrambleMapping implements SerialMapping { throw new RuntimeException( __METHOD__ . ": The index $index is too large" ); } - private function powmod( $num, $exponent, $modulus ) { + private function powmod( int $num, int $exponent, int $modulus ): int { if ( $this->hasGmp ) { return \gmp_intval( \gmp_powm( $num, $exponent, $modulus ) ); } elseif ( $this->hasBcm ) { diff --git a/includes/watchlist/WatchedItemQueryService.php b/includes/watchlist/WatchedItemQueryService.php index 15e8f6ce48e8..d6d90fcdf903 100644 --- a/includes/watchlist/WatchedItemQueryService.php +++ b/includes/watchlist/WatchedItemQueryService.php @@ -369,7 +369,7 @@ class WatchedItemQueryService { return $watchedItems; } - private function getRecentChangeFieldsFromRow( \stdClass $row ) { + private function getRecentChangeFieldsFromRow( \stdClass $row ): array { return array_filter( get_object_vars( $row ), static function ( $key ) { @@ -379,7 +379,7 @@ class WatchedItemQueryService { ); } - private function getWatchedItemsWithRCInfoQueryTables( array $options ) { + private function getWatchedItemsWithRCInfoQueryTables( array $options ): array { $tables = [ 'recentchanges', 'watchlist' ]; if ( $this->expiryEnabled ) { @@ -403,7 +403,7 @@ class WatchedItemQueryService { return $tables; } - private function getWatchedItemsWithRCInfoQueryFields( array $options ) { + private function getWatchedItemsWithRCInfoQueryFields( array $options ): array { $fields = [ 'rc_id', 'rc_namespace', @@ -466,7 +466,7 @@ class WatchedItemQueryService { IReadableDatabase $db, User $user, array $options - ) { + ): array { $watchlistOwnerId = $this->getWatchlistOwnerId( $user, $options ); $conds = [ 'wl_user' => $watchlistOwnerId ]; @@ -511,7 +511,7 @@ class WatchedItemQueryService { return $conds; } - private function getWatchlistOwnerId( UserIdentity $user, array $options ) { + private function getWatchlistOwnerId( UserIdentity $user, array $options ): int { if ( array_key_exists( 'watchlistOwner', $options ) ) { /** @var UserIdentity $watchlistOwner */ $watchlistOwner = $options['watchlistOwner']; @@ -530,7 +530,7 @@ class WatchedItemQueryService { IReadableDatabase $dbr, User $user, array $options - ) { + ): array { $conds = []; if ( in_array( self::FILTER_MINOR, $options['filters'] ) ) { @@ -588,7 +588,7 @@ class WatchedItemQueryService { return $conds; } - private function getStartEndConds( IReadableDatabase $db, array $options ) { + private function getStartEndConds( IReadableDatabase $db, array $options ): array { if ( !isset( $options['start'] ) && !isset( $options['end'] ) ) { return []; } @@ -606,7 +606,7 @@ class WatchedItemQueryService { return $conds; } - private function getUserRelatedConds( IReadableDatabase $db, Authority $user, array $options ) { + private function getUserRelatedConds( IReadableDatabase $db, Authority $user, array $options ): array { if ( !array_key_exists( 'onlyByUser', $options ) && !array_key_exists( 'notByUser', $options ) ) { return []; } @@ -633,7 +633,7 @@ class WatchedItemQueryService { return $conds; } - private function getExtraDeletedPageLogEntryRelatedCond( IReadableDatabase $db, Authority $user ) { + private function getExtraDeletedPageLogEntryRelatedCond( IReadableDatabase $db, Authority $user ): string { // LogPage::DELETED_ACTION hides the affected page, too. So hide those // entirely from the watchlist, or someone could guess the title. $bitmask = 0; @@ -651,7 +651,7 @@ class WatchedItemQueryService { return ''; } - private function getStartFromConds( IReadableDatabase $db, array $options, array $startFrom ) { + private function getStartFromConds( IReadableDatabase $db, array $options, array $startFrom ): string { $op = $options['dir'] === self::DIR_OLDER ? '<=' : '>='; [ $rcTimestamp, $rcId ] = $startFrom; $rcTimestamp = $db->timestamp( $rcTimestamp ); @@ -708,7 +708,7 @@ class WatchedItemQueryService { ] ); } - private function getWatchedItemsWithRCInfoQueryDbOptions( array $options ) { + private function getWatchedItemsWithRCInfoQueryDbOptions( array $options ): array { $dbOptions = []; if ( array_key_exists( 'dir', $options ) ) { @@ -740,7 +740,7 @@ class WatchedItemQueryService { } } - private function getWatchedItemsWithRCInfoQueryJoinConds( array $options ) { + private function getWatchedItemsWithRCInfoQueryJoinConds( array $options ): array { $joinConds = [ 'watchlist' => [ 'JOIN', [ |