api: Add missing documentation to class properties

Add doc-typehints to class properties found by the PropertyDocumentation
sniff to improve the documentation.

Once the sniff is enabled it avoids that new code is missing type
declarations. This is focused on documentation and does not change code.

Change-Id: I8b33b5f4d91c1935228e7010327dbc6ce138fc00
This commit is contained in:
Umherirrender 2024-09-07 22:22:13 +02:00
parent e659256efe
commit 3fca49a1f4
33 changed files with 80 additions and 1 deletions

View file

@ -288,6 +288,7 @@ abstract class ApiBase extends ContextSource {
/** @var string */
private $mModulePrefix;
/** @var IReadableDatabase|null */
private $mReplicaDB = null;
/**
* @var array

View file

@ -46,6 +46,7 @@ class ApiComparePages extends ApiBase {
/** @var Title|null|false */
private $guessedTitle = false;
/** @var array<string,true> */
private $props;
private IContentHandlerFactory $contentHandlerFactory;

View file

@ -46,7 +46,9 @@ class ApiErrorFormatter {
protected $lang;
/** @var PageReference|null page used for rendering error messages, or null to use the dummy title */
private $title = null;
/** @var bool */
protected $useDB = false;
/** @var string */
protected $format = 'none';
/**

View file

@ -38,6 +38,7 @@ use Wikimedia\ParamValidator\TypeDef\IntegerDef;
*/
class ApiFeedRecentChanges extends ApiBase {
/** @var array */
private $params;
private SpecialPageFactory $specialPageFactory;

View file

@ -37,7 +37,9 @@ use Wikimedia\ParamValidator\TypeDef\IntegerDef;
*/
class ApiFeedWatchlist extends ApiBase {
/** @var ApiBase|null */
private $watchlistModule = null;
/** @var bool */
private $linkToSections = false;
private ParserFactory $parserFactory;

View file

@ -39,8 +39,11 @@ abstract class ApiFormatBase extends ApiBase {
private string $mFormat;
private string $mBuffer = '';
private bool $mDisabled = false;
/** @var bool */
private $mIsWrappedHtml = false;
/** @var int|false */
private $mHttpStatus = false;
/** @var bool */
protected $mForceDefaultParams = false;
/**

View file

@ -29,6 +29,7 @@ use Wikimedia\ParamValidator\ParamValidator;
*/
class ApiFormatJson extends ApiFormatBase {
/** @var bool */
private $isRaw;
public function __construct( ApiMain $main, $format ) {

View file

@ -26,7 +26,9 @@
*/
class ApiFormatRaw extends ApiFormatBase {
/** @var ApiFormatBase|null */
private $errorFallback;
/** @var bool */
private $mFailWithHTTPError = false;
/**

View file

@ -30,9 +30,13 @@ use Wikimedia\ParamValidator\ParamValidator;
*/
class ApiFormatXml extends ApiFormatBase {
/** @var string */
private $mRootElemName = 'api';
/** @var string */
public static $namespace = 'http://www.mediawiki.org/xml/api/';
/** @var bool */
private $mIncludeNamespace = false;
/** @var string|null */
private $mXslt = null;
public function getMimeType() {

View file

@ -35,8 +35,11 @@ use MediaWiki\Message\Message;
*/
class ApiHelpParamValueMessage extends Message {
/** @var string */
protected $paramValue;
/** @var bool */
protected $deprecated;
/** @var bool */
protected $internal;
/**

View file

@ -27,6 +27,7 @@ use Wikimedia\ParamValidator\ParamValidator;
* @ingroup API
*/
class ApiImageRotate extends ApiBase {
/** @var ApiPageSet|null */
private $mPageSet = null;
private RepoGroup $repoGroup;

View file

@ -29,6 +29,7 @@ use MediaWiki\Title\ForeignTitle;
* @ingroup API
*/
class ApiImportReporter extends ImportReporter {
/** @var array[] */
private $mResultArr = [];
/**

View file

@ -2417,6 +2417,7 @@ class ApiMain extends ApiBase {
}
}
/** @var bool|null */
private $mCanApiHighLimits = null;
/**

View file

@ -30,6 +30,7 @@ trait ApiMessageTrait {
/**
* Compatibility code mappings for various MW messages.
* @todo Ideally anything relying on this should be changed to use ApiMessage.
* @var string[]
*/
protected static $messageMap = [
'actionthrottledtext' => 'ratelimited',
@ -93,7 +94,9 @@ trait ApiMessageTrait {
'userrights-no-interwiki' => 'nointerwikiuserrights',
];
/** @var string|null */
protected $apiCode = null;
/** @var array */
protected $apiData = [];
public function getApiCode() {

View file

@ -35,7 +35,9 @@ use Wikimedia\ParamValidator\ParamValidator;
class ApiOpenSearch extends ApiBase {
use SearchApi;
/** @var string|null */
private $format = null;
/** @var string|null */
private $fm = null;
private LinkBatchFactory $linkBatchFactory;

View file

@ -26,6 +26,7 @@
* @ingroup API
*/
class ApiOpenSearchFormatJson extends ApiFormatJson {
/** @var bool */
private $warningsAsError;
public function __construct( ApiMain $main, $fm, $warningsAsError ) {

View file

@ -33,6 +33,7 @@ use Wikimedia\ParamValidator\ParamValidator;
*/
class ApiParamInfo extends ApiBase {
/** @var string */
private $helpFormat;
/** @var RequestContext */

View file

@ -567,7 +567,9 @@ class ApiQuery extends ApiBase {
*/
private $mPageSet;
/** @var array */
private $mParams;
/** @var ApiModuleManager */
private $mModuleMgr;
private WikiExporterFactory $wikiExporterFactory;

View file

@ -40,10 +40,15 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase {
private string $table;
private string $tablePrefix;
private string $indexTag;
/** @var string */
private $fieldTitle = 'title';
/** @var int */
private $dfltNamespace = NS_MAIN;
/** @var bool */
private $hasNamespace = true;
/** @var string|null */
private $useIndex = null;
/** @var array */
private $props = [];
private NamespaceInfo $namespaceInfo;

View file

@ -45,9 +45,11 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
*/
private $linksMigration;
/** @var array */
private $params;
/** @var array */
private $cont;
/** @var bool */
private $redirect;
private string $bl_ns;
@ -67,9 +69,12 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
* @var array
*/
private $pageMap = [];
/** @var array */
private $resultArr;
/** @var array */
private $redirTitles = [];
/** @var string|null */
private $continueStr = null;
/** @var string[][] output element name, database column field prefix, database table */

View file

@ -27,6 +27,7 @@
*/
abstract class ApiQueryGeneratorBase extends ApiQueryBase {
/** @var ApiPageSet|null */
private $mGeneratorPageSet = null;
/**

View file

@ -36,6 +36,7 @@ use Wikimedia\ParamValidator\TypeDef\IntegerDef;
*/
class ApiQueryImageInfo extends ApiQueryBase {
public const TRANSFORM_LIMIT = 50;
/** @var int */
private static $transformCount = 0;
private RepoGroup $repoGroup;

View file

@ -95,6 +95,7 @@ class ApiQueryInfo extends ApiQueryBase {
*/
private $fld_associatedpage = false;
/** @var array */
private $params;
/** @var array<int,PageIdentity> */
@ -130,15 +131,25 @@ class ApiQueryInfo extends ApiQueryBase {
*/
private $pageLength;
/** @var array[][][] */
private $protections;
/** @var string[][][] */
private $restrictionTypes;
/** @var bool[][] */
private $watched;
/** @var int[][] */
private $watchers;
/** @var int[][] */
private $visitingwatchers;
/** @var string[][] */
private $notificationtimestamps;
/** @var int[][] */
private $talkids;
/** @var int[][] */
private $subjectids;
/** @var string[][] */
private $displaytitles;
/** @var string[][] */
private $variantTitles;
/**
@ -153,8 +164,10 @@ class ApiQueryInfo extends ApiQueryBase {
*/
private $linkClasses;
/** @var bool */
private $showZeroWatchers = false;
/** @var int */
private $countTestedActions = 0;
/**

View file

@ -55,6 +55,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
private TempUserConfig $tempUserConfig;
private LogFormatterFactory $logFormatterFactory;
/** @var string[] */
private $formattedComments = [];
/**

View file

@ -64,20 +64,31 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
// endregion
// phpcs:ignore MediaWiki.Commenting.PropertyDocumentation.WrongStyle
/** @var int|string|null */
protected $limit;
/** @var int|string|null */
protected $diffto;
/** @var string|null */
protected $difftotext;
/** @var bool */
protected $difftotextpst;
/** @var int|string|null */
protected $expandTemplates;
/** @var bool */
protected $generateXML;
/** @var int|string|null */
protected $section;
/** @var bool */
protected $parseContent;
/** @var bool */
protected $fetchContent;
/** @var string */
protected $contentFormat;
protected bool $setParsedLimit = true;
protected ?array $slotRoles = null;
/** @var string[] */
protected $slotContentFormats;
/** @var bool */
protected $needSlots;
protected bool $fld_ids = false;

View file

@ -36,6 +36,7 @@ use Wikimedia\ParamValidator\ParamValidator;
class ApiQueryUsers extends ApiQueryBase {
use ApiQueryBlockInfoTrait;
/** @var array<string,true> */
private $prop;
private UserNameUtils $userNameUtils;

View file

@ -31,7 +31,9 @@ use MediaWiki\MainConfigNames;
*/
class ApiRemoveAuthenticationData extends ApiBase {
/** @var string */
private $authAction;
/** @var string */
private $operation;
private AuthManager $authManager;

View file

@ -143,6 +143,7 @@ class ApiResult implements ApiSerializable {
*/
public const META_BC_SUBELEMENTS = '_BC_subelements';
/** @var mixed */
private $data;
private int $size;
/** @var int|false */

View file

@ -37,6 +37,7 @@ use Wikimedia\Rdbms\IConnectionProvider;
*/
class ApiSetNotificationTimestamp extends ApiBase {
/** @var ApiPageSet|null */
private $mPageSet = null;
private RevisionStore $revisionStore;

View file

@ -49,6 +49,7 @@ class ApiUpload extends ApiBase {
/** @var UploadBase|UploadFromChunks */
protected $mUpload = null;
/** @var array */
protected $mParams;
private JobQueueGroup $jobQueueGroup;

View file

@ -31,7 +31,9 @@ use Wikimedia\Message\MessageSpecifier;
*/
class ApiUsageException extends MWException implements Stringable, ILocalizedException {
/** @var string|null */
protected $modulePath;
/** @var StatusValue */
protected $status;
/**

View file

@ -35,6 +35,7 @@ use Wikimedia\ParamValidator\TypeDef\ExpiryDef;
* @ingroup API
*/
class ApiWatch extends ApiBase {
/** @var ApiPageSet|null */
private $mPageSet = null;
/** @var bool Whether watchlist expiries are enabled. */

View file

@ -51,6 +51,7 @@ trait SearchApi {
* a valid option for an array for PARAM_TYPE, so we'll use a fake name
* that can't possibly be a class name and describes what the null behavior
* does
* @var string
*/
private static $BACKEND_NULL_PARAM = 'database-backed';