Skip to content

Commit a945538

Browse files
libraryupgraderumherirrender
libraryupgrader
authored andcommitted
build: Updating mediawiki/mediawiki-codesniffer to 46.0.0
Change-Id: I0f8a8cac36015bba52aea3ee2affd92f83d3574a
1 parent b341a16 commit a945538

26 files changed

+34
-38
lines changed

Diff for: .phan/config.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class_exists( WeakMap::class ) ? [] : [ '.phan/stubs/WeakMap.php' ],
152152
// Exclude Parsoid's src/DOM in favor of .phan/stubs/DomImpl.php
153153
$cfg['exclude_file_list'] = array_merge(
154154
$cfg['exclude_file_list'],
155-
array_map( fn ( $f ) => "vendor/wikimedia/parsoid/src/DOM/{$f}.php", [
155+
array_map( static fn ( $f ) => "vendor/wikimedia/parsoid/src/DOM/{$f}.php", [
156156
'Attr', 'CharacterData', 'Comment', 'Document', 'DocumentFragment',
157157
'DocumentType', 'Element', 'Node', 'ProcessingInstruction', 'Text',
158158
] )

Diff for: composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
"giorgiosironi/eris": "^0.14.0",
9595
"hamcrest/hamcrest-php": "^2.0",
9696
"johnkary/phpunit-speedtrap": "^4.0",
97-
"mediawiki/mediawiki-codesniffer": "45.0.0",
97+
"mediawiki/mediawiki-codesniffer": "46.0.0",
9898
"mediawiki/mediawiki-phan-config": "0.15.1",
9999
"mediawiki/minus-x": "1.1.3",
100100
"nikic/php-parser": "^5.3.1",

Diff for: includes/ResourceLoader/ForeignResourceManager.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ private function generateCdxForModules( array $modules ): array {
550550
}
551551
if ( $module['authors'] ?? false ) {
552552
$moduleCdx['authors'] = array_map(
553-
fn ( $author ) => [ 'name' => $author ],
553+
static fn ( $author ) => [ 'name' => $author ],
554554
preg_split( '/,( and)? /', $module['authors'] )
555555
);
556556
}

Diff for: includes/api/ApiParse.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ public function execute() {
569569
$langlinks = $outputPage->getLanguageLinks();
570570
} else {
571571
$langlinks = array_map(
572-
fn ( $item ) => $item['link'],
572+
static fn ( $item ) => $item['link'],
573573
$p_result->getLinkList( ParserOutputLinkTypes::LANGUAGE )
574574
);
575575
// The deprecated 'effectivelanglinks' option pre-dates OutputPage
@@ -611,7 +611,7 @@ public function execute() {
611611
}
612612
if ( isset( $prop['images'] ) ) {
613613
$result_array['images'] = array_map(
614-
fn ( $item ) => $item['link']->getDBkey(),
614+
static fn ( $item ) => $item['link']->getDBkey(),
615615
$p_result->getLinkList( ParserOutputLinkTypes::MEDIA )
616616
);
617617
}
@@ -703,7 +703,7 @@ public function execute() {
703703

704704
if ( isset( $prop['iwlinks'] ) ) {
705705
$links = array_map(
706-
fn ( $item ) => $item['link'],
706+
static fn ( $item ) => $item['link'],
707707
$p_result->getLinkList( ParserOutputLinkTypes::INTERWIKI )
708708
);
709709
$result_array['iwlinks'] = $this->formatIWLinks( $links );

Diff for: includes/auth/AuthManager.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2797,7 +2797,7 @@ private function initializeAuthenticationProviders() {
27972797
$conf = $this->config->get( MainConfigNames::AuthManagerConfig )
27982798
?: $this->config->get( MainConfigNames::AuthManagerAutoConfig );
27992799

2800-
$providers = array_map( fn ( $stepConf ) => array_fill_keys( array_keys( $stepConf ), true ), $conf );
2800+
$providers = array_map( static fn ( $stepConf ) => array_fill_keys( array_keys( $stepConf ), true ), $conf );
28012801
$this->getHookRunner()->onAuthManagerFilterProviders( $providers );
28022802
foreach ( $conf as $step => $stepConf ) {
28032803
$conf[$step] = array_intersect_key( $stepConf, array_filter( $providers[$step] ) );

Diff for: includes/http/HttpRequestFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public function request( $method, $url, array $options = [], $caller = __METHOD_
184184
if ( $status->isOK() ) {
185185
return $req->getContent();
186186
} else {
187-
$errors = array_map( fn ( $msg ) => $msg->getKey(), $status->getMessages( 'error' ) );
187+
$errors = array_map( static fn ( $msg ) => $msg->getKey(), $status->getMessages( 'error' ) );
188188
$logger->warning( Status::wrap( $status )->getWikiText( false, false, 'en' ),
189189
[ 'error' => $errors, 'caller' => $caller, 'content' => $req->getContent() ] );
190190
return null;

Diff for: includes/libs/rdbms/database/QueryBuilderFromRawSql.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ private static function getQueryVerb( $sql ) {
133133
// @phan-suppress-next-line PhanRedundantCondition https://github.com/phan/phan/issues/4720
134134
if ( !isset( self::$queryVerbRegex ) ) {
135135
$multiwordVerbsRegex = implode( '|', array_map(
136-
fn ( $words ) => str_replace( ' ', '\s+', $words ),
136+
static fn ( $words ) => str_replace( ' ', '\s+', $words ),
137137
Query::MULTIWORD_VERBS
138138
) );
139139
self::$queryVerbRegex = "/^\s*($multiwordVerbsRegex|[a-z]+)/i";

Diff for: includes/skins/components/SkinComponentUtils.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static function getReturnToParam( $title, $request, $authority ) {
5858
];
5959
( new HookRunner( MediaWikiServices::getInstance()->getHookContainer() ) )
6060
->onAuthPreserveQueryParams( $params, [ 'reset' => true ] );
61-
return array_filter( $params, fn ( $val ) => $val !== null );
61+
return array_filter( $params, static fn ( $val ) => $val !== null );
6262
}
6363

6464
# Due to T34276, if a user does not have read permissions,

Diff for: includes/specialpage/AuthManagerSpecialPage.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ protected function getPreservedParams( $options = [] ) {
583583
$params, [ 'reset' => $options['reset'] ]
584584
);
585585

586-
return array_filter( $params, fn ( $val ) => $val !== null );
586+
return array_filter( $params, static fn ( $val ) => $val !== null );
587587
}
588588

589589
/**

Diff for: includes/specialpage/ChangesListSpecialPage.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ private function removeRegistrationFilterDefinitions(): void {
609609
if ( $value['name'] == "userExpLevel" ) {
610610
$this->filterGroupDefinitions[ $key ][ 'filters' ] = array_filter(
611611
$this->filterGroupDefinitions[ $key ][ 'filters' ],
612-
fn ( $val, $key ) => $val[ 'name' ] != 'registered'
612+
static fn ( $val, $key ) => $val[ 'name' ] != 'registered'
613613
&& $val[ 'name' ] != 'unregistered', ARRAY_FILTER_USE_BOTH );
614614
}
615615
}

Diff for: includes/specialpage/LoginSignupSpecialPage.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ protected function getPreservedParams( $options = [] ) {
271271
$params['display'] = $this->mDisplay;
272272
}
273273

274-
return array_filter( $params, fn ( $val ) => $val !== null );
274+
return array_filter( $params, static fn ( $val ) => $val !== null );
275275
}
276276

277277
protected function beforeExecute( $subPage ) {

Diff for: includes/specials/SpecialWhatLinksHere.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ private function getPrevNext( $prevNamespace, $prevPageId, $nextNamespace, $next
613613
array_diff_key(
614614
array_filter(
615615
$this->formData,
616-
fn ( $value ) => $value !== null && $value !== '' && $value !== false
616+
static fn ( $value ) => $value !== null && $value !== '' && $value !== false
617617
),
618618
[ 'target' => null, 'from' => null ]
619619
)

Diff for: tests/parser/ParserTestRunner.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1654,7 +1654,7 @@ private function addParserOutputInfo(
16541654
}
16551655
if ( isset( $opts['showmedia'] ) ) {
16561656
$images = array_map(
1657-
fn ( $item ) => $item['link']->getDBkey(),
1657+
static fn ( $item ) => $item['link']->getDBkey(),
16581658
$output->getLinkList( ParserOutputLinkTypes::MEDIA )
16591659
);
16601660
$after[] = 'images=' . implode( ', ', $images );

Diff for: tests/phpunit/MediaWikiTestCaseTrait.php

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
use Wikimedia\Services\NoSuchServiceException;
1515
use Wikimedia\Timestamp\ConvertibleTimestamp;
1616

17-
// phpcs:disable MediaWiki.Commenting.FunctionAnnotations.UnrecognizedAnnotation -- Remove with v46.0.0
18-
1917
/**
2018
* For code common to both MediaWikiUnitTestCase and MediaWikiIntegrationTestCase.
2119
*/

Diff for: tests/phpunit/includes/api/query/ApiQueryBasicTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ public function testGeneratorRedirects() {
356356
public function testApiQueryCheckCanExecute() {
357357
$this->setTemporaryHook( 'ApiQueryCheckCanExecute',
358358
function ( $modules, $authority, &$message ) {
359-
$moduleNames = array_map( fn ( ApiQueryBase $module ) => $module->getModuleName(), $modules );
359+
$moduleNames = array_map( static fn ( ApiQueryBase $module ) => $module->getModuleName(), $modules );
360360
$this->assertArrayEquals( [ 'links', 'templates', 'categories' ], $moduleNames );
361361
$message = new RawMessage( 'Prevented by hook' );
362362
return false;

Diff for: tests/phpunit/includes/auth/TemporaryPasswordPrimaryAuthenticationProviderTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,11 @@ public function provideTestUserCanAuthenticateErrorCases(): iterable {
239239
yield 'nonexistent user' => [ 'DoesNotExist' ];
240240
yield 'user with invalid password' => [
241241
null,
242-
fn () => PasswordFactory::newInvalidPassword()->toString()
242+
static fn () => PasswordFactory::newInvalidPassword()->toString()
243243
];
244244
yield 'user with expired password' => [
245245
null,
246-
fn ( PasswordFactory $passwordFactory ) => $passwordFactory->newFromPlaintext( 'password' )->toString(),
246+
static fn ( PasswordFactory $passwordFactory ) => $passwordFactory->newFromPlaintext( 'password' )->toString(),
247247
time() - 3_600
248248
];
249249
}
@@ -764,7 +764,7 @@ public function testProviderChangeAuthenticationDataEmailError(
764764
$this->assertFalse( $status->isGood() );
765765
$this->assertSame(
766766
[ $expectedError ],
767-
array_map( fn ( MessageSpecifier $spec ) => $spec->getKey(), $status->getMessages() )
767+
array_map( static fn ( MessageSpecifier $spec ) => $spec->getKey(), $status->getMessages() )
768768
);
769769
}
770770

Diff for: tests/phpunit/includes/filerepo/MigrateFileRepoLayoutTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected function setUp(): void {
5252
new FakeResultWrapper( [] ), // image
5353
new FakeResultWrapper( [] ) // filearchive
5454
);
55-
$dbMock->method( 'newSelectQueryBuilder' )->willReturnCallback( fn () => new SelectQueryBuilder( $dbMock ) );
55+
$dbMock->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn () => new SelectQueryBuilder( $dbMock ) );
5656

5757
$repoMock = $this->getMockBuilder( LocalRepo::class )
5858
->onlyMethods( [ 'getPrimaryDB', 'getReplicaDB' ] )

Diff for: tests/phpunit/includes/libs/serialization/SerializationTestUtils.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public function getStoredSerializedInstance(
215215
// swap _ and - to ensure that 1.43-foo sorts after 1.43_wmf...-foo
216216
usort(
217217
$savedFiles,
218-
fn ( $a, $b ) => strtr( $a, '-_', '_-' ) <=> strtr( $b, '-_', '_-' )
218+
static fn ( $a, $b ) => strtr( $a, '-_', '_-' ) <=> strtr( $b, '-_', '_-' )
219219
);
220220
$path = end( $savedFiles );
221221
} else {

Diff for: tests/phpunit/includes/parser/BeforeParserFetchTemplateRevisionRecordTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ private function checkResult( $expected, $actual ) {
2929
$this->assertSame( $expected['finalTitle'], $actual['finalTitle']->getPrefixedText() );
3030
// Simplify 'deps'
3131
$simpleActualDeps = array_map(
32-
fn ( $dep ) => $dep['title']->getPrefixedText(),
32+
static fn ( $dep ) => $dep['title']->getPrefixedText(),
3333
$actual['deps']
3434
);
3535
$this->assertArrayEquals( $expected['deps'], $simpleActualDeps );

Diff for: tests/phpunit/includes/parser/ParserOptionsTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ public function testGetSpeculativeRevid() {
465465
public function testSetupFakeRevision_new() {
466466
$options = ParserOptions::newFromAnon();
467467
$options->setIsPreview( true );
468-
$options->setSpeculativePageIdCallback( fn () => 105 );
468+
$options->setSpeculativePageIdCallback( static fn () => 105 );
469469

470470
$page = PageIdentityValue::localIdentity( 0, NS_MAIN, __METHOD__ );
471471
$content = new DummyContentForTesting( '12345' );

Diff for: tests/phpunit/integration/includes/user/Options/UserOptionsManagerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ public function testNoLocalAccountOptionsStore() {
524524
$services->getObjectFactory(),
525525
[
526526
'NoLocalAccountStore' => [
527-
'factory' => fn () => $store,
527+
'factory' => static fn () => $store,
528528
],
529529
]
530530
);

Diff for: tests/phpunit/integration/includes/user/UserSelectQueryBuilderTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ public function testNamedAndTempWhenTempUserAutoCreateDisabled( $methodName ) {
248248
} else {
249249
// With temp users disabled, the temp user is treated as a normal user and included.
250250
$userIds = array_map(
251-
fn ( $userRow ) => $userRow['actor_user'],
251+
static fn ( $userRow ) => $userRow['actor_user'],
252252
array_filter( self::TEST_USERS, static function ( array $testUser ) {
253253
return $testUser['actor_user'] !== null;
254254
} )
@@ -257,7 +257,7 @@ public function testNamedAndTempWhenTempUserAutoCreateDisabled( $methodName ) {
257257

258258
$this->assertArrayEquals(
259259
$userIds,
260-
array_map( fn ( $actor ) => $actor->getId(), $actors )
260+
array_map( static fn ( $actor ) => $actor->getId(), $actors )
261261
);
262262
}
263263
}

Diff for: tests/phpunit/maintenance/MoveBatchTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ public function testExecuteForGoodMove(
114114

115115
public static function provideExecuteForGoodMove() {
116116
return [
117-
'No options provided' => [ [], true, '', fn () => 'Move page script' ],
117+
'No options provided' => [ [], true, '', static fn () => 'Move page script' ],
118118
'--noredirects set, custom reason, and custom performer' => [
119-
[ 'noredirects' => 1, 'r' => 'Test', 'u' => fn () => static::$testPerformer->getName() ],
120-
false, 'Test', fn () => static::$testPerformer->getName()
119+
[ 'noredirects' => 1, 'r' => 'Test', 'u' => static fn () => static::$testPerformer->getName() ],
120+
false, 'Test', static fn () => static::$testPerformer->getName()
121121
],
122122
];
123123
}

Diff for: tests/phpunit/mocks/ExpectCallbackTrait.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<?php
22
namespace MediaWiki\Tests;
33

4-
// phpcs:disable MediaWiki.Commenting.FunctionAnnotations.UnrecognizedAnnotation -- Remove with v46.0.0
5-
64
/**
75
* Trait for asserting callback invocation.
86
*/
@@ -103,7 +101,7 @@ private function makeExpectedCallback(
103101
/**
104102
* @postCondition
105103
*/
106-
public function expectedCallbackInvocationsPostCondition(): void {
104+
public function expectedCallbackInvocationsPostConditions(): void {
107105
$this->runDeferredUpdates();
108106

109107
foreach ( $this->expectedCallbackInvocations as $name => $count ) {

Diff for: tests/phpunit/unit/includes/installer/LocalSettingsGeneratorTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ private function getLocalSettingsGenerator( array $vars ): LocalSettingsGenerato
2828

2929
$installer = $this->createMock( Installer::class );
3030
$installer->method( 'getVar' )
31-
->willReturnCallback( fn ( string $name ) => $vars[$name] ?? '' );
31+
->willReturnCallback( static fn ( string $name ) => $vars[$name] ?? '' );
3232

3333
$installer->method( 'getDBInstaller' )
3434
->willReturn( $db );

Diff for: tests/phpunit/unit/includes/libs/telemetry/TracerTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected function setUp(): void {
4343
] );
4444

4545
$this->clock->method( 'getCurrentNanoTime' )
46-
->willReturnCallback( fn () => hrtime( true ) );
46+
->willReturnCallback( static fn () => hrtime( true ) );
4747

4848
$this->tracer = new Tracer(
4949
$this->clock,
@@ -144,7 +144,7 @@ public function testMultipleSpanCreation(): void {
144144
while ( array_pop( $spans ) !== null );
145145

146146
$exportedSpanIds = array_map(
147-
fn ( SpanContext $spanContext ) => $spanContext->getSpanId(),
147+
static fn ( SpanContext $spanContext ) => $spanContext->getSpanId(),
148148
$this->tracerState->getSpanContexts()
149149
);
150150

@@ -156,7 +156,7 @@ public function testMultipleSpanCreation(): void {
156156

157157
public function testCreatingSpansWithoutActiveSpan(): void {
158158
$this->clock->method( 'getCurrentNanoTime' )
159-
->willReturnCallback( fn () => hrtime( true ) );
159+
->willReturnCallback( static fn () => hrtime( true ) );
160160

161161
$this->sampler->method( 'shouldSample' )
162162
->willReturn( true );

0 commit comments

Comments
 (0)