From c659bc63087b10d8765056500a8ed4bce6cfdbf4 Mon Sep 17 00:00:00 2001 From: Daimona Eaytoy Date: Sat, 31 Aug 2019 18:14:38 +0200 Subject: [PATCH] Unsuppress another phan issue (part 7) Bug: T231636 Depends-On: I2cd24e73726394e3200a570c45d5e86b6849bfa9 Depends-On: I4fa3e6aad872434ca397325ed7a83f94973661d0 Change-Id: Ie6233561de78457cae5e4e44e220feec2d1272d8 --- .phan/config.php | 2 - .phan/internal_stubs/dom.phan_php | 420 ++++++++++++++++++ .phan/stubs/mail.php | 5 + includes/FileDeleteForm.php | 4 +- .../Navigation/PrevNextNavigationRenderer.php | 24 +- includes/OutputPage.php | 2 + includes/Rest/SimpleHandler.php | 2 + includes/Revision/MutableRevisionRecord.php | 3 +- includes/Storage/PageUpdater.php | 1 + includes/Title.php | 1 + includes/TitleArray.php | 2 + includes/actions/RevertAction.php | 2 + includes/api/ApiDelete.php | 2 + includes/api/ApiErrorFormatter.php | 1 + includes/api/ApiExpandTemplates.php | 2 + includes/api/ApiFeedWatchlist.php | 1 + includes/api/ApiImageRotate.php | 2 + includes/api/ApiMain.php | 1 + includes/api/ApiMessageTrait.php | 1 + includes/api/ApiOpenSearch.php | 3 +- includes/api/ApiParse.php | 1 + includes/api/ApiQuery.php | 3 +- includes/api/ApiQueryBlocks.php | 2 + includes/api/ApiQueryImageInfo.php | 5 + includes/api/ApiQueryRevisionsBase.php | 6 + .../auth/RememberMeAuthenticationRequest.php | 1 + includes/block/BlockManager.php | 2 + .../block/Restriction/PageRestriction.php | 2 + includes/block/Restriction/Restriction.php | 2 +- .../changes/ChangesListBooleanFilterGroup.php | 2 + includes/changes/ChangesListFilterGroup.php | 1 + .../ChangesListStringOptionsFilterGroup.php | 1 + includes/changetags/ChangeTagsList.php | 6 + includes/content/TextContent.php | 5 +- includes/content/TextContentHandler.php | 1 + includes/content/UnknownContentHandler.php | 1 + includes/content/WikitextContent.php | 2 + includes/deferred/DeferredUpdates.php | 1 + includes/diff/TextSlotDiffRenderer.php | 1 + includes/export/WikiExporter.php | 5 +- includes/export/XmlDumpWriter.php | 2 + includes/filerepo/file/File.php | 1 + includes/filerepo/file/LocalFile.php | 2 + includes/filerepo/file/LocalFileMoveBatch.php | 2 + includes/htmlform/HTMLFormElement.php | 1 + includes/http/MWHttpRequest.php | 2 +- .../ImportableUploadRevisionImporter.php | 1 + includes/installer/DatabaseInstaller.php | 2 + includes/installer/DatabaseUpdater.php | 3 + includes/installer/Installer.php | 1 + includes/installer/MysqlInstaller.php | 1 + includes/installer/MysqlUpdater.php | 1 + includes/installer/PostgresInstaller.php | 5 + includes/installer/WebInstaller.php | 4 + includes/installer/WebInstallerOutput.php | 1 + includes/page/ImageHistoryList.php | 1 + includes/page/ImagePage.php | 1 + includes/page/Page.php | 5 + includes/parser/PPDPart_Hash.php | 1 + includes/parser/PPDStack.php | 6 +- includes/parser/PPDStackElement_Hash.php | 4 +- includes/parser/PPFrame_DOM.php | 1 + includes/parser/PPNode_DOM.php | 1 + includes/parser/Parser.php | 2 + includes/parser/Preprocessor_Hash.php | 2 + .../password/LayeredParameterizedPassword.php | 4 + includes/poolcounter/PoolCounterRedis.php | 4 + .../preferences/DefaultPreferencesFactory.php | 8 +- .../profiler/output/ProfilerOutputDump.php | 1 + .../revisiondelete/RevDelArchivedFileItem.php | 5 +- includes/revisiondelete/RevDelFileList.php | 2 + includes/revisiondelete/RevDelList.php | 6 + .../revisiondelete/RevDelRevisionItem.php | 2 + includes/search/SearchResultSetTrait.php | 1 + includes/session/PHPSessionHandler.php | 6 +- includes/session/SessionInfo.php | 1 + includes/session/SessionManager.php | 3 +- includes/skins/SkinTemplate.php | 1 + .../specialpage/LoginSignupSpecialPage.php | 1 + includes/specialpage/SpecialPageFactory.php | 1 + includes/specials/SpecialBlock.php | 2 + includes/specials/SpecialExpandTemplates.php | 2 + includes/specials/SpecialRecentChanges.php | 10 + includes/specials/SpecialUndelete.php | 1 + includes/specials/SpecialUserrights.php | 7 +- includes/specials/SpecialWatchlist.php | 1 + includes/specials/pagers/BlockListPager.php | 1 + includes/user/BotPassword.php | 1 + includes/utils/AvroValidator.php | 1 + languages/Language.php | 3 +- languages/LanguageConverter.php | 1 + maintenance/Maintenance.php | 1 + maintenance/addSite.php | 6 +- maintenance/archives/upgradeLogging.php | 6 +- maintenance/checkLess.php | 1 + maintenance/cleanupUploadStash.php | 1 + maintenance/compareParsers.php | 2 + maintenance/convertLinks.php | 1 + maintenance/deleteArchivedFiles.php | 1 + maintenance/eraseArchivedFile.php | 1 + maintenance/importDump.php | 1 + maintenance/importImages.php | 1 + maintenance/nukeNS.php | 2 + maintenance/populateImageSha1.php | 2 + maintenance/preprocessDump.php | 2 + maintenance/preprocessorFuzzTest.php | 2 +- maintenance/rebuildImages.php | 5 +- maintenance/storage/checkStorage.php | 2 + maintenance/update.php | 4 +- maintenance/updateExtensionJsonSchema.php | 1 + maintenance/userDupes.inc | 2 +- maintenance/wrapOldPasswords.php | 2 + 112 files changed, 657 insertions(+), 49 deletions(-) create mode 100644 .phan/internal_stubs/dom.phan_php diff --git a/.phan/config.php b/.phan/config.php index e02dba7e15..fe63e474b9 100644 --- a/.phan/config.php +++ b/.phan/config.php @@ -87,8 +87,6 @@ $cfg['suppress_issue_types'] = array_merge( $cfg['suppress_issue_types'], [ "PhanUndeclaredConstant", // approximate error count: 60 "PhanTypeMismatchArgument", - // approximate error count: 219 - "PhanUndeclaredMethod", // approximate error count: 752 "PhanUndeclaredProperty", ] ); diff --git a/.phan/internal_stubs/dom.phan_php b/.phan/internal_stubs/dom.phan_php new file mode 100644 index 0000000000..608e3a1549 --- /dev/null +++ b/.phan/internal_stubs/dom.phan_php @@ -0,0 +1,420 @@ +deleteOld( $oldimage, $reason, $suppress, $user ); - if ( $status->ok ) { + if ( $status->isOK() ) { // Need to do a log item $logComment = wfMessage( 'deletedrevision', $oldimage )->inContentLanguage()->text(); if ( trim( $reason ) != '' ) { diff --git a/includes/Navigation/PrevNextNavigationRenderer.php b/includes/Navigation/PrevNextNavigationRenderer.php index c60b8c6130..539758f28c 100644 --- a/includes/Navigation/PrevNextNavigationRenderer.php +++ b/includes/Navigation/PrevNextNavigationRenderer.php @@ -20,12 +20,13 @@ namespace MediaWiki\Navigation; -use MediaWiki\Linker\LinkTarget; -use MessageLocalizer; use Html; +use MessageLocalizer; +use Title; /** * Helper class for generating prev/next links for paging. + * @todo Use LinkTarget instead of Title * * @since 1.34 */ @@ -36,6 +37,9 @@ class PrevNextNavigationRenderer { */ private $messageLocalizer; + /** + * @param MessageLocalizer $messageLocalizer + */ public function __construct( MessageLocalizer $messageLocalizer ) { $this->messageLocalizer = $messageLocalizer; } @@ -43,15 +47,19 @@ class PrevNextNavigationRenderer { /** * Generate (prev x| next x) (20|50|100...) type links for paging * - * @param LinkTarget $title LinkTarget object to link + * @param Title $title Title object to link * @param int $offset * @param int $limit * @param array $query Optional URL query parameter string * @param bool $atend Optional param for specified if this is the last page * @return string */ - public function buildPrevNextNavigation( LinkTarget $title, $offset, $limit, - array $query = [], $atend = false + public function buildPrevNextNavigation( + Title $title, + $offset, + $limit, + array $query = [], + $atend = false ) { # Make 'previous' link $prev = $this->messageLocalizer->msg( 'prevn' )->title( $title ) @@ -76,6 +84,8 @@ class PrevNextNavigationRenderer { # Make links to set number of items per page $numLinks = []; + // @phan-suppress-next-next-line PhanUndeclaredMethod + // @fixme MessageLocalizer doesn't have a getLanguage() method! $lang = $this->messageLocalizer->getLanguage(); foreach ( [ 20, 50, 100, 250, 500 ] as $num ) { $numLinks[] = $this->numLink( $title, $offset, $num, $query, @@ -89,7 +99,7 @@ class PrevNextNavigationRenderer { /** * Helper function for buildPrevNextNavigation() that generates links * - * @param LinkTarget $title LinkTarget object to link + * @param Title $title Title object to link * @param int $offset * @param int $limit * @param array $query Extra query parameters @@ -98,7 +108,7 @@ class PrevNextNavigationRenderer { * @param string $class Value of the "class" attribute of the link * @return string HTML fragment */ - private function numLink( LinkTarget $title, $offset, $limit, array $query, $link, + private function numLink( Title $title, $offset, $limit, array $query, $link, $tooltipMsg, $class ) { $query = [ 'limit' => $limit, 'offset' => $offset ] + $query; diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 170356541c..14639aa867 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -995,6 +995,8 @@ class OutputPage extends ContextSource { * @param Title $t */ public function setTitle( Title $t ) { + // @phan-suppress-next-next-line PhanUndeclaredMethod + // @fixme Not all implementations of IContextSource have this method! $this->getContext()->setTitle( $t ); } diff --git a/includes/Rest/SimpleHandler.php b/includes/Rest/SimpleHandler.php index 85749c6229..3718d66b93 100644 --- a/includes/Rest/SimpleHandler.php +++ b/includes/Rest/SimpleHandler.php @@ -8,12 +8,14 @@ namespace MediaWiki\Rest; * * run() must be declared in the subclass. It cannot be declared as abstract * here because it has a variable parameter list. + * @todo Declare it as abstract after dropping HHVM * * @package MediaWiki\Rest */ class SimpleHandler extends Handler { public function execute() { $params = array_values( $this->getRequest()->getPathParams() ); + // @phan-suppress-next-line PhanUndeclaredMethod return $this->run( ...$params ); } } diff --git a/includes/Revision/MutableRevisionRecord.php b/includes/Revision/MutableRevisionRecord.php index e9136cbb5d..8bb2c89893 100644 --- a/includes/Revision/MutableRevisionRecord.php +++ b/includes/Revision/MutableRevisionRecord.php @@ -37,6 +37,7 @@ use Wikimedia\Assert\Assert; * * @since 1.31 * @since 1.32 Renamed from MediaWiki\Storage\MutableRevisionRecord + * @property MutableRevisionSlots $mSlots */ class MutableRevisionRecord extends RevisionRecord { @@ -78,8 +79,6 @@ class MutableRevisionRecord extends RevisionRecord { $slots = new MutableRevisionSlots(); parent::__construct( $title, $slots, $dbDomain ); - - $this->mSlots = $slots; // redundant, but nice for static analysis } /** diff --git a/includes/Storage/PageUpdater.php b/includes/Storage/PageUpdater.php index 7246238696..fd555f623e 100644 --- a/includes/Storage/PageUpdater.php +++ b/includes/Storage/PageUpdater.php @@ -882,6 +882,7 @@ class PageUpdater { // TODO: introduce something like an UnsavedRevisionFactory service instead! /** @var MutableRevisionRecord $rev */ $rev = $this->derivedDataUpdater->getRevision(); + '@phan-var MutableRevisionRecord $rev'; $rev->setPageId( $title->getArticleID() ); diff --git a/includes/Title.php b/includes/Title.php index f621e6611c..547b28c0c3 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -3212,6 +3212,7 @@ class Title implements LinkTarget, IDBAccessObject { // splitTitleString method, but the only implementation (MediaWikiTitleCodec) does /** @var MediaWikiTitleCodec $titleCodec */ $titleCodec = MediaWikiServices::getInstance()->getTitleParser(); + '@phan-var MediaWikiTitleCodec $titleCodec'; // MalformedTitleException can be thrown here $parts = $titleCodec->splitTitleString( $this->mDbkeyform, $this->mDefaultNamespace ); diff --git a/includes/TitleArray.php b/includes/TitleArray.php index f6969851d5..895b5a76b6 100644 --- a/includes/TitleArray.php +++ b/includes/TitleArray.php @@ -29,6 +29,8 @@ use Wikimedia\Rdbms\IResultWrapper; /** * The TitleArray class only exists to provide the newFromResult method at pre- * sent. + * + * @method int count() */ abstract class TitleArray implements Iterator { /** diff --git a/includes/actions/RevertAction.php b/includes/actions/RevertAction.php index 8a5d7c9046..254f7a891c 100644 --- a/includes/actions/RevertAction.php +++ b/includes/actions/RevertAction.php @@ -118,7 +118,9 @@ class RevertAction extends FormAction { $this->useTransactionalTimeLimit(); $old = $this->getRequest()->getText( 'oldimage' ); + /** @var LocalFile $localFile */ $localFile = $this->page->getFile(); + '@phan-var LocalFile $localFile'; $oldFile = OldLocalFile::newFromArchiveName( $this->getTitle(), $localFile->getRepo(), $old ); $source = $localFile->getArchiveVirtualUrl( $old ); diff --git a/includes/api/ApiDelete.php b/includes/api/ApiDelete.php index 0e13d705ff..ad171c66de 100644 --- a/includes/api/ApiDelete.php +++ b/includes/api/ApiDelete.php @@ -42,6 +42,7 @@ class ApiDelete extends ApiBase { $pageObj = $this->getTitleOrPageId( $params, 'fromdbmaster' ); $titleObj = $pageObj->getTitle(); if ( !$pageObj->exists() && + // @phan-suppress-next-line PhanUndeclaredMethod !( $titleObj->getNamespace() == NS_FILE && self::canDeleteFile( $pageObj->getFile() ) ) ) { $this->dieWithError( 'apierror-missingtitle' ); @@ -156,6 +157,7 @@ class ApiDelete extends ApiBase { ) { $title = $page->getTitle(); + // @phan-suppress-next-line PhanUndeclaredMethod There's no right typehint for it $file = $page->getFile(); if ( !self::canDeleteFile( $file ) ) { return self::delete( $page, $user, $reason, $tags ); diff --git a/includes/api/ApiErrorFormatter.php b/includes/api/ApiErrorFormatter.php index 8049cd84b9..81ee9b9932 100644 --- a/includes/api/ApiErrorFormatter.php +++ b/includes/api/ApiErrorFormatter.php @@ -26,6 +26,7 @@ * ApiResult. * @since 1.25 * @ingroup API + * @phan-file-suppress PhanUndeclaredMethod Undeclared methods in IApiMessage */ class ApiErrorFormatter { /** @var Title Dummy title to silence warnings from MessageCache::parse() */ diff --git a/includes/api/ApiExpandTemplates.php b/includes/api/ApiExpandTemplates.php index 851373d5e3..1c7f63d000 100644 --- a/includes/api/ApiExpandTemplates.php +++ b/includes/api/ApiExpandTemplates.php @@ -104,8 +104,10 @@ class ApiExpandTemplates extends ApiBase { $parser->startExternalParse( $titleObj, $options, Parser::OT_PREPROCESS ); $dom = $parser->preprocessToDom( $params['text'] ); if ( is_callable( [ $dom, 'saveXML' ] ) ) { + // @phan-suppress-next-line PhanUndeclaredMethod $xml = $dom->saveXML(); } else { + // @phan-suppress-next-line PhanUndeclaredMethod $xml = $dom->__toString(); } if ( isset( $prop['parsetree'] ) ) { diff --git a/includes/api/ApiFeedWatchlist.php b/includes/api/ApiFeedWatchlist.php index c4977f4115..953c4d8d93 100644 --- a/includes/api/ApiFeedWatchlist.php +++ b/includes/api/ApiFeedWatchlist.php @@ -150,6 +150,7 @@ class ApiFeedWatchlist extends ApiBase { if ( $e instanceof ApiUsageException ) { foreach ( $e->getStatusValue()->getErrors() as $error ) { + // @phan-suppress-next-line PhanUndeclaredMethod $msg = ApiMessage::create( $error ) ->inLanguage( $this->getLanguage() ); $errorTitle = $this->msg( 'api-feed-error-title', $msg->getApiCode() ); diff --git a/includes/api/ApiImageRotate.php b/includes/api/ApiImageRotate.php index ccb26a8392..1f8b012ef2 100644 --- a/includes/api/ApiImageRotate.php +++ b/includes/api/ApiImageRotate.php @@ -104,6 +104,7 @@ class ApiImageRotate extends ApiBase { $tmpFile = MediaWikiServices::getInstance()->getTempFSFileFactory() ->newTempFSFile( 'rotate_', $ext ); $dstPath = $tmpFile->getPath(); + // @phan-suppress-next-line PhanUndeclaredMethod $err = $handler->rotate( $file, [ 'srcPath' => $srcPath, 'dstPath' => $dstPath, @@ -113,6 +114,7 @@ class ApiImageRotate extends ApiBase { $comment = wfMessage( 'rotate-comment' )->numParams( $rotation )->inContentLanguage()->text(); + // @phan-suppress-next-line PhanUndeclaredMethod $status = $file->upload( $dstPath, $comment, diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 574d83bd18..efa4b04bbb 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -167,6 +167,7 @@ class ApiMain extends ApiBase { * @param IContextSource|WebRequest|null $context If this is an instance of * FauxRequest, errors are thrown and no printing occurs * @param bool $enableWrite Should be set to true if the api may modify data + * @suppress PhanUndeclaredMethod */ public function __construct( $context = null, $enableWrite = false ) { if ( $context === null ) { diff --git a/includes/api/ApiMessageTrait.php b/includes/api/ApiMessageTrait.php index 147b3bd6dc..528a8b5ac2 100644 --- a/includes/api/ApiMessageTrait.php +++ b/includes/api/ApiMessageTrait.php @@ -23,6 +23,7 @@ * @since 1.27 * @ingroup API * @phan-file-suppress PhanTraitParentReference + * @phan-file-suppress PhanUndeclaredMethod */ trait ApiMessageTrait { diff --git a/includes/api/ApiOpenSearch.php b/includes/api/ApiOpenSearch.php index 0ba4a0e4a5..7fcb818418 100644 --- a/includes/api/ApiOpenSearch.php +++ b/includes/api/ApiOpenSearch.php @@ -71,6 +71,7 @@ class ApiOpenSearch extends ApiBase { case 'xml': $printer = $this->getMain()->createPrinterByName( 'xml' . $this->fm ); + '@phan-var ApiFormatXML $printer'; $printer->setRootElement( 'SearchSuggestion' ); return $printer; @@ -112,7 +113,7 @@ class ApiOpenSearch extends ApiBase { * @param string $search the search query * @param array $params api request params * @return array search results. Keys are integers. - * @phan-return array + * @phan-return array * Note that phan annotations don't support keys containing a space. */ private function search( $search, array $params ) { diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index a7390e617a..40edafa687 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -491,6 +491,7 @@ class ApiParse extends ApiBase { $parser = MediaWikiServices::getInstance()->getParser(); $parser->startExternalParse( $titleObj, $popts, Parser::OT_PREPROCESS ); + // @phan-suppress-next-line PhanUndeclaredMethod $xml = $parser->preprocessToDom( $this->content->getText() )->__toString(); $result_array['parsetree'] = $xml; $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'parsetree'; diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php index bdb0dc22aa..c78e445f42 100644 --- a/includes/api/ApiQuery.php +++ b/includes/api/ApiQuery.php @@ -223,7 +223,9 @@ class ApiQuery extends ApiBase { // Filter modules based on continue parameter $continuationManager = new ApiContinuationManager( $this, $allModules, $propModules ); $this->setContinuationManager( $continuationManager ); + /** @var ApiQueryBase[] $modules */ $modules = $continuationManager->getRunModules(); + '@phan-var ApiQueryBase[] $modules'; if ( !$continuationManager->isGeneratorDone() ) { // Query modules may optimize data requests through the $this->getPageSet() @@ -242,7 +244,6 @@ class ApiQuery extends ApiBase { $cacheMode = $this->mPageSet->getCacheMode(); // Execute all unfinished modules - /** @var ApiQueryBase $module */ foreach ( $modules as $module ) { $params = $module->extractRequestParams(); $cacheMode = $this->mergeCacheMode( diff --git a/includes/api/ApiQueryBlocks.php b/includes/api/ApiQueryBlocks.php index c5a8d0825f..f9da9a3108 100644 --- a/includes/api/ApiQueryBlocks.php +++ b/includes/api/ApiQueryBlocks.php @@ -305,6 +305,8 @@ class ApiQueryBlocks extends ApiQueryBase { $id = $restriction->getBlockId(); switch ( $restriction->getType() ) { case 'page': + /** @var \MediaWiki\Block\Restriction\PageRestriction $restriction */ + '@phan-var \MediaWiki\Block\Restriction\PageRestriction $restriction'; $value = [ 'id' => $restriction->getValue() ]; if ( $restriction->getTitle() ) { self::addTitleInfo( $value, $restriction->getTitle() ); diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index 5e737c3c0e..97a9b0a5b5 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -523,6 +523,8 @@ class ApiQueryImageInfo extends ApiQueryBase { $vals['thumbmime'] = $mime; } } elseif ( $mto && $mto->isError() ) { + /** @var MediaTransformError $mto */ + '@phan-var MediaTransformError $mto'; $vals['thumberror'] = $mto->toText(); } } @@ -562,6 +564,7 @@ class ApiQueryImageInfo extends ApiQueryBase { // Thus there should be no issue with format=xml. $format = new FormatMetadata; $format->setSingleLanguage( !$opts['multilang'] ); + // @phan-suppress-next-line PhanUndeclaredMethod $format->getContext()->setLanguage( $opts['language'] ); $extmetaArray = $format->fetchExtendedMetadata( $file ); if ( $opts['extmetadatafilter'] ) { @@ -581,6 +584,8 @@ class ApiQueryImageInfo extends ApiQueryBase { } if ( $archive && $file->isOld() ) { + /** @var OldLocalFile $file */ + '@phan-var OldLocalFile $file'; $vals['archivename'] = $file->getArchiveName(); } diff --git a/includes/api/ApiQueryRevisionsBase.php b/includes/api/ApiQueryRevisionsBase.php index 0d284c0c01..7c92b3565a 100644 --- a/includes/api/ApiQueryRevisionsBase.php +++ b/includes/api/ApiQueryRevisionsBase.php @@ -501,6 +501,8 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { if ( $this->fld_parsetree || ( $this->fld_content && $this->generateXML ) ) { if ( $content->getModel() === CONTENT_MODEL_WIKITEXT ) { + /** @var WikitextContent $content */ + '@phan-var WikitextContent $content'; $t = $content->getText(); # note: don't set $text $parser = MediaWikiServices::getInstance()->getParser(); @@ -511,8 +513,10 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { ); $dom = $parser->preprocessToDom( $t ); if ( is_callable( [ $dom, 'saveXML' ] ) ) { + // @phan-suppress-next-line PhanUndeclaredMethod $xml = $dom->saveXML(); } else { + // @phan-suppress-next-line PhanUndeclaredMethod $xml = $dom->__toString(); } $vals['parsetree'] = $xml; @@ -534,6 +538,8 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { if ( $this->expandTemplates && !$this->parseContent ) { if ( $content->getModel() === CONTENT_MODEL_WIKITEXT ) { + /** @var WikitextContent $content */ + '@phan-var WikitextContent $content'; $text = $content->getText(); $text = MediaWikiServices::getInstance()->getParser()->preprocess( diff --git a/includes/auth/RememberMeAuthenticationRequest.php b/includes/auth/RememberMeAuthenticationRequest.php index 06060b16f9..39bcbf3e77 100644 --- a/includes/auth/RememberMeAuthenticationRequest.php +++ b/includes/auth/RememberMeAuthenticationRequest.php @@ -43,6 +43,7 @@ class RememberMeAuthenticationRequest extends AuthenticationRequest { public function __construct() { /** @var SessionProvider $provider */ $provider = SessionManager::getGlobalSession()->getProvider(); + '@phan-var SessionProvider $provider'; $this->expiration = $provider->getRememberUserDuration(); } diff --git a/includes/block/BlockManager.php b/includes/block/BlockManager.php index 83b59c7e59..e27ebac7ef 100644 --- a/includes/block/BlockManager.php +++ b/includes/block/BlockManager.php @@ -223,6 +223,8 @@ class BlockManager { if ( $block instanceof SystemBlock ) { $systemBlocks[] = $block; } elseif ( $block->getType() === DatabaseBlock::TYPE_AUTO ) { + /** @var DatabaseBlock $block */ + '@phan-var DatabaseBlock $block'; if ( !isset( $databaseBlocks[$block->getParentBlockId()] ) ) { $databaseBlocks[$block->getParentBlockId()] = $block; } diff --git a/includes/block/Restriction/PageRestriction.php b/includes/block/Restriction/PageRestriction.php index 45aab46b7a..78d67228d9 100644 --- a/includes/block/Restriction/PageRestriction.php +++ b/includes/block/Restriction/PageRestriction.php @@ -87,7 +87,9 @@ class PageRestriction extends AbstractRestriction { * @inheritDoc */ public static function newFromRow( \stdClass $row ) { + /** @var self $restriction */ $restriction = parent::newFromRow( $row ); + '@phan-var self $restriction'; // If the page_namespace and the page_title were provided, add the title to // the restriction. diff --git a/includes/block/Restriction/Restriction.php b/includes/block/Restriction/Restriction.php index d717fe7e86..5dddd785d1 100644 --- a/includes/block/Restriction/Restriction.php +++ b/includes/block/Restriction/Restriction.php @@ -70,7 +70,7 @@ interface Restriction { * * @since 1.33 * @param \stdClass $row - * @return self + * @return static */ public static function newFromRow( \stdClass $row ); diff --git a/includes/changes/ChangesListBooleanFilterGroup.php b/includes/changes/ChangesListBooleanFilterGroup.php index 4401378b28..59f59d1541 100644 --- a/includes/changes/ChangesListBooleanFilterGroup.php +++ b/includes/changes/ChangesListBooleanFilterGroup.php @@ -8,6 +8,7 @@ use Wikimedia\Rdbms\IDatabase; * but 'Bot' is unchecked, hidebots=1 will be sent. * * @since 1.29 + * @method ChangesListBooleanFilter[] getFilters() */ class ChangesListBooleanFilterGroup extends ChangesListFilterGroup { /** @@ -55,6 +56,7 @@ class ChangesListBooleanFilterGroup extends ChangesListFilterGroup { * Registers a filter in this group * * @param ChangesListBooleanFilter $filter + * @suppress PhanParamSignaturePHPDocMismatchHasParamType,PhanParamSignatureMismatch */ public function registerFilter( ChangesListBooleanFilter $filter ) { $this->filters[$filter->getName()] = $filter; diff --git a/includes/changes/ChangesListFilterGroup.php b/includes/changes/ChangesListFilterGroup.php index ec863073d5..5f0cd221ff 100644 --- a/includes/changes/ChangesListFilterGroup.php +++ b/includes/changes/ChangesListFilterGroup.php @@ -32,6 +32,7 @@ use Wikimedia\Rdbms\IDatabase; * Represents a filter group (used on ChangesListSpecialPage and descendants) * * @since 1.29 + * @method registerFilter($filter) */ abstract class ChangesListFilterGroup { /** diff --git a/includes/changes/ChangesListStringOptionsFilterGroup.php b/includes/changes/ChangesListStringOptionsFilterGroup.php index e06f0817ba..b18ae61ec1 100644 --- a/includes/changes/ChangesListStringOptionsFilterGroup.php +++ b/includes/changes/ChangesListStringOptionsFilterGroup.php @@ -155,6 +155,7 @@ class ChangesListStringOptionsFilterGroup extends ChangesListFilterGroup { * Registers a filter in this group * * @param ChangesListStringOptionsFilter $filter + * @suppress PhanParamSignaturePHPDocMismatchHasParamType,PhanParamSignatureMismatch */ public function registerFilter( ChangesListStringOptionsFilter $filter ) { $this->filters[$filter->getName()] = $filter; diff --git a/includes/changetags/ChangeTagsList.php b/includes/changetags/ChangeTagsList.php index 89f8f76350..fc53d13ed3 100644 --- a/includes/changetags/ChangeTagsList.php +++ b/includes/changetags/ChangeTagsList.php @@ -21,6 +21,12 @@ /** * Generic list for change tagging. + * + * @property ChangeTagsLogItem $current + * @method ChangeTagsLogItem next() + * @method ChangeTagsLogItem reset() + * @method ChangeTagsLogItem current() + * @phan-file-suppress PhanParamSignatureMismatch */ abstract class ChangeTagsList extends RevisionListBase { function __construct( IContextSource $context, Title $title, array $ids ) { diff --git a/includes/content/TextContent.php b/includes/content/TextContent.php index 71dd35c84d..54a57a55e6 100644 --- a/includes/content/TextContent.php +++ b/includes/content/TextContent.php @@ -155,7 +155,9 @@ class TextContent extends AbstractContent { * @return string|bool The raw text, or false if the conversion failed. */ public function getWikitextForTransclusion() { + /** @var WikitextContent $wikitext */ $wikitext = $this->convert( CONTENT_MODEL_WIKITEXT, 'lossy' ); + '@phan-var WikitextContent $wikitext'; if ( $wikitext ) { return $wikitext->getText(); @@ -214,7 +216,8 @@ class TextContent extends AbstractContent { */ public function diff( Content $that, Language $lang = null ) { $this->checkModelID( $that->getModel() ); - + /** @var self $that */ + '@phan-var self $that'; // @todo could implement this in DifferenceEngine and just delegate here? if ( !$lang ) { diff --git a/includes/content/TextContentHandler.php b/includes/content/TextContentHandler.php index e3dc187ffe..e48dd511b8 100644 --- a/includes/content/TextContentHandler.php +++ b/includes/content/TextContentHandler.php @@ -45,6 +45,7 @@ class TextContentHandler extends ContentHandler { public function serializeContent( Content $content, $format = null ) { $this->checkFormat( $format ); + // @phan-suppress-next-line PhanUndeclaredMethod return $content->getText(); } diff --git a/includes/content/UnknownContentHandler.php b/includes/content/UnknownContentHandler.php index 1427e2b3bd..a5be21c764 100644 --- a/includes/content/UnknownContentHandler.php +++ b/includes/content/UnknownContentHandler.php @@ -68,6 +68,7 @@ class UnknownContentHandler extends ContentHandler { */ public function serializeContent( Content $content, $format = null ) { /** @var UnknownContent $content */ + '@phan-var UnknownContent $content'; return $content->getData(); } diff --git a/includes/content/WikitextContent.php b/includes/content/WikitextContent.php index 70b638b4b4..a760a1b52f 100644 --- a/includes/content/WikitextContent.php +++ b/includes/content/WikitextContent.php @@ -89,6 +89,8 @@ class WikitextContent extends TextContent { "document uses $myModelId but " . "section uses $sectionModelId." ); } + /** @var self $with $oldtext */ + '@phan-var self $with'; $oldtext = $this->getText(); $text = $with->getText(); diff --git a/includes/deferred/DeferredUpdates.php b/includes/deferred/DeferredUpdates.php index 3380364b6d..3716971bca 100644 --- a/includes/deferred/DeferredUpdates.php +++ b/includes/deferred/DeferredUpdates.php @@ -161,6 +161,7 @@ class DeferredUpdates { if ( isset( $queue[$class] ) ) { /** @var MergeableUpdate $existingUpdate */ $existingUpdate = $queue[$class]; + '@phan-var MergeableUpdate $existingUpdate'; $existingUpdate->merge( $update ); // Move the update to the end to handle things like mergeable purge // updates that might depend on the prior updates in the queue running diff --git a/includes/diff/TextSlotDiffRenderer.php b/includes/diff/TextSlotDiffRenderer.php index 935172a11a..ef8058cd4f 100644 --- a/includes/diff/TextSlotDiffRenderer.php +++ b/includes/diff/TextSlotDiffRenderer.php @@ -67,6 +67,7 @@ class TextSlotDiffRenderer extends SlotDiffRenderer { /** @var TextSlotDiffRenderer $slotDiffRenderer */ $slotDiffRenderer = ContentHandler::getForModelID( CONTENT_MODEL_TEXT ) ->getSlotDiffRenderer( RequestContext::getMain() ); + '@phan-var TextSlotDiffRenderer $slotDiffRenderer'; return $slotDiffRenderer->getTextDiff( $oldText, $newText ); } diff --git a/includes/export/WikiExporter.php b/includes/export/WikiExporter.php index 3ab88e2927..ec0b344e3c 100644 --- a/includes/export/WikiExporter.php +++ b/includes/export/WikiExporter.php @@ -30,7 +30,6 @@ use MediaWiki\MediaWikiServices as MediaWikiServicesAlias; use MediaWiki\Storage\RevisionRecord; use Wikimedia\Rdbms\IResultWrapper; -use Wikimedia\Rdbms\IDatabase; /** * @ingroup SpecialPage Dump @@ -68,7 +67,7 @@ class WikiExporter { /** @var XmlDumpWriter */ private $writer; - /** @var IDatabase */ + /** @var Database */ protected $db; /** @var array|int */ @@ -87,7 +86,7 @@ class WikiExporter { } /** - * @param IDatabase $db + * @param Database $db * @param int|array $history One of WikiExporter::FULL, WikiExporter::CURRENT, * WikiExporter::RANGE or WikiExporter::STABLE, or an associative array: * - offset: non-inclusive offset at which to start the query diff --git a/includes/export/XmlDumpWriter.php b/includes/export/XmlDumpWriter.php index 000350662b..e697ef2197 100644 --- a/includes/export/XmlDumpWriter.php +++ b/includes/export/XmlDumpWriter.php @@ -658,6 +658,8 @@ class XmlDumpWriter { */ function writeUpload( $file, $dumpContents = false ) { if ( $file->isOld() ) { + /** @var OldLocalFile $file */ + '@phan-var OldLocalFile $file'; $archiveName = " " . Xml::element( 'archivename', null, $file->getArchiveName() ) . "\n"; } else { diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php index d14e0ded00..0d5776bba2 100644 --- a/includes/filerepo/file/File.php +++ b/includes/filerepo/file/File.php @@ -1172,6 +1172,7 @@ abstract class File implements IDBAccessObject { $thumb = false; } elseif ( $thumb->isError() ) { // transform error /** @var MediaTransformError $thumb */ + '@phan-var MediaTransformError $thumb'; $this->lastError = $thumb->toText(); // Ignore errors if requested if ( $wgIgnoreImageErrors && !( $flags & self::RENDER_NOW ) ) { diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index 0ef6034544..4751a59031 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -1868,6 +1868,7 @@ class LocalFile extends File { : FSFile::getSha1Base36FromPath( $srcPath ); /** @var FileBackendDBRepoWrapper $wrapperBackend */ $wrapperBackend = $repo->getBackend(); + '@phan-var FileBackendDBRepoWrapper $wrapperBackend'; $dst = $wrapperBackend->getPathForSHA1( $sha1 ); $status = $repo->quickImport( $src, $dst ); if ( $flags & File::DELETE_SOURCE ) { @@ -1937,6 +1938,7 @@ class LocalFile extends File { $oldTitleFile->purgeEverything(); foreach ( $archiveNames as $archiveName ) { /** @var OldLocalFile $oldTitleFile */ + '@phan-var OldLocalFile $oldTitleFile'; $oldTitleFile->purgeOldThumbnails( $archiveName ); } $newTitleFile->purgeEverything(); diff --git a/includes/filerepo/file/LocalFileMoveBatch.php b/includes/filerepo/file/LocalFileMoveBatch.php index 21980b90eb..137119d2bc 100644 --- a/includes/filerepo/file/LocalFileMoveBatch.php +++ b/includes/filerepo/file/LocalFileMoveBatch.php @@ -126,8 +126,10 @@ class LocalFileMoveBatch { public function execute() { $repo = $this->file->repo; $status = $repo->newGood(); + /** @var LocalFile $destFile */ $destFile = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo() ->newFile( $this->target ); + '@phan-var LocalFile $destFile'; $this->file->lock(); $destFile->lock(); // quickly fail if destination is not available diff --git a/includes/htmlform/HTMLFormElement.php b/includes/htmlform/HTMLFormElement.php index b77c17e964..1e4460a022 100644 --- a/includes/htmlform/HTMLFormElement.php +++ b/includes/htmlform/HTMLFormElement.php @@ -5,6 +5,7 @@ * (defined in htmlform.Element.js) picks up the extra config when constructed using OO.ui.infuse(). * * Currently only supports passing 'hide-if' data. + * @phan-file-suppress PhanUndeclaredMethod */ trait HTMLFormElement { diff --git a/includes/http/MWHttpRequest.php b/includes/http/MWHttpRequest.php index 3a2f982a04..3885c0319a 100644 --- a/includes/http/MWHttpRequest.php +++ b/includes/http/MWHttpRequest.php @@ -373,7 +373,7 @@ abstract class MWHttpRequest implements LoggerAwareInterface { /** * Take care of whatever is necessary to perform the URI request. * - * @return StatusValue + * @return Status * @note currently returns Status for B/C */ public function execute() { diff --git a/includes/import/ImportableUploadRevisionImporter.php b/includes/import/ImportableUploadRevisionImporter.php index 4be13b0a2c..e5f4b5748a 100644 --- a/includes/import/ImportableUploadRevisionImporter.php +++ b/includes/import/ImportableUploadRevisionImporter.php @@ -114,6 +114,7 @@ class ImportableUploadRevisionImporter implements UploadRevisionImporter { $user ); } else { + '@phan-var LocalFile $file'; $flags = 0; $status = $file->upload( $source, diff --git a/includes/installer/DatabaseInstaller.php b/includes/installer/DatabaseInstaller.php index 8b94d977a6..ac8c9e6745 100644 --- a/includes/installer/DatabaseInstaller.php +++ b/includes/installer/DatabaseInstaller.php @@ -177,6 +177,7 @@ abstract class DatabaseInstaller { * This will return a cached connection if one is available. * * @return Status + * @suppress PhanUndeclaredMethod */ public function getConnection() { if ( $this->db ) { @@ -341,6 +342,7 @@ abstract class DatabaseInstaller { public function setupSchemaVars() { $status = $this->getConnection(); if ( $status->isOK() ) { + // @phan-suppress-next-line PhanUndeclaredMethod $status->value->setSchemaVars( $this->getSchemaVars() ); } else { $msg = __METHOD__ . ': unexpected error while establishing' diff --git a/includes/installer/DatabaseUpdater.php b/includes/installer/DatabaseUpdater.php index 8a9cd05871..e1df8444d9 100644 --- a/includes/installer/DatabaseUpdater.php +++ b/includes/installer/DatabaseUpdater.php @@ -1233,6 +1233,7 @@ abstract class DatabaseUpdater { $cl = $this->maintenance->runChild( RebuildLocalisationCache::class, 'rebuildLocalisationCache.php' ); + '@phan-var RebuildLocalisationCache $cl'; $this->output( "Rebuilding localisation cache...\n" ); $cl->setForce(); $cl->execute(); @@ -1292,6 +1293,7 @@ abstract class DatabaseUpdater { $task = $this->maintenance->runChild( MigrateImageCommentTemp::class, 'migrateImageCommentTemp.php' ); + // @phan-suppress-next-line PhanUndeclaredMethod $task->setForce(); $ok = $task->execute(); $this->output( $ok ? "done.\n" : "errors were encountered.\n" ); @@ -1329,6 +1331,7 @@ abstract class DatabaseUpdater { if ( $this->db->fieldExists( 'archive', 'ar_text', __METHOD__ ) ) { $this->output( "Migrating archive ar_text to modern storage.\n" ); $task = $this->maintenance->runChild( MigrateArchiveText::class, 'migrateArchiveText.php' ); + // @phan-suppress-next-line PhanUndeclaredMethod $task->setForce(); if ( $task->execute() ) { $this->applyPatch( 'patch-drop-ar_text.sql', false, diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 289a721e92..ccc548b7de 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -731,6 +731,7 @@ abstract class Installer { if ( !$status->isOK() ) { return $status; } + // @phan-suppress-next-line PhanUndeclaredMethod $status->value->insert( 'site_stats', [ diff --git a/includes/installer/MysqlInstaller.php b/includes/installer/MysqlInstaller.php index 69d03bde6c..383f8d8fc6 100644 --- a/includes/installer/MysqlInstaller.php +++ b/includes/installer/MysqlInstaller.php @@ -131,6 +131,7 @@ class MysqlInstaller extends DatabaseInstaller { * @var Database $conn */ $conn = $status->value; + '@phan-var Database $conn'; // Check version return static::meetsMinimumRequirement( $conn->getServerVersion() ); diff --git a/includes/installer/MysqlUpdater.php b/includes/installer/MysqlUpdater.php index c33d3ddc3c..0d516b48fe 100644 --- a/includes/installer/MysqlUpdater.php +++ b/includes/installer/MysqlUpdater.php @@ -29,6 +29,7 @@ use MediaWiki\MediaWikiServices; * * @ingroup Deployment * @since 1.17 + * @property DatabaseMysqlBase $db */ class MysqlUpdater extends DatabaseUpdater { protected function getCoreUpdateList() { diff --git a/includes/installer/PostgresInstaller.php b/includes/installer/PostgresInstaller.php index d6a5145cda..9a3d4a384a 100644 --- a/includes/installer/PostgresInstaller.php +++ b/includes/installer/PostgresInstaller.php @@ -353,6 +353,7 @@ class PostgresInstaller extends DatabaseInstaller { if ( !$status->isOK() ) { return $status; } + // @phan-suppress-next-line PhanUndeclaredMethod $exists = $status->value->roleExists( $this->getVar( 'wgDBuser' ) ); } @@ -507,6 +508,7 @@ class PostgresInstaller extends DatabaseInstaller { } /** @var DatabasePostgres $conn */ $conn = $status->value; + '@phan-var DatabasePostgres $conn'; // Create the schema if necessary $schema = $this->getVar( 'wgDBmwschema' ); @@ -542,7 +544,9 @@ class PostgresInstaller extends DatabaseInstaller { if ( !$status->isOK() ) { return $status; } + /** @var DatabasePostgres $conn */ $conn = $status->value; + '@phan-var DatabasePostgres $conn'; $safeuser = $conn->addIdentifierQuotes( $this->getVar( 'wgDBuser' ) ); $safepass = $conn->addQuotes( $this->getVar( 'wgDBpassword' ) ); @@ -599,6 +603,7 @@ class PostgresInstaller extends DatabaseInstaller { /** @var DatabasePostgres $conn */ $conn = $status->value; + '@phan-var DatabasePostgres $conn'; if ( $conn->tableExists( 'archive' ) ) { $status->warning( 'config-install-tables-exist' ); diff --git a/includes/installer/WebInstaller.php b/includes/installer/WebInstaller.php index db26c0b63d..b6e90a9b45 100644 --- a/includes/installer/WebInstaller.php +++ b/includes/installer/WebInstaller.php @@ -188,7 +188,9 @@ class WebInstaller extends Installer { # Special case for Creative Commons partner chooser box. if ( $this->request->getVal( 'SubmitCC' ) ) { + /** @var WebInstallerOptions $page */ $page = $this->getPageByName( 'Options' ); + '@phan-var WebInstallerOptions $page'; $this->output->useShortHeader(); $this->output->allowFrames(); $page->submitCC(); @@ -197,7 +199,9 @@ class WebInstaller extends Installer { } if ( $this->request->getVal( 'ShowCC' ) ) { + /** @var WebInstallerOptions $page */ $page = $this->getPageByName( 'Options' ); + '@phan-var WebInstallerOptions $page'; $this->output->useShortHeader(); $this->output->allowFrames(); $this->output->addHTML( $page->getCCDoneBox() ); diff --git a/includes/installer/WebInstallerOutput.php b/includes/installer/WebInstallerOutput.php index 991e484da7..51d4250b12 100644 --- a/includes/installer/WebInstallerOutput.php +++ b/includes/installer/WebInstallerOutput.php @@ -168,6 +168,7 @@ class WebInstallerOutput { foreach ( $moduleNames as $moduleName ) { /** @var ResourceLoaderFileModule $module */ $module = $resourceLoader->getModule( $moduleName ); + '@phan-var ResourceLoaderFileModule $module'; if ( !$module ) { // T98043: Don't fatal, but it won't look as pretty. continue; diff --git a/includes/page/ImageHistoryList.php b/includes/page/ImageHistoryList.php index dc755410e1..9edacccd52 100644 --- a/includes/page/ImageHistoryList.php +++ b/includes/page/ImageHistoryList.php @@ -120,6 +120,7 @@ class ImageHistoryList extends ContextSource { $lang = $this->getLanguage(); $pm = MediaWikiServices::getInstance()->getPermissionManager(); $timestamp = wfTimestamp( TS_MW, $file->getTimestamp() ); + // @phan-suppress-next-line PhanUndeclaredMethod $img = $iscur ? $file->getName() : $file->getArchiveName(); $userId = $file->getUser( 'id' ); $userText = $file->getUser( 'text' ); diff --git a/includes/page/ImagePage.php b/includes/page/ImagePage.php index d3f063877f..2f6d4da028 100644 --- a/includes/page/ImagePage.php +++ b/includes/page/ImagePage.php @@ -29,6 +29,7 @@ use Wikimedia\Rdbms\ResultWrapper; * @ingroup Media * * @property WikiFilePage $mPage Set by overwritten newPage() in this class + * @method WikiFilePage getPage() */ class ImagePage extends Article { /** @var File|false */ diff --git a/includes/page/Page.php b/includes/page/Page.php index 2cb1fc0389..52b2719735 100644 --- a/includes/page/Page.php +++ b/includes/page/Page.php @@ -20,6 +20,11 @@ /** * Interface for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage) + * + * @method array getActionOverrides() + * @method string getUserText($audience=1,User $user=null) + * @method string getTimestamp() + * @method Title getTitle() */ interface Page { } diff --git a/includes/parser/PPDPart_Hash.php b/includes/parser/PPDPart_Hash.php index 327dd77a68..d4f66f7a48 100644 --- a/includes/parser/PPDPart_Hash.php +++ b/includes/parser/PPDPart_Hash.php @@ -21,6 +21,7 @@ /** * @ingroup Parser + * @property string[] $out */ // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps class PPDPart_Hash extends PPDPart { diff --git a/includes/parser/PPDStack.php b/includes/parser/PPDStack.php index adc0bc0014..68f1bb27bf 100644 --- a/includes/parser/PPDStack.php +++ b/includes/parser/PPDStack.php @@ -24,10 +24,12 @@ * @ingroup Parser */ class PPDStack { - public $stack, $rootAccum; + /** @var PPDStackElement[] */ + public $stack; + public $rootAccum; /** - * @var PPDStack|false + * @var PPDStackElement|false */ public $top; public $out; diff --git a/includes/parser/PPDStackElement_Hash.php b/includes/parser/PPDStackElement_Hash.php index 816548ce7d..750049de4d 100644 --- a/includes/parser/PPDStackElement_Hash.php +++ b/includes/parser/PPDStackElement_Hash.php @@ -21,6 +21,7 @@ /** * @ingroup Parser + * @property PPDPart_Hash[] $parts */ // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps class PPDStackElement_Hash extends PPDStackElement { @@ -39,7 +40,6 @@ class PPDStackElement_Hash extends PPDStackElement { */ public function breakSyntax( $openingCount = false ) { if ( $this->open == "\n" ) { - // @phan-suppress-next-line PhanTypeMismatchArgumentInternal $accum = array_merge( [ $this->savedPrefix ], $this->parts[0]->out ); } else { if ( $openingCount === false ) { @@ -61,7 +61,7 @@ class PPDStackElement_Hash extends PPDStackElement { } else { $accum[++$lastIndex] = '|'; } - // @phan-suppress-next-line PhanTypeMismatchForeach + foreach ( $part->out as $node ) { if ( is_string( $node ) && is_string( $accum[$lastIndex] ) ) { $accum[$lastIndex] .= $node; diff --git a/includes/parser/PPFrame_DOM.php b/includes/parser/PPFrame_DOM.php index 00bfe98959..ac3a26642c 100644 --- a/includes/parser/PPFrame_DOM.php +++ b/includes/parser/PPFrame_DOM.php @@ -23,6 +23,7 @@ * An expansion frame, used as a context to expand the result of preprocessToObj() * @deprecated since 1.34, use PPFrame_Hash * @ingroup Parser + * @phan-file-suppress PhanUndeclaredMethod */ // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps class PPFrame_DOM implements PPFrame { diff --git a/includes/parser/PPNode_DOM.php b/includes/parser/PPNode_DOM.php index 53b17617bb..ae7f8a2ca6 100644 --- a/includes/parser/PPNode_DOM.php +++ b/includes/parser/PPNode_DOM.php @@ -22,6 +22,7 @@ /** * @deprecated since 1.34, use PPNode_Hash_{Tree,Text,Array,Attr} * @ingroup Parser + * @phan-file-suppress PhanUndeclaredMethod */ // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps class PPNode_DOM implements PPNode { diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 962313e43e..5c55124492 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -6192,7 +6192,9 @@ class Parser { */ private static function normalizeSectionName( $text ) { # T90902: ensure the same normalization is applied for IDs as to links + /** @var MediaWikiTitleCodec $titleParser */ $titleParser = MediaWikiServices::getInstance()->getTitleParser(); + '@phan-var MediaWikiTitleCodec $titleParser'; try { $parts = $titleParser->splitTitleString( "#$text" ); diff --git a/includes/parser/Preprocessor_Hash.php b/includes/parser/Preprocessor_Hash.php index f7f37ac044..9f4b7c73f0 100644 --- a/includes/parser/Preprocessor_Hash.php +++ b/includes/parser/Preprocessor_Hash.php @@ -628,7 +628,9 @@ class Preprocessor_Hash extends Preprocessor { } $i += $count; } elseif ( $found == 'close' ) { + /** @var PPDStackElement_Hash $piece */ $piece = $stack->top; + '@phan-var PPDStackElement_Hash $piece'; # lets check if there are enough characters for closing brace $maxCount = $piece->count; if ( $piece->close === '}-' && $curChar === '}' ) { diff --git a/includes/password/LayeredParameterizedPassword.php b/includes/password/LayeredParameterizedPassword.php index f3d8d03e30..389b8c3865 100644 --- a/includes/password/LayeredParameterizedPassword.php +++ b/includes/password/LayeredParameterizedPassword.php @@ -59,6 +59,7 @@ class LayeredParameterizedPassword extends ParameterizedPassword { // Construct pseudo-hash based on params and arguments /** @var ParameterizedPassword $passObj */ $passObj = $this->factory->newFromType( $type ); + '@phan-var ParameterizedPassword $passObj'; $params = ''; $args = ''; @@ -72,6 +73,7 @@ class LayeredParameterizedPassword extends ParameterizedPassword { // Hash the last hash with the next type in the layer $passObj = $this->factory->newFromCiphertext( $existingHash ); + '@phan-var ParameterizedPassword $passObj'; $passObj->crypt( $lastHash ); // Move over the params and args @@ -114,6 +116,7 @@ class LayeredParameterizedPassword extends ParameterizedPassword { // Construct pseudo-hash based on params and arguments /** @var ParameterizedPassword $passObj */ $passObj = $this->factory->newFromType( $type ); + '@phan-var ParameterizedPassword $passObj'; $params = ''; $args = ''; @@ -127,6 +130,7 @@ class LayeredParameterizedPassword extends ParameterizedPassword { // Hash the last hash with the next type in the layer $passObj = $this->factory->newFromCiphertext( $existingHash ); + '@phan-var ParameterizedPassword $passObj'; $passObj->crypt( $lastHash ); // Move over the params and args diff --git a/includes/poolcounter/PoolCounterRedis.php b/includes/poolcounter/PoolCounterRedis.php index f5fa4c7319..c89dc15693 100644 --- a/includes/poolcounter/PoolCounterRedis.php +++ b/includes/poolcounter/PoolCounterRedis.php @@ -152,7 +152,9 @@ class PoolCounterRedis extends PoolCounter { if ( !$status->isOK() ) { return $status; } + /** @var RedisConnRef $conn */ $conn = $status->value; + '@phan-var RedisConnRef $conn'; // phpcs:disable Generic.Files.LineLength static $script = @@ -238,7 +240,9 @@ LUA; if ( !$status->isOK() ) { return $status; } + /** @var RedisConnRef $conn */ $conn = $status->value; + '@phan-var RedisConnRef $conn'; $now = microtime( true ); try { diff --git a/includes/preferences/DefaultPreferencesFactory.php b/includes/preferences/DefaultPreferencesFactory.php index c672b7b7d1..8a82add61f 100644 --- a/includes/preferences/DefaultPreferencesFactory.php +++ b/includes/preferences/DefaultPreferencesFactory.php @@ -1688,11 +1688,15 @@ class DefaultPreferencesFactory implements PreferencesFactory { * Save the form data and reload the page * * @param array $formData - * @param HTMLForm $form + * @param PreferencesFormOOUI $form * @param array $formDescriptor * @return Status */ - protected function submitForm( array $formData, HTMLForm $form, array $formDescriptor ) { + protected function submitForm( + array $formData, + PreferencesFormOOUI $form, + array $formDescriptor + ) { $res = $this->saveFormData( $formData, $form, $formDescriptor ); if ( $res === true ) { diff --git a/includes/profiler/output/ProfilerOutputDump.php b/includes/profiler/output/ProfilerOutputDump.php index 09f5688785..64a504a3eb 100644 --- a/includes/profiler/output/ProfilerOutputDump.php +++ b/includes/profiler/output/ProfilerOutputDump.php @@ -26,6 +26,7 @@ * @ingroup Profiler * * @since 1.25 + * @property ProfilerXhprof $collector */ class ProfilerOutputDump extends ProfilerOutput { diff --git a/includes/revisiondelete/RevDelArchivedFileItem.php b/includes/revisiondelete/RevDelArchivedFileItem.php index ab9830f706..5b03ad03ff 100644 --- a/includes/revisiondelete/RevDelArchivedFileItem.php +++ b/includes/revisiondelete/RevDelArchivedFileItem.php @@ -23,10 +23,11 @@ use MediaWiki\Storage\RevisionRecord; /** * Item class for a filearchive table row + * + * @property ArchivedFile $file + * @property RevDelArchivedFileList $list */ class RevDelArchivedFileItem extends RevDelFileItem { - /** @var RevDelArchivedFileList $list */ - /** @var ArchivedFile $file */ /** @var LocalFile */ protected $lockFile; diff --git a/includes/revisiondelete/RevDelFileList.php b/includes/revisiondelete/RevDelFileList.php index ca7bc040d0..334dccfcfe 100644 --- a/includes/revisiondelete/RevDelFileList.php +++ b/includes/revisiondelete/RevDelFileList.php @@ -110,8 +110,10 @@ class RevDelFileList extends RevDelList { } public function doPostCommitUpdates( array $visibilityChangeMap ) { + /** @var LocalFile $file */ $file = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo() ->newFile( $this->title ); + '@phan-var LocalFile $file'; $file->purgeCache(); $file->purgeDescription(); diff --git a/includes/revisiondelete/RevDelList.php b/includes/revisiondelete/RevDelList.php index dc43aedb40..74dd7bc58e 100644 --- a/includes/revisiondelete/RevDelList.php +++ b/includes/revisiondelete/RevDelList.php @@ -27,6 +27,12 @@ use MediaWiki\Storage\RevisionRecord; * needs to be able to make a query from a set of identifiers to pull * relevant rows, to return RevDelItem subclasses wrapping them, and * to wrap bulk update operations. + * + * @property RevDelItem $current + * @method RevDelItem next() + * @method RevDelItem reset() + * @method RevDelItem current() + * @phan-file-suppress PhanParamSignatureMismatch */ abstract class RevDelList extends RevisionListBase { function __construct( IContextSource $context, Title $title, array $ids ) { diff --git a/includes/revisiondelete/RevDelRevisionItem.php b/includes/revisiondelete/RevDelRevisionItem.php index a5859e5565..f61d378dc0 100644 --- a/includes/revisiondelete/RevDelRevisionItem.php +++ b/includes/revisiondelete/RevDelRevisionItem.php @@ -23,6 +23,8 @@ use MediaWiki\Storage\RevisionRecord; /** * Item class for a live revision table row + * + * @property RevDelRevisionList $list */ class RevDelRevisionItem extends RevDelItem { /** @var Revision */ diff --git a/includes/search/SearchResultSetTrait.php b/includes/search/SearchResultSetTrait.php index f36a7b513f..7361265052 100644 --- a/includes/search/SearchResultSetTrait.php +++ b/includes/search/SearchResultSetTrait.php @@ -7,6 +7,7 @@ * This trait can be used directly by extensions providing a SearchEngine. * * @ingroup Search + * @phan-file-suppress PhanUndeclaredMethod */ trait SearchResultSetTrait { /** diff --git a/includes/session/PHPSessionHandler.php b/includes/session/PHPSessionHandler.php index 64c2b84d8d..a0b024e642 100644 --- a/includes/session/PHPSessionHandler.php +++ b/includes/session/PHPSessionHandler.php @@ -54,7 +54,7 @@ class PHPSessionHandler implements \SessionHandlerInterface { /** @var array Track original session fields for later modification check */ protected $sessionFieldCache = []; - protected function __construct( SessionManagerInterface $manager ) { + protected function __construct( SessionManager $manager ) { $this->setEnableFlags( \RequestContext::getMain()->getConfig()->get( 'PHPSessionHandling' ) ); @@ -106,9 +106,9 @@ class PHPSessionHandler implements \SessionHandlerInterface { /** * Install a session handler for the current web request - * @param SessionManagerInterface $manager + * @param SessionManager $manager */ - public static function install( SessionManagerInterface $manager ) { + public static function install( SessionManager $manager ) { if ( self::$instance ) { $manager->setupPHPSessionHandler( self::$instance ); return; diff --git a/includes/session/SessionInfo.php b/includes/session/SessionInfo.php index a7bbcce2e2..882eb390cc 100644 --- a/includes/session/SessionInfo.php +++ b/includes/session/SessionInfo.php @@ -156,6 +156,7 @@ class SessionInfo { $this->idIsSafe = $data['idIsSafe']; $this->forceUse = $data['forceUse'] && $this->provider; } else { + // @phan-suppress-next-line PhanUndeclaredMethod $this->id = $this->provider->getManager()->generateSessionId(); $this->idIsSafe = true; $this->forceUse = false; diff --git a/includes/session/SessionManager.php b/includes/session/SessionManager.php index fc117a8c9c..fcc428da6e 100644 --- a/includes/session/SessionManager.php +++ b/includes/session/SessionManager.php @@ -86,8 +86,7 @@ final class SessionManager implements SessionManagerInterface { /** * Get the global SessionManager - * @return SessionManagerInterface - * (really a SessionManager, but this is to make IDEs less confused) + * @return self */ public static function singleton() { if ( self::$instance === null ) { diff --git a/includes/skins/SkinTemplate.php b/includes/skins/SkinTemplate.php index 3e8972c0c0..70df73bc21 100644 --- a/includes/skins/SkinTemplate.php +++ b/includes/skins/SkinTemplate.php @@ -376,6 +376,7 @@ class SkinTemplate extends Skin { /** @var CreditsAction $action */ $action = Action::factory( 'credits', $this->getWikiPage(), $this->getContext() ); + '@phan-var CreditsAction $action'; $tpl->set( 'credits', $action->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ) ); } else { diff --git a/includes/specialpage/LoginSignupSpecialPage.php b/includes/specialpage/LoginSignupSpecialPage.php index 62818a14d6..ce80c1a311 100644 --- a/includes/specialpage/LoginSignupSpecialPage.php +++ b/includes/specialpage/LoginSignupSpecialPage.php @@ -760,6 +760,7 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage { $isLoggedIn = $this->getUser()->isLoggedIn(); $continuePart = $this->isContinued() ? 'continue-' : ''; $anotherPart = $isLoggedIn ? 'another-' : ''; + // @phan-suppress-next-line PhanUndeclaredMethod $expiration = $this->getRequest()->getSession()->getProvider()->getRememberUserDuration(); $expirationDays = ceil( $expiration / ( 3600 * 24 ) ); $secureLoginLink = ''; diff --git a/includes/specialpage/SpecialPageFactory.php b/includes/specialpage/SpecialPageFactory.php index f2c964476c..8134c9a829 100644 --- a/includes/specialpage/SpecialPageFactory.php +++ b/includes/specialpage/SpecialPageFactory.php @@ -568,6 +568,7 @@ class SpecialPageFactory { return $title; } + // @phan-suppress-next-line PhanUndeclaredMethod $context->setTitle( $page->getPageTitle( $par ) ); } elseif ( !$page->isIncludable() ) { return false; diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index 3a266f23d7..07214af4fa 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -423,6 +423,8 @@ class SpecialBlock extends FormSpecialPage { foreach ( $block->getRestrictions() as $restriction ) { switch ( $restriction->getType() ) { case PageRestriction::TYPE: + /** @var PageRestriction $restriction */ + '@phan-var PageRestriction $restriction'; if ( $restriction->getTitle() ) { $pageRestrictions[] = $restriction->getTitle()->getPrefixedText(); } diff --git a/includes/specials/SpecialExpandTemplates.php b/includes/specials/SpecialExpandTemplates.php index ceba987f8a..ef1b3d89f1 100644 --- a/includes/specials/SpecialExpandTemplates.php +++ b/includes/specials/SpecialExpandTemplates.php @@ -83,8 +83,10 @@ class SpecialExpandTemplates extends SpecialPage { $dom = $parser->preprocessToDom( $input ); if ( method_exists( $dom, 'saveXML' ) ) { + // @phan-suppress-next-line PhanUndeclaredMethod $xml = $dom->saveXML(); } else { + // @phan-suppress-next-line PhanUndeclaredMethod $xml = $dom->__toString(); } } diff --git a/includes/specials/SpecialRecentChanges.php b/includes/specials/SpecialRecentChanges.php index 30f4655bad..0bfe1855df 100644 --- a/includes/specials/SpecialRecentChanges.php +++ b/includes/specials/SpecialRecentChanges.php @@ -197,26 +197,36 @@ class SpecialRecentChanges extends ChangesListSpecialPage { $user = $this->getUser(); $significance = $this->getFilterGroup( 'significance' ); + /** @var ChangesListBooleanFilter $hideMinor */ $hideMinor = $significance->getFilter( 'hideminor' ); + '@phan-var ChangesListBooleanFilter $hideMinor'; $hideMinor->setDefault( $user->getBoolOption( 'hideminor' ) ); $automated = $this->getFilterGroup( 'automated' ); + /** @var ChangesListBooleanFilter $hideBots */ $hideBots = $automated->getFilter( 'hidebots' ); + '@phan-var ChangesListBooleanFilter $hideBots'; $hideBots->setDefault( true ); + /** @var ChangesListStringOptionsFilterGroup|null $reviewStatus */ $reviewStatus = $this->getFilterGroup( 'reviewStatus' ); + '@phan-var ChangesListStringOptionsFilterGroup|null $reviewStatus'; if ( $reviewStatus !== null ) { // Conditional on feature being available and rights if ( $user->getBoolOption( 'hidepatrolled' ) ) { $reviewStatus->setDefault( 'unpatrolled' ); $legacyReviewStatus = $this->getFilterGroup( 'legacyReviewStatus' ); + /** @var ChangesListBooleanFilter $legacyHidePatrolled */ $legacyHidePatrolled = $legacyReviewStatus->getFilter( 'hidepatrolled' ); + '@phan-var ChangesListBooleanFilter $legacyHidePatrolled'; $legacyHidePatrolled->setDefault( true ); } } $changeType = $this->getFilterGroup( 'changeType' ); + /** @var ChangesListBooleanFilter $hideCategorization */ $hideCategorization = $changeType->getFilter( 'hidecategorization' ); + '@phan-var ChangesListBooleanFilter $hideCategorization'; if ( $hideCategorization !== null ) { // Conditional on feature being available $hideCategorization->setDefault( $user->getBoolOption( 'hidecategorization' ) ); diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index 32be932d9b..075b5df0c2 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -493,6 +493,7 @@ class SpecialUndelete extends SpecialPage { $buttonFields = []; if ( $isText ) { + '@phan-var TextContent $content'; // TODO: MCR: make this work for multiple slots // source view for textual content $sourceView = Xml::element( 'textarea', [ diff --git a/includes/specials/SpecialUserrights.php b/includes/specials/SpecialUserrights.php index a45ccca8a7..5747f67b83 100644 --- a/includes/specials/SpecialUserrights.php +++ b/includes/specials/SpecialUserrights.php @@ -86,6 +86,7 @@ class UserrightsPage extends SpecialPage { * * @param string|null $par String if any subpage provided, else null * @throws UserBlockedError|PermissionsError + * @suppress PhanUndeclaredMethod */ public function execute( $par ) { $user = $this->getUser(); @@ -479,10 +480,12 @@ class UserrightsPage extends SpecialPage { $this->getOutput()->addWikiTextAsInterface( $status->getWikiText() ); return; - } else { - $user = $status->value; } + /** @var User $user */ + $user = $status->value; + '@phan-var User $user'; + $groups = $user->getGroups(); $groupMemberships = $user->getGroupMemberships(); $this->showEditUserGroupsForm( $user, $groups, $groupMemberships ); diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index f5239b4713..3d563309de 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -148,6 +148,7 @@ class SpecialWatchlist extends ChangesListSpecialPage { /** * @inheritDoc + * @suppress PhanUndeclaredMethod */ protected function registerFilters() { parent::registerFilters(); diff --git a/includes/specials/pagers/BlockListPager.php b/includes/specials/pagers/BlockListPager.php index 6faf22bbea..63cff94593 100644 --- a/includes/specials/pagers/BlockListPager.php +++ b/includes/specials/pagers/BlockListPager.php @@ -266,6 +266,7 @@ class BlockListPager extends TablePager { switch ( $restriction->getType() ) { case PageRestriction::TYPE: + '@phan-var PageRestriction $restriction'; if ( $restriction->getTitle() ) { $items[$restriction->getType()][] = Html::rawElement( 'li', diff --git a/includes/user/BotPassword.php b/includes/user/BotPassword.php index df5edef2f3..c3cbc6d7f0 100644 --- a/includes/user/BotPassword.php +++ b/includes/user/BotPassword.php @@ -514,6 +514,7 @@ class BotPassword implements IDBAccessObject { $throttle->clear( $user->getName(), $request->getIP() ); } return self::loginHook( $user, $bp, + // @phan-suppress-next-line PhanUndeclaredMethod Status::newGood( $provider->newSessionForRequest( $user, $bp, $request ) ) ); } diff --git a/includes/utils/AvroValidator.php b/includes/utils/AvroValidator.php index b2d6077c26..f3a8810a98 100644 --- a/includes/utils/AvroValidator.php +++ b/includes/utils/AvroValidator.php @@ -34,6 +34,7 @@ class AvroValidator { * @return string|string[] An error or list of errors in the * provided $datum. When no errors exist the empty array is * returned. + * @suppress PhanUndeclaredMethod */ public static function getErrors( AvroSchema $schema, $datum ) { switch ( $schema->type ) { diff --git a/languages/Language.php b/languages/Language.php index 7ee6a65b5a..16a6e1a778 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -55,7 +55,7 @@ class Language { const SUPPORTED = 'mwfile'; /** - * @var LanguageConverter + * @var LanguageConverter|FakeConverter */ public $mConverter; @@ -457,7 +457,6 @@ class Language { } function __construct() { - // @phan-suppress-next-line PhanTypeMismatchProperty $this->mConverter = new FakeConverter( $this ); // Set the code to the name of the descendant if ( static::class === 'Language' ) { diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index 350aa67947..9886425f8b 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -1044,6 +1044,7 @@ class LanguageConverter { $revision = Revision::newFromTitle( $title ); if ( $revision ) { if ( $revision->getContentModel() == CONTENT_MODEL_WIKITEXT ) { + // @phan-suppress-next-line PhanUndeclaredMethod $txt = $revision->getContent( RevisionRecord::RAW )->getText(); } diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index 130d1fbf71..81bee4c621 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -1324,6 +1324,7 @@ abstract class Maintenance { $res = $dbw->select( 'content', 'content_address', [], __METHOD__, [ 'DISTINCT' ] ); $blobStore = MediaWikiServices::getInstance()->getBlobStore(); foreach ( $res as $row ) { + // @phan-suppress-next-line PhanUndeclaredMethod $textId = $blobStore->getTextIdFromAddress( $row->content_address ); if ( $textId ) { $cur[] = $textId; diff --git a/maintenance/addSite.php b/maintenance/addSite.php index b0ee966711..8fb0d68a37 100644 --- a/maintenance/addSite.php +++ b/maintenance/addSite.php @@ -39,7 +39,10 @@ class AddSite extends Maintenance { */ public function execute() { $siteStore = MediaWikiServices::getInstance()->getSiteStore(); - $siteStore->reset(); + if ( method_exists( $siteStore, 'reset' ) ) { + // @phan-suppress-next-line PhanUndeclaredMethod + $siteStore->reset(); + } $globalId = $this->getArg( 0 ); $group = $this->getArg( 1 ); @@ -81,6 +84,7 @@ class AddSite extends Maintenance { $siteStore->saveSites( [ $site ] ); if ( method_exists( $siteStore, 'reset' ) ) { + // @phan-suppress-next-line PhanUndeclaredMethod $siteStore->reset(); } diff --git a/maintenance/archives/upgradeLogging.php b/maintenance/archives/upgradeLogging.php index bcf70230e5..6faeee832b 100644 --- a/maintenance/archives/upgradeLogging.php +++ b/maintenance/archives/upgradeLogging.php @@ -23,8 +23,6 @@ require __DIR__ . '/../commandLine.inc'; -use Wikimedia\Rdbms\IMaintainableDatabase; - /** * Maintenance script that upgrade for log_id/log_deleted fields in a * replication-safe way. @@ -34,14 +32,14 @@ use Wikimedia\Rdbms\IMaintainableDatabase; class UpdateLogging { /** - * @var IMaintainableDatabase + * @var Database */ public $dbw; public $batchSize = 1000; public $minTs = false; function execute() { - $this->dbw = $this->getDB( DB_MASTER ); + $this->dbw = wfGetDB( DB_MASTER ); $logging = $this->dbw->tableName( 'logging' ); $logging_1_10 = $this->dbw->tableName( 'logging_1_10' ); $logging_pre_1_10 = $this->dbw->tableName( 'logging_pre_1_10' ); diff --git a/maintenance/checkLess.php b/maintenance/checkLess.php index 55ffcb838f..62d6680c3f 100644 --- a/maintenance/checkLess.php +++ b/maintenance/checkLess.php @@ -58,6 +58,7 @@ class CheckLess extends Maintenance { "$IP/tests/phpunit/phpunit.php", "$IP/tests/phpunit/suites/LessTestSuite.php" ]; + // @phan-suppress-next-line PhanUndeclaredMethod $textUICommand->run( $argv ); } } diff --git a/maintenance/cleanupUploadStash.php b/maintenance/cleanupUploadStash.php index d255348374..b4bfff009f 100644 --- a/maintenance/cleanupUploadStash.php +++ b/maintenance/cleanupUploadStash.php @@ -147,6 +147,7 @@ class CleanupUploadStash extends Maintenance { protected function doOperations( FileRepo $tempRepo, array $ops ) { $status = $tempRepo->getBackend()->doQuickOperations( $ops ); if ( !$status->isOK() ) { + // @phan-suppress-next-line PhanUndeclaredMethod $this->error( print_r( $status->getErrorsArray(), true ) ); } } diff --git a/maintenance/compareParsers.php b/maintenance/compareParsers.php index 2f0bcdf2a2..3f5587832e 100644 --- a/maintenance/compareParsers.php +++ b/maintenance/compareParsers.php @@ -144,6 +144,8 @@ class CompareParsers extends DumpIterator { return; } + /** @var WikitextContent $content */ + '@phan-var WikitextContent $content'; $text = strval( $content->getText() ); $output1 = $parser1->parse( $text, $title, $this->options ); diff --git a/maintenance/convertLinks.php b/maintenance/convertLinks.php index 02152f7b66..23c46bc2ff 100644 --- a/maintenance/convertLinks.php +++ b/maintenance/convertLinks.php @@ -117,6 +117,7 @@ class ConvertLinks extends Maintenance { } $res = $dbw->query( "SELECT l_from FROM $links LIMIT 1" ); + // @phan-suppress-next-line PhanUndeclaredMethod if ( $dbw->fieldType( $res, 0 ) == "int" ) { $this->output( "Schema already converted\n" ); diff --git a/maintenance/deleteArchivedFiles.php b/maintenance/deleteArchivedFiles.php index d010073b90..7b2ef17a31 100644 --- a/maintenance/deleteArchivedFiles.php +++ b/maintenance/deleteArchivedFiles.php @@ -68,6 +68,7 @@ class DeleteArchivedFiles extends Maintenance { /** @var LocalFile $file */ $file = $repo->newFile( $row->fa_name ); + '@phan-var LocalFile $file'; try { $file->lock(); } catch ( LocalFileLockError $e ) { diff --git a/maintenance/eraseArchivedFile.php b/maintenance/eraseArchivedFile.php index 49fadaa2d8..24e88bc3ba 100644 --- a/maintenance/eraseArchivedFile.php +++ b/maintenance/eraseArchivedFile.php @@ -109,6 +109,7 @@ class EraseArchivedFile extends Maintenance { $this->output( "Deleted version '$key' ($ts) of file '$name'\n" ); } else { $this->output( "Failed to delete version '$key' ($ts) of file '$name'\n" ); + // @phan-suppress-next-line PhanUndeclaredMethod $this->output( print_r( $status->getErrorsArray(), true ) ); } } else { diff --git a/maintenance/importDump.php b/maintenance/importDump.php index 0ff362218a..cda16fe3b3 100644 --- a/maintenance/importDump.php +++ b/maintenance/importDump.php @@ -211,6 +211,7 @@ TEXT } $this->uploadCount++; // $this->report(); + // @phan-suppress-next-line PhanUndeclaredMethod $this->progress( "upload: " . $revision->getFilename() ); if ( !$this->dryRun ) { diff --git a/maintenance/importImages.php b/maintenance/importImages.php index f5d9359d43..e4d1f096e0 100644 --- a/maintenance/importImages.php +++ b/maintenance/importImages.php @@ -332,6 +332,7 @@ class ImportImages extends Maintenance { if ( $this->hasOption( 'dry' ) ) { $this->output( "done.\n" ); + // @phan-suppress-next-line PhanUndeclaredMethod } elseif ( $image->recordUpload2( $archive->value, $summary, diff --git a/maintenance/nukeNS.php b/maintenance/nukeNS.php index ee1f59c124..05688df5fc 100644 --- a/maintenance/nukeNS.php +++ b/maintenance/nukeNS.php @@ -88,7 +88,9 @@ class NukeNS extends Maintenance { $dbw->query( "DELETE FROM $tbl_pag WHERE page_id = $id" ); $this->commitTransaction( $dbw, __METHOD__ ); // Delete revisions as appropriate + /** @var NukePage $child */ $child = $this->runChild( NukePage::class, 'nukePage.php' ); + '@phan-var NukePage $child'; $child->deleteRevisions( $revs ); $this->purgeRedundantText( true ); $n_deleted++; diff --git a/maintenance/populateImageSha1.php b/maintenance/populateImageSha1.php index 9f77fda55c..5d6a19fb2f 100644 --- a/maintenance/populateImageSha1.php +++ b/maintenance/populateImageSha1.php @@ -151,6 +151,8 @@ class PopulateImageSha1 extends LoggedUpdateMaintenance { } // Upgrade the old file versions... foreach ( $file->getHistory() as $oldFile ) { + /** @var OldLocalFile $oldFile */ + '@phan-var OldLocalFile $oldFile'; $sha1 = $oldFile->getRepo()->getFileSha1( $oldFile->getPath() ); if ( strval( $sha1 ) !== '' ) { // file on disk and hashed properly if ( $isRegen && $oldFile->getSha1() !== $sha1 ) { diff --git a/maintenance/preprocessDump.php b/maintenance/preprocessDump.php index b9e084eab1..963bfec48f 100644 --- a/maintenance/preprocessDump.php +++ b/maintenance/preprocessDump.php @@ -87,6 +87,8 @@ class PreprocessDump extends DumpIterator { if ( $content->getModel() !== CONTENT_MODEL_WIKITEXT ) { return; } + /** @var WikitextContent $content */ + '@phan-var WikitextContent $content'; try { $this->mPreprocessor->preprocessToObj( strval( $content->getText() ), 0 ); diff --git a/maintenance/preprocessorFuzzTest.php b/maintenance/preprocessorFuzzTest.php index e57e977511..68fb6435a5 100644 --- a/maintenance/preprocessorFuzzTest.php +++ b/maintenance/preprocessorFuzzTest.php @@ -72,7 +72,7 @@ class PPFuzzTester { $passed = 'passed'; } catch ( Exception $e ) { $testReport = self::$currentTest->getReport(); - $exceptionReport = $e->getText(); + $exceptionReport = $e instanceof MWException ? $e->getText() : (string)$e; $hash = md5( $testReport ); file_put_contents( "results/ppft-$hash.in", serialize( self::$currentTest ) ); file_put_contents( "results/ppft-$hash.fail", diff --git a/maintenance/rebuildImages.php b/maintenance/rebuildImages.php index dfce2021e6..bfbee9b65b 100644 --- a/maintenance/rebuildImages.php +++ b/maintenance/rebuildImages.php @@ -76,7 +76,7 @@ class ImageBuilder extends Maintenance { } /** - * @return FileRepo + * @return LocalRepo */ function getRepo() { if ( !isset( $this->repo ) ) { @@ -203,7 +203,8 @@ class ImageBuilder extends Maintenance { $filename = $altname; $this->output( "Estimating transcoding... $altname\n" ); } else { - # @todo FIXME: create renameFile() + // @fixme create renameFile() + // @phan-suppress-next-line PhanUndeclaredMethod See comment above... $filename = $this->renameFile( $filename ); } } diff --git a/maintenance/storage/checkStorage.php b/maintenance/storage/checkStorage.php index d8a8808cc3..060f32768d 100644 --- a/maintenance/storage/checkStorage.php +++ b/maintenance/storage/checkStorage.php @@ -106,7 +106,9 @@ class CheckStorage { [], [ 'content' => [ 'INNER JOIN', [ 'content_id = slot_content_id' ] ] ] ); + /** @var \MediaWiki\Storage\SqlBlobStore $blobStore */ $blobStore = MediaWikiServices::getInstance()->getBlobStore(); + '@phan-var \MediaWiki\Storage\SqlBlobStore $blobStore'; foreach ( $res as $row ) { $textId = $blobStore->getTextIdFromAddress( $row->content_address ); if ( $textId ) { diff --git a/maintenance/update.php b/maintenance/update.php index a3534f8541..94ec207725 100755 --- a/maintenance/update.php +++ b/maintenance/update.php @@ -27,7 +27,6 @@ require_once __DIR__ . '/Maintenance.php'; -use Wikimedia\Rdbms\IMaintainableDatabase; use Wikimedia\Rdbms\DatabaseSqlite; /** @@ -160,7 +159,8 @@ class UpdateMediaWiki extends Maintenance { $dbDomain = WikiMap::getCurrentWikiDbDomain()->getId(); $this->output( "Going to run database updates for $dbDomain\n" ); if ( $db->getType() === 'sqlite' ) { - /** @var IMaintainableDatabase|DatabaseSqlite $db */ + /** @var DatabaseSqlite $db */ + '@phan-var DatabaseSqlite $db'; $this->output( "Using SQLite file: '{$db->getDbFilePath()}'\n" ); } $this->output( "Depending on the size of your database this may take a while!\n" ); diff --git a/maintenance/updateExtensionJsonSchema.php b/maintenance/updateExtensionJsonSchema.php index c9fb78054c..18c71a3eaf 100644 --- a/maintenance/updateExtensionJsonSchema.php +++ b/maintenance/updateExtensionJsonSchema.php @@ -34,6 +34,7 @@ class UpdateExtensionJsonSchema extends Maintenance { while ( $json['manifest_version'] !== ExtensionRegistry::MANIFEST_VERSION ) { $json['manifest_version'] += 1; $func = "updateTo{$json['manifest_version']}"; + // @phan-suppress-next-line PhanUndeclaredMethod $this->$func( $json ); } diff --git a/maintenance/userDupes.inc b/maintenance/userDupes.inc index 5f7f9d5e43..038ef23928 100644 --- a/maintenance/userDupes.inc +++ b/maintenance/userDupes.inc @@ -36,7 +36,7 @@ use Wikimedia\Rdbms\IMaintainableDatabase; */ class UserDupes { /** - * @var IMaintainableDatabase + * @var Database */ private $db; private $reassigned; diff --git a/maintenance/wrapOldPasswords.php b/maintenance/wrapOldPasswords.php index 00046d33bb..544c071525 100644 --- a/maintenance/wrapOldPasswords.php +++ b/maintenance/wrapOldPasswords.php @@ -95,8 +95,10 @@ class WrapOldPasswords extends Maintenance { $user = User::newFromId( $row->user_id ); /** @var ParameterizedPassword $password */ $password = $passwordFactory->newFromCiphertext( $row->user_password ); + '@phan-var ParameterizedPassword $password'; /** @var LayeredParameterizedPassword $layeredPassword */ $layeredPassword = $passwordFactory->newFromType( $layeredType ); + '@phan-var LayeredParameterizedPassword $layeredPassword'; $layeredPassword->partialCrypt( $password ); $updateUsers[] = $user; -- 2.20.1