build: Updating mediawiki/mediawiki-codesniffer to 43.0.0

The following sniffs are failing and were disabled:
* MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic

Change-Id: I6075c76d53a899aac56af027f9a956a6b9e6a667
This commit is contained in:
libraryupgrader 2024-03-16 18:52:48 +00:00
parent fb1273541e
commit a8c9fab2cc
22 changed files with 59 additions and 52 deletions

View file

@ -1,6 +1,8 @@
<?xml version="1.0"?>
<ruleset>
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki" />
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic" />
</rule>
<rule ref="Generic.Files.LineLength">
<exclude-pattern>AbuseFilter\.alias\.php</exclude-pattern>
</rule>

View file

@ -500,7 +500,7 @@ $specialPageAliases['uk'] = [
/** Urdu (اردو) */
$specialPageAliases['ur'] = [
'AbuseLog' => [ 'نوشتہ_غلط_کاری' ],
'AbuseFilter' => [ 'مقطر_غلط_کاری', 'مقطار_غلط_کاری' ],
'AbuseFilter' => [ 'مقطر_غلط_کاری', 'مقطار_غلط_کاری' ],
];
/** Venetian (vèneto) */

View file

@ -8,7 +8,7 @@
"wikimedia/equivset": "^1.6.1"
},
"require-dev": {
"mediawiki/mediawiki-codesniffer": "41.0.0",
"mediawiki/mediawiki-codesniffer": "43.0.0",
"mediawiki/mediawiki-phan-config": "0.14.0",
"mediawiki/minus-x": "1.1.1",
"php-parallel-lint/php-console-highlighter": "1.0.0",
@ -26,5 +26,10 @@
],
"phan": "phan -d . --long-progress-bar",
"phpcs": "phpcs -sp --cache"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}

View file

