Merge "Fix bunch of PHPCS errors"

This commit is contained in:
jenkins-bot 2021-04-17 12:19:30 +00:00 committed by Gerrit Code Review
commit 0e78237815
9 changed files with 71 additions and 8 deletions

View file

@ -1,15 +1,9 @@
<?xml version="1.0"?>
<ruleset>
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationProtected" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic" />
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPrivate" />
<exclude name="MediaWiki.Commenting.PropertyDocumentation.WrongStyle" />
<exclude name="MediaWiki.Usage.ExtendClassUsage.FunctionConfigUsage" />
</rule>
<file>.</file>
<arg name="extensions" value="php" />
<arg name="encoding" value="UTF-8" />
<exclude-pattern>vendor</exclude-pattern>
</ruleset>

View file

@ -27,6 +27,10 @@ use ApiResult;
use Title;
class ApiQueryLintErrors extends ApiQueryBase {
/**
* @param ApiQuery $queryModule
* @param string $moduleName
*/
public function __construct( ApiQuery $queryModule, $moduleName ) {
parent::__construct( $queryModule, $moduleName, 'lnt' );
}
@ -106,6 +110,7 @@ class ApiQueryLintErrors extends ApiQueryBase {
}
}
/** @inheritDoc */
public function getAllowedParams() {
$visibleCats = ( new CategoryManager() )->getVisibleCategories();
return [
@ -139,6 +144,7 @@ class ApiQueryLintErrors extends ApiQueryBase {
];
}
/** @inheritDoc */
public function getExamplesMessages() {
return [
'action=query&list=linterrors&lntcategories=obsolete-tag' =>

View file

@ -25,6 +25,9 @@ use ApiResult;
use MediaWiki\MediaWikiServices;
class ApiQueryLinterStats extends ApiQueryBase {
/**
* @param ApiQuery $queryModule
*/
public function __construct( ApiQuery $queryModule ) {
parent::__construct( $queryModule, 'linterstats', 'ls' );
}
@ -43,6 +46,7 @@ class ApiQueryLinterStats extends ApiQueryBase {
$this->getResult()->addValue( [ 'query', 'linterstats' ], 'totals', $totals );
}
/** @inheritDoc */
public function getExamplesMessages() {
return [
'action=query&meta=linterstats' =>

View file

@ -56,6 +56,7 @@ class ApiRecordLint extends ApiBase {
return true;
}
/** @inheritDoc */
public function getAllowedParams() {
return [
'data' => [

View file

@ -85,10 +85,18 @@ class CategoryManager {
sort( $this->categories[self::LOW] );
}
/**
* @param string $name
* @return bool
*/
public function needsParserMigrationEdit( $name ) {
return isset( $this->parserMigrationCategories[$name] );
}
/**
* @param string $name
* @return bool
*/
public function hasNameParam( $name ) {
return isset( $this->hasNameParam[$name] );
}

View file

@ -51,7 +51,7 @@ class LintError {
*/
public $templateInfo;
/*
/**
* Optional hint for the linter category ID.
* Passed through from Parsoid when a new category has been added
* that isn't known to PHP yet.

View file

@ -33,10 +33,19 @@ use TitleValue;
class LintErrorsPager extends TablePager {
/**
* @var CategoryManager
*/
private $categoryManager;
/**
* @var string
*/
private $category;
/**
* @var int|null
*/
private $categoryId;
/**
@ -55,10 +64,18 @@ class LintErrorsPager extends TablePager {
private $namespace;
/**
* @var bool|null
* @var bool
*/
private $invertnamespace;
/**
* @param IContextSource $context
* @param string $category
* @param LinkRenderer $linkRenderer
* @param CategoryManager $catManager
* @param int|null $namespace
* @param bool $invertnamespace
*/
public function __construct( IContextSource $context, $category, LinkRenderer $linkRenderer,
CategoryManager $catManager, $namespace, $invertnamespace
) {
@ -72,6 +89,7 @@ class LintErrorsPager extends TablePager {
parent::__construct( $context );
}
/** @inheritDoc */
public function getQueryInfo() {
$conds = [ 'linter_cat' => $this->categoryId ];
if ( $this->namespace !== null ) {
@ -101,10 +119,17 @@ class LintErrorsPager extends TablePager {
}
}
/** @inheritDoc */
public function isFieldSortable( $field ) {
return false;
}
/**
* @param string $name
* @param string $value
* @return string
* @throws InvalidArgumentException
*/
public function formatValue( $name, $value ) {
$row = $this->mCurrentRow;
$row->linter_cat = $this->categoryId;
@ -202,10 +227,14 @@ class LintErrorsPager extends TablePager {
}
}
/** @inheritDoc */
public function getDefaultSort() {
return 'linter_id';
}
/**
* @return string[]
*/
public function getFieldNames() {
$names = [
'title' => $this->msg( 'linter-pager-title' )->text(),

View file

@ -27,12 +27,19 @@ use SpecialPage;
class SpecialLintErrors extends SpecialPage {
/**
* @var string
*/
private $category;
public function __construct() {
parent::__construct( 'LintErrors' );
}
/**
* @param int|null $ns
* @param bool $nsinvert
*/
protected function showNamespaceFilterForm( $ns, $nsinvert ) {
$fields = [
'namespace' => [
@ -59,6 +66,9 @@ class SpecialLintErrors extends SpecialPage {
$form->prepareForm()->displayForm( false );
}
/**
* @param string|null $par
*/
public function execute( $par ) {
$this->setHeaders();
$this->outputHeader();
@ -102,6 +112,9 @@ class SpecialLintErrors extends SpecialPage {
$out->addHTML( $this->buildCategoryList( $categories, $totals ) );
}
/**
* @param CategoryManager $catManager
*/
private function showCategoryListings( CategoryManager $catManager ) {
$lookup = new TotalsLookup(
$catManager,
@ -136,10 +149,14 @@ class SpecialLintErrors extends SpecialPage {
return $html;
}
/** @inheritDoc */
public function getGroupName() {
return 'maintenance';
}
/**
* @return string[]
*/
protected function getSubpagesForPrefixSearch() {
return ( new CategoryManager() )->getVisibleCategories();
}

View file

@ -39,6 +39,10 @@ class TotalsLookup {
*/
private $catManager;
/**
* @param CategoryManager $catManager
* @param WANObjectCache $cache
*/
public function __construct( CategoryManager $catManager, WANObjectCache $cache ) {
$this->cache = $cache;
$this->catManager = $catManager;