phan: Disable null_casts_as_any_type setting

Make phan stricter about null types by setting null_casts_as_any_type to
false (the default in mediawiki-phan-config)
Remaining false positive issues are suppressed.
The suppression and the setting change can only be done together

Bug: T242536
Bug: T301991
Change-Id: I0f295382b96fb3be8037a01c10487d9d591e7e01
This commit is contained in:
Umherirrender 2021-10-25 21:15:52 +02:00 committed by Krinkle
parent 50938694e5
commit 1f71eccf63
178 changed files with 318 additions and 12 deletions

View file

@ -93,7 +93,6 @@ $cfg['exclude_analysis_directory_list'] = [
];
// These are too spammy for now. TODO enable
$cfg['null_casts_as_any_type'] = true;
$cfg['suppress_issue_types'][] = 'PhanTypePossiblyInvalidDimOffset';
$cfg['suppress_issue_types'][] = 'PhanPossiblyUndeclaredVariable';
$cfg['suppress_issue_types'][] = 'PhanCompatibleAccessMethodOnTraitDefinition'; // T289813

View file

@ -105,6 +105,7 @@ class CategoryViewer extends ContextSource {
'title',
'1.37',
function (): Title {
// @phan-suppress-next-line PhanTypeMismatchReturnNullable castFrom does not return null here
return Title::castFromPageIdentity( $this->page );
},
function ( PageIdentity $page ) {
@ -243,6 +244,7 @@ class CategoryViewer extends ContextSource {
$link = null;
$legacyTitle = MediaWikiServices::getInstance()->getTitleFactory()
->castFromPageReference( $page );
// @phan-suppress-next-line PhanTypeMismatchArgument castFrom does not return null here
$this->getHookRunner()->onCategoryViewer__generateLink( $type, $legacyTitle, $html, $link );
if ( $link === null ) {
$linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
@ -302,8 +304,10 @@ class CategoryViewer extends ContextSource {
if ( $this->showGallery ) {
$flip = $this->flip['file'];
if ( $flip ) {
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
$this->gallery->insert( $title );
} else {
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
$this->gallery->add( $title );
}
} else {

View file

@ -265,6 +265,7 @@ class CommentFormatter {
} else {
$key = $i;
}
// @phan-suppress-next-line PhanTypeMismatchDimAssignment getId does not return null here
$outputs[$key] = $this->preprocessRevComment(
$parser, $authority, $rev, $samePage, $isPublic, $useParentheses );
}

View file

@ -419,6 +419,7 @@ class CommentParser {
if ( $linkMarker ) {
// If the link is still valid, go ahead and replace it in!
$comment = preg_replace(
// @phan-suppress-next-line PhanTypeMismatchArgumentNullableInternal linkRegexp set when used
$linkRegexp,
$linkMarker,
$comment,

View file

@ -1265,6 +1265,7 @@ class EditPage implements IEditObject {
$params = $request->getArray( 'preloadparams', $params );
}
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable getVal does not return null here
$content = $this->getPreloadedContent( $preload, $params );
}
// For existing pages, get text based on "undo" or section parameters.
@ -1454,8 +1455,11 @@ class EditPage implements IEditObject {
$undoIsLatest = $this->page->getRevisionRecord()->getId() === $undoRev->getId();
return $handler->getUndoContent(
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable Content is for public use
$currentContent,
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable Content is for public use
$undoContent,
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable Content is for public use
$undoAfterContent,
$undoIsLatest
);
@ -1624,6 +1628,7 @@ class EditPage implements IEditObject {
* @param Authority $performer
* @return bool
* @throws Exception
* @phan-assert-true-condition $page
*/
private function isPageExistingAndViewable( ?PageIdentity $page, Authority $performer ): bool {
return $page && $page->exists() && $performer->authorizeRead( 'read', $page );
@ -1674,7 +1679,7 @@ class EditPage implements IEditObject {
/**
* Attempt submission
* @param array|bool &$resultDetails See docs for $result in internalAttemptSave
* @param array|bool &$resultDetails See docs for $result in internalAttemptSave @phan-output-reference
* @throws UserBlockedError|ReadOnlyError|ThrottledError|PermissionsError
* @return Status
*/
@ -1810,6 +1815,7 @@ class EditPage implements IEditObject {
case self::AS_BLOCKED_PAGE_FOR_USER:
throw new UserBlockedError(
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable Block is checked and not null
$this->context->getUser()->getBlock(),
$this->context->getUser(),
$this->context->getLanguage(),
@ -2081,6 +2087,7 @@ class EditPage implements IEditObject {
}
$pageUpdater = $this->page->newPageUpdater( $user )
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable False positive
->setContent( SlotRecord::MAIN, $content );
$pageUpdater->prepareUpdate( $flags );
@ -2760,6 +2767,7 @@ class EditPage implements IEditObject {
(
$block->isSitewide() ||
$this->permManager->isBlockedFrom(
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable False positive
$user,
$this->mTitle,
true
@ -3616,6 +3624,7 @@ class EditPage implements IEditObject {
);
$this->context->getOutput()->addHTML(
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable False positive, text is not null
Html::textarea( $name, $builder->addNewLineAtEnd( $text ), $attribs )
);
}
@ -4164,6 +4173,7 @@ class EditPage implements IEditObject {
$content = $content->addSectionHeader( $this->summary );
}
// @phan-suppress-next-line PhanTypeMismatchArgument Type mismatch on pass-by-ref args
$this->getHookRunner()->onEditPageGetPreviewContent( $this, $content );
$parserResult = $this->doPreviewParse( $content );

View file

@ -1497,6 +1497,7 @@ function wfEscapeWikiText( $text ) {
$repl2 = $repl2 ? '/\b(' . implode( '|', $repl2 ) . '):/i' : '/^(?!)/';
}
$text = substr( strtr( "\n$text", $repl ), 1 );
// @phan-suppress-next-line PhanTypeMismatchArgumentNullableInternal False positive
$text = preg_replace( $repl2, '$1:', $text );
return $text;
}
@ -2141,6 +2142,7 @@ function wfRelativePath( $path, $from ) {
}
// relative dots to bump us to the parent
// @phan-suppress-next-line PhanTypeMismatchArgumentNullableInternal False positive
while ( count( $against ) ) {
array_unshift( $pieces, '..' );
array_shift( $against );

View file

@ -302,7 +302,9 @@ class Linker {
$res = null;
$dummy = new DummyLinker;
if ( !Hooks::runner()->onImageBeforeProduceHTML( $dummy, $title,
// @phan-suppress-next-line PhanTypeMismatchArgument Type mismatch on pass-by-ref args
$file, $frameParams, $handlerParams, $time, $res,
// @phan-suppress-next-line PhanTypeMismatchArgument Type mismatch on pass-by-ref args
$parser, $query, $widthOption )
) {
return $res;

View file

@ -396,6 +396,7 @@ class MergeHistory {
$logId = $logEntry->insert();
$logEntry->publish( $logId );
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
$this->hookRunner->onArticleMergeComplete( $legacySource, $legacyDest );
$this->dbw->endAtomic( __METHOD__ );
@ -428,6 +429,7 @@ class MergeHistory {
$newContent = $contentHandler->makeEmptyContent();
} else {
$msg = wfMessage( 'mergehistory-redirect-text' )->inContentLanguage()->plain();
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
$newContent = $contentHandler->makeRedirectContent( $legacyDestTitle, $msg );
}

View file

@ -211,7 +211,9 @@ class PageProps {
$pageProperties[$row->pp_propname] = $row->pp_value;
}
if ( $pageProperties != [] ) {
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable pageID set when used
$this->cacheProperties( $pageID, $pageProperties );
// @phan-suppress-next-line PhanTypeMismatchDimAssignment pageID set when used
$values[$pageID] = $pageProperties;
}
}

View file

@ -353,6 +353,7 @@ class PermissionManager {
if ( $title->equals( $user->getTalkPage() ) ) {
$blocked = $block->appliesToUsertalk( $title );
} else {
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
$blocked = $block->appliesToTitle( $title );
}
}
@ -361,6 +362,7 @@ class PermissionManager {
$allowUsertalk = $block->isUsertalkEditAllowed();
// Allow extensions to let a blocked user access a particular page
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
$this->hookRunner->onUserIsBlockedFrom( $user, $title, $blocked, $allowUsertalk );
return $blocked;

View file

@ -305,6 +305,7 @@ class RestrictionStore {
if ( $this->hookContainer->isRegistered( 'TitleGetRestrictionTypes' ) ) {
$this->hookRunner->onTitleGetRestrictionTypes(
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
Title::castFromPageIdentity( $page ), $types );
}

View file

@ -66,6 +66,7 @@ class MediaFileHandler extends SimpleHandler {
if ( $this->file === false ) {
$page = $this->getPage();
$this->file =
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable
$this->repoGroup->findFile( $page, [ 'private' => $this->getAuthority() ] ) ?: null;
}
return $this->file;

View file

@ -215,7 +215,9 @@ class PageContentHelper {
$revision = $this->getTargetRevision();
return [
'id' => $page->getId(),
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable
'key' => $this->titleFormatter->getPrefixedDBkey( $page ),
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable
'title' => $this->titleFormatter->getPrefixedText( $page ),
'latest' => [
'id' => $revision->getId(),
@ -274,6 +276,7 @@ class PageContentHelper {
);
}
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable Validated by hasContent
if ( !$this->authority->authorizeRead( 'read', $this->getPage() ) ) {
throw new LocalizedHttpException(
MessageValue::new( 'rest-permission-denied-title' )->plaintextParams( $titleText ),

View file

@ -112,7 +112,9 @@ class RevisionContentHelper extends PageContentHelper {
'content_model' => $mainSlot->getModel(),
'page' => [
'id' => $page->getId(),
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable
'key' => $this->titleFormatter->getPrefixedDBkey( $page ),
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable
'title' => $this->titleFormatter->getPrefixedText( $page ),
],
'license' => [
@ -134,6 +136,7 @@ class RevisionContentHelper extends PageContentHelper {
$comment = $revision->getComment( RevisionRecord::FOR_THIS_USER, $this->authority );
$metadata['comment'] = $comment ? $comment->text : null;
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable
$parent = $this->revisionLookup->getPreviousRevision( $revision );
if ( $parent ) {
$metadata['delta'] = $revision->getSize() - $parent->getSize();
@ -171,6 +174,7 @@ class RevisionContentHelper extends PageContentHelper {
);
}
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable Validated by hasContent
if ( !$this->authority->authorizeRead( 'read', $this->getPage() ) ) {
throw new LocalizedHttpException(
MessageValue::new( 'rest-permission-denied-revision' )->plaintextParams( $revId ),

View file

@ -69,6 +69,7 @@ class RevisionSourceHandler extends SimpleHandler {
case 'bare':
$revisionRecord = $this->contentHelper->getTargetRevision();
$body = $this->contentHelper->constructMetadata();
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable revisionRecord is set when used
$body['html_url'] = $this->constructHtmlUrl( $revisionRecord );
$response = $this->getResponseFactory()->createJson( $body );
$this->contentHelper->setCacheControl( $response );

View file

@ -380,7 +380,9 @@ class SearchHandler extends Handler {
$res = $this->buildResultFromPageInfos( $pageInfos );
$result = array_map( "array_merge",
$this->buildResultFromPageInfos( $pageInfos ),
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable False positive
$this->buildDescriptionsFromPageIdentities( $pageIdentities ),
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable False positive
$this->buildThumbnailsFromPageIdentities( $pageIdentities )
);
$response = $this->getResponseFactory()->createJson( [ 'pages' => $result ] );

View file

@ -93,6 +93,7 @@ class MainSlotRoleHandler extends SlotRoleHandler {
$title = $this->titleFactory->castFromPageIdentity( $page );
$handler = $this->contentHandlerFactory->getContentHandler( $model );
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
return $handler->canBeUsedOn( $title );
}
@ -115,6 +116,7 @@ class MainSlotRoleHandler extends SlotRoleHandler {
} else {
$title = $this->titleFactory->castFromLinkTarget( $page );
}
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom notnull/Type mismatch on pass-by-ref args
if ( !$this->hookRunner->onContentHandlerDefaultModelFor( $title, $model ) && $model !== null ) {
return $model;
}

View file

@ -355,6 +355,7 @@ abstract class RevisionRecord implements WikiAwareEntity {
public function getPageAsLinkTarget() {
// TODO: Should be TitleValue::newFromPage( $this->mPage ),
// but Title is used too much still, so let's keep propagating it
// @phan-suppress-next-line PhanTypeMismatchReturnNullable castFrom does not return null here
return Title::castFromPageIdentity( $this->mPage );
}

View file

@ -301,6 +301,7 @@ class RevisionStore
}
$page = $this->getPage( $pageId, $revId, $queryFlags );
// @phan-suppress-next-line PhanTypeMismatchReturnNullable castFrom does not return null here
return $this->titleFactory->castFromPageIdentity( $page );
}
@ -380,6 +381,7 @@ class RevisionStore
// over and over later on.
// When there is less need to convert to Title, this special case can
// be removed.
// @phan-suppress-next-line PhanTypeMismatchReturnNullable castFrom does not return null here
return $this->titleFactory->castFromPageIdentity( $page );
} else {
return $page;
@ -1886,6 +1888,7 @@ class RevisionStore
}
}
// @phan-suppress-next-line PhanTypeMismatchReturnNullable getPageByName/newFromID should not return null
return $page;
}

View file

@ -107,6 +107,7 @@ class CachedSource implements SettingsSource, SettingsIncludeLocator {
);
}
// @phan-suppress-next-line PhanTypeMismatchReturn WaitConditionLoop throws or value set
return $result;
}

View file

@ -275,6 +275,7 @@ class SettingsBuilder {
$this->settingsConfig[ $key ] = $config[ $key ];
}
}
// @phan-suppress-next-line PhanTypeMismatchReturnNullable Always set
return $key;
}

View file

@ -361,6 +361,7 @@ if ( isset( $wgShortPagesNamespaceBlacklist ) ) {
}
// Prohibited file extensions shouldn't appear on the "allowed" list
// @phan-suppress-next-line PhanTypeMismatchArgumentNullableInternal False positive
$wgFileExtensions = array_values( array_diff( $wgFileExtensions, $wgProhibitedFileExtensions ) );
// Fix path to icon images after they were moved in 1.24

View file

@ -1460,6 +1460,7 @@ class DerivedPageDataUpdater implements IDBAccessObject, LoggerAwareInterface, P
$recursive
);
if ( $this->options['moved'] ) {
// @phan-suppress-next-line PhanTypeMismatchArgument Oldtitle is set along with moved
$linksUpdate->setMoveDetails( $this->options['oldtitle'] );
}
@ -1769,6 +1770,7 @@ class DerivedPageDataUpdater implements IDBAccessObject, LoggerAwareInterface, P
// updates that are not defined as being related.
$update = new RefreshSecondaryDataUpdate(
$this->loadbalancerFactory,
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable Already checked
$triggeringUser,
$this->wikiPage,
$this->revision,

View file

@ -108,7 +108,9 @@ class NameTableStoreFactory {
$this->cache,
$this->logger,
$tableName,
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable False positive
$info['idField'],
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable False positive
$info['nameField'],
$info['normalizationCallback'] ?? null,
$wiki,

View file

@ -1001,6 +1001,7 @@ class PageUpdater {
// XXX: do we need PST?
$this->flags |= EDIT_INTERNAL;
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable revision is checked
$this->status = $this->doUpdate( $revision );
}
@ -1165,6 +1166,7 @@ class PageUpdater {
// XXX: We may push this up to the "edit controller" level, see T192777.
$contentHandler = $this->contentHandlerFactory->getContentHandler( $content->getModel() );
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable getId is not null here
$validationParams = new ValidationParams( $wikiPage, $this->flags, $oldid );
$prepStatus = $contentHandler->validateSave( $content, $validationParams );
@ -1564,6 +1566,7 @@ class PageUpdater {
$summary,
$this->flags,
$newRevisionRecord,
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable Not null already checked
$editResult,
$approved
);
@ -1585,6 +1588,7 @@ class PageUpdater {
$summary->text,
$this->flags,
$newRevisionRecord,
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable Not null already checked
$editResult
);
}

View file

@ -278,6 +278,7 @@ class RevertedTagUpdate implements DeferrableUpdate {
}
$this->markAsReverted(
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable revertedRevision is already checked
$this->editResult->getOldestRevertedRevisionId(),
$this->getTagExtraParams()
);
@ -363,6 +364,7 @@ class RevertedTagUpdate implements DeferrableUpdate {
private function getNewestRevertedRevision(): ?RevisionRecord {
if ( !isset( $this->newestRevertedRevision ) ) {
$this->newestRevertedRevision = $this->revisionStore->getRevisionById(
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable newestRevertedRevision is checked
$this->editResult->getNewestRevertedRevisionId()
);
}
@ -377,6 +379,7 @@ class RevertedTagUpdate implements DeferrableUpdate {
private function getOldestRevertedRevision(): ?RevisionRecord {
if ( !isset( $this->oldestRevertedRevision ) ) {
$this->oldestRevertedRevision = $this->revisionStore->getRevisionById(
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable oldestRevertedRevision is checked
$this->editResult->getOldestRevertedRevisionId()
);
}

View file

@ -723,6 +723,7 @@ class Title implements LinkTarget, PageIdentity, IDBAccessObject {
if ( !$title ) {
$title = self::newFromText( 'Main Page' );
}
// @phan-suppress-next-line PhanTypeMismatchReturnNullable Fallback is always valid
return $title;
}

View file

@ -1338,6 +1338,7 @@ class WebRequest {
}
# Allow extensions to improve our guess
// @phan-suppress-next-line PhanTypeMismatchArgument Type mismatch on pass-by-ref args
Hooks::runner()->onGetIP( $ip );
if ( !$ip ) {

View file

@ -121,6 +121,7 @@ class CreditsAction extends FormlessAction {
}
return $this->msg( 'lastmodifiedatby', $d, $t )->rawParams(
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable RIGOR_NONE never returns null
$this->userLink( $user ) )->params( $user->getName() )->escaped();
}

View file

@ -301,6 +301,7 @@ class RawAction extends FormlessAction {
break;
}
// @phan-suppress-next-line PhanTypeMismatchReturnNullable RevisionRecord::getId does not return null here
return $oldid;
}

View file

@ -176,6 +176,7 @@ class RollbackAction extends FormAction {
}
$rollbackResult = $this->rollbackPageFactory
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable use of raw avoids null here
->newRollbackPage( $this->getWikiPage(), $this->getContext()->getAuthority(), $revUser )
->setSummary( $request->getText( 'summary' ) )
->markAsBot( $request->getBool( 'bot' ) )

View file

@ -1042,6 +1042,7 @@ abstract class ApiBase extends ContextSource {
if ( !$titleObj->canExist() ) {
$this->dieWithError( 'apierror-pagecannotexist' );
}
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable T240141
$pageObj = WikiPage::factory( $titleObj );
if ( $load !== false ) {
$pageObj->loadPageData( $load );
@ -1056,6 +1057,7 @@ abstract class ApiBase extends ContextSource {
}
}
// @phan-suppress-next-line PhanTypeMismatchReturnNullable requireOnlyOneParameter guard it is always set
return $pageObj;
}
@ -1076,6 +1078,7 @@ abstract class ApiBase extends ContextSource {
if ( !$titleObj || $titleObj->isExternal() ) {
$this->dieWithError( [ 'apierror-invalidtitle', wfEscapeWikiText( $params['title'] ) ] );
}
// @phan-suppress-next-line PhanTypeMismatchReturnNullable T240141
return $titleObj;
} elseif ( isset( $params['pageid'] ) ) {
$titleObj = Title::newFromID( $params['pageid'] );
@ -1084,6 +1087,7 @@ abstract class ApiBase extends ContextSource {
}
}
// @phan-suppress-next-line PhanTypeMismatchReturnNullable requireOnlyOneParameter guard it is always set
return $titleObj;
}
@ -1186,6 +1190,7 @@ abstract class ApiBase extends ContextSource {
[ 'nosuchusershort', wfEscapeWikiText( $params['owner'] ) ], 'bad_wlowner'
);
}
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable T240141
$token = $services->getUserOptionsLookup()->getOption( $user, 'watchlisttoken' );
if ( $token == '' || !hash_equals( $token, $params['token'] ) ) {
$this->dieWithError( 'apierror-bad-watchlist-token', 'bad_wltoken' );
@ -1198,6 +1203,7 @@ abstract class ApiBase extends ContextSource {
$this->checkUserRightsAny( 'viewmywatchlist' );
}
// @phan-suppress-next-line PhanTypeMismatchReturnNullable T240141
return $user;
}
@ -1251,6 +1257,7 @@ abstract class ApiBase extends ContextSource {
if ( is_string( $error[0] ) && isset( self::$blockMsgMap[$error[0]] ) && $user->getBlock() ) {
list( $msg, $code ) = self::$blockMsgMap[$error[0]];
$status->fatal( ApiMessage::create( $msg, $code,
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable Block is checked and not null
[ 'blockinfo' => $this->getBlockDetails( $user->getBlock() ) ]
) );
} else {
@ -1581,8 +1588,10 @@ abstract class ApiBase extends ContextSource {
$status = new PermissionStatus();
foreach ( (array)$actions as $action ) {
if ( $this->isWriteMode() ) {
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
$this->getAuthority()->authorizeWrite( $action, $pageIdentity, $status );
} else {
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
$this->getAuthority()->authorizeRead( $action, $pageIdentity, $status );
}
}

View file

@ -455,6 +455,7 @@ class ApiComparePages extends ApiBase {
// Deprecated 'fromsection'/'tosection'
if ( isset( $params["{$prefix}section"] ) ) {
$section = $params["{$prefix}section"];
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable T240141
$newRev = MutableRevisionRecord::newFromParentRevision( $rev );
$content = $rev->getContent( SlotRecord::MAIN, RevisionRecord::FOR_THIS_USER,
$this->getUser() );
@ -470,6 +471,7 @@ class ApiComparePages extends ApiBase {
"nosuch{$prefix}section"
);
}
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable T240141
$newRev->setContent( SlotRecord::MAIN, $content );
}
@ -543,6 +545,7 @@ class ApiComparePages extends ApiBase {
$popts = ParserOptions::newFromContext( $this->getContext() );
$content = $this->contentTransformer->preSaveTransform(
$content,
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable T240141
$title,
$this->getUser(),
$popts
@ -565,6 +568,7 @@ class ApiComparePages extends ApiBase {
$this->dieWithError( [ 'apierror-sectionsnotsupported', $content->getModel() ] );
}
try {
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable T240141
$content = $oldContent->replaceSection( $section, $content, '' );
} catch ( TimeoutException $e ) {
throw $e;
@ -589,6 +593,7 @@ class ApiComparePages extends ApiBase {
}
}
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable T240141
$newRev->setContent( $role, $content );
}
return [ $newRev, $rev, null ];

View file

@ -288,8 +288,11 @@ class ApiEditPage extends ApiBase {
}
$newContent = $contentHandler->getUndoContent(
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable Content is for public use here
$pageObj->getRevisionRecord()->getContent( SlotRecord::MAIN ),
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable Content is for public use here
$undoRev->getContent( SlotRecord::MAIN ),
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable Content is for public use here
$undoafterRev->getContent( SlotRecord::MAIN ),
$pageObj->getRevisionRecord()->getId() === $undoRev->getId()
);
@ -531,6 +534,7 @@ class ApiEditPage extends ApiBase {
// obvious that this is even possible.
// @codeCoverageIgnoreStart
case EditPage::AS_BLOCKED_PAGE_FOR_USER:
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable Block is checked and not null
$this->dieBlocked( $user->getBlock() );
// dieBlocked prevents continuation

View file

@ -105,6 +105,7 @@ class ApiFileRevert extends ApiBase {
// Check if the archivename is valid for this file
$this->archiveName = $this->params['archivename'];
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable T240141
$oldFile = $localRepo->newFromArchiveName( $title, $this->archiveName );
if ( !$oldFile->exists() ) {
$this->dieWithError( 'filerevert-badversion' );

View file

@ -171,6 +171,7 @@ class ApiFormatXml extends ApiFormatBase {
if ( $content !== null ) {
if ( is_scalar( $content ) ) {
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable name is check for null in other code
$retval .= $indstr . Xml::element( $name, $attributes, $content );
} else {
if ( $name !== null ) {
@ -205,8 +206,10 @@ class ApiFormatXml extends ApiFormatBase {
// to make sure null value doesn't produce unclosed element,
// which is what Xml::element( $name, null, null ) returns
if ( $value === null ) {
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable name is check for null in other code
$retval .= $indstr . Xml::element( $name, $attributes );
} else {
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable name is check for null in other code
$retval .= $indstr . Xml::element( $name, $attributes, $value );
}
}

View file

@ -48,6 +48,7 @@ class ApiImportReporter extends ImportReporter {
$r['invalid'] = true;
} else {
$titleFactory = MediaWikiServices::getInstance()->getTitleFactory();
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
ApiQueryBase::addTitleInfo( $r, $titleFactory->castFromPageIdentity( $pageIdentity ) );
$r['revisions'] = (int)$successCount;
}

View file

@ -225,6 +225,7 @@ class ApiLogin extends ApiBase {
break;
case 'Failed':
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable message set on error
$result['reason'] = $this->formatMessage( $message );
break;

View file

@ -573,6 +573,7 @@ class ApiMain extends ApiBase {
if ( $uselang === 'content' ) {
$uselang = $services->getContentLanguage()->getCode();
}
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable getRawVal does not return null
$code = RequestContext::sanitizeLangCode( $uselang );
$derivativeContext->setLanguage( $code );
if ( !$this->mInternalMode ) {
@ -968,6 +969,7 @@ class ApiMain extends ApiBase {
if ( $failed ) {
$this->mPrinter = null;
$this->createErrorPrinter();
// @phan-suppress-next-line PhanNonClassMethodCall False positive
$this->mPrinter->forceDefaultParams();
if ( $httpCode ) {
$response->statusHeader( 200 ); // Reset in case the fallback doesn't want a non-200
@ -1264,6 +1266,7 @@ class ApiMain extends ApiBase {
if ( !$this->mModuleMgr->isDefined( $value, 'format' ) ) {
$value = self::API_DEFAULT_FORMAT;
}
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable getVal does not return null here
$this->mPrinter = $this->createPrinterByName( $value );
}
@ -1506,6 +1509,7 @@ class ApiMain extends ApiBase {
}
}
// @phan-suppress-next-line PhanTypeMismatchReturnNullable T240141
return $module;
}

View file

@ -83,6 +83,7 @@ class ApiMergeHistory extends ApiBase {
$timestamp = $params['timestamp'];
// Merge!
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable T240141
$status = $this->merge( $fromTitle, $toTitle, $timestamp, $reason );
if ( !$status->isOK() ) {
$this->dieStatus( $status );

View file

@ -116,6 +116,7 @@ class ApiMove extends ApiBase {
// Move the page
$toTitleExists = $toTitle->exists();
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable T240141
$status = $this->movePage( $fromTitle, $toTitle, $params['reason'], !$params['noredirect'],
$params['tags'] ?: [] );
if ( !$status->isOK() ) {
@ -162,6 +163,7 @@ class ApiMove extends ApiBase {
// Move subpages
if ( $params['movesubpages'] ) {
$r['subpages'] = $this->moveSubpages(
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable T240141
$fromTitle,
$toTitle,
$params['reason'],
@ -189,6 +191,7 @@ class ApiMove extends ApiBase {
$watchlistExpiry = $this->getExpiryFromParams( $params );
// Watch pages
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable T240141
$this->setWatch( $watch, $fromTitle, $user, 'watchmoves', $watchlistExpiry );
$this->setWatch( $watch, $toTitle, $user, 'watchmoves', $watchlistExpiry );

View file

@ -273,6 +273,7 @@ class ApiPageSet extends ApiBase {
}
// Create a temporary pageset to store generator's output,
// add any additional fields generator may need, and execute pageset to populate titles/pageids
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable T240141
$tmpPageSet = new ApiPageSet( $dbSource, self::DISABLE_GENERATORS );
$generator->setGeneratorMode( $tmpPageSet );
$this->mCacheMode = $generator->getCacheMode( $generator->extractRequestParams() );
@ -286,6 +287,7 @@ class ApiPageSet extends ApiBase {
if ( !$isDryRun ) {
$generator->executeGenerator( $this );
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable T240141
$this->getHookRunner()->onAPIQueryGeneratorAfterExecute( $generator, $this );
} else {
// Prevent warnings from being reported on these parameters
@ -1385,6 +1387,7 @@ class ApiPageSet extends ApiBase {
// ILanguageConverter::findVariantLink will modify titleText and
// titleObj into the canonical variant if possible
$titleText = $title !== false ? $title : $titleObj->getPrefixedText();
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
$this->languageConverter->findVariantLink( $titleText, $titleObj );
$titleWasConverted = $unconvertedTitle !== $titleObj->getPrefixedText();
}
@ -1420,6 +1423,7 @@ class ApiPageSet extends ApiBase {
}
} else {
// Regular page
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
$linkBatch->addObj( $titleObj );
}
}

View file

@ -86,6 +86,7 @@ class ApiParamInfo extends ApiBase {
}
continue;
}
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable recursive is set when used
$submodules = $this->listAllSubmodules( $module, $recursive );
if ( $submodules ) {
$modules = array_merge( $modules, $submodules );

View file

@ -819,6 +819,7 @@ class ApiParse extends ApiBase {
$this->dieWithError( [ 'apierror-sectionsnotsupported-what', $what ], 'nosuchsection' );
}
// @phan-suppress-next-line PhanTypeMismatchReturnNullable T240141
return $section;
}

View file

@ -443,7 +443,7 @@ abstract class ApiQueryBase extends ApiBase {
* @since 1.28
* @param stdClass $row Database row
* @param array &$data Data to be added to the result
* @param array &$hookData Hook data from ApiQueryBase::select()
* @param array &$hookData Hook data from ApiQueryBase::select() @phan-output-reference
* @return bool Return false if row processing should end with continuation
*/
protected function processRow( $row, array &$data, array &$hookData ) {

View file

@ -219,6 +219,7 @@ class ApiQueryContributors extends ApiQueryBase {
'ug_expiry IS NULL OR ug_expiry >= ' . $db->addQuotes( $db->timestamp() )
]
] ] );
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable excludeGroups is set when used
$this->addWhereIf( 'ug_user IS NULL', $excludeGroups );
}

View file

@ -364,6 +364,7 @@ class ApiQueryInfo extends ApiQueryBase {
$pageInfo['preload'] = '';
} else {
$text = null;
// @phan-suppress-next-line PhanTypeMismatchArgument Type mismatch on pass-by-ref args
$this->getHookRunner()->onEditFormPreloadText( $text, $title );
$pageInfo['preload'] = $text;

View file

@ -165,7 +165,9 @@ class ApiQueryLogEvents extends ApiQueryBase {
);
}
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable T240141
$this->addWhereFld( 'log_type', $type );
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable T240141
$this->addWhereFld( 'log_action', $action );
} elseif ( $params['type'] !== null ) {
$this->addWhereFld( 'log_type', $params['type'] );
@ -322,6 +324,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
}
if ( LogEventsList::userCan( $row, LogPage::DELETED_ACTION, $user ) ) {
if ( $this->fld_title ) {
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable title is set when used
ApiQueryBase::addTitleInfo( $vals, $title );
}
if ( $this->fld_ids ) {

View file

@ -83,6 +83,7 @@ class ApiQueryQueryPage extends ApiQueryGeneratorBase {
'Special page ' . $name . ' is not a QueryPage'
);
}
// @phan-suppress-next-line PhanTypeMismatchReturnNullable T240141
return $qp;
}

View file

@ -206,6 +206,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
if ( !$difftoRev ) {
$this->dieWithError( [ 'apierror-nosuchrevid', $params['diffto'] ] );
}
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable T240141
$revDel = $this->checkRevDel( $difftoRev, RevisionRecord::DELETED_TEXT );
if ( $revDel & self::CANNOT_VIEW ) {
$this->addWarning( [ 'apiwarn-difftohidden', $difftoRev->getId() ] );

View file

@ -341,6 +341,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
)
) {
if ( $this->fld_title ) {
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
ApiQueryBase::addTitleInfo( $vals, $title );
}
if ( $this->fld_ids ) {

View file

@ -899,6 +899,7 @@ class ApiResult implements ApiSerializable {
$keepMetadata = &$metadata;
break;
case 'bc':
// @phan-suppress-next-line PhanTypeMismatchArgumentNullableInternal Type mismatch on pass-by-ref args
$keepMetadata = array_intersect_key( $metadata, [
self::META_INDEXED_TAG_NAME => 1,
self::META_SUBELEMENTS => 1,
@ -943,6 +944,7 @@ class ApiResult implements ApiSerializable {
ksort( $data );
$data = array_values( $data );
$metadata[self::META_TYPE] = 'array';
// @phan-suppress-next-line PhanTypeMismatchReturnNullable Type mismatch on pass-by-ref args
return $data + $keepMetadata;
case 'kvp':
@ -992,6 +994,7 @@ class ApiResult implements ApiSerializable {
}
$metadata[self::META_TYPE] = 'array';
// @phan-suppress-next-line PhanTypeMismatchReturnNullable Type mismatch on pass-by-ref args
return $ret + $keepMetadata;
default:

View file

@ -93,6 +93,7 @@ class ApiRevisionDelete extends ApiBase {
// TODO: replace use of PermissionManager
if ( $this->getPermissionManager()->isBlockedFrom( $user, $targetObj ) ) {
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable Block is checked and not null
$this->dieBlocked( $user->getBlock() );
}

View file

@ -120,6 +120,7 @@ class ApiTag extends ApiBase {
$idResult += $this->getErrorFormatter()->formatMessage( ApiMessage::create(
'apierror-blocked',
'blocked',
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable Block is checked and not null
[ 'blockinfo' => $this->getBlockDetails( $user->getBlock() ) ]
) );
return $idResult;
@ -137,6 +138,7 @@ class ApiTag extends ApiBase {
$idResult += $this->getErrorFormatter()->formatMessage( ApiMessage::create(
'apierror-blocked',
'blocked',
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable Block is checked and not null
[ 'blockinfo' => $this->getBlockDetails( $user->getBlock() ) ]
) );
return $idResult;

View file

@ -92,6 +92,7 @@ class ApiUnblock extends ApiBase {
$this->dieWithError(
$status,
null,
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable Block is checked and not null
[ 'blockinfo' => $this->getBlockDetails( $performer->getBlock() ) ]
);
}

View file

@ -596,6 +596,7 @@ class ApiUpload extends ApiBase {
// Check blocks
if ( $user->isBlockedFromUpload() ) {
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable Block is checked and not null
$this->dieBlocked( $user->getBlock() );
}

View file

@ -1167,6 +1167,7 @@ class AuthManager implements LoggerAwareInterface {
$req->username = $username;
$req->returnToUrl = $returnToUrl;
if ( $req instanceof UserDataAuthenticationRequest ) {
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable user should be checked and valid here
$status = $req->populateUser( $user );
if ( !$status->isGood() ) {
$status = Status::wrap( $status );

View file

@ -302,6 +302,7 @@ abstract class AuthenticationRequest {
} elseif ( $username !== $req->username ) {
$requestClass = get_class( $req );
throw new \UnexpectedValueException( "Conflicting username fields: \"{$req->username}\" from "
// @phan-suppress-next-line PhanTypeSuspiciousStringExpression $otherClass always set
. "$requestClass::\$username vs. \"$username\" from $otherClass::\$username" );
}
}
@ -350,6 +351,7 @@ abstract class AuthenticationRequest {
// If there is a primary not requiring this field, no matter how many others do,
// authentication can proceed without it.
|| $req->required === self::PRIMARY_REQUIRED
// @phan-suppress-next-line PhanTypeMismatchArgumentNullableInternal False positive
&& !in_array( $name, $sharedRequiredPrimaryFields, true )
) {
$options['optional'] = true;

View file

@ -332,6 +332,7 @@ class BlockManager {
$databaseBlocks[$block->getParentBlockId()] = $block;
}
} else {
// @phan-suppress-next-line PhanTypeMismatchDimAssignment getId is not null here
$databaseBlocks[$block->getId()] = $block;
}
}

View file

@ -112,6 +112,7 @@ class PageRestriction extends AbstractRestriction {
}
$restriction = new self( 0, $title->getArticleID() );
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable Title is always valid
$restriction->setTitle( $title );
return $restriction;

View file

@ -282,6 +282,7 @@ class BacklinkCache {
return $prefixes[$table];
} else {
$prefix = null;
// @phan-suppress-next-line PhanTypeMismatchArgument Type mismatch on pass-by-ref args
$this->getHookRunner()->onBacklinkCacheGetPrefix( $table, $prefix );
if ( $prefix ) {
return $prefix;
@ -331,7 +332,11 @@ class BacklinkCache {
default:
$conds = null;
$this->getHookRunner()->onBacklinkCacheGetConditions( $table,
Title::castFromPageReference( $this->page ), $conds );
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
Title::castFromPageReference( $this->page ),
// @phan-suppress-next-line PhanTypeMismatchArgument Type mismatch on pass-by-ref args
$conds
);
if ( !$conds ) {
throw new MWException( "Invalid table \"$table\" in " . __CLASS__ );
}

View file

@ -175,6 +175,7 @@ class HtmlCacheUpdater {
}
if ( $this->useFileCache ) {
// @phan-suppress-next-line PhanTypeMismatchArgument castFrom does not return null here
$update = HtmlFileCacheUpdate::newFromPages( $pageIdentities );
if ( $this->fieldHasFlag( $flags, self::PURGE_PRESEND ) ) {
DeferredUpdates::addUpdate( $update, DeferredUpdates::PRESEND );
@ -188,6 +189,7 @@ class HtmlCacheUpdater {
$urls = [];
foreach ( $pageIdentities as $pi ) {
/** @var PageIdentity $pi */
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
$urls = array_merge( $urls, $this->getUrls( $pi, $flags ) );
}
$this->purgeUrls( $urls, $flags );
@ -235,6 +237,7 @@ class HtmlCacheUpdater {
// Extensions may add novel ways to access this content
$append = [];
$mode = $flags & self::PURGE_URLS_LINKSUPDATE_ONLY;
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
$this->hookRunner->onHtmlCacheUpdaterAppendUrls( $title, $mode, $append );
$urls = array_merge( $urls, $append );
@ -244,6 +247,7 @@ class HtmlCacheUpdater {
$urls = array_merge( $urls, $append );
// Legacy. TODO: Deprecate this
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
$this->hookRunner->onTitleSquidURLs( $title, $urls );
return $urls;

View file

@ -1065,6 +1065,7 @@ class MessageCache implements LoggerAwareInterface {
}
$message = $this->getMsgFromNamespace(
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable uckey is set when used
$this->getMessagePageName( $code, $uckey ), $code );
if ( $message !== false ) {

View file

@ -260,6 +260,7 @@ class IcuCollation extends Collation {
}
$this->mainCollator = $mainCollator;
// @phan-suppress-next-line PhanPossiblyNullTypeMismatchProperty successed before, no null check needed
$this->primaryCollator = Collator::create( $locale );
$this->primaryCollator->setStrength( Collator::PRIMARY );

View file

@ -133,14 +133,12 @@ class EtcdConfig implements Config, LoggerAwareInterface {
public function has( $name ) {
$this->load();
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable procCache is set after load()
return array_key_exists( $name, $this->procCache['config'] );
}
public function get( $name ) {
$this->load();
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable procCache is set after load()
if ( !array_key_exists( $name, $this->procCache['config'] ) ) {
throw new ConfigException( "No entry found for '$name'." );
}
@ -150,7 +148,6 @@ class EtcdConfig implements Config, LoggerAwareInterface {
public function getModifiedIndex() {
$this->load();
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable procCache is set after load()
return $this->procCache['modifiedIndex'];
}
@ -228,9 +225,11 @@ class EtcdConfig implements Config, LoggerAwareInterface {
if ( $loop->invoke() !== WaitConditionLoop::CONDITION_REACHED ) {
// No cached value exists and etcd query failed; throw an error
// @phan-suppress-next-line PhanTypeSuspiciousStringExpression WaitConditionLoop throws or error set
throw new ConfigException( "Failed to load configuration from etcd: $error" );
}
// @phan-suppress-next-line PhanTypeMismatchProperty WaitConditionLoop throws ore data set
$this->procCache = $data;
}

View file

@ -1695,6 +1695,7 @@ abstract class ContentHandler {
$po = new ParserOutput();
$parserOptions->registerWatcher( [ $po, 'recordOption' ] );
if ( Hooks::runner()->onContentGetParserOutput(
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
$content, $title, $cpoParams->getRevId(), $parserOptions, $cpoParams->getGenerateHtml(), $po )
) {
// Save and restore the old value, just in case something is reusing
@ -1715,6 +1716,7 @@ abstract class ContentHandler {
$parserOptions->setRedirectTarget( $oldRedir );
}
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
Hooks::runner()->onContentAlterParserOutput( $content, $title, $po );
$parserOptions->registerWatcher( null );
@ -1805,6 +1807,7 @@ abstract class ContentHandler {
$legacyTitle = $services->getTitleFactory()->castFromPageReference( $params->getPage() );
return $content->preSaveTransform(
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
$legacyTitle,
$legacyUser,
$params->getParserOptions()
@ -1826,6 +1829,7 @@ abstract class ContentHandler {
$services = MediaWikiServices::getInstance();
$legacyTitle = $services->getTitleFactory()->castFromPageReference( $params->getPage() );
return $content->preloadTransform(
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
$legacyTitle,
$params->getParserOptions(),
$params->getParams()
@ -1847,6 +1851,7 @@ abstract class ContentHandler {
$services = MediaWikiServices::getInstance();
$legacyTitle = $services->getTitleFactory()->castFromPageReference( $cpoParams->getPage() );
return $content->getParserOutput(
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
$legacyTitle,
$cpoParams->getRevId(),
$cpoParams->getParserOptions(),

View file

@ -268,6 +268,7 @@ final class ContentHandlerFactory implements IContentHandlerFactory {
*/
private function createContentHandlerFromHook( string $modelID ): ContentHandler {
$contentHandler = null;
// @phan-suppress-next-line PhanTypeMismatchArgument Type mismatch on pass-by-ref args
$this->hookRunner->onContentHandlerForModelID( $modelID, $contentHandler );
$this->validateContentHandler( $modelID, $contentHandler );

View file

@ -56,6 +56,7 @@ class CssContent extends TextContent {
return $this;
}
// @phan-suppress-next-line PhanTypeMismatchReturnSuperType False positive
return $this->getContentHandler()->makeRedirectContent( $target );
}

View file

@ -59,6 +59,7 @@ class JavaScriptContent extends TextContent {
return $this;
}
// @phan-suppress-next-line PhanTypeMismatchReturnSuperType False positive
return $this->getContentHandler()->makeRedirectContent( $target );
}

View file

@ -80,6 +80,7 @@ class WikitextContent extends TextContent {
* @see Content::replaceSection()
*/
public function replaceSection( $sectionId, Content $with, $sectionTitle = '' ) {
// @phan-suppress-previous-line PhanParamSignatureMismatch False positive
$myModelId = $this->getModel();
$sectionModelId = $with->getModel();
@ -253,6 +254,7 @@ class WikitextContent extends TextContent {
$title = $context->getTitle();
}
$contentRenderer = MediaWikiServices::getInstance()->getContentRenderer();
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable getTitle does not return null here
$po = $contentRenderer->getParserOutput( $this, $title, null, null, false );
$links = $po->getLinks();
$hasLinks = !empty( $links );

View file

@ -291,6 +291,7 @@ class WikitextContentHandler extends TextContentHandler {
list( $redir, $text ) = $content->getRedirectTargetAndText();
$parserOutput = $services->getParser()->getFreshParser()
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
->parse( $text, $title, $parserOptions, true, true, $revId );
// Add redirect indicator at the top

View file

@ -153,6 +153,7 @@ class LegacyHandler extends AbstractProcessingHandler {
$this->sink = null;
throw new UnexpectedValueException( sprintf(
'The stream or file "%s" could not be opened: %s',
// @phan-suppress-next-line PhanTypeMismatchArgumentInternalProbablyReal Set by error handler
$this->uri, $this->error
) );
}

View file

@ -145,12 +145,14 @@ class LineFormatter extends MonologLineFormatter {
];
$e = array_merge( $defaults, $e );
// @phan-suppress-next-line PhanTypeMismatchArgumentNullableInternal class is always set
$which = is_a( $e['class'], Error::class, true ) ? 'Error' : 'Exception';
$str = "\n[$which {$e['class']}] (" .
"{$e['file']}:{$e['line']}) {$e['message']}";
if ( $this->includeStacktraces && $e['trace'] ) {
$str .= "\n" .
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable trace is always set
MWExceptionHandler::prettyPrintTrace( $e['trace'], ' ' );
}

View file

@ -93,6 +93,7 @@ class LinksUpdate extends DataUpdate {
public function __construct( PageIdentity $page, ParserOutput $parserOutput, $recursive = true ) {
parent::__construct();
// @phan-suppress-next-line PhanPossiblyNullTypeMismatchProperty castFrom does not return null here
$this->mTitle = Title::castFromPageIdentity( $page );
$this->mParserOutput = $parserOutput;
@ -359,10 +360,12 @@ class LinksUpdate extends DataUpdate {
if ( !$backlinkCache ) {
wfDeprecatedMsg( __METHOD__ . " needs a BacklinkCache object, null passed", '1.37' );
$backlinkCache = MediaWikiServices::getInstance()->getBacklinkCacheFactory()
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
->getBacklinkCache( $title );
}
if ( $backlinkCache->hasLinks( $table ) ) {
$job = new RefreshLinksJob(
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
$title,
[
'table' => $table,

View file

@ -28,6 +28,7 @@ abstract class TitleLinksTable extends LinksTable {
* @return Title
*/
protected function makeTitle( $linkId ): Title {
// @phan-suppress-next-line PhanTypeMismatchReturnNullable castFrom does not return null here
return Title::castFromPageReference( $this->makePageReferenceValue( $linkId ) );
}

View file

@ -1916,6 +1916,7 @@ class DifferenceEngine extends ContextSource {
$newid = intval( $new );
}
// @phan-suppress-next-line PhanTypeMismatchReturn getId does not return null here
return [ $oldid, $newid ];
}
@ -1937,6 +1938,7 @@ class DifferenceEngine extends ContextSource {
}
$this->hookRunner->onNewDifferenceEngine(
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable False positive
$this->getTitle(), $this->mOldid, $this->mNewid, $old, $new );
}

View file

@ -54,6 +54,7 @@ class DifferenceEngineSlotDiffRenderer extends SlotDiffRenderer {
/** @inheritDoc */
public function getDiff( Content $oldContent = null, Content $newContent = null ) {
$this->normalizeContents( $oldContent, $newContent );
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable Null handled by normalizeContents
return $this->differenceEngine->generateContentDiffBody( $oldContent, $newContent );
}

View file

@ -287,6 +287,7 @@ class MWExceptionHandler {
break;
}
// @phan-suppress-next-line PhanTypeMismatchArgumentNullableInternal False positive
$e = new ErrorException( $prefix . $message, 0, $level, $file, $line );
self::logError( $e, 'error', $severity, self::CAUGHT_BY_HANDLER );

View file

@ -58,6 +58,7 @@ class PermissionsError extends ErrorPageError {
$groups = [];
foreach ( MediaWikiServices::getInstance()
->getGroupPermissionsLookup()
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable Null on permission is check when used here
->getGroupsWithPermission( $this->permission ) as $group
) {
$groups[] = UserGroupMembership::getLink( $group, RequestContext::getMain(), 'wiki' );

View file

@ -559,6 +559,7 @@ class WikiExporter {
throw new LogicException( 'Error while processing a stream of slot rows' );
}
// @phan-suppress-next-line PhanTypeMismatchReturnNullable False positive
return $lastRow;
}

View file

@ -80,6 +80,7 @@ trait MediaFileTrait {
foreach ( $transforms as $transformType => $transform ) {
$responseFile[$transformType] = $this->getTransformInfo(
$file,
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable False positive
$duration,
$transform['maxWidth'],
$transform['maxHeight']

View file

@ -270,6 +270,7 @@ class HTMLMultiSelectField extends HTMLFormField implements HTMLNestedFilterable
if ( $this->isSubmitAttempt( $request ) || $fromRequest ) {
// Checkboxes are just not added to the request arrays if they're not checked,
// so it's perfectly possible for there not to be an entry at all
// @phan-suppress-next-line PhanTypeMismatchReturnNullable getArray does not return null
return $fromRequest;
} else {
// That's ok, the user has not yet submitted the form, so show the defaults

View file

@ -579,6 +579,7 @@ class WikiImporter {
}
$title = Title::castFromPageIdentity( $pageIdentity );
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
return $this->hookRunner->onAfterImportPage( $title, $foreignTitle,
$revCount, $sRevCount, $pageInfo );
}

View file

@ -261,6 +261,7 @@ class WebInstaller extends Installer {
# Execute the page.
$this->currentPageName = $page->getName();
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable pageName is not null here
$this->startPageWrapper( $pageName );
if ( $page->isSlow() ) {
@ -274,6 +275,7 @@ class WebInstaller extends Installer {
if ( $result == 'skip' ) {
# Page skipped without explicit submission.
# Skip it when we click "back" so that we don't just go forward again.
// @phan-suppress-next-line PhanTypeMismatchDimAssignment pageName is not null here
$this->skippedPages[$pageName] = true;
$result = 'continue';
} else {

View file

@ -61,6 +61,7 @@ class HTMLCacheUpdateJob extends Job {
public static function newForBacklinks( PageReference $page, $table, $params = [] ) {
$title = Title::castFromPageReference( $page );
return new self(
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
$title,
[
'table' => $table,

View file

@ -3466,6 +3466,7 @@ class Language {
}
$text = implode( $comma, $list ) . $and . $space . $text;
}
// @phan-suppress-next-line PhanTypeMismatchReturnNullable False positive
return $text;
}

View file

@ -177,6 +177,7 @@ class LanguageConverterFactory {
if ( isset( $this->cache[$lang->getCode()] ) ) {
return $this->cache[$lang->getCode()];
}
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable False positive
$converter = $this->instantiateConverter( $lang );
$this->cache[$lang->getCode()] = $converter;
return $converter;

View file

@ -217,6 +217,7 @@ class LanguageNameUtils {
if ( $inLanguage !== self::AUTONYMS ) {
# TODO: also include for self::AUTONYMS, when this code is more efficient
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable False positive
$this->hookRunner->onLanguageGetTranslatedLanguageNames( $names, $inLanguage );
}

View file

@ -1496,6 +1496,7 @@ class Message implements MessageSpecifier, Serializable {
// NOTE: The constructor makes sure keysToTry isn't empty,
// so we know that $key and $message are initialized.
// @phan-suppress-next-line PhanPossiblyNullTypeMismatchProperty False positive
$this->key = $key;
$this->message = $message;
}

View file

@ -152,6 +152,7 @@ class HashRing implements Serializable {
break; // all nodes visited
}
}
// @phan-suppress-next-line PhanTypeMismatchDimFetchNullable False positive
$nodeLocation = $ring[$currentIndex][self::KEY_LOCATION];
if ( !in_array( $nodeLocation, $locations, true ) ) {
// Ignore other nodes for the same locations already added

View file

@ -79,6 +79,7 @@ class MWCryptHash {
self::$hashLength[$key] = strlen( self::hash( '', $raw ) );
}
// @phan-suppress-next-line PhanTypeMismatchReturnNullable False positive
return self::$hashLength[$key];
}

View file

@ -52,6 +52,7 @@ class SimpleCallbacks implements Callbacks {
$file = new UploadedFile( $file );
$this->files[$name] = $file;
}
// @phan-suppress-next-line PhanTypeMismatchReturnNullable False positive
return $file;
}

View file

@ -130,7 +130,7 @@ abstract class SwiftFileBackendList implements Iterator {
*
* @param string $container Resolved container name
* @param string $dir Resolved path relative to container
* @param string &$after
* @param string &$after @phan-output-reference
* @param int $limit
* @param array $params
* @return Traversable|array

View file

@ -30,6 +30,7 @@ class NotRecursiveIterator extends IteratorDecorator implements RecursiveIterato
}
public function getChildren() {
// @phan-suppress-next-line PhanTypeMismatchReturnProbablyReal False positive
return null;
}
}

View file

@ -152,6 +152,7 @@ abstract class LockManager {
);
$loop->invoke();
// @phan-suppress-next-line PhanTypeMismatchReturn WaitConditionLoop throws or status is set
return $status;
}

View file

@ -895,6 +895,7 @@ class MimeAnalyzer implements LoggerAwareInterface {
} else {
$this->logger->info( __METHOD__ . ": unable to identify type of ZIP archive" );
}
// @phan-suppress-next-line PhanTypeMismatchReturnNullable mime should be always set
return $mime;
}
@ -1009,6 +1010,7 @@ class MimeAnalyzer implements LoggerAwareInterface {
// If MIME type is unknown, guess it
if ( !$mime ) {
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable False positive
$mime = $this->guessMimeType( $path, false );
}

View file

@ -63,6 +63,7 @@ class MemcachedPhpBagOStuff extends MemcachedBagOStuff {
// T257003: only require "gets" (instead of "get") when a CAS token is needed
return $getToken
// @phan-suppress-next-line PhanTypeMismatchArgument False positive
? $this->client->get( $routeKey, $casToken )
: $this->client->get( $routeKey );
}

View file

@ -1655,6 +1655,7 @@ class WANObjectCache implements
$hasLock = $useRegenerationLock && $this->claimStampedeLock( $key );
if ( $useRegenerationLock && !$hasLock ) {
// Determine if there is stale or volatile cached value that is still usable
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable False positive
if ( $this->isValid( $volValue, $volState[self::RES_AS_OF], $minAsOf ) ) {
$this->logger->debug( "fetchOrRegenerate($key): returning stale value" );
$this->stats->timing(

View file

@ -5101,6 +5101,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
}
if ( $this->fieldHasBit( $flags, self::LOCK_TIMESTAMP ) ) {
// @phan-suppress-next-line PhanTypeMismatchReturnNullable Possible null is documented on the constant
return $lockTsUnix;
} else {
return $locked;

View file

@ -125,6 +125,7 @@ class DatabaseMysqli extends DatabaseMysqlBase {
}
$mysqli->options( MYSQLI_OPT_CONNECT_TIMEOUT, 3 );
// @phan-suppress-next-line PhanTypeMismatchArgumentNullableInternal socket seems set when used
$ok = $mysqli->real_connect( $realServer, $user, $password, $db, $port, $socket, $flags );
return $ok ? $mysqli : null;

Some files were not shown because too many files have changed in this diff Show more