Fix more Squiz.Scope.MethodScope.Missing

Member variables in HistoryBlobStub have been marked protected

SpecialPage::setListed() and listed() have been deprecated

CategoryPage::getCategoryViewerClass() and setCategoryViewerClass()
have been deprecated

Change-Id: Id1f530c2c8ec1171615f726dc7446431ee7ca8fe
This commit is contained in:
Reedy 2020-05-17 17:28:19 +01:00 committed by Jforrester
parent ec5f8b2c69
commit 51d3ade7d4
10 changed files with 77 additions and 67 deletions

View file

@ -19,10 +19,6 @@
</rule>
<!-- TODO Still to be done -->
<rule ref="Squiz.Scope.MethodScope.Missing">
<exclude-pattern>includes/historyblob/HistoryBlobStub.php</exclude-pattern>
<exclude-pattern>includes/historyblob/DiffHistoryBlob.php</exclude-pattern>
<exclude-pattern>includes/page/CategoryPage.php</exclude-pattern>
<exclude-pattern>includes/pager/IndexPager.php</exclude-pattern>
<exclude-pattern>includes/parser/Sanitizer.php</exclude-pattern>
<exclude-pattern>includes/filerepo/</exclude-pattern>
<exclude-pattern>includes/libs/rdbms/field/SQLiteField.php</exclude-pattern>
@ -35,10 +31,6 @@
<exclude-pattern>includes/skins/QuickTemplate.php</exclude-pattern>
<exclude-pattern>includes/skins/BaseTemplate.php</exclude-pattern>
<exclude-pattern>includes/specials/</exclude-pattern>
<exclude-pattern>includes/specialpage/QueryPage.php</exclude-pattern>
<exclude-pattern>includes/specialpage/SpecialPage.php</exclude-pattern>
<exclude-pattern>includes/specialpage/WantedQueryPage.php</exclude-pattern>
<exclude-pattern>includes/specialpage/ImageQueryPage.php</exclude-pattern>
<exclude-pattern>includes/user/User.php</exclude-pattern>
<exclude-pattern>includes/user/UserRightsProxy.php</exclude-pattern>
<exclude-pattern>includes/user/UserArrayFromResult.php</exclude-pattern>

View file

@ -1031,6 +1031,11 @@ because of Phabricator reports.
* UserRetrieveNewTalks hook was deprecated without replacement.
* User::getNewtalk and ::setNewtalk were deprecated. Use service
TalkPageNotificationManager instead.
* SpecialPage::setListed() and SpecialPage::listed() were deprecated. Subclass
UnlistedSpecialPage to set listed as false, and use SpecialPage::isListed()
to get the value.
* CategoryPage::getCategoryViewerClass() and ::setCategoryViewerClass() were
deprecated.
* …
=== Other changes in 1.35 ===

View file

