build: Upgrade mediawiki-codesniffer from v35.0.0 to v36.0.0

Change-Id: I8905d0d69738a1cd6997c104080fdf128d315e8b
This commit is contained in:
James D. Forrester 2021-04-29 09:24:12 -07:00
parent 623f80ff04
commit 64898405cb
23 changed files with 44 additions and 41 deletions

View file

@ -81,7 +81,7 @@
"hamcrest/hamcrest-php": "^2.0",
"johnkary/phpunit-speedtrap": "^3.1",
"justinrainbow/json-schema": "~5.2",
"mediawiki/mediawiki-codesniffer": "35.0.0",
"mediawiki/mediawiki-codesniffer": "36.0.0",
"mediawiki/mediawiki-phan-config": "0.10.6",
"monolog/monolog": "~2.2.0",
"nikic/php-parser": "4.10.2",

View file

@ -830,7 +830,7 @@ class MediaWiki {
// during post-send processing to warnings and unexpected behavior (T191537)
WebResponse::disableForPostSend();
// Run post-send updates while preventing further output for sanity...
ob_start( function () {
ob_start( static function () {
return ''; // do not output uncaught exceptions
} );
try {

View file

@ -266,7 +266,7 @@ class MergeHistory {
*/
public function probablyCanMerge( Authority $performer, string $reason = null ): PermissionStatus {
return $this->authorizeInternal(
function ( string $action, PageIdentity $target, PermissionStatus $status ) use ( $performer ) {
static function ( string $action, PageIdentity $target, PermissionStatus $status ) use ( $performer ) {
return $performer->probablyCan( $action, $target, $status );
},
$performer,
@ -287,7 +287,7 @@ class MergeHistory {
*/
public function authorizeMerge( Authority $performer, string $reason = null ): PermissionStatus {
return $this->authorizeInternal(
function ( string $action, PageIdentity $target, PermissionStatus $status ) use ( $performer ) {
static function ( string $action, PageIdentity $target, PermissionStatus $status ) use ( $performer ) {
return $performer->authorizeWrite( $action, $target, $status );
},
$performer,
@ -305,7 +305,7 @@ class MergeHistory {
public function checkPermissions( Authority $performer, $reason ) {
wfDeprecated( __METHOD__, '1.36' );
$permissionStatus = $this->authorizeInternal(
function ( string $action, PageIdentity $target, PermissionStatus $status ) use ( $performer ) {
static function ( string $action, PageIdentity $target, PermissionStatus $status ) use ( $performer ) {
return $performer->definitelyCan( $action, $target, $status );
},
$performer,

View file

@ -237,7 +237,7 @@ class MovePage {
*/
public function probablyCanMove( Authority $performer, string $reason = null ): PermissionStatus {
return $this->authorizeInternal(
function ( string $action, PageIdentity $target, PermissionStatus $status ) use ( $performer ) {
static function ( string $action, PageIdentity $target, PermissionStatus $status ) use ( $performer ) {
return $performer->probablyCan( $action, $target, $status );
},
$performer,
@ -258,7 +258,7 @@ class MovePage {
*/
public function authorizeMove( Authority $performer, string $reason = null ): PermissionStatus {
return $this->authorizeInternal(
function ( string $action, PageIdentity $target, PermissionStatus $status ) use ( $performer ) {
static function ( string $action, PageIdentity $target, PermissionStatus $status ) use ( $performer ) {
return $performer->authorizeWrite( $action, $target, $status );
},
$performer,
@ -277,7 +277,7 @@ class MovePage {
*/
public function checkPermissions( Authority $performer, $reason ) {
$permissionStatus = $this->authorizeInternal(
function ( string $action, PageIdentity $target, PermissionStatus $status ) use ( $performer ) {
static function ( string $action, PageIdentity $target, PermissionStatus $status ) use ( $performer ) {
return $performer->definitelyCan( $action, $target, $status );
},
$performer,
@ -522,7 +522,7 @@ class MovePage {
UserIdentity $user, $reason = null, $createRedirect = true, array $changeTags = []
) {
return $this->moveSubpagesInternal(
function ( Title $oldSubpage, Title $newSubpage )
static function ( Title $oldSubpage, Title $newSubpage )
use ( $user, $reason, $createRedirect, $changeTags ) {
$mp = new MovePage( $oldSubpage, $newSubpage );
return $mp->move( $user, $reason, $createRedirect, $changeTags );
@ -550,7 +550,7 @@ class MovePage {
return Status::newFatal( 'cant-move-subpages' );
}
return $this->moveSubpagesInternal(
function ( Title $oldSubpage, Title $newSubpage )
static function ( Title $oldSubpage, Title $newSubpage )
use ( $performer, $reason, $createRedirect, $changeTags ) {
$mp = new MovePage( $oldSubpage, $newSubpage );
return $mp->moveIfAllowed( $performer, $reason, $createRedirect, $changeTags );

View file

@ -1867,7 +1867,7 @@ class LocalFile extends File {
// Also, we should generally not schedule any Jobs or the DeferredUpdates that
// assume the update is complete until after the transaction has been committed and
// we are sure that the upload was indeed successful.
$dbw->onTransactionCommitOrIdle( function () use ( $reupload, $purgeUpdate, $cacheUpdateJob ) {
$dbw->onTransactionCommitOrIdle( static function () use ( $reupload, $purgeUpdate, $cacheUpdateJob ) {
DeferredUpdates::addUpdate( $purgeUpdate, DeferredUpdates::PRESEND );
if ( !$reupload ) {

View file

@ -86,11 +86,14 @@ interface ILoadBalancer {
* @since 1.36
*/
public const DB_PRIMARY = -2;
// phpcs:disable MediaWiki.Usage.DeprecatedConstantUsage.DB_MASTER
/**
* Request a primary, write-enabled DB connection
* @deprecated since 1.36, Use DB_PRIMARY instead
*/
public const DB_MASTER = self::DB_PRIMARY;
// phpcs:enable MediaWiki.Usage.DeprecatedConstantUsage.DB_MASTER
/** Domain specifier when no specific database needs to be selected */
public const DOMAIN_ANY = '';

View file

@ -318,7 +318,7 @@ class SpecialBlock extends FormSpecialPage {
'type' => 'multiselect',
'cssclass' => 'mw-block-action-restriction',
'options-messages' => array_combine(
array_map( function ( $action ) {
array_map( static function ( $action ) {
return "ipb-action-$action";
}, array_keys( $blockActions ) ),
$blockActions
@ -881,7 +881,7 @@ class SpecialBlock extends FormSpecialPage {
isset( $data['ActionRestrictions'] ) &&
$data['ActionRestrictions'] !== ''
) {
$actionRestrictions = array_map( function ( $id ) {
$actionRestrictions = array_map( static function ( $id ) {
return new ActionRestriction( 0, $id );
}, $data['ActionRestrictions'] );
}

View file

@ -863,7 +863,7 @@ class User implements Authority, IDBAccessObject, UserIdentity, UserEmailContact
// If it's a reserved user that had an anonymous actor created for it at
// some point, we need special handling.
return self::insertNewUser( function ( UserIdentity $actor, IDatabase $dbw ) {
return self::insertNewUser( static function ( UserIdentity $actor, IDatabase $dbw ) {
return MediaWikiServices::getInstance()->getActorStore()->acquireSystemActorId( $actor, $dbw );
}, $name, [ 'token' => self::INVALID_TOKEN ] );
}
@ -3474,7 +3474,7 @@ class User implements Authority, IDBAccessObject, UserIdentity, UserEmailContact
* @return User|null User object, or null if the username already exists.
*/
public static function createNew( $name, $params = [] ) {
return self::insertNewUser( function ( UserIdentity $actor, IDatabase $dbw ) {
return self::insertNewUser( static function ( UserIdentity $actor, IDatabase $dbw ) {
return MediaWikiServices::getInstance()->getActorStore()->createNewActor( $actor, $dbw );
}, $name, $params );
}

View file

@ -612,7 +612,7 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac
$dbOptions['HAVING'] = 'COUNT(*) >= ' . (int)$options['minimumWatchers'];
}
$linkTargets = array_map( function ( $target ) {
$linkTargets = array_map( static function ( $target ) {
if ( !$target instanceof LinkTarget ) {
return new TitleValue( $target->getNamespace(), $target->getDBkey() );
}

View file

@ -36,10 +36,10 @@ class CommentStoreTest extends MediaWikiLangTestCase {
*/
private function makeStore( $stage ) {
$lang = $this->createMock( Language::class );
$lang->method( 'truncateForDatabase' )->willReturnCallback( function ( $str, $len ) {
$lang->method( 'truncateForDatabase' )->willReturnCallback( static function ( $str, $len ) {
return strlen( $str ) > $len ? substr( $str, 0, $len - 3 ) . '...' : $str;
} );
$lang->method( 'truncateForVisual' )->willReturnCallback( function ( $str, $len ) {
$lang->method( 'truncateForVisual' )->willReturnCallback( static function ( $str, $len ) {
return mb_strlen( $str ) > $len ? mb_substr( $str, 0, $len - 3 ) . '...' : $str;
} );
return new class( $lang, $stage ) extends CommentStore {

View file

@ -22,17 +22,17 @@ class MWTimestampTest extends MediaWikiLangTestCase {
[ 'getOption', 'getIntOption', 'getDefaultOption' ]
);
$mock->method( 'getOption' )
->willReturnCallback( function ( $user, $name ) use ( $options, $defaults ) {
->willReturnCallback( static function ( $user, $name ) use ( $options, $defaults ) {
return $options[$name] ?? $defaults[ $name ];
}
);
$mock->method( 'getIntOption' )
->willReturnCallback( function ( $user, $name ) use ( $options, $defaults ) {
->willReturnCallback( static function ( $user, $name ) use ( $options, $defaults ) {
return $options[$name] ?? $defaults[ $name ];
}
);
$mock->method( 'getDefaultOption' )
->willReturnCallback( function ( $name ) use ( $defaults ) {
->willReturnCallback( static function ( $name ) use ( $defaults ) {
return $defaults[$name];
}
);

View file

@ -3175,7 +3175,7 @@ class OutputPageTest extends MediaWikiIntegrationTestCase {
]
];
yield 'only can edit relevant title' => [
'performer' => $this->mockAnonAuthority( function (
'performer' => $this->mockAnonAuthority( static function (
string $permission,
PageIdentity $page
) {

View file

@ -490,7 +490,7 @@ class RecentChangeTest extends MediaWikiIntegrationTestCase {
string $expectError
) {
$rc = $this->getDummyEditRecentChange();
$performer = $this->mockRegisteredAuthority( function (
$performer = $this->mockRegisteredAuthority( static function (
string $permission,
PageIdentity $page,
PermissionStatus $status
@ -513,7 +513,7 @@ class RecentChangeTest extends MediaWikiIntegrationTestCase {
*/
public function testDoMarkPatrolledPermissions_Hook() {
$rc = $this->getDummyEditRecentChange();
$this->setTemporaryHook( 'MarkPatrolled', function () {
$this->setTemporaryHook( 'MarkPatrolled', static function () {
return false;
} );
$errors = $rc->doMarkPatrolled( $this->mockRegisteredUltimateAuthority() );

View file

@ -280,7 +280,7 @@ class ContentModelChangeTest extends MediaWikiIntegrationTestCase {
'Sanity check: `ExistingPage` should be wikitext'
);
$performer = $this->mockRegisteredAuthority( function (
$performer = $this->mockRegisteredAuthority( static function (
string $permission,
PageIdentity $page,
PermissionStatus $status

View file

@ -1782,7 +1782,7 @@ more stuff
$this->getRow( [
'page_lang' => null,
] ),
function ( WikiPage $wikiPage, self $test ) {
static function ( WikiPage $wikiPage, self $test ) {
$test->assertNull(
$wikiPage->getLanguage()
);
@ -1800,7 +1800,7 @@ more stuff
$this->getRow( [
'page_is_new' => '0',
] ),
function ( WikiPage $wikiPage, self $test ) {
static function ( WikiPage $wikiPage, self $test ) {
$test->assertFalse( $wikiPage->isNew() );
}
];

View file

@ -272,7 +272,7 @@ class ParserOptionsTest extends MediaWikiLangTestCase {
$ctr = 0;
$this->setTemporaryHook( 'ParserOptionsRegister',
function ( &$defaults, &$inCacheKey, &$lazyOptions ) use ( &$ctr ) {
static function ( &$defaults, &$inCacheKey, &$lazyOptions ) use ( &$ctr ) {
$defaults['testMatches'] = null;
$lazyOptions['testMatches'] = static function () use ( &$ctr ) {
return ++$ctr;

View file

@ -16,7 +16,7 @@ class ParserTest extends MediaWikiIntegrationTestCase {
$mockConfig = $this->createMock( Config::class );
$mockConfig->method( 'has' )->willReturn( true );
$mockConfig->method( 'get' )->will(
$this->returnCallback( function ( $arg ) {
$this->returnCallback( static function ( $arg ) {
return ( $arg === 'TidyConfig' ) ? null : 'I like otters.';
} )
);

View file

@ -19,7 +19,7 @@ class ApiWatchlistTraitTest extends MediaWikiIntegrationTestCase {
$user = $this->createMock( User::class );
$user->method( 'isBot' )->willReturn( $isBot );
$user->method( 'getBoolOption' )->willReturnCallback(
function ( $optionName ) use ( $setOption ) {
static function ( $optionName ) use ( $setOption ) {
if ( $optionName === 'watchdefault' ) {
return (bool)$setOption;
}

View file

@ -119,7 +119,7 @@ trait MockAuthorityTrait {
): Authority {
return $this->mockAuthority(
$user,
function ( $permission ) use ( $permissions ) {
static function ( $permission ) use ( $permissions ) {
return !in_array( $permission, $permissions );
}
);

View file

@ -42,7 +42,7 @@ class MovePageTest extends MediaWikiUnitTestCase {
'good' => false,
];
yield 'can not edit old page' => [
'authority' => $this->mockAnonAuthority( function (
'authority' => $this->mockAnonAuthority( static function (
string $permission,
PageIdentity $page,
PermissionStatus $status
@ -71,7 +71,7 @@ class MovePageTest extends MediaWikiUnitTestCase {
'good' => false,
];
yield 'can not edit new page' => [
'authority' => $this->mockAnonAuthority( function (
'authority' => $this->mockAnonAuthority( static function (
string $permission,
PageIdentity $page,
PermissionStatus $status
@ -117,7 +117,7 @@ class MovePageTest extends MediaWikiUnitTestCase {
public function testCheckPermissions_spam() {
$spamChecker = $this->createNoOpMock( SpamChecker::class, [ 'checkSummary' ] );
$spamChecker->method( 'checkSummary' )
->willReturnCallback( function ( string $reason ) {
->willReturnCallback( static function ( string $reason ) {
return $reason === 'SPAM';
} );
$mp = $this->newServiceInstance(

View file

@ -70,7 +70,7 @@ class NaiveForeignTitleFactoryTest extends MediaWikiUnitTestCase {
$contentLanguage = $this->createMock( Language::class );
$contentLanguage->method( 'getNsIndex' )
->willReturnCallback(
function ( $text ) {
static function ( $text ) {
$text = strtolower( $text );
if ( $text === '' ) {
return NS_MAIN;

View file

@ -467,10 +467,10 @@ class WatchedItemStoreUnitTest extends MediaWikiUnitTestCase {
}
public function provideTestPageFactory() {
yield [ function ( $pageId, $namespace, $dbKey ) {
yield [ static function ( $pageId, $namespace, $dbKey ) {
return new TitleValue( $namespace, $dbKey );
} ];
yield [ function ( $pageId, $namespace, $dbKey ) {
yield [ static function ( $pageId, $namespace, $dbKey ) {
return new PageIdentityValue( $pageId, $namespace, $dbKey, PageIdentityValue::LOCAL );
} ];
yield [ function ( $pageId, $namespace, $dbKey ) {

View file

@ -113,7 +113,7 @@ class WatchlistManagerUnitTest extends MediaWikiUnitTestCase {
// service
$wikiPageFactory = $this->createMock( WikiPageFactory::class );
$wikiPageFactory->method( 'newFromTitle' )->willReturnCallback(
function ( PageIdentity $pageIdentity ) {
static function ( PageIdentity $pageIdentity ) {
// We can't use Title::castFromPageIdentity because that
// calls Title::resetArticleID which uses MediaWikiServices
// Thankfully, however, the only methods on the Title that are
@ -186,7 +186,7 @@ class WatchlistManagerUnitTest extends MediaWikiUnitTestCase {
->willReturnCallback( function ( $userIdentity ) use ( $permissions ) {
$user = $this->createMock( User::class );
$user->method( 'isAllowed' )
->willReturnCallback( function ( $permission ) use ( $permissions ) {
->willReturnCallback( static function ( $permission ) use ( $permissions ) {
return in_array( $permission, $permissions );
} );
$user->method( 'getUser' )
@ -324,10 +324,10 @@ class WatchlistManagerUnitTest extends MediaWikiUnitTestCase {
}
public function provideTestPageFactory() {
yield [ function ( $pageId, $namespace, $dbKey ) {
yield [ static function ( $pageId, $namespace, $dbKey ) {
return new TitleValue( $namespace, $dbKey );
} ];
yield [ function ( $pageId, $namespace, $dbKey ) {
yield [ static function ( $pageId, $namespace, $dbKey ) {
return new PageIdentityValue( $pageId, $namespace, $dbKey, PageIdentityValue::LOCAL );
} ];
yield [ function ( $pageId, $namespace, $dbKey ) {