aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api
diff options
context:
space:
mode:
authorUmherirrender <umherirrender_de.wp@web.de>2021-10-25 21:15:52 +0200
committerKrinkle <krinkle@fastmail.com>2022-03-21 18:25:07 +0000
commit1f71eccf6370c6e437092e4b24d4f4957cc47e84 (patch)
treef1f2feb09cfcef8d7cb1c7e9c5b4ab79cd12ca89 /includes/api
parent50938694e59f9928ea3a1e8a4144374034d43a2a (diff)
downloadmediawikicore-1f71eccf6370c6e437092e4b24d4f4957cc47e84.tar.gz
mediawikicore-1f71eccf6370c6e437092e4b24d4f4957cc47e84.zip
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
Diffstat (limited to 'includes/api')
-rw-r--r--includes/api/ApiBase.php9
-rw-r--r--includes/api/ApiComparePages.php5
-rw-r--r--includes/api/ApiEditPage.php4
-rw-r--r--includes/api/ApiFileRevert.php1
-rw-r--r--includes/api/ApiFormatXml.php3
-rw-r--r--includes/api/ApiImportReporter.php1
-rw-r--r--includes/api/ApiLogin.php1
-rw-r--r--includes/api/ApiMain.php4
-rw-r--r--includes/api/ApiMergeHistory.php1
-rw-r--r--includes/api/ApiMove.php3
-rw-r--r--includes/api/ApiPageSet.php4
-rw-r--r--includes/api/ApiParamInfo.php1
-rw-r--r--includes/api/ApiParse.php1
-rw-r--r--includes/api/ApiQueryBase.php2
-rw-r--r--includes/api/ApiQueryContributors.php1
-rw-r--r--includes/api/ApiQueryInfo.php1
-rw-r--r--includes/api/ApiQueryLogEvents.php3
-rw-r--r--includes/api/ApiQueryQueryPage.php1
-rw-r--r--includes/api/ApiQueryRevisionsBase.php1
-rw-r--r--includes/api/ApiQueryWatchlist.php1
-rw-r--r--includes/api/ApiResult.php3
-rw-r--r--includes/api/ApiRevisionDelete.php1
-rw-r--r--includes/api/ApiTag.php2
-rw-r--r--includes/api/ApiUnblock.php1
-rw-r--r--includes/api/ApiUpload.php1
25 files changed, 55 insertions, 1 deletions
diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php
index 2fca3c85d328..ec7a8574244a 100644
--- a/includes/api/ApiBase.php
+++ b/includes/api/ApiBase.php
@@ -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 );
}
}
diff --git a/includes/api/ApiComparePages.php b/includes/api/ApiComparePages.php
index 1b8974ada89d..b4ccad795778 100644
--- a/includes/api/ApiComparePages.php
+++ b/includes/api/ApiComparePages.php
@@ -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 ];
diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php
index a767dea25ece..8b7f4d6febb8 100644
--- a/includes/api/ApiEditPage.php
+++ b/includes/api/ApiEditPage.php
@@ -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
diff --git a/includes/api/ApiFileRevert.php b/includes/api/ApiFileRevert.php
index 4fefdf0577a6..84bf788af6e2 100644
--- a/includes/api/ApiFileRevert.php
+++ b/includes/api/ApiFileRevert.php
@@ -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' );
diff --git a/includes/api/ApiFormatXml.php b/includes/api/ApiFormatXml.php
index 6f7d5ce769b5..fb3cbfc02443 100644
--- a/includes/api/ApiFormatXml.php
+++ b/includes/api/ApiFormatXml.php
@@ -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 );
}
}
diff --git a/includes/api/ApiImportReporter.php b/includes/api/ApiImportReporter.php
index 32ece0655e32..d6815ecb9a1d 100644
--- a/includes/api/ApiImportReporter.php
+++ b/includes/api/ApiImportReporter.php
@@ -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;
}
diff --git a/includes/api/ApiLogin.php b/includes/api/ApiLogin.php
index 6ba75dc10e33..7e30b9eddca5 100644
--- a/includes/api/ApiLogin.php
+++ b/includes/api/ApiLogin.php
@@ -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;
diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php
index 0a384bf3d0ca..d78afce1426a 100644
--- a/includes/api/ApiMain.php
+++ b/includes/api/ApiMain.php
@@ -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;
}
diff --git a/includes/api/ApiMergeHistory.php b/includes/api/ApiMergeHistory.php
index 33f06dff77b6..abcbe7237688 100644
--- a/includes/api/ApiMergeHistory.php
+++ b/includes/api/ApiMergeHistory.php
@@ -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 );
diff --git a/includes/api/ApiMove.php b/includes/api/ApiMove.php
index 83ae0c455115..9a274e635bee 100644
--- a/includes/api/ApiMove.php
+++ b/includes/api/ApiMove.php
@@ -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 );
diff --git a/includes/api/ApiPageSet.php b/includes/api/ApiPageSet.php
index 7734ced72740..d6f2d575b664 100644
--- a/includes/api/ApiPageSet.php
+++ b/includes/api/ApiPageSet.php
@@ -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 );
}
}
diff --git a/includes/api/ApiParamInfo.php b/includes/api/ApiParamInfo.php
index 9ed6a49d2e8c..8e3fbd47365e 100644
--- a/includes/api/ApiParamInfo.php
+++ b/includes/api/ApiParamInfo.php
@@ -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 );
diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php
index bb852afd910d..d00b425f59df 100644
--- a/includes/api/ApiParse.php
+++ b/includes/api/ApiParse.php
@@ -819,6 +819,7 @@ class ApiParse extends ApiBase {
$this->dieWithError( [ 'apierror-sectionsnotsupported-what', $what ], 'nosuchsection' );
}
+ // @phan-suppress-next-line PhanTypeMismatchReturnNullable T240141
return $section;
}
diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php
index fedcdd6286ed..9e622ed810af 100644
--- a/includes/api/ApiQueryBase.php
+++ b/includes/api/ApiQueryBase.php
@@ -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 ) {
diff --git a/includes/api/ApiQueryContributors.php b/includes/api/ApiQueryContributors.php
index 0b841c2dd422..adba44a3987f 100644
--- a/includes/api/ApiQueryContributors.php
+++ b/includes/api/ApiQueryContributors.php
@@ -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 );
}
diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php
index 718a5e2f7f8c..f680681639c4 100644
--- a/includes/api/ApiQueryInfo.php
+++ b/includes/api/ApiQueryInfo.php
@@ -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;
diff --git a/includes/api/ApiQueryLogEvents.php b/includes/api/ApiQueryLogEvents.php
index a2f6d15ed367..48e543e8ba83 100644
--- a/includes/api/ApiQueryLogEvents.php
+++ b/includes/api/ApiQueryLogEvents.php
@@ -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 ) {
diff --git a/includes/api/ApiQueryQueryPage.php b/includes/api/ApiQueryQueryPage.php
index 406e36f61f81..b5345356f318 100644
--- a/includes/api/ApiQueryQueryPage.php
+++ b/includes/api/ApiQueryQueryPage.php
@@ -83,6 +83,7 @@ class ApiQueryQueryPage extends ApiQueryGeneratorBase {
'Special page ' . $name . ' is not a QueryPage'
);
}
+ // @phan-suppress-next-line PhanTypeMismatchReturnNullable T240141
return $qp;
}
diff --git a/includes/api/ApiQueryRevisionsBase.php b/includes/api/ApiQueryRevisionsBase.php
index 88a2d978dbf8..90e8e7984374 100644
--- a/includes/api/ApiQueryRevisionsBase.php
+++ b/includes/api/ApiQueryRevisionsBase.php
@@ -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() ] );
diff --git a/includes/api/ApiQueryWatchlist.php b/includes/api/ApiQueryWatchlist.php
index 8a3c4268293b..b7577a7427b3 100644
--- a/includes/api/ApiQueryWatchlist.php
+++ b/includes/api/ApiQueryWatchlist.php
@@ -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 ) {
diff --git a/includes/api/ApiResult.php b/includes/api/ApiResult.php
index a4ce67947d9c..793d5e930fe2 100644
--- a/includes/api/ApiResult.php
+++ b/includes/api/ApiResult.php
@@ -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:
diff --git a/includes/api/ApiRevisionDelete.php b/includes/api/ApiRevisionDelete.php
index 7db62b9162d6..6eeb62434e0f 100644
--- a/includes/api/ApiRevisionDelete.php
+++ b/includes/api/ApiRevisionDelete.php
@@ -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() );
}
diff --git a/includes/api/ApiTag.php b/includes/api/ApiTag.php
index 2a4634a26018..1338feaf5191 100644
--- a/includes/api/ApiTag.php
+++ b/includes/api/ApiTag.php
@@ -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;
diff --git a/includes/api/ApiUnblock.php b/includes/api/ApiUnblock.php
index cb124cf1899e..9fb3a370dd8c 100644
--- a/includes/api/ApiUnblock.php
+++ b/includes/api/ApiUnblock.php
@@ -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() ) ]
);
}
diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php
index 0c8ee166da35..04a5c73dd746 100644
--- a/includes/api/ApiUpload.php
+++ b/includes/api/ApiUpload.php
@@ -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() );
}