@ -79,7 +79,7 @@ class DiffHistoryBlob implements HistoryBlob {
* @param string $text
* @return int
*/
function addItem( $text ) {
public function addItem( $text ) {
if ( $this->mFrozen ) {
throw new MWException( __METHOD__ . ": Cannot add more items after sleep/wakeup" );
}
@ -94,28 +94,28 @@ class DiffHistoryBlob implements HistoryBlob {
* @param string $key
* @return string
*/
function getItem( $key ) {
public function getItem( $key ) {
return $this->mItems[$key];
}
/**
* @param string $text
*/
function setText( $text ) {
public function setText( $text ) {
$this->mDefaultKey = $this->addItem( $text );
}
/**
* @return string
*/
function getText() {
public function getText() {
return $this->getItem( $this->mDefaultKey );
}
/**
* @throws MWException
*/
function compress() {
private function compress() {
if ( !function_exists( 'xdiff_string_rabdiff' ) ) {
throw new MWException( "Need xdiff 1.5+ support to write DiffHistoryBlob\n" );
}
@ -192,7 +192,7 @@ class DiffHistoryBlob implements HistoryBlob {
* @param string $t2
* @return string
*/
function diff( $t1, $t2 ) {
private function diff( $t1, $t2 ) {
# Need to do a null concatenation with warnings off, due to bugs in the current version of xdiff
# "String is not zero-terminated"
Wikimedia\suppressWarnings();
@ -206,7 +206,7 @@ class DiffHistoryBlob implements HistoryBlob {
* @param string $diff
* @return bool|string
*/
function patch( $base, $diff ) {
private function patch( $base, $diff ) {
if ( function_exists( 'xdiff_string_bpatch' ) ) {
Wikimedia\suppressWarnings();
$text = xdiff_string_bpatch( $base, $diff ) . '';
@ -268,7 +268,7 @@ class DiffHistoryBlob implements HistoryBlob {
* @param string $s
* @return string|bool False if the hash extension is not available
*/
function xdiffAdler32( $s ) {
public function xdiffAdler32( $s ) {
if ( !function_exists( 'hash' ) ) {
return false;
}
@ -284,7 +284,7 @@ class DiffHistoryBlob implements HistoryBlob {
return strrev( hash( 'adler32', $init . $s, true ) );
}
function uncompress() {
private function uncompress() {
if ( !$this->mDiffs ) {
return;
}
@ -368,7 +368,7 @@ class DiffHistoryBlob implements HistoryBlob {
*
* @return bool
*/
function isHappy() {
public function isHappy() {
return $this->mSize < $this->mMaxSize
&& count( $this->mItems ) < $this->mMaxCount;
}

View file

@ -35,13 +35,13 @@ class HistoryBlobStub {
protected static $blobCache = [];
/** @var int */
public $mOldId;
protected $mOldId;
/** @var string */
public $mHash;
protected $mHash;
/** @var string */
public $mRef;
protected $mRef;
/**
* @param string $hash The content hash of the text
@ -56,7 +56,7 @@ class HistoryBlobStub {
* points
* @param int $id
*/
function setLocation( $id ) {
public function setLocation( $id ) {
$this->mOldId = $id;
}
@ -64,7 +64,7 @@ class HistoryBlobStub {
* Sets the location (old_id) of the referring object
* @param string $id
*/
function setReferrer( $id ) {
public function setReferrer( $id ) {
$this->mRef = $id;
}
@ -72,14 +72,14 @@ class HistoryBlobStub {
* Gets the location of the referring object
* @return string
*/
function getReferrer() {
public function getReferrer() {
return $this->mRef;
}
/**
* @return string|false
*/
function getText() {
public function getText() {
if ( isset( self::$blobCache[$this->mOldId] ) ) {
$obj = self::$blobCache[$this->mOldId];
} else {
@ -137,7 +137,7 @@ class HistoryBlobStub {
*
* @return string
*/
function getHash() {
public function getHash() {
return $this->mHash;
}
}

View file

@ -40,7 +40,7 @@ class CategoryPage extends Article {
return new WikiCategoryPage( $title );
}
function view() {
public function view() {
$request = $this->getContext()->getRequest();
$diff = $request->getVal( 'diff' );
$diffOnly = $request->getBool( 'diffonly',
@ -77,11 +77,11 @@ class CategoryPage extends Article {
);
}
function openShowCategory() {
public function openShowCategory() {
# For overloading
}
function closeShowCategory() {
public function closeShowCategory() {
// Use these as defaults for back compat --catrope
$request = $this->getContext()->getRequest();
$oldFrom = $request->getVal( 'from' );
@ -118,11 +118,19 @@ class CategoryPage extends Article {
$this->addHelpLink( 'Help:Categories' );
}
function getCategoryViewerClass() {
/**
* @deprecated since 1.35
*/
public function getCategoryViewerClass() {
wfDeprecated( __METHOD__, '1.35' );
return $this->mCategoryViewerClass;
}
function setCategoryViewerClass( $class ) {
/**
* @deprecated since 1.35
*/
public function setCategoryViewerClass( $class ) {
wfDeprecated( __METHOD__, '1.35' );
$this->mCategoryViewerClass = $class;
}
}

View file

@ -744,7 +744,7 @@ abstract class IndexPager extends ContextSource implements Pager {
*
* @return bool
*/
function isNavigationBarShown() {
protected function isNavigationBarShown() {
if ( !$this->mQueryDone ) {
$this->doQuery();
}

View file

@ -66,8 +66,7 @@ abstract class ImageQueryPage extends QueryPage {
}
}
// Gotta override this since it's abstract
function formatResult( $skin, $result ) {
protected function formatResult( $skin, $result ) {
return false;
}

View file

@ -147,7 +147,7 @@ abstract class QueryPage extends SpecialPage {
*
* @param bool $bool
*/
function setListoutput( $bool ) {
protected function setListoutput( $bool ) {
$this->listoutput = $bool;
}
@ -187,7 +187,7 @@ abstract class QueryPage extends SpecialPage {
* @throws MWException
* @return string
*/
function getSQL() {
protected function getSQL() {
/* Implement getQueryInfo() instead */
throw new MWException( "Bug in a QueryPage: doesn't implement getQueryInfo() nor "
. "getQuery() properly" );
@ -200,7 +200,7 @@ abstract class QueryPage extends SpecialPage {
* @return string[]
* @since 1.18
*/
function getOrderFields() {
protected function getOrderFields() {
return [ 'value' ];
}
@ -223,7 +223,7 @@ abstract class QueryPage extends SpecialPage {
*
* @return bool
*/
function sortDescending() {
protected function sortDescending() {
return true;
}
@ -264,27 +264,27 @@ abstract class QueryPage extends SpecialPage {
*
* @return bool
*/
function isSyndicated() {
public function isSyndicated() {
return true;
}
/**
* Formats the results of the query for display. The skin is the current
* skin; you can use it for making links. The result is a single row of
* result data. You should be able to grab SQL results off of it.
* result data. You should be able to grab SQL results from it.
* If the function returns false, the line output will be skipped.
* @param Skin $skin
* @param object $result Result row
* @return string|bool String or false to skip
*/
abstract function formatResult( $skin, $result );
abstract protected function formatResult( $skin, $result );
/**
* The content returned by this function will be output before any result
*
* @return string
*/
function getPageHeader() {
protected function getPageHeader() {
return '';
}
@ -306,7 +306,7 @@ abstract class QueryPage extends SpecialPage {
*
* @return array
*/
function linkParameters() {
protected function linkParameters() {
return [];
}
@ -396,7 +396,7 @@ abstract class QueryPage extends SpecialPage {
* Get a DB connection to be used for slow recache queries
* @return IDatabase
*/
function getRecacheDB() {
protected function getRecacheDB() {
return wfGetDB( DB_REPLICA, [ $this->getName(), 'QueryPage::recache', 'vslow' ] );
}
@ -529,7 +529,7 @@ abstract class QueryPage extends SpecialPage {
* @return array
* @since 1.29
*/
function getCacheOrderFields() {
protected function getCacheOrderFields() {
return [ 'value' ];
}
@ -769,14 +769,14 @@ abstract class QueryPage extends SpecialPage {
* @param int $offset
* @return string
*/
function openList( $offset ) {
protected function openList( $offset ) {
return "\n<ol start='" . ( $offset + 1 ) . "' class='special'>\n";
}
/**
* @return string
*/
function closeList() {
protected function closeList() {
return "</ol>\n";
}
@ -785,7 +785,7 @@ abstract class QueryPage extends SpecialPage {
* @param IDatabase $db
* @param IResultWrapper $res
*/
function preprocessResults( $db, $res ) {
protected function preprocessResults( $db, $res ) {
}
/**

View file

@ -150,7 +150,7 @@ class SpecialPage implements MessageLocalizer {
* Get the name of this Special Page.
* @return string
*/
function getName() {
public function getName() {
return $this->mName;
}
@ -158,7 +158,7 @@ class SpecialPage implements MessageLocalizer {
* Get the permission that a user must have to execute this page
* @return string
*/
function getRestriction() {
public function getRestriction() {
return $this->mRestriction;
}
@ -169,27 +169,33 @@ class SpecialPage implements MessageLocalizer {
* @since 1.3 (r3583)
* @return bool
*/
function isListed() {
public function isListed() {
return $this->mListed;
}
/**
* Set whether this page is listed in Special:Specialpages, at run-time
* @since 1.3
* @param bool $listed
* @deprecated since 1.35
* @param bool $listed Set via subclassing UnlistedSpecialPage, get via
* isListed()
* @return bool
*/
function setListed( $listed ) {
public function setListed( $listed ) {
wfDeprecated( __METHOD__, '1.35' );
return wfSetVar( $this->mListed, $listed );
}
/**
* Get or set whether this special page is listed in Special:SpecialPages
* @since 1.6
* @deprecated since 1.35 Set via subclassing UnlistedSpecialPage, get via
* isListed()
* @param bool|null $x
* @return bool
*/
function listed( $x = null ) {
public function listed( $x = null ) {
wfDeprecated( __METHOD__, '1.35' );
return wfSetVar( $this->mListed, $x );
}
@ -227,7 +233,7 @@ class SpecialPage implements MessageLocalizer {
* @param bool|null $x
* @return bool
*/
function including( $x = null ) {
public function including( $x = null ) {
return wfSetVar( $this->mIncluding, $x );
}
@ -235,7 +241,7 @@ class SpecialPage implements MessageLocalizer {
* Get the localised name of the special page
* @return string
*/
function getLocalName() {
public function getLocalName() {
if ( !isset( $this->mLocalName ) ) {
$this->mLocalName = MediaWikiServices::getInstance()->getSpecialPageFactory()->
getLocalNameFor( $this->mName );
@ -301,7 +307,7 @@ class SpecialPage implements MessageLocalizer {
* Output an error message telling the user what access level they have to have
* @throws PermissionsError
*/
function displayRestrictionError() {
protected function displayRestrictionError() {
throw new PermissionsError( $this->mRestriction );
}
@ -535,7 +541,7 @@ class SpecialPage implements MessageLocalizer {
/**
* Sets headers - this should be called from the execute() method of all derived classes!
*/
function setHeaders() {
protected function setHeaders() {
$out = $this->getOutput();
$out->setArticleRelated( false );
$out->setRobotPolicy( $this->getRobotPolicy() );
@ -637,7 +643,7 @@ class SpecialPage implements MessageLocalizer {
*
* @param string $summaryMessageKey Message key of the summary
*/
function outputHeader( $summaryMessageKey = '' ) {
protected function outputHeader( $summaryMessageKey = '' ) {
if ( $summaryMessageKey == '' ) {
$msg = MediaWikiServices::getInstance()->getContentLanguage()->lc( $this->getName() ) .
'-summary';
@ -659,7 +665,7 @@ class SpecialPage implements MessageLocalizer {
*
* @return string
*/
function getDescription() {
public function getDescription() {
return $this->msg( strtolower( $this->mName ) )->text();
}
@ -670,7 +676,7 @@ class SpecialPage implements MessageLocalizer {
* @return Title
* @since 1.23
*/
function getPageTitle( $subpage = false ) {
public function getPageTitle( $subpage = false ) {
return self::getTitleFor( $this->mName, $subpage );
}

View file

@ -34,7 +34,7 @@ abstract class WantedQueryPage extends QueryPage {
return true;
}
function isSyndicated() {
public function isSyndicated() {
return false;
}
@ -43,7 +43,7 @@ abstract class WantedQueryPage extends QueryPage {
* @param IDatabase $db
* @param IResultWrapper $res
*/
function preprocessResults( $db, $res ) {
protected function preprocessResults( $db, $res ) {
$this->executeLBFromResultWrapper( $res );
}
@ -55,7 +55,7 @@ abstract class WantedQueryPage extends QueryPage {
* 6220).
* @return bool
*/
function forceExistenceCheck() {
protected function forceExistenceCheck() {
return false;
}
@ -122,7 +122,7 @@ abstract class WantedQueryPage extends QueryPage {
* @return array
* @since 1.29
*/
function getOrderFields() {
protected function getOrderFields() {
return [ 'value DESC', 'namespace', 'title' ];
}
@ -135,7 +135,7 @@ abstract class WantedQueryPage extends QueryPage {
* @return bool
* @since 1.29
*/
function sortDescending() {
protected function sortDescending() {
return false;
}
@ -144,7 +144,7 @@ abstract class WantedQueryPage extends QueryPage {
* @return array
* @since 1.29
*/
function getCacheOrderFields() {
protected function getCacheOrderFields() {
return $this->getOrderFields();
}