Remove unused default values from class properties

In all these cases the property is unconditionally set in
the constructor. The extra initialisation is effectively
dead code and an extra source of errors and confusion.

Change-Id: Icae13390d5ca5c14e2754f3be4eb956dd7f54ac4
This commit is contained in:
Thiemo Kreuz 2021-05-12 10:47:18 +02:00
parent 64b8677ca2
commit 6805f39a30
29 changed files with 51 additions and 44 deletions

View file

@ -244,7 +244,7 @@ class EditPage implements IEditObject {
private $watchthis = false;
/** @var bool Corresponds to $wgWatchlistExpiry */
private $watchlistExpiryEnabled = false;
private $watchlistExpiryEnabled;
/** @var WatchedItemStoreInterface */
private $watchedItemStore;

View file

@ -43,7 +43,7 @@ class PageProps {
private const CACHE_SIZE = 100; // integer; max cached pages
/** @var MapCacheLRU */
private $cache = null;
private $cache;
/**
* @return PageProps

View file

@ -12,7 +12,7 @@ namespace MediaWiki\Rest;
class HttpException extends \Exception {
/** @var array|null */
private $errorData = null;
private $errorData;
/**
* @stable to call

View file

@ -14,7 +14,10 @@ namespace MediaWiki\Rest;
* fill with null bytes as in a real file, it throws an exception instead.
*/
class StringStream implements CopyableStreamInterface {
private $contents = '';
/** @var string */
private $contents;
/** @var int */
private $offset = 0;
/**

View file

@ -48,7 +48,7 @@ class NameTableStore {
private $tableCache = null;
/** @var bool|string */
private $domain = false;
private $domain;
/** @var int */
private $cacheTTL;
@ -60,9 +60,9 @@ class NameTableStore {
/** @var string */
private $nameField;
/** @var null|callable */
private $normalizationCallback = null;
private $normalizationCallback;
/** @var null|callable */
private $insertCallback = null;
private $insertCallback;
/**
* @param ILoadBalancer $dbLoadBalancer A load balancer for acquiring database connections

View file

@ -27,7 +27,7 @@ class ApiContinuationManager {
private $source;
private $allModules = [];
private $generatedModules = [];
private $generatedModules;
/** @var array[] */
private $continuationData = [];

View file

@ -26,7 +26,7 @@
* @ingroup API
*/
class ApiOpenSearchFormatJson extends ApiFormatJson {
private $warningsAsError = false;
private $warningsAsError;
public function __construct( ApiMain $main, $fm, $warningsAsError ) {
parent::__construct( $main, "json$fm" );

View file

@ -47,7 +47,7 @@ class ApiPageSet extends ApiBase {
private const DISABLE_GENERATORS = 1;
private $mDbSource;
private $mParams = [];
private $mParams;
private $mResolveRedirects;
private $mConvertTitles;
private $mAllowGenerator;
@ -82,7 +82,7 @@ class ApiPageSet extends ApiBase {
/** @var array */
private $mRequestedPageFields = [];
/** @var int */
private $mDefaultNamespace = NS_MAIN;
private $mDefaultNamespace;
/** @var callable|null */
private $mRedirectMergePolicy;

View file

@ -51,7 +51,7 @@ class LocalisationCache {
* Setting this reduces the overhead of cache freshness checking, which
* requires doing a stat() for every extension i18n file.
*/
private $manualRecache = false;
private $manualRecache;
/**
* The cache data. 3-d array, where the first key is the language code,

View file

@ -25,7 +25,7 @@ use Wikimedia\Assert\Assert;
* @since 1.34
*/
class ServiceOptions {
private $keys = [];
private $keys;
private $options = [];
/**

View file

@ -46,7 +46,7 @@ final class ContentHandlerFactory implements IContentHandlerFactory {
/**
* @var string[]|callable[]
*/
private $handlerSpecs = [];
private $handlerSpecs;
/**
* @var ContentHandler[] Registry of ContentHandler instances by model id

View file

@ -30,7 +30,7 @@ use Wikimedia\Assert\Assert;
*/
class HtmlFileCacheUpdate implements DeferrableUpdate, MergeableUpdate {
/** @var PageIdentity[] List of pages */
private $pages = [];
private $pages;
/**
* @param PageIdentity[] $pages List of pages

View file

@ -31,7 +31,7 @@ class ForeignAPIFile extends File {
/** @var bool */
private $mExists;
/** @var array */
private $mInfo = [];
private $mInfo;
protected $repoClass = ForeignAPIRepo::class;

View file

@ -41,7 +41,7 @@ class LocalFileRestoreBatch {
private $all;
/** @var bool Whether to remove all settings for suppressed fields */
private $unsuppress = false;
private $unsuppress;
/**
* @param LocalFile $file

View file

@ -22,7 +22,7 @@
* Wrapper around strtr() that holds replacements
*/
class ReplacementArray {
private $data = [];
private $data;
/**
* Create an object with the specified replacement array

View file

@ -38,7 +38,7 @@ class LBFactorySimple extends LBFactory {
private $loadMonitorConfig;
/** @var array[] Map of (server index => server config map) */
private $mainServers = [];
private $mainServers;
/** @var array[][] Map of (cluster => server index => server config map) */
private $externalServersByCluster = [];

View file

@ -35,8 +35,8 @@ class SVGReader {
public const LANG_PREFIX_MATCH = 1;
public const LANG_FULL_MATCH = 2;
/** @var null|XMLReader */
private $reader = null;
/** @var XMLReader */
private $reader;
/** @var bool */
private $mDebug = false;

View file

@ -43,17 +43,17 @@ class VersionChecker {
/**
* @var string[] List of installed PHP extensions
*/
private $phpExtensions = [];
private $phpExtensions;
/**
* @var bool[] List of provided abilities
*/
private $abilities = [];
private $abilities;
/**
* @var string[] List of provided ability errors
*/
private $abilityErrors = [];
private $abilityErrors;
/**
* @var array Loaded extensions

View file

@ -131,7 +131,7 @@ final class SessionBackend {
private $delaySave = 0;
/** @var bool */
private $usePhpSessionHandling = true;
private $usePhpSessionHandling;
/** @var bool */
private $checkPHPSessionRecursionGuard = false;

View file

@ -36,13 +36,13 @@ class Token {
public const SUFFIX = '+\\';
/** @var string */
private $secret = '';
private $secret;
/** @var string */
private $salt = '';
private $salt;
/** @var bool */
private $new = false;
private $new;
/**
* @param string $secret Token secret

View file

@ -54,7 +54,7 @@ class SkinFactory {
*
* @var string[]
*/
private $skipSkins = [];
private $skipSkins;
/**
* @internal For ServiceWiring only

View file

@ -44,7 +44,7 @@ class SpecialBotPasswords extends FormSpecialPage {
private $password = null;
/** @var Psr\Log\LoggerInterface */
private $logger = null;
private $logger;
/** @var PasswordFactory */
private $passwordFactory;

View file

@ -28,10 +28,10 @@ use MediaWiki\MediaWikiServices;
class ImportReporter extends ContextSource {
use ProtectedHookAccessorTrait;
private $reason = false;
private $reason;
private $logTags = [];
private $mOriginalLogCallback = null;
private $mOriginalPageOutCallback = null;
private $mOriginalLogCallback;
private $mOriginalPageOutCallback;
private $mLogItemCount = 0;
private $mPageCount;
private $mIsUpload;

View file

@ -51,7 +51,7 @@ class ContribsPager extends RangeChronologicalPager {
/**
* @var string|int A single namespace number, or an empty string for all namespaces
*/
private $namespace = '';
private $namespace;
/**
* @var string|false Name of tag to filter, or false to ignore tags

View file

@ -24,9 +24,13 @@
* @since 1.23
*/
class MalformedTitleException extends Exception implements ILocalizedException {
private $titleText = null;
private $errorMessage = null;
private $errorMessageParameters = [];
/** @var string|null */
private $titleText;
/** @var string */
private $errorMessage;
/** @var array */
private $errorMessageParameters;
/**
* @stable to call

View file

@ -68,8 +68,8 @@ class BotPassword implements IDBAccessObject {
/** @var string[] */
private $grants;
/** @var int */
private $flags = self::READ_NORMAL;
/** @var int Defaults to {@see READ_NORMAL} */
private $flags;
/**
* @param stdClass $row bot_passwords database row

View file

@ -31,12 +31,12 @@ class ExternalUserNames {
/**
* @var string
*/
private $usernamePrefix = 'imported';
private $usernamePrefix;
/**
* @var bool
*/
private $assignKnownUsers = false;
private $assignKnownUsers;
/**
* @var bool[]

View file

@ -31,8 +31,8 @@ use Psr\Log\LogLevel;
* @since 1.27
*/
class TestLogger extends \Psr\Log\AbstractLogger {
private $collect = false;
private $collectContext = false;
private $collect;
private $collectContext;
private $buffer = [];
/** @var callable|null */
private $filter;

View file

@ -37,7 +37,7 @@ class ParserIntegrationTest extends PHPUnit\Framework\TestCase {
private $ptRunner;
/** @var string|null */
private $skipMessage = null;
private $skipMessage;
public function __construct( $runner, $fileName, $test, $skipMessage = null ) {
parent::__construct( 'testParse', [ ( $test['parsoid'] ?? false ) ? 'parsoid' : 'legacy parser' ],