aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--includes/api/ApiAuthManagerHelper.php9
-rw-r--r--includes/api/ApiCSPReport.php2
-rw-r--r--includes/api/ApiComparePages.php4
-rw-r--r--includes/api/ApiEditPage.php1
-rw-r--r--includes/api/ApiHelp.php1
-rw-r--r--includes/api/ApiImageRotate.php10
-rw-r--r--includes/api/ApiMain.php13
-rw-r--r--includes/api/ApiManageTags.php30
-rw-r--r--includes/api/ApiMove.php1
-rw-r--r--includes/api/ApiOpenSearch.php3
-rw-r--r--includes/api/ApiPageSet.php5
-rw-r--r--includes/api/ApiParamInfo.php2
-rw-r--r--includes/api/ApiQueryBlockInfoTrait.php1
-rw-r--r--includes/api/ApiQueryFileRepoInfo.php14
-rw-r--r--includes/api/ApiQueryLogEvents.php1
-rw-r--r--includes/api/ApiQueryRecentChanges.php1
-rw-r--r--includes/api/ApiQueryRevisionsBase.php1
-rw-r--r--includes/api/ApiQueryUserContribs.php5
-rw-r--r--includes/api/ApiQueryUsers.php2
-rw-r--r--includes/api/ApiQueryWatchlist.php1
-rw-r--r--includes/api/ApiRemoveAuthenticationData.php3
-rw-r--r--includes/api/ApiRevisionDelete.php2
-rw-r--r--includes/api/Validator/ApiParamValidatorCallbacks.php1
-rw-r--r--includes/api/Validator/SubmoduleDef.php1
24 files changed, 70 insertions, 44 deletions
diff --git a/includes/api/ApiAuthManagerHelper.php b/includes/api/ApiAuthManagerHelper.php
index d8db845bc80d..dad9805fb480 100644
--- a/includes/api/ApiAuthManagerHelper.php
+++ b/includes/api/ApiAuthManagerHelper.php
@@ -148,9 +148,12 @@ class ApiAuthManagerHelper {
$wantedRequests = [ $params['request'] => true ];
}
if ( $wantedRequests !== null ) {
- $reqs = array_filter( $reqs, function ( $req ) use ( $wantedRequests ) {
- return isset( $wantedRequests[$req->getUniqueId()] );
- } );
+ $reqs = array_filter(
+ $reqs,
+ function ( AuthenticationRequest $req ) use ( $wantedRequests ) {
+ return isset( $wantedRequests[$req->getUniqueId()] );
+ }
+ );
}
// Collect the fields for all the requests
diff --git a/includes/api/ApiCSPReport.php b/includes/api/ApiCSPReport.php
index be2da342802f..b9f44499bafa 100644
--- a/includes/api/ApiCSPReport.php
+++ b/includes/api/ApiCSPReport.php
@@ -21,6 +21,7 @@
*/
use MediaWiki\Logger\LoggerFactory;
+use Psr\Log\LoggerInterface;
/**
* Api module to receive and log CSP violation reports
@@ -29,6 +30,7 @@ use MediaWiki\Logger\LoggerFactory;
*/
class ApiCSPReport extends ApiBase {
+ /** @var LoggerInterface */
private $log;
/**
diff --git a/includes/api/ApiComparePages.php b/includes/api/ApiComparePages.php
index 3c632fad0969..a7f7c938033c 100644
--- a/includes/api/ApiComparePages.php
+++ b/includes/api/ApiComparePages.php
@@ -38,7 +38,9 @@ class ApiComparePages extends ApiBase {
/** @var \MediaWiki\Revision\SlotRoleRegistry */
private $slotRoleRegistry;
- private $guessedTitle = false, $props;
+ /** @var Title|false */
+ private $guessedTitle = false;
+ private $props;
/** @var IContentHandlerFactory */
private $contentHandlerFactory;
diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php
index 6a0ce5eede75..c9487857108f 100644
--- a/includes/api/ApiEditPage.php
+++ b/includes/api/ApiEditPage.php
@@ -387,7 +387,6 @@ class ApiEditPage extends ApiBase {
$ep->setApiEditOverride( true );
$ep->setContextTitle( $titleObj );
$ep->importFormData( $req );
- $content = $ep->textbox1;
// Do the actual save
$oldRevId = $articleObject->getRevIdFetched();
diff --git a/includes/api/ApiHelp.php b/includes/api/ApiHelp.php
index ab6c77345948..a0fcd9c91c78 100644
--- a/includes/api/ApiHelp.php
+++ b/includes/api/ApiHelp.php
@@ -192,6 +192,7 @@ class ApiHelp extends ApiBase {
$doc = $formatter->getDoc();
$xpath = new DOMXPath( $doc );
$nodes = $xpath->query( '//a[@href][not(contains(@class,\'apihelp-linktrail\'))]' );
+ /** @var DOMElement $node */
foreach ( $nodes as $node ) {
$href = $node->getAttribute( 'href' );
do {
diff --git a/includes/api/ApiImageRotate.php b/includes/api/ApiImageRotate.php
index 8a0e8c974d66..ad48e1db6303 100644
--- a/includes/api/ApiImageRotate.php
+++ b/includes/api/ApiImageRotate.php
@@ -83,15 +83,7 @@ class ApiImageRotate extends ApiBase {
}
// Check whether we're allowed to rotate this file
- $permError = $this->checkTitleUserPermissions( $file->getTitle(), [ 'edit', 'upload' ] );
- if ( $permError ) {
- $r['result'] = 'Failure';
- $r['errors'] = $this->getErrorFormatter()->arrayFromStatus(
- $this->errorArrayToStatus( $permError )
- );
- $result[] = $r;
- continue;
- }
+ $this->checkTitleUserPermissions( $file->getTitle(), [ 'edit', 'upload' ] );
$srcPath = $file->getLocalRefPath();
if ( $srcPath === false ) {
diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php
index 3b8f6863eec7..1bfdf96899ae 100644
--- a/includes/api/ApiMain.php
+++ b/includes/api/ApiMain.php
@@ -170,7 +170,6 @@ 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 ) {
@@ -181,10 +180,11 @@ class ApiMain extends ApiBase {
$context = RequestContext::getMain();
}
// We set a derivative context so we can change stuff later
- $this->setContext( new DerivativeContext( $context ) );
+ $derivativeContext = new DerivativeContext( $context );
+ $this->setContext( $derivativeContext );
if ( isset( $request ) ) {
- $this->getContext()->setRequest( $request );
+ $derivativeContext->setRequest( $request );
} else {
$request = $this->getRequest();
}
@@ -203,7 +203,7 @@ class ApiMain extends ApiBase {
global $wgUser;
wfDebug( "API: stripping user credentials when the same-origin policy is not applied\n" );
$wgUser = new User();
- $this->getContext()->setUser( $wgUser );
+ $derivativeContext->setUser( $wgUser );
$request->response()->header( 'MediaWiki-Login-Suppressed: true' );
}
}
@@ -226,10 +226,10 @@ class ApiMain extends ApiBase {
$uselang = MediaWikiServices::getInstance()->getContentLanguage()->getCode();
}
$code = RequestContext::sanitizeLangCode( $uselang );
- $this->getContext()->setLanguage( $code );
+ $derivativeContext->setLanguage( $code );
if ( !$this->mInternalMode ) {
global $wgLang;
- $wgLang = $this->getContext()->getLanguage();
+ $wgLang = $derivativeContext->getLanguage();
RequestContext::getMain()->setLanguage( $wgLang );
}
}
@@ -677,7 +677,6 @@ class ApiMain extends ApiBase {
$request = $this->getRequest();
$response = $request->response();
- $matchedOrigin = false;
$allowTiming = false;
$varyOrigin = true;
diff --git a/includes/api/ApiManageTags.php b/includes/api/ApiManageTags.php
index 6cd717a680fc..9347d787b8ea 100644
--- a/includes/api/ApiManageTags.php
+++ b/includes/api/ApiManageTags.php
@@ -47,15 +47,27 @@ class ApiManageTags extends ApiBase {
}
$result = $this->getResult();
- $funcName = "{$params['operation']}TagWithChecks";
- $status = ChangeTags::$funcName(
- $params['tag'],
- $params['reason'],
- $user,
- $params['ignorewarnings'],
- $params['tags'] ?: []
- );
-
+ $tag = $params['tag'];
+ $reason = $params['reason'];
+ $ignoreWarnings = $params['ignorewarnings'];
+ $tags = $params['tags'] ?: [];
+ switch ( $params['operation'] ) {
+ case 'create':
+ $status = ChangeTags::createTagWithChecks( $tag, $reason, $user, $ignoreWarnings, $tags );
+ break;
+ case 'delete':
+ $status = ChangeTags::deleteTagWithChecks( $tag, $reason, $user, $ignoreWarnings, $tags );
+ break;
+ case 'activate':
+ $status = ChangeTags::activateTagWithChecks( $tag, $reason, $user, $ignoreWarnings, $tags );
+ break;
+ case 'deactivate':
+ $status = ChangeTags::deactivateTagWithChecks( $tag, $reason, $user, $ignoreWarnings, $tags );
+ break;
+ default:
+ // unreachable
+ throw new \UnexpectedValueException( 'invalid operation' );
+ }
if ( !$status->isOK() ) {
$this->dieStatus( $status );
}
diff --git a/includes/api/ApiMove.php b/includes/api/ApiMove.php
index 74c6f8fccdb7..6c0f31f8ca19 100644
--- a/includes/api/ApiMove.php
+++ b/includes/api/ApiMove.php
@@ -216,6 +216,7 @@ class ApiMove extends ApiBase {
// At least some pages could be moved
// Report each of them separately
foreach ( $result->getValue() as $oldTitle => $status ) {
+ /** @var Status $status */
$r = [ 'from' => $oldTitle ];
if ( $status->isOK() ) {
$r['to'] = $status->getValue();
diff --git a/includes/api/ApiOpenSearch.php b/includes/api/ApiOpenSearch.php
index 8c2b3f8fed05..269a7efafeb4 100644
--- a/includes/api/ApiOpenSearch.php
+++ b/includes/api/ApiOpenSearch.php
@@ -71,7 +71,8 @@ class ApiOpenSearch extends ApiBase {
case 'xml':
$printer = $this->getMain()->createPrinterByName( 'xml' . $this->fm );
- '@phan-var ApiFormatXML $printer';
+ '@phan-var ApiFormatXml $printer';
+ /** @var ApiFormatXml $printer */
$printer->setRootElement( 'SearchSuggestion' );
return $printer;
diff --git a/includes/api/ApiPageSet.php b/includes/api/ApiPageSet.php
index f637cb1cb3e6..d2902a0e7f35 100644
--- a/includes/api/ApiPageSet.php
+++ b/includes/api/ApiPageSet.php
@@ -415,7 +415,7 @@ class ApiPageSet extends ApiBase {
/**
* Title objects for good and missing titles.
- * @return array
+ * @return Title[]
*/
public function getGoodAndMissingTitles() {
return $this->mGoodTitles + $this->mMissingTitles;
@@ -1117,6 +1117,7 @@ class ApiPageSet extends ApiBase {
if ( $this->mPendingRedirectSpecialPages ) {
foreach ( $this->mPendingRedirectSpecialPages as $key => list( $from, $to ) ) {
+ /** @var Title $from */
$fromKey = $from->getPrefixedText();
$this->mResolvedRedirectTitles[$fromKey] = $from;
$this->mRedirectTitles[$fromKey] = $to;
@@ -1163,7 +1164,6 @@ class ApiPageSet extends ApiBase {
* @return LinkBatch
*/
private function processTitlesArray( $titles ) {
- $usernames = [];
$linkBatch = new LinkBatch();
$services = MediaWikiServices::getInstance();
$contLang = $services->getContentLanguage();
@@ -1172,6 +1172,7 @@ class ApiPageSet extends ApiBase {
foreach ( $titles as $index => $title ) {
if ( is_string( $title ) ) {
try {
+ /** @var Title $titleObj */
$titleObj = Title::newFromTextThrow( $title, $this->mDefaultNamespace );
} catch ( MalformedTitleException $ex ) {
// Handle invalid titles gracefully
diff --git a/includes/api/ApiParamInfo.php b/includes/api/ApiParamInfo.php
index 86a8769db822..b3fca40d3b75 100644
--- a/includes/api/ApiParamInfo.php
+++ b/includes/api/ApiParamInfo.php
@@ -26,6 +26,8 @@
class ApiParamInfo extends ApiBase {
private $helpFormat;
+
+ /** @var RequestContext */
private $context;
public function __construct( ApiMain $main, $action ) {
diff --git a/includes/api/ApiQueryBlockInfoTrait.php b/includes/api/ApiQueryBlockInfoTrait.php
index 37ee8334ddfb..2ea4de4b8011 100644
--- a/includes/api/ApiQueryBlockInfoTrait.php
+++ b/includes/api/ApiQueryBlockInfoTrait.php
@@ -83,6 +83,7 @@ trait ApiQueryBlockInfoTrait {
/**
* @see IContextSource::getUser
+ * @return User
*/
abstract public function getUser();
diff --git a/includes/api/ApiQueryFileRepoInfo.php b/includes/api/ApiQueryFileRepoInfo.php
index 279bc0a2f3eb..2b35c979c5ea 100644
--- a/includes/api/ApiQueryFileRepoInfo.php
+++ b/includes/api/ApiQueryFileRepoInfo.php
@@ -51,12 +51,14 @@ class ApiQueryFileRepoInfo extends ApiQueryBase {
$repoGroup = $this->getInitialisedRepoGroup();
$foreignTargets = $conf->get( 'ForeignUploadTargets' );
- $repoGroup->forEachForeignRepo( function ( $repo ) use ( &$repos, $props, $foreignTargets ) {
- $repoProps = $repo->getInfo();
- $repoProps['canUpload'] = in_array( $repoProps['name'], $foreignTargets );
+ $repoGroup->forEachForeignRepo(
+ function ( FileRepo $repo ) use ( &$repos, $props, $foreignTargets ) {
+ $repoProps = $repo->getInfo();
+ $repoProps['canUpload'] = in_array( $repoProps['name'], $foreignTargets );
- $repos[] = array_intersect_key( $repoProps, $props );
- } );
+ $repos[] = array_intersect_key( $repoProps, $props );
+ }
+ );
$localInfo = $repoGroup->getLocalRepo()->getInfo();
$localInfo['canUpload'] = $conf->get( 'EnableUploads' );
@@ -90,7 +92,7 @@ class ApiQueryFileRepoInfo extends ApiQueryBase {
$props = [];
$repoGroup = $this->getInitialisedRepoGroup();
- $repoGroup->forEachForeignRepo( function ( $repo ) use ( &$props ) {
+ $repoGroup->forEachForeignRepo( function ( FileRepo $repo ) use ( &$props ) {
$props = array_merge( $props, array_keys( $repo->getInfo() ) );
} );
diff --git a/includes/api/ApiQueryLogEvents.php b/includes/api/ApiQueryLogEvents.php
index d06f154f58b3..4f031559baf0 100644
--- a/includes/api/ApiQueryLogEvents.php
+++ b/includes/api/ApiQueryLogEvents.php
@@ -31,6 +31,7 @@ use MediaWiki\Storage\NameTableAccessException;
*/
class ApiQueryLogEvents extends ApiQueryBase {
+ /** @var CommentStore */
private $commentStore;
public function __construct( ApiQuery $query, $moduleName ) {
diff --git a/includes/api/ApiQueryRecentChanges.php b/includes/api/ApiQueryRecentChanges.php
index d697948c06b2..3b9bdf00a0d4 100644
--- a/includes/api/ApiQueryRecentChanges.php
+++ b/includes/api/ApiQueryRecentChanges.php
@@ -37,6 +37,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
parent::__construct( $query, $moduleName, 'rc' );
}
+ /** @var CommentStore */
private $commentStore;
private $fld_comment = false, $fld_parsedcomment = false, $fld_user = false, $fld_userid = false,
diff --git a/includes/api/ApiQueryRevisionsBase.php b/includes/api/ApiQueryRevisionsBase.php
index 613ca6dd8a92..b55ef4346a09 100644
--- a/includes/api/ApiQueryRevisionsBase.php
+++ b/includes/api/ApiQueryRevisionsBase.php
@@ -421,6 +421,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
// @todo Move this into extractSlotInfo() (and remove its $content parameter)
// when extractDeprecatedContent() is no more.
if ( $content ) {
+ /** @var Content $content */
$vals['slots'][$role]['contentmodel'] = $content->getModel();
$vals['slots'][$role]['contentformat'] = $content->getDefaultFormat();
ApiResult::setContentValue(
diff --git a/includes/api/ApiQueryUserContribs.php b/includes/api/ApiQueryUserContribs.php
index ac8018de4b5c..4223e26f67f0 100644
--- a/includes/api/ApiQueryUserContribs.php
+++ b/includes/api/ApiQueryUserContribs.php
@@ -36,7 +36,10 @@ class ApiQueryUserContribs extends ApiQueryBase {
parent::__construct( $query, $moduleName, 'uc' );
}
- private $params, $multiUserMode, $orderBy, $parentLens, $commentStore;
+ private $params, $multiUserMode, $orderBy, $parentLens;
+
+ /** @var CommentStore */
+ private $commentStore;
private $fld_ids = false, $fld_title = false, $fld_timestamp = false,
$fld_comment = false, $fld_parsedcomment = false, $fld_flags = false,
diff --git a/includes/api/ApiQueryUsers.php b/includes/api/ApiQueryUsers.php
index 0c49ba10b95e..865752842896 100644
--- a/includes/api/ApiQueryUsers.php
+++ b/includes/api/ApiQueryUsers.php
@@ -98,8 +98,6 @@ class ApiQueryUsers extends ApiQueryBase {
public function execute() {
$db = $this->getDB();
- $commentStore = CommentStore::getStore();
-
$params = $this->extractRequestParams();
$this->requireMaxOneParameter( $params, 'userids', 'users' );
diff --git a/includes/api/ApiQueryWatchlist.php b/includes/api/ApiQueryWatchlist.php
index d68f72d75118..de8d1088de82 100644
--- a/includes/api/ApiQueryWatchlist.php
+++ b/includes/api/ApiQueryWatchlist.php
@@ -190,6 +190,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
$nsInfo = $services->getNamespaceInfo();
$usernames = [];
foreach ( $items as list( $watchedItem, $recentChangeInfo ) ) {
+ /** @var WatchedItem $watchedItem */
$linkTarget = $watchedItem->getLinkTarget();
if ( $nsInfo->hasGenderDistinction( $linkTarget->getNamespace() ) ) {
$usernames[] = $linkTarget->getText();
diff --git a/includes/api/ApiRemoveAuthenticationData.php b/includes/api/ApiRemoveAuthenticationData.php
index e18484be2c9e..4a9320fe289f 100644
--- a/includes/api/ApiRemoveAuthenticationData.php
+++ b/includes/api/ApiRemoveAuthenticationData.php
@@ -20,6 +20,7 @@
* @file
*/
+use MediaWiki\Auth\AuthenticationRequest;
use MediaWiki\Auth\AuthManager;
/**
@@ -61,7 +62,7 @@ class ApiRemoveAuthenticationData extends ApiBase {
: [];
$reqs = array_filter(
$manager->getAuthenticationRequests( $this->authAction, $this->getUser() ),
- function ( $req ) use ( $params, $blacklist ) {
+ function ( AuthenticationRequest $req ) use ( $params, $blacklist ) {
return $req->getUniqueId() === $params['request'] &&
!isset( $blacklist[get_class( $req )] );
}
diff --git a/includes/api/ApiRevisionDelete.php b/includes/api/ApiRevisionDelete.php
index 60b24f09f1f8..8076545d4040 100644
--- a/includes/api/ApiRevisionDelete.php
+++ b/includes/api/ApiRevisionDelete.php
@@ -125,7 +125,7 @@ class ApiRevisionDelete extends ApiBase {
$result->addValue( null, $this->getModuleName(), $data );
}
- private function extractStatusInfo( $status ) {
+ private function extractStatusInfo( Status $status ) {
$ret = [
'status' => $status->isOK() ? 'Success' : 'Fail',
];
diff --git a/includes/api/Validator/ApiParamValidatorCallbacks.php b/includes/api/Validator/ApiParamValidatorCallbacks.php
index 9618e1d71fb9..40da6832ec00 100644
--- a/includes/api/Validator/ApiParamValidatorCallbacks.php
+++ b/includes/api/Validator/ApiParamValidatorCallbacks.php
@@ -77,6 +77,7 @@ class ApiParamValidatorCallbacks implements Callbacks {
public function recordCondition(
DataMessageValue $message, $name, $value, array $settings, array $options
) {
+ /** @var \ApiBase $module */
$module = $options['module'];
$code = $message->getCode();
diff --git a/includes/api/Validator/SubmoduleDef.php b/includes/api/Validator/SubmoduleDef.php
index 3850ea80bcf9..345f6d19cc15 100644
--- a/includes/api/Validator/SubmoduleDef.php
+++ b/includes/api/Validator/SubmoduleDef.php
@@ -85,6 +85,7 @@ class SubmoduleDef extends EnumDef {
public function getParamInfo( $name, array $settings, array $options ) {
$info = parent::getParamInfo( $name, $settings, $options );
+ /** @var ApiBase $module */
$module = $options['module'];
if ( isset( $settings[self::PARAM_SUBMODULE_MAP] ) ) {