diff options
25 files changed, 59 insertions, 57 deletions
diff --git a/includes/ResourceLoader/ResourceLoader.php b/includes/ResourceLoader/ResourceLoader.php index 884c9e6a96e0..4fac6167a7de 100644 --- a/includes/ResourceLoader/ResourceLoader.php +++ b/includes/ResourceLoader/ResourceLoader.php @@ -1881,7 +1881,7 @@ MESSAGE; $result = $cache->getWithSetCallback( $key, BagOStuff::TTL_DAY, - function () use ( $filter, $data, &$incKey ) { + static function () use ( $filter, $data, &$incKey ) { $incKey = "resourceloader_cache.$filter.miss"; return self::applyFilter( $filter, $data ); } diff --git a/includes/SiteStats/SiteStats.php b/includes/SiteStats/SiteStats.php index 94541b639d5f..d333ee227cad 100644 --- a/includes/SiteStats/SiteStats.php +++ b/includes/SiteStats/SiteStats.php @@ -153,7 +153,7 @@ class SiteStats { return $cache->getWithSetCallback( $cache->makeKey( 'SiteStats', 'groupcounts', $group ), $cache::TTL_HOUR, - function ( $oldValue, &$ttl, array &$setOpts ) use ( $group, $fname ) { + static function ( $oldValue, &$ttl, array &$setOpts ) use ( $group, $fname ) { $dbr = self::getLB()->getConnectionRef( DB_REPLICA ); $setOpts += Database::getCacheSetOptions( $dbr ); return (int)$dbr->newSelectQueryBuilder() @@ -205,7 +205,7 @@ class SiteStats { return $cache->getWithSetCallback( $cache->makeKey( 'SiteStats', 'page-in-namespace', $ns ), $cache::TTL_HOUR, - function ( $oldValue, &$ttl, array &$setOpts ) use ( $ns, $fname ) { + static function ( $oldValue, &$ttl, array &$setOpts ) use ( $ns, $fname ) { $dbr = self::getLB()->getConnectionRef( DB_REPLICA ); $setOpts += Database::getCacheSetOptions( $dbr ); diff --git a/includes/WikiMap/WikiMap.php b/includes/WikiMap/WikiMap.php index 7fbce6e6f1ec..f90511f4d99b 100644 --- a/includes/WikiMap/WikiMap.php +++ b/includes/WikiMap/WikiMap.php @@ -194,7 +194,7 @@ class WikiMap { return $cache->getWithSetCallback( $cache->makeGlobalKey( 'wikimap', 'canonical-urls' ), $cache::TTL_DAY, - function () { + static function () { global $wgLocalDatabases, $wgCanonicalServer; $infoMap = []; diff --git a/includes/changes/RCCacheEntryFactory.php b/includes/changes/RCCacheEntryFactory.php index 32c8301084a0..6c2368f04ddd 100644 --- a/includes/changes/RCCacheEntryFactory.php +++ b/includes/changes/RCCacheEntryFactory.php @@ -109,7 +109,7 @@ class RCCacheEntryFactory { $this->context->getUser()->getName(), $this->context->getLanguage()->getCode() ), - fn() => Linker::userToolLinks( + static fn() => Linker::userToolLinks( $cacheEntry->mAttribs['rc_user'], $cacheEntry->mAttribs['rc_user_text'], // Should the contributions link be red if the user has no edits (using default) @@ -328,7 +328,7 @@ class RCCacheEntryFactory { $this->context->getUser()->getName(), $this->context->getLanguage()->getCode() ), - fn() => Linker::userLink( + static fn() => Linker::userLink( $cacheEntry->mAttribs['rc_user'], $cacheEntry->mAttribs['rc_user_text'], ExternalUserNames::getLocal( $cacheEntry->mAttribs['rc_user_text'] ) diff --git a/includes/specialpage/AuthManagerSpecialPage.php b/includes/specialpage/AuthManagerSpecialPage.php index bb4af073e407..78ad1eb1de02 100644 --- a/includes/specialpage/AuthManagerSpecialPage.php +++ b/includes/specialpage/AuthManagerSpecialPage.php @@ -747,7 +747,7 @@ abstract class AuthManagerSpecialPage extends SpecialPage { foreach ( $formDescriptor as &$field ) { $field['__index'] = $i++; } - uasort( $formDescriptor, function ( $first, $second ) { + uasort( $formDescriptor, static function ( $first, $second ) { return self::getField( $first, 'weight', 0 ) <=> self::getField( $second, 'weight', 0 ) ?: $first['__index'] <=> $second['__index']; } ); diff --git a/includes/specials/SpecialUserRights.php b/includes/specials/SpecialUserRights.php index 8d6a2255ac53..b636fb60d3c3 100644 --- a/includes/specials/SpecialUserRights.php +++ b/includes/specials/SpecialUserRights.php @@ -539,12 +539,12 @@ class SpecialUserRights extends SpecialPage { ) { // make sure $oldUGMs and $newUGMs are in the same order, and serialise // each UGM object to a simplified array - $oldUGMs = array_map( function ( $group ) use ( $oldUGMs ) { + $oldUGMs = array_map( static function ( $group ) use ( $oldUGMs ) { return isset( $oldUGMs[$group] ) ? self::serialiseUgmForLog( $oldUGMs[$group] ) : null; }, $oldGroups ); - $newUGMs = array_map( function ( $group ) use ( $newUGMs ) { + $newUGMs = array_map( static function ( $group ) use ( $newUGMs ) { return isset( $newUGMs[$group] ) ? self::serialiseUgmForLog( $newUGMs[$group] ) : null; diff --git a/includes/user/User.php b/includes/user/User.php index 2be179b21121..ff886a81978e 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -2691,7 +2691,9 @@ class User implements Authority, UserIdentity, UserEmailContact { $fields["user_$name"] = $value; } - return $dbw->doAtomicSection( __METHOD__, function ( IDatabase $dbw, $fname ) use ( $fields, $insertActor ) { + return $dbw->doAtomicSection( __METHOD__, static function ( IDatabase $dbw, $fname ) + use ( $fields, $insertActor ) + { $dbw->newInsertQueryBuilder() ->insert( 'user' ) ->ignore() diff --git a/tests/phpunit/includes/MediaWikiTest.php b/tests/phpunit/includes/MediaWikiTest.php index b7c1f80c3354..312eb945556c 100644 --- a/tests/phpunit/includes/MediaWikiTest.php +++ b/tests/phpunit/includes/MediaWikiTest.php @@ -288,13 +288,13 @@ class MediaWikiTest extends MediaWikiIntegrationTestCase { public static function provideParseTitleExistingPage(): array { return [ "Valid 'oldid'" => [ - fn ( WikiPage $page ): array => wfCgiToArray( '?oldid=' . $page->getRevisionRecord()->getId() ), + static fn ( WikiPage $page ): array => wfCgiToArray( '?oldid=' . $page->getRevisionRecord()->getId() ), ], "Valid 'diff'" => [ - fn ( WikiPage $page ): array => wfCgiToArray( '?diff=' . $page->getRevisionRecord()->getId() ), + static fn ( WikiPage $page ): array => wfCgiToArray( '?diff=' . $page->getRevisionRecord()->getId() ), ], "Valid 'curid'" => [ - fn ( WikiPage $page ): array => wfCgiToArray( '?curid=' . $page->getId() ), + static fn ( WikiPage $page ): array => wfCgiToArray( '?curid=' . $page->getId() ), ], ]; } diff --git a/tests/phpunit/includes/Revision/RevisionRendererTest.php b/tests/phpunit/includes/Revision/RevisionRendererTest.php index d23874c15051..d262b25ab42c 100644 --- a/tests/phpunit/includes/Revision/RevisionRendererTest.php +++ b/tests/phpunit/includes/Revision/RevisionRendererTest.php @@ -61,7 +61,7 @@ class RevisionRendererTest extends MediaWikiIntegrationTestCase { ); } ); - $db->method( 'newSelectQueryBuilder' )->willReturnCallback( fn() => new SelectQueryBuilder( $db ) ); + $db->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $db ) ); return $db; } diff --git a/tests/phpunit/includes/Storage/NameTableStoreTest.php b/tests/phpunit/includes/Storage/NameTableStoreTest.php index 3c8f5cf7d133..8192ed3d36ce 100644 --- a/tests/phpunit/includes/Storage/NameTableStoreTest.php +++ b/tests/phpunit/includes/Storage/NameTableStoreTest.php @@ -85,8 +85,8 @@ class NameTableStoreTest extends MediaWikiIntegrationTestCase { return $this->db->$method( ...$args ); } ); } - $mock->method( 'newSelectQueryBuilder' )->willReturnCallback( fn() => new SelectQueryBuilder( $mock ) ); - $mock->method( 'newInsertQueryBuilder' )->willReturnCallback( fn() => new InsertQueryBuilder( $mock ) ); + $mock->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $mock ) ); + $mock->method( 'newInsertQueryBuilder' )->willReturnCallback( static fn() => new InsertQueryBuilder( $mock ) ); return $mock; } @@ -393,7 +393,7 @@ class NameTableStoreTest extends MediaWikiIntegrationTestCase { return true; } ); - $db->method( 'newInsertQueryBuilder' )->willReturnCallback( fn() => new InsertQueryBuilder( $db ) ); + $db->method( 'newInsertQueryBuilder' )->willReturnCallback( static fn() => new InsertQueryBuilder( $db ) ); $lb = $this->createMock( LoadBalancer::class ); $lb->method( 'getConnection' ) diff --git a/tests/phpunit/includes/api/ApiBaseTest.php b/tests/phpunit/includes/api/ApiBaseTest.php index 204fc6d12d11..9fbdcb328397 100644 --- a/tests/phpunit/includes/api/ApiBaseTest.php +++ b/tests/phpunit/includes/api/ApiBaseTest.php @@ -1323,7 +1323,7 @@ class ApiBaseTest extends ApiTestCase { $paramDescription = $mock->getFinalParamDescription(); $this->assertArrayHasKey( 'param', $paramDescription ); $messages = $paramDescription['param']; - $messageKeys = array_map( fn( MessageSpecifier $m ) => $m->getKey(), $messages ); + $messageKeys = array_map( static fn( MessageSpecifier $m ) => $m->getKey(), $messages ); $this->assertSame( $expectedMessages, $messageKeys ); } diff --git a/tests/phpunit/includes/auth/LocalPasswordPrimaryAuthenticationProviderTest.php b/tests/phpunit/includes/auth/LocalPasswordPrimaryAuthenticationProviderTest.php index abf0b885f1a8..62f083141284 100644 --- a/tests/phpunit/includes/auth/LocalPasswordPrimaryAuthenticationProviderTest.php +++ b/tests/phpunit/includes/auth/LocalPasswordPrimaryAuthenticationProviderTest.php @@ -433,49 +433,49 @@ class LocalPasswordPrimaryAuthenticationProviderTest extends \MediaWikiIntegrati return [ [ AuthenticationRequest::class, - fn ( $sysopUsername ) => $sysopUsername, + static fn ( $sysopUsername ) => $sysopUsername, Status::newGood(), StatusValue::newGood( 'ignored' ), StatusValue::newGood( 'ignored' ) ], [ PasswordAuthenticationRequest::class, - fn ( $sysopUsername ) => $sysopUsername, + static fn ( $sysopUsername ) => $sysopUsername, Status::newGood(), StatusValue::newGood(), StatusValue::newGood() ], [ PasswordAuthenticationRequest::class, - fn ( $sysopUsername ) => lcfirst( $sysopUsername ), + static fn ( $sysopUsername ) => lcfirst( $sysopUsername ), Status::newGood(), StatusValue::newGood(), StatusValue::newGood() ], [ PasswordAuthenticationRequest::class, - fn ( $sysopUsername ) => $sysopUsername, + static fn ( $sysopUsername ) => $sysopUsername, Status::wrap( $err ), StatusValue::newGood(), $err ], [ PasswordAuthenticationRequest::class, - fn ( $sysopUsername ) => $sysopUsername, + static fn ( $sysopUsername ) => $sysopUsername, Status::newFatal( 'arbitrary-error' ), StatusValue::newGood(), StatusValue::newFatal( 'arbitrary-error' ) ], [ PasswordAuthenticationRequest::class, - fn () => 'DoesNotExist', + static fn () => 'DoesNotExist', Status::newGood(), StatusValue::newGood(), StatusValue::newGood( 'ignored' ) ], [ PasswordDomainAuthenticationRequest::class, - fn ( $sysopUsername ) => $sysopUsername, + static fn ( $sysopUsername ) => $sysopUsername, Status::newGood(), StatusValue::newGood( 'ignored' ), StatusValue::newGood( 'ignored' ) diff --git a/tests/phpunit/includes/auth/TemporaryPasswordPrimaryAuthenticationProviderTest.php b/tests/phpunit/includes/auth/TemporaryPasswordPrimaryAuthenticationProviderTest.php index 83c939f56245..0c1c2d8853aa 100644 --- a/tests/phpunit/includes/auth/TemporaryPasswordPrimaryAuthenticationProviderTest.php +++ b/tests/phpunit/includes/auth/TemporaryPasswordPrimaryAuthenticationProviderTest.php @@ -422,56 +422,56 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiInteg return [ [ AuthenticationRequest::class, - fn ( $sysopUsername ) => $sysopUsername, + static fn ( $sysopUsername ) => $sysopUsername, Status::newGood(), StatusValue::newGood( 'ignored' ), StatusValue::newGood( 'ignored' ) ], [ PasswordAuthenticationRequest::class, - fn ( $sysopUsername ) => $sysopUsername, + static fn ( $sysopUsername ) => $sysopUsername, Status::newGood(), StatusValue::newGood( 'ignored' ), StatusValue::newGood( 'ignored' ) ], [ TemporaryPasswordAuthenticationRequest::class, - fn ( $sysopUsername ) => $sysopUsername, + static fn ( $sysopUsername ) => $sysopUsername, Status::newGood(), StatusValue::newGood(), StatusValue::newGood() ], [ TemporaryPasswordAuthenticationRequest::class, - fn ( $sysopUsername ) => lcfirst( $sysopUsername ), + static fn ( $sysopUsername ) => lcfirst( $sysopUsername ), Status::newGood(), StatusValue::newGood(), StatusValue::newGood() ], [ TemporaryPasswordAuthenticationRequest::class, - fn ( $sysopUsername ) => $sysopUsername, + static fn ( $sysopUsername ) => $sysopUsername, Status::wrap( $err ), StatusValue::newGood(), $err ], [ TemporaryPasswordAuthenticationRequest::class, - fn ( $sysopUsername ) => $sysopUsername, + static fn ( $sysopUsername ) => $sysopUsername, Status::newFatal( 'arbitrary-error' ), StatusValue::newGood(), StatusValue::newFatal( 'arbitrary-error' ) ], [ TemporaryPasswordAuthenticationRequest::class, - fn () => 'DoesNotExist', + static fn () => 'DoesNotExist', Status::newGood(), StatusValue::newGood(), StatusValue::newGood( 'ignored' ) ], [ TemporaryPasswordAuthenticationRequest::class, - fn () => '<invalid>', + static fn () => '<invalid>', Status::newGood(), StatusValue::newGood(), StatusValue::newGood( 'ignored' ) diff --git a/tests/phpunit/includes/filerepo/FileBackendDBRepoWrapperTest.php b/tests/phpunit/includes/filerepo/FileBackendDBRepoWrapperTest.php index d1dd0d8ecf23..d379c541457d 100644 --- a/tests/phpunit/includes/filerepo/FileBackendDBRepoWrapperTest.php +++ b/tests/phpunit/includes/filerepo/FileBackendDBRepoWrapperTest.php @@ -24,7 +24,7 @@ class FileBackendDBRepoWrapperTest extends MediaWikiIntegrationTestCase { $dbMock->expects( $dbReadsExpected ) ->method( 'selectField' ) ->willReturn( $dbReturnValue ); - $dbMock->method( 'newSelectQueryBuilder' )->willReturnCallback( fn() => new SelectQueryBuilder( $dbMock ) ); + $dbMock->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $dbMock ) ); $newPaths = $wrapperMock->getBackendPaths( [ $originalPath ], $latest ); @@ -101,7 +101,7 @@ class FileBackendDBRepoWrapperTest extends MediaWikiIntegrationTestCase { $dbMock->expects( $this->once() ) ->method( 'selectField' ) ->willReturn( '96246614d75ba1703bdfd5d7660bb57407aaf5d9' ); - $dbMock->method( 'newSelectQueryBuilder' )->willReturnCallback( fn() => new SelectQueryBuilder( $dbMock ) ); + $dbMock->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $dbMock ) ); $backendMock->expects( $this->once() ) ->method( 'getFileContentsMulti' ) @@ -121,7 +121,7 @@ class FileBackendDBRepoWrapperTest extends MediaWikiIntegrationTestCase { ->disableOriginalClone() ->disableOriginalConstructor() ->getMock(); - $dbMock->method( 'newSelectQueryBuilder' )->willReturnCallback( fn() => new SelectQueryBuilder( $dbMock ) ); + $dbMock->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $dbMock ) ); $backendMock = $this->getMockBuilder( FSFileBackend::class ) ->setConstructorArgs( [ [ diff --git a/tests/phpunit/includes/parser/ParserCacheSerializationTestCases.php b/tests/phpunit/includes/parser/ParserCacheSerializationTestCases.php index ee9fd9cab9dc..1120b41af8d8 100644 --- a/tests/phpunit/includes/parser/ParserCacheSerializationTestCases.php +++ b/tests/phpunit/includes/parser/ParserCacheSerializationTestCases.php @@ -270,7 +270,7 @@ abstract class ParserCacheSerializationTestCases { return [ 'empty' => [ 'instance' => new ParserOutput( '' ), - 'assertions' => function ( MediaWikiIntegrationTestCase $testCase, ParserOutput $object ) { + 'assertions' => static function ( MediaWikiIntegrationTestCase $testCase, ParserOutput $object ) { // Empty CacheTime assertions self::getCacheTimeTestCases()['empty']['assertions']( $testCase, $object ); // Empty string text is counted as having text. diff --git a/tests/phpunit/includes/user/ActorMigrationTest.php b/tests/phpunit/includes/user/ActorMigrationTest.php index 312e1a4dc615..e1e090b78995 100644 --- a/tests/phpunit/includes/user/ActorMigrationTest.php +++ b/tests/phpunit/includes/user/ActorMigrationTest.php @@ -284,7 +284,7 @@ class ActorMigrationTest extends MediaWikiLangTestCase { $mock = $this->createNoOpMock( ActorStore::class, [ 'findActorId' ] ); $mock->method( 'findActorId' ) - ->willReturnCallback( function ( UserIdentity $user ) { + ->willReturnCallback( static function ( UserIdentity $user ) { $row = self::findRow( self::ACTORS, 1, $user->getName() ); return $row ? $row[2] : null; } ); diff --git a/tests/phpunit/includes/user/UserOptionsManagerTest.php b/tests/phpunit/includes/user/UserOptionsManagerTest.php index 82f640fd87f2..ec5df7cac32a 100644 --- a/tests/phpunit/includes/user/UserOptionsManagerTest.php +++ b/tests/phpunit/includes/user/UserOptionsManagerTest.php @@ -293,8 +293,8 @@ class UserOptionsManagerTest extends UserOptionsLookupTest { 'up_property' => 'test_option', ] ] ) ); - $mockDb->method( 'newSelectQueryBuilder' )->willReturnCallback( fn() => new SelectQueryBuilder( $mockDb ) ); - $mockDb->method( 'newInsertQueryBuilder' )->willReturnCallback( fn() => new InsertQueryBuilder( $mockDb ) ); + $mockDb->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $mockDb ) ); + $mockDb->method( 'newInsertQueryBuilder' )->willReturnCallback( static fn() => new InsertQueryBuilder( $mockDb ) ); $mockDbProvider = $this->createMock( IConnectionProvider::class ); $mockDbProvider ->method( 'getPrimaryDatabase' ) @@ -328,7 +328,7 @@ class UserOptionsManagerTest extends UserOptionsLookupTest { ] ) ); $mockDb->expects( $this->never() ) // This is critical what we are testing ->method( 'delete' ); - $mockDb->method( 'newSelectQueryBuilder' )->willReturnCallback( fn() => new SelectQueryBuilder( $mockDb ) ); + $mockDb->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $mockDb ) ); $mockDbProvider = $this->createMock( IConnectionProvider::class ); $mockDbProvider ->method( 'getPrimaryDatabase' ) @@ -355,7 +355,7 @@ class UserOptionsManagerTest extends UserOptionsLookupTest { $mockDb = $this->createMock( DBConnRef::class ); $mockDb ->method( 'newDeleteQueryBuilder' ) - ->willReturnCallback( fn() => new DeleteQueryBuilder( $mockDb ) ); + ->willReturnCallback( static fn() => new DeleteQueryBuilder( $mockDb ) ); $mockDb->expects( $this->once() ) ->method( 'select' ) ->willReturn( new FakeResultWrapper( [ @@ -385,7 +385,7 @@ class UserOptionsManagerTest extends UserOptionsLookupTest { 'up_property' => [ 'set_default', 'set_default_null', 'set_default_not_null' ] ] ); - $mockDb->method( 'newSelectQueryBuilder' )->willReturnCallback( fn() => new SelectQueryBuilder( $mockDb ) ); + $mockDb->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $mockDb ) ); $mockDbProvider = $this->createMock( IConnectionProvider::class ); $mockDbProvider ->method( 'getPrimaryDatabase' ) diff --git a/tests/phpunit/includes/utils/BatchRowUpdateTest.php b/tests/phpunit/includes/utils/BatchRowUpdateTest.php index d048f74a141e..04f2d97c7290 100644 --- a/tests/phpunit/includes/utils/BatchRowUpdateTest.php +++ b/tests/phpunit/includes/utils/BatchRowUpdateTest.php @@ -39,7 +39,7 @@ class BatchRowUpdateTest extends MediaWikiIntegrationTestCase { public function testReaderBasicIterate() { $batchSize = 2; - $response = $this->genSelectResult( $batchSize, /*numRows*/ 5, function () { + $response = $this->genSelectResult( $batchSize, /*numRows*/ 5, static function () { static $i = 0; return [ 'id_field' => ++$i ]; } ); @@ -173,7 +173,7 @@ class BatchRowUpdateTest extends MediaWikiIntegrationTestCase { public function testReaderSelectConditionsMultiplePrimaryKeys( $message, $expectedSecondIteration, $primaryKeys, $batchSize = 3 ) { - $results = $this->genSelectResult( $batchSize, $batchSize * 3, function () { + $results = $this->genSelectResult( $batchSize, $batchSize * 3, static function () { static $i = 0, $j = 100, $k = 1000; return [ 'id_field' => ++$i, 'foo' => ++$j, 'bar' => ++$k ]; } ); diff --git a/tests/phpunit/integration/includes/user/UserRightsProxyTest.php b/tests/phpunit/integration/includes/user/UserRightsProxyTest.php index 07c1f60addb0..64457f44be59 100644 --- a/tests/phpunit/integration/includes/user/UserRightsProxyTest.php +++ b/tests/phpunit/integration/includes/user/UserRightsProxyTest.php @@ -37,7 +37,7 @@ class UserRightsProxyTest extends MediaWikiIntegrationTestCase { 'user_id' => 12345, ]; $dbMock->method( 'selectRow' )->willReturn( $row ); - $dbMock->method( 'newSelectQueryBuilder' )->willReturnCallback( fn() => new SelectQueryBuilder( $dbMock ) ); + $dbMock->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $dbMock ) ); $lbMock = $this->createMock( ILoadBalancer::class ); $lbMock->method( 'getMaintenanceConnectionRef' )->willReturn( $dbMock ); @@ -197,7 +197,7 @@ class UserRightsProxyTest extends MediaWikiIntegrationTestCase { $dbMock->method( 'selectRow' )->willReturn( $row ); $dbMock->method( 'timestamp' )->willReturn( 'timestamp' ); $dbMock->method( 'getDomainID' )->willReturn( 'foowiki' ); - $dbMock->method( 'newSelectQueryBuilder' )->willReturnCallback( fn() => new SelectQueryBuilder( $dbMock ) ); + $dbMock->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $dbMock ) ); $dbMock->expects( $this->once() ) ->method( 'replace' ) diff --git a/tests/phpunit/unit/includes/Permissions/RestrictionStoreTest.php b/tests/phpunit/unit/includes/Permissions/RestrictionStoreTest.php index 1b8606c7d994..2d4100f50c42 100644 --- a/tests/phpunit/unit/includes/Permissions/RestrictionStoreTest.php +++ b/tests/phpunit/unit/includes/Permissions/RestrictionStoreTest.php @@ -797,7 +797,7 @@ class RestrictionStoreTest extends MediaWikiUnitTestCase { 'Hook' => [ [ 'move', 'liquify' ], PageIdentityValue::localIdentity( 1, NS_MAIN, 'X' ), - [ 'hookFn' => function ( Title $title, array &$types ): bool { + [ 'hookFn' => static function ( Title $title, array &$types ): bool { self::assertEquals( Title::castFromPageIdentity( PageIdentityValue::localIdentity( 1, NS_MAIN, 'X' ) ), $title ); self::assertSame( [ 'edit', 'move' ], $types ); diff --git a/tests/phpunit/unit/includes/PingbackTest.php b/tests/phpunit/unit/includes/PingbackTest.php index 69397ee356f4..3fae4a8b9544 100644 --- a/tests/phpunit/unit/includes/PingbackTest.php +++ b/tests/phpunit/unit/includes/PingbackTest.php @@ -65,7 +65,7 @@ class PingbackTest extends MediaWikiUnitTestCase { // - cache lock is unavailable $database = $this->createNoOpMock( DBConnRef::class, [ 'selectField', 'newSelectQueryBuilder' ] ); $database->expects( $this->once() )->method( 'selectField' )->willReturn( false ); - $database->method( 'newSelectQueryBuilder' )->willReturnCallback( fn() => new SelectQueryBuilder( $database ) ); + $database->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $database ) ); $cache = $this->createMock( BagOStuff::class ); $cache->method( 'add' )->willReturn( false ); @@ -93,7 +93,7 @@ class PingbackTest extends MediaWikiUnitTestCase { $database = $this->createNoOpMock( DBConnRef::class, [ 'selectField', 'lock', 'newSelectQueryBuilder' ] ); $database->expects( $this->once() )->method( 'selectField' )->willReturn( false ); $database->expects( $this->once() )->method( 'lock' )->willReturn( false ); - $database->method( 'newSelectQueryBuilder' )->willReturnCallback( fn() => new SelectQueryBuilder( $database ) ); + $database->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $database ) ); $pingback = $this->makePingback( $database, @@ -125,7 +125,7 @@ class PingbackTest extends MediaWikiUnitTestCase { ->with( 'https://www.mediawiki.org/beacon/event?%7B%22some%22%3A%22stuff%22%7D;' ) ->willReturn( true ); $database->expects( $this->once() )->method( 'upsert' ); - $database->method( 'newSelectQueryBuilder' )->willReturnCallback( fn() => new SelectQueryBuilder( $database ) ); + $database->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $database ) ); $pingback = $this->makePingback( $database, @@ -154,7 +154,7 @@ class PingbackTest extends MediaWikiUnitTestCase { $database->expects( $this->once() )->method( 'selectField' )->willReturn( ConvertibleTimestamp::convert( TS_UNIX, '20110401080000' ) ); - $database->method( 'newSelectQueryBuilder' )->willReturnCallback( fn() => new SelectQueryBuilder( $database ) ); + $database->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $database ) ); $pingback = $this->makePingback( $database, diff --git a/tests/phpunit/unit/includes/Revision/SlotRecordTest.php b/tests/phpunit/unit/includes/Revision/SlotRecordTest.php index 7e4886efb466..b0e6ea3c8a98 100644 --- a/tests/phpunit/unit/includes/Revision/SlotRecordTest.php +++ b/tests/phpunit/unit/includes/Revision/SlotRecordTest.php @@ -297,7 +297,7 @@ class SlotRecordTest extends MediaWikiUnitTestCase { } public function provideHasSameContent() { - $fail = function () { + $fail = static function () { self::fail( 'There should be no need to actually load the content.' ); }; diff --git a/tests/phpunit/unit/includes/Storage/EditResultCacheTest.php b/tests/phpunit/unit/includes/Storage/EditResultCacheTest.php index a8f80fb1d716..f1a6c6f3ad68 100644 --- a/tests/phpunit/unit/includes/Storage/EditResultCacheTest.php +++ b/tests/phpunit/unit/includes/Storage/EditResultCacheTest.php @@ -116,7 +116,7 @@ class EditResultCacheTest extends MediaWikiUnitTestCase { $dbr->expects( $this->once() ) ->method( 'selectField' ) ->willReturn( FormatJson::encode( $editResult ) ); - $dbr->method( 'newSelectQueryBuilder' )->willReturnCallback( fn() => new SelectQueryBuilder( $dbr ) ); + $dbr->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $dbr ) ); $loadBalancer = $this->createMock( ILoadBalancer::class ); $loadBalancer->expects( $this->once() ) ->method( 'getConnectionRef' ) @@ -152,7 +152,7 @@ class EditResultCacheTest extends MediaWikiUnitTestCase { $dbr->expects( $this->once() ) ->method( 'selectField' ) ->willReturn( false ); - $dbr->method( 'newSelectQueryBuilder' )->willReturnCallback( fn() => new SelectQueryBuilder( $dbr ) ); + $dbr->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $dbr ) ); $loadBalancer = $this->createMock( ILoadBalancer::class ); $loadBalancer->expects( $this->once() ) ->method( 'getConnectionRef' ) diff --git a/tests/phpunit/unit/includes/filebackend/FileBackendGroupTestTrait.php b/tests/phpunit/unit/includes/filebackend/FileBackendGroupTestTrait.php index 9aa1df880f4b..dae57418bc10 100644 --- a/tests/phpunit/unit/includes/filebackend/FileBackendGroupTestTrait.php +++ b/tests/phpunit/unit/includes/filebackend/FileBackendGroupTestTrait.php @@ -134,7 +134,7 @@ trait FileBackendGroupTestTrait { return [ 'domainId with neither wikiId nor domainId set' => [ 'domainId', - function () { + static function () { return self::getWikiID(); }, ], diff --git a/tests/phpunit/unit/includes/user/UserNamePrefixSearchTest.php b/tests/phpunit/unit/includes/user/UserNamePrefixSearchTest.php index 0a0dc980aa50..b90af7d7c7f4 100644 --- a/tests/phpunit/unit/includes/user/UserNamePrefixSearchTest.php +++ b/tests/phpunit/unit/includes/user/UserNamePrefixSearchTest.php @@ -85,7 +85,7 @@ class UserNamePrefixSearchTest extends MediaWikiUnitTestCase { $joinConds ) ->willReturn( $result ); - $database->method( 'newSelectQueryBuilder' )->willReturnCallback( fn() => new SelectQueryBuilder( $database ) ); + $database->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn() => new SelectQueryBuilder( $database ) ); $dbProvider = $this->createMock( IConnectionProvider::class ); $dbProvider->expects( $this->once() ) |