@ -121,7 +121,7 @@ class AbuseLogger {
$loggedGlobalFilters = [];
foreach ( $actionsTaken as $filter => $actions ) {
list( $filterID, $global ) = GlobalNameUtils::splitGlobalName( $filter );
[ $filterID, $global ] = GlobalNameUtils::splitGlobalName( $filter );
$thisLog = $logTemplate;
$thisLog['afl_filter_id'] = $filterID;
$thisLog['afl_global'] = (int)$global;

View file

@ -333,7 +333,7 @@ class ConsequencesExecutor {
switch ( $actionName ) {
case 'throttle':
$throttleId = array_shift( $rawParams );
list( $rateCount, $ratePeriod ) = explode( ',', array_shift( $rawParams ) );
[ $rateCount, $ratePeriod ] = explode( ',', array_shift( $rawParams ) );
$throttleParams = [
'id' => $throttleId,

View file

@ -51,7 +51,7 @@ class ConsequencesLookup {
$localFilters = [];
foreach ( $filters as $filter ) {
list( $filterID, $global ) = GlobalNameUtils::splitGlobalName( $filter );
[ $filterID, $global ] = GlobalNameUtils::splitGlobalName( $filter );
if ( $global ) {
$globalFilters[] = $filterID;

View file

@ -220,7 +220,7 @@ class FilterProfiler {
$slowFilterThreshold = $this->options->get( 'AbuseFilterSlowFilterRuntimeLimit' );
foreach ( $data as $filterName => $params ) {
list( $filterID, $global ) = GlobalNameUtils::splitGlobalName( $filterName );
[ $filterID, $global ] = GlobalNameUtils::splitGlobalName( $filterName );
// @todo Maybe add a parameter to recordProfilingResult to record global filters
// data separately (in the foreign wiki)
if ( !$global ) {

View file

@ -223,7 +223,7 @@ class FilterValidator {
* @return Status
*/
public function checkThrottleParameters( array $params ): Status {
list( $throttleCount, $throttlePeriod ) = explode( ',', $params[1], 2 );
[ $throttleCount, $throttlePeriod ] = explode( ',', $params[1], 2 );
$throttleGroups = array_slice( $params, 2 );
$validGroups = [
'ip',

View file

@ -25,7 +25,7 @@ class AbuseFilterModifyLogFormatter extends LogFormatter {
protected function extractParameters() {
$parameters = $this->entry->getParameters();
if ( $this->entry->isLegacy() ) {
list( $historyId, $filterId ) = $parameters;
[ $historyId, $filterId ] = $parameters;
} else {
$historyId = $parameters['historyId'];
$filterId = $parameters['newId'];

View file

@ -148,7 +148,7 @@ class AbuseFilterPager extends TablePager {
return parent::reallyDoQuery( $offset, $limit, $order );
}
list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
[ $tables, $fields, $conds, $fname, $options, $join_conds ] =
$this->buildQueryInfo( $offset, $limit, $order );
unset( $options['LIMIT'] );

View file

@ -88,7 +88,7 @@ class AFPTreeParser {
* Advances the parser to the next token in the filter code.
*/
private function move() {
list( $this->mCur, $this->mPos ) = $this->mTokens[$this->mPos];
[ $this->mCur, $this->mPos ] = $this->mTokens[$this->mPos];
}
/**

View file

@ -497,7 +497,7 @@ class FilterEvaluator {
return $this->callFunc( $functionName, $dataArgs, $node->position );
case AFPTreeNode::ARRAY_INDEX:
list( $array, $offset ) = $node->children;
[ $array, $offset ] = $node->children;
$array = $this->evalNode( $array );
// Note: we MUST evaluate the offset to ensure it is valid, regardless
@ -529,7 +529,7 @@ class FilterEvaluator {
return $array[$offset];
case AFPTreeNode::UNARY:
list( $operation, $argument ) = $node->children;
[ $operation, $argument ] = $node->children;
$argument = $this->evalNode( $argument );
if ( $operation === '-' ) {
return $argument->unaryMinus();
@ -537,30 +537,30 @@ class FilterEvaluator {
return $argument;
case AFPTreeNode::KEYWORD_OPERATOR:
list( $keyword, $leftOperand, $rightOperand ) = $node->children;
[ $keyword, $leftOperand, $rightOperand ] = $node->children;
$leftOperand = $this->evalNode( $leftOperand );
$rightOperand = $this->evalNode( $rightOperand );
return $this->callKeyword( $keyword, $leftOperand, $rightOperand, $node->position );
case AFPTreeNode::BOOL_INVERT:
list( $argument ) = $node->children;
[ $argument ] = $node->children;
$argument = $this->evalNode( $argument );
return $argument->boolInvert();
case AFPTreeNode::POW:
list( $base, $exponent ) = $node->children;
[ $base, $exponent ] = $node->children;
$base = $this->evalNode( $base );
$exponent = $this->evalNode( $exponent );
return $base->pow( $exponent );
case AFPTreeNode::MUL_REL:
list( $op, $leftOperand, $rightOperand ) = $node->children;
[ $op, $leftOperand, $rightOperand ] = $node->children;
$leftOperand = $this->evalNode( $leftOperand );
$rightOperand = $this->evalNode( $rightOperand );
return $leftOperand->mulRel( $rightOperand, $op, $node->position );
case AFPTreeNode::SUM_REL:
list( $op, $leftOperand, $rightOperand ) = $node->children;
[ $op, $leftOperand, $rightOperand ] = $node->children;
$leftOperand = $this->evalNode( $leftOperand );
$rightOperand = $this->evalNode( $rightOperand );
switch ( $op ) {
@ -575,14 +575,14 @@ class FilterEvaluator {
}
// Unreachable line
case AFPTreeNode::COMPARE:
list( $op, $leftOperand, $rightOperand ) = $node->children;
[ $op, $leftOperand, $rightOperand ] = $node->children;
$leftOperand = $this->evalNode( $leftOperand );
$rightOperand = $this->evalNode( $rightOperand );
$this->raiseCondCount();
return $leftOperand->compareOp( $rightOperand, $op );
case AFPTreeNode::LOGIC:
list( $op, $leftOperand, $rightOperand ) = $node->children;
[ $op, $leftOperand, $rightOperand ] = $node->children;
$leftOperand = $this->evalNode( $leftOperand );
$value = $leftOperand->getType() === AFPData::DUNDEFINED ? false : $leftOperand->toBool();
// Short-circuit.
@ -596,7 +596,7 @@ class FilterEvaluator {
return $leftOperand->boolOp( $rightOperand, $op );
case AFPTreeNode::CONDITIONAL:
list( $condition, $valueIfTrue, $valueIfFalse ) = $node->children;
[ $condition, $valueIfTrue, $valueIfFalse ] = $node->children;
$condition = $this->evalNode( $condition );
$isTrue = $condition->getType() === AFPData::DUNDEFINED ? false : $condition->toBool();
if ( $isTrue ) {
@ -613,13 +613,13 @@ class FilterEvaluator {
}
case AFPTreeNode::ASSIGNMENT:
list( $varName, $value ) = $node->children;
[ $varName, $value ] = $node->children;
$value = $this->evalNode( $value );
$this->setUserVariable( $varName, $value );
return $value;
case AFPTreeNode::INDEX_ASSIGNMENT:
list( $varName, $offset, $value ) = $node->children;
[ $varName, $offset, $value ] = $node->children;
$array = $this->getVarValue( $varName );
@ -658,7 +658,7 @@ class FilterEvaluator {
return $value;
case AFPTreeNode::ARRAY_APPEND:
list( $varName, $value ) = $node->children;
[ $varName, $value ] = $node->children;
$array = $this->getVarValue( $varName );
$value = $this->evalNode( $value );

View file

@ -164,7 +164,7 @@ class SyntaxChecker {
case AFPTreeNode::LOGIC:
$result = $this->newNodeBinop( $node );
list( $op, $left, $right ) = $result->children;
[ $op, $left, $right ] = $result->children;
if ( $op === '&' || $op === '|' ) {
return $this->desugarAndOr( $op, $left, $right, $node->position );
} else {
@ -190,7 +190,7 @@ class SyntaxChecker {
return $this->newNodeMapAll( $node );
case AFPTreeNode::ASSIGNMENT:
list( $varname, $value ) = $node->children;
[ $varname, $value ] = $node->children;
return new AFPTreeNode(
AFPTreeNode::FUNCTION_CALL,
@ -484,19 +484,19 @@ class SyntaxChecker {
}
case AFPTreeNode::BINOP:
list( , $left, $right ) = $node->children;
[ , $left, $right ] = $node->children;
return $this->check( $right, $this->check( $left, $bound ) );
case AFPTreeNode::UNARY:
list( , $argument ) = $node->children;
[ , $argument ] = $node->children;
return $this->check( $argument, $bound );
case AFPTreeNode::BOOL_INVERT:
list( $argument ) = $node->children;
[ $argument ] = $node->children;
return $this->check( $argument, $bound );
// phpcs:ignore PSR2.ControlStructures.SwitchDeclaration.TerminatingComment
case AFPTreeNode::CONDITIONAL:
list( $condition, $exprIfTrue, $exprIfFalse ) = $node->children;
[ $condition, $exprIfTrue, $exprIfFalse ] = $node->children;
$bound = $this->check( $condition, $bound );
$boundLeft = $this->check( $exprIfTrue, $bound );
$boundRight = $this->check( $exprIfFalse, $bound );
@ -512,7 +512,7 @@ class SyntaxChecker {
}
case AFPTreeNode::INDEX_ASSIGNMENT:
list( $varName, $offset, $value ) = $node->children;
[ $varName, $offset, $value ] = $node->children;
// deal with unbound $varName
$bound = $this->lookupVar( $varName, $node->position, $bound );
@ -522,7 +522,7 @@ class SyntaxChecker {
return $this->assignVar( $varName, $node->position, $bound );
case AFPTreeNode::ARRAY_APPEND:
list( $varName, $value ) = $node->children;
[ $varName, $value ] = $node->children;
// deal with unbound $varName
$bound = $this->lookupVar( $varName, $node->position, $bound );
@ -646,7 +646,7 @@ class SyntaxChecker {
throw new InvalidArgumentException( "$func is not a valid function." );
// @codeCoverageIgnoreEnd
}
list( $min, $max ) = FilterEvaluator::FUNC_ARG_COUNT[ $func ];
[ $min, $max ] = FilterEvaluator::FUNC_ARG_COUNT[ $func ];
if ( count( $args ) < $min ) {
throw new UserVisibleException(
$min === 1 ? 'noparams' : 'notenoughargs',

View file

@ -549,7 +549,7 @@ class SpecialAbuseLog extends AbuseFilterSpecialPage {
$filterConds = [ 'local' => [], 'global' => [] ];
foreach ( $searchIDs as $filter ) {
list( $filterID, $isGlobal ) = GlobalNameUtils::splitGlobalName( $filter );
[ $filterID, $isGlobal ] = GlobalNameUtils::splitGlobalName( $filter );
$key = $isGlobal ? 'global' : 'local';
$filterConds[$key][] = $filterID;
}

View file

@ -84,7 +84,7 @@ class SpecsFormatter {
$displayAction = $lang->commaList( $messages );
} elseif ( $action === 'throttle' ) {
array_shift( $parameters );
list( $actions, $time ) = explode( ',', array_shift( $parameters ) );
[ $actions, $time ] = explode( ',', array_shift( $parameters ) );
// Join comma-separated groups in a commaList with a final "and", and convert to messages.
// Messages used here: abusefilter-throttle-ip, abusefilter-throttle-user,

View file

@ -19,7 +19,7 @@ class ThrottleFilterPresentationModel extends EchoEventPresentationModel {
*/
public function getHeaderMessage() {
$text = $this->event->getTitle()->getText();
list( , $filter ) = explode( '/', $text, 2 );
[ , $filter ] = explode( '/', $text, 2 );
$disabledActions = $this->event->getExtraParam( 'throttled-actions' );
if ( $disabledActions === null ) {
// BC for when we didn't include the actions here.

View file

@ -89,7 +89,7 @@ class RunVariableGenerator extends VariableGenerator {
if ( $filterText === null ) {
return null;
}
list( $oldContent, $oldAfText, $text ) = $filterText;
[ $oldContent, $oldAfText, $text ] = $filterText;
return $this->newVariableHolderForEdit(
$page, $summary, $content, $text, $oldAfText, $oldContent
);
@ -202,7 +202,7 @@ class RunVariableGenerator extends VariableGenerator {
if ( $filterText === null ) {
return null;
}
list( $oldContent, $oldAfText, $text ) = $filterText;
[ $oldContent, $oldAfText, $text ] = $filterText;
} else {
// Optimization
$oldContent = null;

View file

@ -226,7 +226,7 @@ class AbuseFilterViewEdit extends AbuseFilterView {
$out->redirect( $this->getTitle()->getLocalURL() );
} else {
// Everything went fine!
list( $new_id, $history_id ) = $status->getValue();
[ $new_id, $history_id ] = $status->getValue();
$out->redirect(
$this->getTitle()->getLocalURL(
[
@ -661,7 +661,7 @@ class AbuseFilterViewEdit extends AbuseFilterView {
if ( $set ) {
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable $parameters is array here
list( $throttleCount, $throttlePeriod ) = explode( ',', $parameters[1], 2 );
[ $throttleCount, $throttlePeriod ] = explode( ',', $parameters[1], 2 );
$throttleGroups = array_slice( $parameters, 2 );
} else {
@ -921,7 +921,7 @@ class AbuseFilterViewEdit extends AbuseFilterView {
case 'block':
if ( $set && count( $parameters ) === 3 ) {
// Both blocktalk and custom block durations available
list( $blockTalk, $defaultAnonDuration, $defaultUserDuration ) = $parameters;
[ $blockTalk, $defaultAnonDuration, $defaultUserDuration ] = $parameters;
} else {
if ( $set && count( $parameters ) === 1 ) {
// Only blocktalk available

View file

@ -265,7 +265,7 @@ class MigrateActorsAF extends LoggedUpdateMaintenance {
// Update the existing rows
foreach ( $rows as $row ) {
if ( !$row->actor_id ) {
list( , $display ) = $this->makeNextCond( $dbw, $primaryKey, $row );
[ , $display ] = $this->makeNextCond( $dbw, $primaryKey, $row );
$this->error(
"Could not make actor for row with $display "
. "$userField={$row->$userField} $nameField={$row->$nameField}\n"
@ -286,7 +286,7 @@ class MigrateActorsAF extends LoggedUpdateMaintenance {
$countUpdated += $dbw->affectedRows();
}
list( $next, $display ) = $this->makeNextCond( $dbw, $primaryKey, $lastRow );
[ $next, $display ] = $this->makeNextCond( $dbw, $primaryKey, $lastRow );
$this->output( "... $display\n" );
$this->waitForReplication();
}

View file

@ -784,7 +784,7 @@ class AbuseFilterConsequencesTest extends MediaWikiIntegrationTestCase {
public function testFilterConsequences( $createIds, $actionParams, $expectedConsequences ) {
$this->createFilters( $createIds );
$result = $this->doAction( $actionParams );
list( $expected, $actual ) = $this->checkConsequences( $result, $actionParams, $expectedConsequences );
[ $expected, $actual ] = $this->checkConsequences( $result, $actionParams, $expectedConsequences );
$this->assertEquals(
$expected,
@ -1007,7 +1007,7 @@ class AbuseFilterConsequencesTest extends MediaWikiIntegrationTestCase {
$results = $this->doActions( $actionsParams );
$res = $this->checkThrottleConsequence( $results );
$lastParams = array_pop( $actionsParams );
list( $expected, $actual ) = $this->checkConsequences( $res, $lastParams, $consequences );
[ $expected, $actual ] = $this->checkConsequences( $res, $lastParams, $consequences );
$this->assertEquals(
$expected,
@ -1115,9 +1115,9 @@ class AbuseFilterConsequencesTest extends MediaWikiIntegrationTestCase {
public function testWarn( $createIds, $actionParams, $warnIDs, $consequences ) {
$this->createFilters( $createIds );
$params = [ $actionParams, $actionParams ];
list( $warnedStatus, $finalStatus ) = $this->doActions( $params );
[ $warnedStatus, $finalStatus ] = $this->doActions( $params );
list( $expectedWarn, $actualWarn ) = $this->checkConsequences(
[ $expectedWarn, $actualWarn ] = $this->checkConsequences(
$warnedStatus,
$actionParams,
[ 'warn' => $warnIDs ]
@ -1129,7 +1129,7 @@ class AbuseFilterConsequencesTest extends MediaWikiIntegrationTestCase {
'The error messages for the first action do not match.'
);
list( $expectedFinal, $actualFinal ) = $this->checkConsequences(
[ $expectedFinal, $actualFinal ] = $this->checkConsequences(
$finalStatus,
$actionParams,
$consequences
@ -1351,7 +1351,7 @@ class AbuseFilterConsequencesTest extends MediaWikiIntegrationTestCase {
$this->fail( "Did not $type the cache as expected for a stashed edit." );
}
list( $expected, $actual ) = $this->checkConsequences( $result, $actionParams, $consequences );
[ $expected, $actual ] = $this->checkConsequences( $result, $actionParams, $consequences );
$this->assertEquals(
$expected,
@ -1494,7 +1494,7 @@ class AbuseFilterConsequencesTest extends MediaWikiIntegrationTestCase {
AbuseFilterServices::getFilterLookup( $this->getServiceContainer() )->hideLocalFiltersForTesting();
$result = $this->doAction( $actionParams );
list( $expected, $actual ) = $this->checkConsequences( $result, $actionParams, $consequences );
[ $expected, $actual ] = $this->checkConsequences( $result, $actionParams, $consequences );
// First check that the filters work as expected
$this->assertEquals(

View file

@ -104,7 +104,7 @@ class FilteredActionsHandlerTest extends \MediaWikiIntegrationTestCase {
$variablesManager = $this->createMock( VariablesManager::class );
$variablesManager->method( 'getVar' )
->willReturnCallback( fn( $unused, $vars ) => AFPData::newFromPHPVar( $urlsAdded ) );
->willReturnCallback( fn ( $unused, $vars ) => AFPData::newFromPHPVar( $urlsAdded ) );
$blockedDomainStorage = $this->createMock( BlockedDomainStorage::class );
$blockedDomainStorage->method( 'loadComputed' )

View file

@ -148,7 +148,7 @@ class FilterProfilerTest extends MediaWikiUnitTestCase {
);
$found = false;
foreach ( $logger->getBuffer() as list( , $entry ) ) {
foreach ( $logger->getBuffer() as [ , $entry ] ) {
$check = preg_match(
"/^Edit filter .+ on .+ is taking longer than expected$/",
$entry