diff options
Diffstat (limited to 'includes')
35 files changed, 88 insertions, 69 deletions
diff --git a/includes/Rest/Handler/CompareHandler.php b/includes/Rest/Handler/CompareHandler.php index 2829f9f6a4cd..ce8267f8e454 100644 --- a/includes/Rest/Handler/CompareHandler.php +++ b/includes/Rest/Handler/CompareHandler.php @@ -111,11 +111,11 @@ class CompareHandler extends Handler { return $rev->userCan( RevisionRecord::DELETED_TEXT, $this->getAuthority() ); } - private function getRole() { + private function getRole(): string { return SlotRecord::MAIN; } - private function getRevisionText( $paramName ) { + private function getRevisionText( string $paramName ): string { if ( !isset( $this->textCache[$paramName] ) ) { $revision = $this->getRevision( $paramName ); try { diff --git a/includes/Rest/Handler/DiscoveryHandler.php b/includes/Rest/Handler/DiscoveryHandler.php index 04fc989269ce..0a80c0b61b37 100644 --- a/includes/Rest/Handler/DiscoveryHandler.php +++ b/includes/Rest/Handler/DiscoveryHandler.php @@ -69,7 +69,7 @@ class DiscoveryHandler extends Handler { ]; } - private function getInfoSpec() { + private function getInfoSpec(): array { return [ 'title' => $this->options->get( MainConfigNames::Sitename ), 'mediawiki' => MW_VERSION, diff --git a/includes/Rest/Handler/Helper/RestStatusTrait.php b/includes/Rest/Handler/Helper/RestStatusTrait.php index ec0257920430..1d19309b8cd3 100644 --- a/includes/Rest/Handler/Helper/RestStatusTrait.php +++ b/includes/Rest/Handler/Helper/RestStatusTrait.php @@ -37,7 +37,7 @@ trait RestStatusTrait { throw new LocalizedHttpException( $msg, $code, $data ); } - private function getStatusErrorKeys( StatusValue $status ) { + private function getStatusErrorKeys( StatusValue $status ): array { $keys = []; foreach ( $status->getMessages() as $msg ) { diff --git a/includes/Rest/Handler/LanguageLinksHandler.php b/includes/Rest/Handler/LanguageLinksHandler.php index fd63c7a5c948..400f9cd1eb40 100644 --- a/includes/Rest/Handler/LanguageLinksHandler.php +++ b/includes/Rest/Handler/LanguageLinksHandler.php @@ -122,7 +122,7 @@ class LanguageLinksHandler extends SimpleHandler { ->createJson( $this->fetchLinks( $page->getId() ) ); } - private function fetchLinks( $pageId ) { + private function fetchLinks( int $pageId ): array { $result = []; $res = $this->dbProvider->getReplicaDatabase()->newSelectQueryBuilder() ->select( [ 'll_title', 'll_lang' ] ) diff --git a/includes/Rest/Handler/ModuleSpecHandler.php b/includes/Rest/Handler/ModuleSpecHandler.php index 9025815c34b4..07ba328ea267 100644 --- a/includes/Rest/Handler/ModuleSpecHandler.php +++ b/includes/Rest/Handler/ModuleSpecHandler.php @@ -144,7 +144,7 @@ class ModuleSpecHandler extends SimpleHandler { return $operationSpec; } - private function getComponentsSpec( Module $module ) { + private function getComponentsSpec( Module $module ): array { $components = []; // XXX: also collect reusable components from handler specs (but how to avoid name collisions?). diff --git a/includes/Rest/Handler/PageHistoryCountHandler.php b/includes/Rest/Handler/PageHistoryCountHandler.php index 4c8c3b6e8dae..e699ff859806 100644 --- a/includes/Rest/Handler/PageHistoryCountHandler.php +++ b/includes/Rest/Handler/PageHistoryCountHandler.php @@ -108,7 +108,7 @@ class PageHistoryCountHandler extends SimpleHandler { ); } - private function normalizeType( $type ) { + private function normalizeType( string $type ): string { return self::DEPRECATED_COUNT_TYPES[$type] ?? $type; } diff --git a/includes/Rest/Handler/ParsoidHandler.php b/includes/Rest/Handler/ParsoidHandler.php index 092cf92f0894..5729dd1b4bc8 100644 --- a/includes/Rest/Handler/ParsoidHandler.php +++ b/includes/Rest/Handler/ParsoidHandler.php @@ -648,7 +648,7 @@ abstract class ParsoidHandler extends Handler { private function wtLint( PageConfig $pageConfig, array $attribs, ?array $linterOverrides = [] - ) { + ): array { $envOptions = $attribs['envOptions'] + [ 'linterOverrides' => $linterOverrides, 'offsetType' => $attribs['offsetType'], diff --git a/includes/Rest/Router.php b/includes/Rest/Router.php index ff2497d6d10b..6960a07f8db5 100644 --- a/includes/Rest/Router.php +++ b/includes/Rest/Router.php @@ -338,7 +338,7 @@ class Router { return $this->moduleMap; } - private function getModuleInfo( $module ): ?array { + private function getModuleInfo( string $module ): ?array { $map = $this->getModuleMap(); return $map[$module] ?? null; } diff --git a/includes/auth/LocalPasswordPrimaryAuthenticationProvider.php b/includes/auth/LocalPasswordPrimaryAuthenticationProvider.php index c37313376a44..b6d0384fd472 100644 --- a/includes/auth/LocalPasswordPrimaryAuthenticationProvider.php +++ b/includes/auth/LocalPasswordPrimaryAuthenticationProvider.php @@ -21,10 +21,14 @@ namespace MediaWiki\Auth; +use BadMethodCallException; use MediaWiki\Deferred\DeferredUpdates; use MediaWiki\MainConfigNames; use MediaWiki\Password\InvalidPassword; +use MediaWiki\Status\Status; use MediaWiki\User\UserRigorOptions; +use StatusValue; +use stdClass; use Wikimedia\Rdbms\DBAccessObjectUtils; use Wikimedia\Rdbms\IConnectionProvider; use Wikimedia\Rdbms\IDBAccessObject; @@ -60,8 +64,8 @@ class LocalPasswordPrimaryAuthenticationProvider * Check if the password has expired and needs a reset * * @param string $username - * @param \stdClass $row A row from the user table - * @return \stdClass|null + * @param stdClass $row A row from the user table + * @return stdClass|null */ protected function getPasswordResetData( $username, $row ) { $now = (int)wfTimestamp(); @@ -74,12 +78,12 @@ class LocalPasswordPrimaryAuthenticationProvider if ( (int)$expiration + $grace < $now ) { $data = [ 'hard' => true, - 'msg' => \MediaWiki\Status\Status::newFatal( 'resetpass-expired' )->getMessage(), + 'msg' => Status::newFatal( 'resetpass-expired' )->getMessage(), ]; } else { $data = [ 'hard' => false, - 'msg' => \MediaWiki\Status\Status::newFatal( 'resetpass-expired-soft' )->getMessage(), + 'msg' => Status::newFatal( 'resetpass-expired-soft' )->getMessage(), ]; } @@ -112,7 +116,7 @@ class LocalPasswordPrimaryAuthenticationProvider $oldRow = clone $row; // Check for *really* old password hashes that don't even have a type - // The old hash format was just an md5 hex hash, with no type information + // The old hash format was just an MD5 hex hash, with no type information if ( preg_match( '/^[0-9a-f]{32}$/', $row->user_password ) ) { $row->user_password = ":B:{$row->user_id}:{$row->user_password}"; } @@ -161,7 +165,9 @@ class LocalPasswordPrimaryAuthenticationProvider public function testUserCanAuthenticate( $username ) { $username = $this->userNameUtils->getCanonical( - $username, UserRigorOptions::RIGOR_USABLE ); + $username, + UserRigorOptions::RIGOR_USABLE + ); if ( $username === false ) { return false; } @@ -176,7 +182,7 @@ class LocalPasswordPrimaryAuthenticationProvider } // Check for *really* old password hashes that don't even have a type - // The old hash format was just an md5 hex hash, with no type information + // The old hash format was just an MD5 hex hash, with no type information if ( preg_match( '/^[0-9a-f]{32}$/', $row->user_password ) ) { return true; } @@ -186,7 +192,9 @@ class LocalPasswordPrimaryAuthenticationProvider public function testUserExists( $username, $flags = IDBAccessObject::READ_NORMAL ) { $username = $this->userNameUtils->getCanonical( - $username, UserRigorOptions::RIGOR_USABLE ); + $username, + UserRigorOptions::RIGOR_USABLE + ); if ( $username === false ) { return false; } @@ -205,12 +213,12 @@ class LocalPasswordPrimaryAuthenticationProvider // We only want to blank the password if something else will accept the // new authentication data, so return 'ignore' here. if ( $this->loginOnly ) { - return \StatusValue::newGood( 'ignored' ); + return StatusValue::newGood( 'ignored' ); } if ( get_class( $req ) === PasswordAuthenticationRequest::class ) { if ( !$checkData ) { - return \StatusValue::newGood(); + return StatusValue::newGood(); } $username = $this->userNameUtils->getCanonical( $req->username, @@ -222,7 +230,7 @@ class LocalPasswordPrimaryAuthenticationProvider ->where( [ 'user_name' => $username ] ) ->caller( __METHOD__ )->fetchRow(); if ( $row ) { - $sv = \StatusValue::newGood(); + $sv = StatusValue::newGood(); if ( $req->password !== null ) { if ( $req->password !== $req->retype ) { $sv->fatal( 'badretype' ); @@ -235,12 +243,12 @@ class LocalPasswordPrimaryAuthenticationProvider } } - return \StatusValue::newGood( 'ignored' ); + return StatusValue::newGood( 'ignored' ); } public function providerChangeAuthenticationData( AuthenticationRequest $req ) { - $username = $req->username !== null ? - $this->userNameUtils->getCanonical( $req->username, UserRigorOptions::RIGOR_USABLE ) + $username = $req->username !== null + ? $this->userNameUtils->getCanonical( $req->username, UserRigorOptions::RIGOR_USABLE ) : false; if ( $username === false ) { return; @@ -279,7 +287,7 @@ class LocalPasswordPrimaryAuthenticationProvider public function testForAccountCreation( $user, $creator, array $reqs ) { $req = AuthenticationRequest::getRequestByClass( $reqs, PasswordAuthenticationRequest::class ); - $ret = \StatusValue::newGood(); + $ret = StatusValue::newGood(); if ( !$this->loginOnly && $req && $req->username !== null && $req->password !== null ) { if ( $req->password !== $req->retype ) { $ret->fatal( 'badretype' ); @@ -294,7 +302,7 @@ class LocalPasswordPrimaryAuthenticationProvider public function beginPrimaryAccountCreation( $user, $creator, array $reqs ) { if ( $this->accountCreationType() === self::TYPE_NONE ) { - throw new \BadMethodCallException( 'Shouldn\'t call this when accountCreationType() is NONE' ); + throw new BadMethodCallException( 'Shouldn\'t call this when accountCreationType() is NONE' ); } $req = AuthenticationRequest::getRequestByClass( $reqs, PasswordAuthenticationRequest::class ); @@ -314,7 +322,7 @@ class LocalPasswordPrimaryAuthenticationProvider public function finishAccountCreation( $user, $creator, AuthenticationResponse $res ) { if ( $this->accountCreationType() === self::TYPE_NONE ) { - throw new \BadMethodCallException( 'Shouldn\'t call this when accountCreationType() is NONE' ); + throw new BadMethodCallException( 'Shouldn\'t call this when accountCreationType() is NONE' ); } // Now that the user is in the DB, set the password on it. diff --git a/includes/filerepo/ThumbnailEntryPoint.php b/includes/filerepo/ThumbnailEntryPoint.php index a1ae53359a1b..e8367ada0d2b 100644 --- a/includes/filerepo/ThumbnailEntryPoint.php +++ b/includes/filerepo/ThumbnailEntryPoint.php @@ -673,7 +673,7 @@ EOT; return false; } - private function vary( $header ) { + private function vary( string $header ) { $this->varyHeader[] = $header; } @@ -823,7 +823,7 @@ EOT; return false; } - private function maybeEnforceRateLimits( File $img, array $params ) { + private function maybeEnforceRateLimits( File $img, array $params ): bool { $authority = $this->getContext()->getAuthority(); $status = PermissionStatus::newEmpty(); diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php index 30844f5c2059..6cb4d8018da0 100644 --- a/includes/filerepo/file/File.php +++ b/includes/filerepo/file/File.php @@ -1147,7 +1147,7 @@ abstract class File implements MediaHandlerState { return $thumbName; } - private function adjustThumbWidthForSteps( $params ) { + private function adjustThumbWidthForSteps( array $params ): array { $thumbnailSteps = MediaWikiServices::getInstance() ->getMainConfig()->get( MainConfigNames::ThumbnailSteps ); $thumbnailStepsRatio = MediaWikiServices::getInstance() diff --git a/includes/filerepo/file/FileSelectQueryBuilder.php b/includes/filerepo/file/FileSelectQueryBuilder.php index a61357b00949..23cf5597a9a1 100644 --- a/includes/filerepo/file/FileSelectQueryBuilder.php +++ b/includes/filerepo/file/FileSelectQueryBuilder.php @@ -73,7 +73,7 @@ class FileSelectQueryBuilder extends SelectQueryBuilder { return new FileSelectQueryBuilder( $db, 'archivedfile', $options ); } - private function initFileOld( $options ) { + private function initFileOld( array $options ) { $this->table( 'image' ) ->join( 'actor', 'image_actor', 'actor_id=img_actor' ) ->join( @@ -112,7 +112,7 @@ class FileSelectQueryBuilder extends SelectQueryBuilder { } } - private function initFileNew( $options ) { + private function initFileNew( array $options ) { $subquery = $this->newSubquery(); $subquery->table( 'file' ) ->join( 'filerevision', null, 'file_latest = fr_id' ) @@ -164,7 +164,7 @@ class FileSelectQueryBuilder extends SelectQueryBuilder { ->from( $subquery ); } - private function initOldFileOld( $options ) { + private function initOldFileOld( array $options ) { $this->table( 'oldimage' ) ->join( 'actor', 'oldimage_actor', 'actor_id=oi_actor' ) ->join( @@ -204,7 +204,7 @@ class FileSelectQueryBuilder extends SelectQueryBuilder { } } - private function initOldFileNew( $options ) { + private function initOldFileNew( array $options ) { $subquery = $this->newSubquery(); $subquery->table( 'filerevision' ) ->join( 'file', null, 'fr_file = file_id' ) @@ -253,7 +253,7 @@ class FileSelectQueryBuilder extends SelectQueryBuilder { ->from( $subquery ); } - private function initArchivedFile( $options ) { + private function initArchivedFile( array $options ) { $this->table( 'filearchive' ) ->join( 'actor', 'filearchive_actor', 'actor_id=fa_actor' ) ->join( diff --git a/includes/filerepo/file/OldLocalFile.php b/includes/filerepo/file/OldLocalFile.php index 76b624f1d5ad..8e4e7811b217 100644 --- a/includes/filerepo/file/OldLocalFile.php +++ b/includes/filerepo/file/OldLocalFile.php @@ -261,7 +261,9 @@ class OldLocalFile extends LocalFile { } } - private function buildQueryBuilderForLoad( IReadableDatabase $dbr, $options = [ 'omit-nonlazy' ] ) { + private function buildQueryBuilderForLoad( + IReadableDatabase $dbr, array $options = [ 'omit-nonlazy' ] + ): FileSelectQueryBuilder { $queryBuilder = FileSelectQueryBuilder::newForOldFile( $dbr, $options ); $queryBuilder->where( [ 'oi_name' => $this->getName() ] ) ->orderBy( 'oi_timestamp', SelectQueryBuilder::SORT_DESC ); diff --git a/includes/filerepo/file/UnregisteredLocalFile.php b/includes/filerepo/file/UnregisteredLocalFile.php index e09923859f0c..1f4ccd182794 100644 --- a/includes/filerepo/file/UnregisteredLocalFile.php +++ b/includes/filerepo/file/UnregisteredLocalFile.php @@ -199,7 +199,7 @@ class UnregisteredLocalFile extends File { return $info['metadata']; } - private function getSizeAndMetadata() { + private function getSizeAndMetadata(): array { if ( $this->sizeAndMetadata === null ) { if ( !$this->getHandler() ) { $this->sizeAndMetadata = [ 'width' => 0, 'height' => 0, 'metadata' => [] ]; diff --git a/includes/jobqueue/jobs/ThumbnailRenderJob.php b/includes/jobqueue/jobs/ThumbnailRenderJob.php index 5fbdb3823bd6..f12532e27a9e 100644 --- a/includes/jobqueue/jobs/ThumbnailRenderJob.php +++ b/includes/jobqueue/jobs/ThumbnailRenderJob.php @@ -153,7 +153,7 @@ class ThumbnailRenderJob extends Job { return false; } - private function maybeEnqueueNextPage( $transformParams ) { + private function maybeEnqueueNextPage( array $transformParams ) { if ( ( $this->params['enqueueNextPage'] ?? false ) && ( $transformParams['page'] ?? 0 ) < ( $this->params['pageLimit'] ?? 0 ) diff --git a/includes/libs/ParamValidator/TypeDef/BooleanDef.php b/includes/libs/ParamValidator/TypeDef/BooleanDef.php index e2ab0cb1460b..19ee271bde00 100644 --- a/includes/libs/ParamValidator/TypeDef/BooleanDef.php +++ b/includes/libs/ParamValidator/TypeDef/BooleanDef.php @@ -57,7 +57,7 @@ class BooleanDef extends TypeDef { ); } - private function quoteVal( $v ) { + private function quoteVal( string $v ): ScalarParam { return new ScalarParam( ParamType::TEXT, "\"$v\"" ); } diff --git a/includes/libs/WRStats/LimitBatch.php b/includes/libs/WRStats/LimitBatch.php index 3758a40fc6e3..b83adb4cffda 100644 --- a/includes/libs/WRStats/LimitBatch.php +++ b/includes/libs/WRStats/LimitBatch.php @@ -72,7 +72,7 @@ class LimitBatch { return $this; } - private function queueOp( $type, $entity, $amount ) { + private function queueOp( string $type, ?EntityKey $entity, ?int $amount ) { $amount ??= $this->defaultAmount; if ( isset( $this->operations[$type] ) ) { throw new WRStatsError( 'Cannot queue multiple actions of the same type, ' . diff --git a/includes/libs/filebackend/FileBackendMultiWrite.php b/includes/libs/filebackend/FileBackendMultiWrite.php index 7be37112be27..7c59e161e396 100644 --- a/includes/libs/filebackend/FileBackendMultiWrite.php +++ b/includes/libs/filebackend/FileBackendMultiWrite.php @@ -776,7 +776,7 @@ class FileBackendMultiWrite extends FileBackend { return $this->backends[$this->masterIndex]->getFileList( $realParams ); } - private function getFileListForWrite( $params ) { + private function getFileListForWrite( array $params ): array { $files = []; // Get the list of thumbnails from all backends to allow // deleting all of them. Otherwise, old thumbnails existing on diff --git a/includes/libs/http/MultiHttpClient.php b/includes/libs/http/MultiHttpClient.php index 4aefaf1551b5..ff0bd5f6866c 100644 --- a/includes/libs/http/MultiHttpClient.php +++ b/includes/libs/http/MultiHttpClient.php @@ -734,7 +734,7 @@ class MultiHttpClient implements LoggerAwareInterface { } } - private function useReverseProxy( array &$req, $proxy ) { + private function useReverseProxy( array &$req, string $proxy ) { $parsedProxy = parse_url( $proxy ); if ( $parsedProxy === false ) { throw new InvalidArgumentException( "Invalid reverseProxy configured: $proxy" ); diff --git a/includes/libs/mime/MSCompoundFileReader.php b/includes/libs/mime/MSCompoundFileReader.php index ff6afe144088..398c2bdd8e9d 100644 --- a/includes/libs/mime/MSCompoundFileReader.php +++ b/includes/libs/mime/MSCompoundFileReader.php @@ -170,11 +170,11 @@ class MSCompoundFileReader { $this->valid = true; } - private function sectorOffset( $sectorId ) { + private function sectorOffset( int $sectorId ): int { return $this->sectorLength * ( $sectorId + 1 ); } - private function decodeClsid( $binaryClsid ) { + private function decodeClsid( string $binaryClsid ): string { $parts = unpack( 'Va/vb/vc/C8d', $binaryClsid ); return sprintf( "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", $parts['a'], @@ -220,7 +220,7 @@ class MSCompoundFileReader { return $data; } - private function bin2dec( $str, $offset, $length ) { + private function bin2dec( string $str, int $offset, int $length ): int { $value = 0; for ( $i = $length - 1; $i >= 0; $i-- ) { $value *= 256; @@ -229,7 +229,7 @@ class MSCompoundFileReader { return $value; } - private function readOffset( $offset, $length ) { + private function readOffset( int $offset, int $length ): string { $this->fseek( $offset ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged $block = @fread( $this->file, $length ); @@ -243,7 +243,7 @@ class MSCompoundFileReader { return $block; } - private function readSector( $sectorId ) { + private function readSector( int $sectorId ): string { return $this->readOffset( $this->sectorOffset( $sectorId ), 1 << $this->header['sector_shift'] ); } @@ -256,7 +256,7 @@ class MSCompoundFileReader { throw new RuntimeException( $message, $code ); } - private function fseek( $offset ) { + private function fseek( int $offset ) { // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged $result = @fseek( $this->file, $offset ); if ( $result !== 0 ) { @@ -287,14 +287,14 @@ class MSCompoundFileReader { } } - private function getNextSectorIdFromFat( $sectorId ) { + private function getNextSectorIdFromFat( int $sectorId ): int { $entriesPerSector = intdiv( $this->sectorLength, 4 ); $fatSectorId = intdiv( $sectorId, $entriesPerSector ); $fatSectorArray = $this->getFatSector( $fatSectorId ); return $fatSectorArray[$sectorId % $entriesPerSector]; } - private function getFatSector( $fatSectorId ) { + private function getFatSector( int $fatSectorId ): array { if ( !isset( $this->fat[$fatSectorId] ) ) { $fat = []; if ( !isset( $this->difat[$fatSectorId] ) ) { diff --git a/includes/libs/mime/XmlTypeCheck.php b/includes/libs/mime/XmlTypeCheck.php index b86fd406bef7..274bcbaafc4c 100644 --- a/includes/libs/mime/XmlTypeCheck.php +++ b/includes/libs/mime/XmlTypeCheck.php @@ -197,7 +197,7 @@ class XmlTypeCheck { } } - private function readNext( XMLReader $reader ) { + private function readNext( XMLReader $reader ): bool { set_error_handler( function ( $line, $file ) { $this->wellFormed = false; return true; @@ -207,7 +207,7 @@ class XmlTypeCheck { return $ret; } - private function validate( $reader ) { + private function validate( XMLReader $reader ) { // First, move through anything that isn't an element, and // handle any processing instructions with the callback do { diff --git a/includes/libs/rdbms/ChronologyProtector.php b/includes/libs/rdbms/ChronologyProtector.php index 5b8783cbe047..95b9fd7d1440 100644 --- a/includes/libs/rdbms/ChronologyProtector.php +++ b/includes/libs/rdbms/ChronologyProtector.php @@ -591,7 +591,7 @@ class ChronologyProtector implements LoggerAwareInterface { $this->wallClockOverride =& $time; } - private function marshalPositions( array $positions ) { + private function marshalPositions( array $positions ): array { foreach ( $positions[ self::FLD_POSITIONS ] as $key => $pos ) { $positions[ self::FLD_POSITIONS ][ $key ] = $pos->toArray(); } diff --git a/includes/libs/rdbms/database/Database.php b/includes/libs/rdbms/database/Database.php index 6904f654ead4..4c2e9495d265 100644 --- a/includes/libs/rdbms/database/Database.php +++ b/includes/libs/rdbms/database/Database.php @@ -877,7 +877,9 @@ abstract class Database implements Stringable, IDatabaseForOwner, IMaintainableD return $status; } - private function handleErroredQuery( QueryStatus $status, $sql, $fname, $queryRuntime, $priorSessInfo ) { + private function handleErroredQuery( + QueryStatus $status, Query $sql, string $fname, float $queryRuntime, CriticalSessionInfo $priorSessInfo + ): int { $errflags = self::ERR_NONE; $error = $status->message; $errno = $status->code; diff --git a/includes/libs/rdbms/database/DatabaseMySQL.php b/includes/libs/rdbms/database/DatabaseMySQL.php index f7afce6b6c6c..2dd9cc904254 100644 --- a/includes/libs/rdbms/database/DatabaseMySQL.php +++ b/includes/libs/rdbms/database/DatabaseMySQL.php @@ -808,7 +808,7 @@ class DatabaseMySQL extends Database { } } - private function mysqlRealEscapeString( $s ) { + private function mysqlRealEscapeString( $s ): string { $conn = $this->getBindingHandle(); return $conn->real_escape_string( (string)$s ); diff --git a/includes/libs/rdbms/database/QueryBuilderFromRawSql.php b/includes/libs/rdbms/database/QueryBuilderFromRawSql.php index 3be8e0e13f69..af268f9cc2e2 100644 --- a/includes/libs/rdbms/database/QueryBuilderFromRawSql.php +++ b/includes/libs/rdbms/database/QueryBuilderFromRawSql.php @@ -99,7 +99,7 @@ class QueryBuilderFromRawSql { ); } - private static function isWriteQuery( $rawSql ) { + private static function isWriteQuery( string $rawSql ): bool { // Treat SELECT queries without FOR UPDATE queries as non-writes. This matches // how MySQL enforces read_only (FOR SHARE and LOCK IN SHADE MODE are allowed). // Handle (SELECT ...) UNION (SELECT ...) queries in a similar fashion. diff --git a/includes/libs/rdbms/dbal/DoctrineAbstractSchemaTrait.php b/includes/libs/rdbms/dbal/DoctrineAbstractSchemaTrait.php index 0f06ee2f4679..ab4b813bfe8c 100644 --- a/includes/libs/rdbms/dbal/DoctrineAbstractSchemaTrait.php +++ b/includes/libs/rdbms/dbal/DoctrineAbstractSchemaTrait.php @@ -31,7 +31,7 @@ trait DoctrineAbstractSchemaTrait { private AbstractPlatform $platform; - private function addTableToSchema( Schema $schema, array $schemaSpec ) { + private function addTableToSchema( Schema $schema, array $schemaSpec ): Schema { $prefix = $this->platform->getName() === 'postgresql' ? '' : '/*_*/'; $table = $schema->createTable( $prefix . $schemaSpec['name'] ); diff --git a/includes/libs/rdbms/expression/LikeValue.php b/includes/libs/rdbms/expression/LikeValue.php index 58b732927887..95bd801defa5 100644 --- a/includes/libs/rdbms/expression/LikeValue.php +++ b/includes/libs/rdbms/expression/LikeValue.php @@ -59,7 +59,7 @@ class LikeValue { return $dbQuoter->addQuotes( $s ) . ' ESCAPE ' . $dbQuoter->addQuotes( $escapeChar ); } - private function escapeLikeInternal( $s, $escapeChar = '`' ) { + private function escapeLikeInternal( string $s, string $escapeChar = '`' ): string { return str_replace( [ $escapeChar, '%', '_' ], [ "{$escapeChar}{$escapeChar}", "{$escapeChar}%", "{$escapeChar}_" ], diff --git a/includes/libs/rdbms/lbfactory/LBFactorySimple.php b/includes/libs/rdbms/lbfactory/LBFactorySimple.php index 4d90b309acd0..80f2eaedd44a 100644 --- a/includes/libs/rdbms/lbfactory/LBFactorySimple.php +++ b/includes/libs/rdbms/lbfactory/LBFactorySimple.php @@ -124,7 +124,7 @@ class LBFactorySimple extends LBFactory { return $lbs; } - private function newLoadBalancer( string $clusterName, array $servers ) { + private function newLoadBalancer( string $clusterName, array $servers ): ILoadBalancerForOwner { $lb = new LoadBalancer( array_merge( $this->baseLoadBalancerParams(), [ diff --git a/includes/libs/rdbms/loadbalancer/LoadBalancer.php b/includes/libs/rdbms/loadbalancer/LoadBalancer.php index 66e3a1ac30b8..db959970be33 100644 --- a/includes/libs/rdbms/loadbalancer/LoadBalancer.php +++ b/includes/libs/rdbms/loadbalancer/LoadBalancer.php @@ -233,7 +233,7 @@ class LoadBalancer implements ILoadBalancerForOwner { $this->defaultGroup = isset( $this->groupLoads[ $group ] ) ? $group : self::GROUP_GENERIC; } - private static function newTrackedConnectionsArray() { + private static function newTrackedConnectionsArray(): array { // Note that CATEGORY_GAUGE connections are untracked return [ self::CATEGORY_ROUND => [], diff --git a/includes/libs/rdbms/platform/SQLPlatform.php b/includes/libs/rdbms/platform/SQLPlatform.php index 6ac4f1c07865..a1bc9168485d 100644 --- a/includes/libs/rdbms/platform/SQLPlatform.php +++ b/includes/libs/rdbms/platform/SQLPlatform.php @@ -1596,7 +1596,7 @@ class SQLPlatform implements ISQLPlatform { ); } - private function scrubArray( $array, $listType = self::LIST_AND ) { + private function scrubArray( $array, int $listType = self::LIST_AND ): string { if ( is_array( $array ) ) { $scrubbedArray = []; foreach ( $array as $key => $value ) { diff --git a/includes/media/DjVuImage.php b/includes/media/DjVuImage.php index 1ff80602730e..d5a18e75bd6d 100644 --- a/includes/media/DjVuImage.php +++ b/includes/media/DjVuImage.php @@ -97,7 +97,7 @@ class DjVuImage { fclose( $file ); } - private function dumpForm( $file, $length, $indent ) { + private function dumpForm( $file, int $length, int $indent ) { $start = ftell( $file ); $secondary = fread( $file, 4 ); echo str_repeat( ' ', $indent * 4 ) . "($secondary)\n"; @@ -159,7 +159,7 @@ class DjVuImage { return $info; } - private function readChunk( $file ) { + private function readChunk( $file ): array { $header = fread( $file, 8 ); if ( strlen( $header ) < 8 ) { return [ false, 0 ]; @@ -169,7 +169,7 @@ class DjVuImage { return [ $arr['chunk'], $arr['length'] ]; } - private function skipChunk( $file, $chunkLength ) { + private function skipChunk( $file, int $chunkLength ) { fseek( $file, $chunkLength, SEEK_CUR ); if ( ( $chunkLength & 1 ) && !feof( $file ) ) { @@ -178,7 +178,7 @@ class DjVuImage { } } - private function getMultiPageInfo( $file, $formLength ) { + private function getMultiPageInfo( $file, int $formLength ) { // For now, we'll just look for the first page in the file // and report its information, hoping others are the same size. $start = ftell( $file ); @@ -366,7 +366,7 @@ EOR; return $json; } - private function pageTextCallback( string $match ) { + private function pageTextCallback( string $match ): string { # Get rid of invalid UTF-8 $val = UtfNormal\Validator::cleanUp( stripcslashes( $match ) ); return str_replace( '�', '', $val ); @@ -434,7 +434,7 @@ EOR; return $result; } - private function parseFormDjvu( $line ) { + private function parseFormDjvu( string $line ) { $parentLevel = strspn( $line, ' ' ); $line = strtok( "\n" ); # Find INFO diff --git a/includes/media/SVGReader.php b/includes/media/SVGReader.php index f988456e2f66..f68f446f1ccb 100644 --- a/includes/media/SVGReader.php +++ b/includes/media/SVGReader.php @@ -314,7 +314,7 @@ class SVGReader { } } - private function debug( $data ) { + private function debug( string $data ) { if ( $this->mDebug ) { wfDebug( "SVGReader: $data" ); } diff --git a/includes/parser/Parsoid/Config/SiteConfig.php b/includes/parser/Parsoid/Config/SiteConfig.php index 24a6eef635b4..4e91f19aa96d 100644 --- a/includes/parser/Parsoid/Config/SiteConfig.php +++ b/includes/parser/Parsoid/Config/SiteConfig.php @@ -749,6 +749,13 @@ class SiteConfig extends ISiteConfig { } /** @inheritDoc */ + protected function shouldValidateExtConfig(): bool { + // Only perform json schema validation for extension module + // configurations when running tests. + return defined( 'MW_PHPUNIT_TEST' ) || defined( 'MW_PARSER_TEST' ); + } + + /** @inheritDoc */ public function getMaxTemplateDepth(): int { return (int)$this->config->get( MainConfigNames::MaxTemplateDepth ); } diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php index 48a8f1240273..17f97ee56fba 100644 --- a/includes/upload/UploadBase.php +++ b/includes/upload/UploadBase.php @@ -918,7 +918,7 @@ abstract class UploadBase { return $warnings; } - private function checkLocalFileWasDeleted( LocalFile $localFile ) { + private function checkLocalFileWasDeleted( LocalFile $localFile ): bool { return $localFile->wasDeleted() && !$localFile->exists(); } diff --git a/includes/upload/UploadFromChunks.php b/includes/upload/UploadFromChunks.php index 85a486dbeaf7..d484a3516022 100644 --- a/includes/upload/UploadFromChunks.php +++ b/includes/upload/UploadFromChunks.php @@ -449,7 +449,7 @@ class UploadFromChunks extends UploadFromFile { return $storeStatus; } - private function getChunkFileKey( $index = null ) { + private function getChunkFileKey( ?int $index = null ): string { return $this->mFileKey . '.' . ( $index ?? $this->getChunkIndex() ); } |