Tests: Mark more more closures as static
Result of a new sniff I25a17fb22b6b669e817317a0f45051ae9c608208 Bug: T274036 Change-Id: I695873737167a75f0d94901fa40383a33984ca55
This commit is contained in:
parent
20f44cb1ea
commit
a1de8b8700
183 changed files with 639 additions and 639 deletions
|
|
@ -170,7 +170,7 @@ abstract class MWHttpRequestTestCase extends PHPUnit\Framework\TestCase {
|
|||
|
||||
$request = $this->factory->create( 'http://httpbin.org/ip' );
|
||||
$data = '';
|
||||
$request->setCallback( function ( $fh, $content ) use ( &$data ) {
|
||||
$request->setCallback( static function ( $fh, $content ) use ( &$data ) {
|
||||
$data .= $content;
|
||||
return strlen( $content );
|
||||
} );
|
||||
|
|
|
|||
|
|
@ -375,7 +375,7 @@ class ParserTestRunner {
|
|||
MediaWikiServices::getInstance()->disableService( 'MediaHandlerFactory' );
|
||||
MediaWikiServices::getInstance()->redefineService(
|
||||
'MediaHandlerFactory',
|
||||
function ( MediaWikiServices $services ) {
|
||||
static function ( MediaWikiServices $services ) {
|
||||
$handlers = $services->getMainConfig()->get( 'ParserTestMediaHandlers' );
|
||||
return new MediaHandlerFactory( $handlers );
|
||||
}
|
||||
|
|
@ -877,7 +877,7 @@ class ParserTestRunner {
|
|||
|
||||
$oldCallback = $options->getCurrentRevisionRecordCallback();
|
||||
$options->setCurrentRevisionRecordCallback(
|
||||
function ( Title $t, $parser = null ) use ( $title, $revRecord, $oldCallback ) {
|
||||
static function ( Title $t, $parser = null ) use ( $title, $revRecord, $oldCallback ) {
|
||||
if ( $t->equals( $title ) ) {
|
||||
return $revRecord;
|
||||
} else {
|
||||
|
|
@ -938,7 +938,7 @@ class ParserTestRunner {
|
|||
$teardownGuard = $this->perTestSetup( $test );
|
||||
[ $title, $options, $revId ] = $this->setupParserOptions(
|
||||
(object)$test,
|
||||
function ( $context, $title, $revId, $wikitext ) {
|
||||
static function ( $context, $title, $revId, $wikitext ) {
|
||||
return ParserOptions::newFromContext( $context );
|
||||
}
|
||||
);
|
||||
|
|
@ -949,12 +949,12 @@ class ParserTestRunner {
|
|||
if ( isset( $opts['styletag'] ) ) {
|
||||
// For testing the behavior of <style> (including those deduplicated
|
||||
// into <link> tags), add tag hooks to allow them to be generated.
|
||||
$parser->setHook( 'style', function ( $content, $attributes, $parser ) {
|
||||
$parser->setHook( 'style', static function ( $content, $attributes, $parser ) {
|
||||
$marker = Parser::MARKER_PREFIX . '-style-' . md5( $content ) . Parser::MARKER_SUFFIX;
|
||||
$parser->mStripState->addNoWiki( $marker, $content );
|
||||
return Html::inlineStyle( $marker, 'all', $attributes );
|
||||
} );
|
||||
$parser->setHook( 'link', function ( $content, $attributes, $parser ) {
|
||||
$parser->setHook( 'link', static function ( $content, $attributes, $parser ) {
|
||||
return Html::element( 'link', $attributes );
|
||||
} );
|
||||
}
|
||||
|
|
@ -1106,7 +1106,7 @@ class ParserTestRunner {
|
|||
$teardownGuard = $this->perTestSetup( $test );
|
||||
[ $title, $options, $revId ] = $this->setupParserOptions(
|
||||
$test,
|
||||
function ( $context, $title, $revId, $wikitext ) use ( $pageConfigFactory, &$pageConfig ) {
|
||||
static function ( $context, $title, $revId, $wikitext ) use ( $pageConfigFactory, &$pageConfig ) {
|
||||
$pageConfig = $pageConfigFactory->create(
|
||||
$title,
|
||||
$context->getUser(),
|
||||
|
|
@ -1256,7 +1256,7 @@ class ParserTestRunner {
|
|||
MediaWikiServices::getInstance()->disableService( 'ContentLanguage' );
|
||||
MediaWikiServices::getInstance()->redefineService(
|
||||
'ContentLanguage',
|
||||
function () use ( $lang ) {
|
||||
static function () use ( $lang ) {
|
||||
return $lang;
|
||||
}
|
||||
);
|
||||
|
|
@ -1711,7 +1711,7 @@ class ParserTestRunner {
|
|||
$setup[] = static function () use ( $lang ) {
|
||||
$services = MediaWikiServices::getInstance();
|
||||
$services->disableService( 'ContentLanguage' );
|
||||
$services->redefineService( 'ContentLanguage', function () use ( $lang ) {
|
||||
$services->redefineService( 'ContentLanguage', static function () use ( $lang ) {
|
||||
return $lang;
|
||||
} );
|
||||
};
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class TestFileReader {
|
|||
if ( isset( $options['regex'] ) ) {
|
||||
$options['filter'] = [ 'regex' => $options['regex'] ];
|
||||
}
|
||||
$parsoidReader = ParsoidTestFileReader::read( $file, function ( $msg ) {
|
||||
$parsoidReader = ParsoidTestFileReader::read( $file, static function ( $msg ) {
|
||||
wfDeprecatedMsg( $msg, '1.35', false, false );
|
||||
} );
|
||||
$testFormat = intval( $parsoidReader->fileOptions['version'] ?? '1' );
|
||||
|
|
|
|||
|
|
@ -409,7 +409,7 @@ class ParserEditTests extends Maintenance {
|
|||
return false;
|
||||
}
|
||||
$result = TestFileEditor::edit( $text, $deletions, $changes,
|
||||
function ( $msg ) {
|
||||
static function ( $msg ) {
|
||||
print "$msg\n";
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ class ParserTestsMaintenance extends Maintenance {
|
|||
}
|
||||
$recorder->addRecorder( new DbTestPreviewer(
|
||||
$recorderDB,
|
||||
function ( $name ) use ( $regex ) {
|
||||
static function ( $name ) use ( $regex ) {
|
||||
// Filter reports of old tests by the filter regex
|
||||
if ( $regex === false ) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -582,7 +582,7 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase {
|
|||
|
||||
// T46192 Do not attempt to send a real e-mail
|
||||
$this->setTemporaryHook( 'AlternateUserMailer',
|
||||
function () {
|
||||
static function () {
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
|
@ -1079,7 +1079,7 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase {
|
|||
$newServices->resetServiceForTesting( 'DBLoadBalancerFactory' );
|
||||
$newServices->redefineService(
|
||||
'DBLoadBalancerFactory',
|
||||
function ( MediaWikiServices $services ) use ( $oldLoadBalancerFactory ) {
|
||||
static function ( MediaWikiServices $services ) use ( $oldLoadBalancerFactory ) {
|
||||
return $oldLoadBalancerFactory;
|
||||
}
|
||||
);
|
||||
|
|
@ -1088,7 +1088,7 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase {
|
|||
$newServices->resetServiceForTesting( 'HttpRequestFactory' );
|
||||
$newServices->redefineService(
|
||||
'HttpRequestFactory',
|
||||
function ( MediaWikiServices $services ) {
|
||||
static function ( MediaWikiServices $services ) {
|
||||
return new NullHttpRequestFactory();
|
||||
}
|
||||
);
|
||||
|
|
@ -1139,7 +1139,7 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase {
|
|||
global $wgParser, $wgContLang;
|
||||
// We don't have to replace the parser if it wasn't unstubbed
|
||||
if ( !( $wgParser instanceof StubObject ) ) {
|
||||
$wgParser = new StubObject( 'wgParser', function () {
|
||||
$wgParser = new StubObject( 'wgParser', static function () {
|
||||
return MediaWikiServices::getInstance()->getParser();
|
||||
} );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class ActorMigrationTest extends MediaWikiLangTestCase {
|
|||
'removed' => $w->removed,
|
||||
'specialFields' => $w->specialFields,
|
||||
];
|
||||
$this->resetActorMigration = new ScopedCallback( function ( $w, $data ) {
|
||||
$this->resetActorMigration = new ScopedCallback( static function ( $w, $data ) {
|
||||
foreach ( $data as $k => $v ) {
|
||||
$w->$k = $v;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class DeprecatedGlobalTest extends MediaWikiIntegrationTestCase {
|
|||
global $wgDummyLazy;
|
||||
|
||||
$called = false;
|
||||
$factory = function () use ( &$called ) {
|
||||
$factory = static function () use ( &$called ) {
|
||||
$called = true;
|
||||
return new HashBagOStuff();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -363,7 +363,7 @@ class EditPageConstraintsTest extends MediaWikiLangTestCase {
|
|||
) {
|
||||
$this->setTemporaryHook(
|
||||
'EditFilterMergedContent',
|
||||
function ( $context, $content, $status, $summary, $user, $minorEdit )
|
||||
static function ( $context, $content, $status, $summary, $user, $minorEdit )
|
||||
use ( $hookReturn, $statusValue, $statusFatal )
|
||||
{
|
||||
if ( $statusValue !== null ) {
|
||||
|
|
@ -700,7 +700,7 @@ class EditPageConstraintsTest extends MediaWikiLangTestCase {
|
|||
public function testUserRateLimitConstraint() {
|
||||
$this->setTemporaryHook(
|
||||
'PingLimiter',
|
||||
function ( $user, $action, &$result, $incrBy ) {
|
||||
static function ( $user, $action, &$result, $incrBy ) {
|
||||
// Always fail
|
||||
$result = true;
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -456,7 +456,7 @@ class EditPageTest extends MediaWikiLangTestCase {
|
|||
|
||||
$checkIds = [];
|
||||
$this->setMwGlobals( 'wgHooks', [
|
||||
'PageContentSaveComplete' => [ function (
|
||||
'PageContentSaveComplete' => [ static function (
|
||||
WikiPage &$page, User &$user, Content $content,
|
||||
$summary, $minor, $u1, $u2, &$flags, Revision $revision,
|
||||
Status &$status, $baseRevId
|
||||
|
|
@ -836,7 +836,7 @@ hello
|
|||
/** @covers EditPage */
|
||||
public function testShouldPreventChangingContentModelWhenUserCannotChangeModelForTitle() {
|
||||
$this->setTemporaryHook( 'getUserPermissionsErrors',
|
||||
function ( Title $page, $user, $action, &$result ) {
|
||||
static function ( Title $page, $user, $action, &$result ) {
|
||||
if ( $action === 'editcontentmodel' &&
|
||||
$page->getContentModel() === CONTENT_MODEL_WIKITEXT ) {
|
||||
$result = false;
|
||||
|
|
@ -865,7 +865,7 @@ hello
|
|||
/** @covers EditPage */
|
||||
public function testShouldPreventChangingContentModelWhenUserCannotEditTargetTitle() {
|
||||
$this->setTemporaryHook( 'getUserPermissionsErrors',
|
||||
function ( Title $page, $user, $action, &$result ) {
|
||||
static function ( Title $page, $user, $action, &$result ) {
|
||||
if ( $action === 'edit' && $page->getContentModel() === CONTENT_MODEL_WIKITEXT ) {
|
||||
$result = false;
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -36,17 +36,17 @@ namespace MediaWiki\HookContainer {
|
|||
$hookContainer = MediaWikiServices::getInstance()->getHookContainer();
|
||||
|
||||
// Some handlers for FooHook have been previously set
|
||||
$reset = $hookContainer->register( 'FooHook', function () {
|
||||
$reset = $hookContainer->register( 'FooHook', static function () {
|
||||
return true;
|
||||
} );
|
||||
$reset1 = $hookContainer->register( 'FooHook', function () {
|
||||
$reset1 = $hookContainer->register( 'FooHook', static function () {
|
||||
return true;
|
||||
} );
|
||||
$handlersBeforeScopedRegister = $hookContainer->getLegacyHandlers( 'FooHook' );
|
||||
$this->assertCount( 2, $handlersBeforeScopedRegister );
|
||||
|
||||
// Wipe out the 2 existing handlers and add a new scoped handler
|
||||
$reset2 = $hookContainer->scopedRegister( 'FooHook', function () {
|
||||
$reset2 = $hookContainer->scopedRegister( 'FooHook', static function () {
|
||||
return true;
|
||||
}, true );
|
||||
$handlersAfterScopedRegister = $hookContainer->getLegacyHandlers( 'FooHook' );
|
||||
|
|
@ -68,10 +68,10 @@ namespace MediaWiki\HookContainer {
|
|||
public function testHookRunsWithMultipleMixedHandlerTypes() {
|
||||
$hookContainer = MediaWikiServices::getInstance()->getHookContainer();
|
||||
$numHandlersExecuted = 0;
|
||||
$reset = $hookContainer->scopedRegister( 'FooHook', function ( &$numHandlersRun ) {
|
||||
$reset = $hookContainer->scopedRegister( 'FooHook', static function ( &$numHandlersRun ) {
|
||||
$numHandlersRun++;
|
||||
}, false );
|
||||
$reset2 = $hookContainer->scopedRegister( 'FooHook', function ( &$numHandlersRun ) {
|
||||
$reset2 = $hookContainer->scopedRegister( 'FooHook', static function ( &$numHandlersRun ) {
|
||||
$numHandlersRun++;
|
||||
}, false );
|
||||
$handlerThree = [
|
||||
|
|
|
|||
|
|
@ -43,12 +43,12 @@ class HooksTest extends MediaWikiIntegrationTestCase {
|
|||
],
|
||||
[ 'Global function', [ 'NothingFunction' ], 'changed-func', 'original' ],
|
||||
[ 'Global function with data', [ 'NothingFunctionData', 'data' ], 'data', 'original' ],
|
||||
[ 'Closure', [ function ( &$foo, $bar ) {
|
||||
[ 'Closure', [ static function ( &$foo, $bar ) {
|
||||
$foo = 'changed-closure';
|
||||
|
||||
return true;
|
||||
} ], 'changed-closure', 'original' ],
|
||||
[ 'Closure with data', [ function ( $data, &$foo, $bar ) {
|
||||
[ 'Closure with data', [ static function ( $data, &$foo, $bar ) {
|
||||
$foo = $data;
|
||||
|
||||
return true;
|
||||
|
|
@ -166,10 +166,10 @@ class HooksTest extends MediaWikiIntegrationTestCase {
|
|||
*/
|
||||
public function testFalseReturn() {
|
||||
$hookContainer = MediaWikiServices::getInstance()->getHookContainer();
|
||||
$hookContainer->register( 'MediaWikiHooksTest001', function ( &$foo ) {
|
||||
$hookContainer->register( 'MediaWikiHooksTest001', static function ( &$foo ) {
|
||||
return false;
|
||||
} );
|
||||
$hookContainer->register( 'MediaWikiHooksTest001', function ( &$foo ) {
|
||||
$hookContainer->register( 'MediaWikiHooksTest001', static function ( &$foo ) {
|
||||
$foo = 'test';
|
||||
return true;
|
||||
} );
|
||||
|
|
@ -183,10 +183,10 @@ class HooksTest extends MediaWikiIntegrationTestCase {
|
|||
*/
|
||||
public function testNullReturn() {
|
||||
$hookContainer = MediaWikiServices::getInstance()->getHookContainer();
|
||||
$hookContainer->register( 'MediaWikiHooksTest001', function ( &$foo ) {
|
||||
$hookContainer->register( 'MediaWikiHooksTest001', static function ( &$foo ) {
|
||||
return;
|
||||
} );
|
||||
$hookContainer->register( 'MediaWikiHooksTest001', function ( &$foo ) {
|
||||
$hookContainer->register( 'MediaWikiHooksTest001', static function ( &$foo ) {
|
||||
$foo = 'test';
|
||||
|
||||
return true;
|
||||
|
|
@ -202,7 +202,7 @@ class HooksTest extends MediaWikiIntegrationTestCase {
|
|||
public function testCallHook_FalseHook() {
|
||||
$hookContainer = MediaWikiServices::getInstance()->getHookContainer();
|
||||
$hookContainer->register( 'MediaWikiHooksTest001', false );
|
||||
$hookContainer->register( 'MediaWikiHooksTest001', function ( &$foo ) {
|
||||
$hookContainer->register( 'MediaWikiHooksTest001', static function ( &$foo ) {
|
||||
$foo = 'test';
|
||||
|
||||
return true;
|
||||
|
|
@ -238,15 +238,15 @@ class HooksTest extends MediaWikiIntegrationTestCase {
|
|||
public function testRunWithoutAbort() {
|
||||
$list = [];
|
||||
$hookContainer = MediaWikiServices::getInstance()->getHookContainer();
|
||||
$hookContainer->register( 'MediaWikiHooksTest001', function ( &$list ) {
|
||||
$hookContainer->register( 'MediaWikiHooksTest001', static function ( &$list ) {
|
||||
$list[] = 1;
|
||||
return true; // Explicit true
|
||||
} );
|
||||
$hookContainer->register( 'MediaWikiHooksTest001', function ( &$list ) {
|
||||
$hookContainer->register( 'MediaWikiHooksTest001', static function ( &$list ) {
|
||||
$list[] = 2;
|
||||
return; // Implicit null
|
||||
} );
|
||||
$hookContainer->register( 'MediaWikiHooksTest001', function ( &$list ) {
|
||||
$hookContainer->register( 'MediaWikiHooksTest001', static function ( &$list ) {
|
||||
$list[] = 3;
|
||||
// No return
|
||||
} );
|
||||
|
|
@ -260,10 +260,10 @@ class HooksTest extends MediaWikiIntegrationTestCase {
|
|||
*/
|
||||
public function testRunWithoutAbortWarning() {
|
||||
$hookContainer = MediaWikiServices::getInstance()->getHookContainer();
|
||||
$hookContainer->register( 'MediaWikiHooksTest001', function ( &$foo ) {
|
||||
$hookContainer->register( 'MediaWikiHooksTest001', static function ( &$foo ) {
|
||||
return false;
|
||||
} );
|
||||
$hookContainer->register( 'MediaWikiHooksTest001', function ( &$foo ) {
|
||||
$hookContainer->register( 'MediaWikiHooksTest001', static function ( &$foo ) {
|
||||
$foo = 'test';
|
||||
return true;
|
||||
} );
|
||||
|
|
@ -281,7 +281,7 @@ class HooksTest extends MediaWikiIntegrationTestCase {
|
|||
*/
|
||||
public function testFatalError() {
|
||||
$hookContainer = MediaWikiServices::getInstance()->getHookContainer();
|
||||
$hookContainer->register( 'MediaWikiHooksTest001', function () {
|
||||
$hookContainer->register( 'MediaWikiHooksTest001', static function () {
|
||||
return 'test';
|
||||
} );
|
||||
$this->expectDeprecation();
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class ListToggleTest extends MediaWikiIntegrationTestCase {
|
|||
$output = $this->createMock( OutputPage::class );
|
||||
$output->expects( $this->any() )
|
||||
->method( 'msg' )
|
||||
->will( $this->returnCallback( function ( $key ) {
|
||||
->will( $this->returnCallback( static function ( $key ) {
|
||||
return wfMessage( $key )->inLanguage( 'qqx' );
|
||||
} ) );
|
||||
$output->expects( $this->once() )
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class MediaWikiServicesTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$newServices->defineService(
|
||||
'Test',
|
||||
function () use ( $service1 ) {
|
||||
static function () use ( $service1 ) {
|
||||
return $service1;
|
||||
}
|
||||
);
|
||||
|
|
@ -124,7 +124,7 @@ class MediaWikiServicesTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$newServices->defineService(
|
||||
'Test',
|
||||
function () use ( &$instantiatorReturnValues ) {
|
||||
static function () use ( &$instantiatorReturnValues ) {
|
||||
return array_shift( $instantiatorReturnValues );
|
||||
}
|
||||
);
|
||||
|
|
@ -156,7 +156,7 @@ class MediaWikiServicesTest extends MediaWikiIntegrationTestCase {
|
|||
[
|
||||
'handler' => [
|
||||
'name' => 'test',
|
||||
'factory' => function () {
|
||||
'factory' => static function () {
|
||||
return new class implements MediaWikiServicesHook {
|
||||
public function onMediaWikiServices( $services ) {
|
||||
}
|
||||
|
|
@ -195,7 +195,7 @@ class MediaWikiServicesTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$newServices->redefineService(
|
||||
'DBLoadBalancerFactory',
|
||||
function () use ( $lbFactory ) {
|
||||
static function () use ( $lbFactory ) {
|
||||
return $lbFactory;
|
||||
}
|
||||
);
|
||||
|
|
@ -242,7 +242,7 @@ class MediaWikiServicesTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$newServices->defineService(
|
||||
'Test',
|
||||
function () use ( &$instantiatorReturnValues ) {
|
||||
static function () use ( &$instantiatorReturnValues ) {
|
||||
return array_shift( $instantiatorReturnValues );
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -197,14 +197,14 @@ class MediaWikiTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
// A job that attempts to set a cookie
|
||||
$jobHasRun = false;
|
||||
DeferredUpdates::addCallableUpdate( function () use ( $response, &$jobHasRun ) {
|
||||
DeferredUpdates::addCallableUpdate( static function () use ( $response, &$jobHasRun ) {
|
||||
$jobHasRun = true;
|
||||
$response->setCookie( 'JobCookie', 'yes' );
|
||||
$response->header( 'Foo: baz' );
|
||||
} );
|
||||
|
||||
$hookWasRun = false;
|
||||
$this->setTemporaryHook( 'WebResponseSetCookie', function () use ( &$hookWasRun ) {
|
||||
$this->setTemporaryHook( 'WebResponseSetCookie', static function () use ( &$hookWasRun ) {
|
||||
$hookWasRun = true;
|
||||
return true;
|
||||
} );
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class TextFormatterTest extends MediaWikiIntegrationTestCase {
|
|||
->getMock();
|
||||
|
||||
$message->method( 'fetchMessage' )
|
||||
->willReturnCallback( function () use ( $message, $includeWikitext ) {
|
||||
->willReturnCallback( static function () use ( $message, $includeWikitext ) {
|
||||
/** @var Message $message */
|
||||
$result = "{$message->getKey()} $1 $2";
|
||||
if ( $includeWikitext ) {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class MovePageTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$mockLocalRepo = $this->createMock( LocalRepo::class );
|
||||
$mockLocalRepo->method( 'newFile' )->will( $this->returnCallback(
|
||||
function ( Title $title ) use ( $mockExistentFile, $mockNonexistentFile ) {
|
||||
static function ( Title $title ) use ( $mockExistentFile, $mockNonexistentFile ) {
|
||||
if ( in_array( $title->getPrefixedText(),
|
||||
[ 'File:Existent.jpg', 'File:Existent2.jpg', 'File:Existent-file-no-page.jpg' ]
|
||||
) ) {
|
||||
|
|
@ -70,7 +70,7 @@ class MovePageTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$mockNsInfo = $this->createMock( NamespaceInfo::class );
|
||||
$mockNsInfo->method( 'isMovable' )->will( $this->returnCallback(
|
||||
function ( $ns ) {
|
||||
static function ( $ns ) {
|
||||
return $ns >= 0;
|
||||
}
|
||||
) );
|
||||
|
|
@ -118,7 +118,7 @@ class MovePageTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
// Set a couple of hooks for specific pages
|
||||
$this->setTemporaryHook( 'ContentModelCanBeUsedOn',
|
||||
function ( $modelId, Title $title, &$ok ) {
|
||||
static function ( $modelId, Title $title, &$ok ) {
|
||||
if ( $title->getPrefixedText() === 'No content allowed' ) {
|
||||
$ok = false;
|
||||
}
|
||||
|
|
@ -126,7 +126,7 @@ class MovePageTest extends MediaWikiIntegrationTestCase {
|
|||
);
|
||||
|
||||
$this->setTemporaryHook( 'TitleIsMovable',
|
||||
function ( Title $title, &$result ) {
|
||||
static function ( Title $title, &$result ) {
|
||||
if ( strtolower( $title->getPrefixedText() ) === 'hooked in place' ) {
|
||||
$result = false;
|
||||
}
|
||||
|
|
@ -373,7 +373,7 @@ class MovePageTest extends MediaWikiIntegrationTestCase {
|
|||
public function testMoveAbortedByTitleMoveHook() {
|
||||
$error = 'Preventing move operation with TitleMove hook.';
|
||||
$this->setTemporaryHook( 'TitleMove',
|
||||
function ( $old, $new, $user, $reason, $status ) use ( $error ) {
|
||||
static function ( $old, $new, $user, $reason, $status ) use ( $error ) {
|
||||
$status->fatal( $error );
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ class MultiHttpClientTest extends MediaWikiIntegrationTestCase {
|
|||
->with(
|
||||
$url,
|
||||
$this->callback(
|
||||
function ( $options ) use ( $expectedReqTimeout, $expectedConnTimeout ) {
|
||||
static function ( $options ) use ( $expectedReqTimeout, $expectedConnTimeout ) {
|
||||
return $options['timeout'] === $expectedReqTimeout
|
||||
&& $options['connectTimeout'] === $expectedConnTimeout;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -528,18 +528,18 @@ class OutputPageTest extends MediaWikiIntegrationTestCase {
|
|||
[ 'UseCdn' => true, 'CdnMaxAge' => 3599 ] ],
|
||||
'Hook allows cache use' =>
|
||||
[ $lastModified + 1, $lastModified, true, [],
|
||||
function ( $op, $that ) {
|
||||
static function ( $op, $that ) {
|
||||
$that->setTemporaryHook( 'OutputPageCheckLastModified',
|
||||
function ( &$modifiedTimes ) {
|
||||
static function ( &$modifiedTimes ) {
|
||||
$modifiedTimes = [ 1 ];
|
||||
}
|
||||
);
|
||||
} ],
|
||||
'Hooks prohibits cache use' =>
|
||||
[ $lastModified, $lastModified, false, [],
|
||||
function ( $op, $that ) {
|
||||
static function ( $op, $that ) {
|
||||
$that->setTemporaryHook( 'OutputPageCheckLastModified',
|
||||
function ( &$modifiedTimes ) {
|
||||
static function ( &$modifiedTimes ) {
|
||||
$modifiedTimes = [ max( $modifiedTimes ) + 1 ];
|
||||
}
|
||||
);
|
||||
|
|
@ -1196,7 +1196,7 @@ class OutputPageTest extends MediaWikiIntegrationTestCase {
|
|||
$mockContLang
|
||||
->expects( $this->any() )
|
||||
->method( 'convertHtml' )
|
||||
->will( $this->returnCallback( function ( $arg ) {
|
||||
->will( $this->returnCallback( static function ( $arg ) {
|
||||
return $arg;
|
||||
} ) );
|
||||
|
||||
|
|
@ -1231,7 +1231,7 @@ class OutputPageTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$op->expects( $this->any() )
|
||||
->method( 'addCategoryLinksToLBAndGetResult' )
|
||||
->will( $this->returnCallback( function ( array $categories ) use ( $fakeResults ) {
|
||||
->will( $this->returnCallback( static function ( array $categories ) use ( $fakeResults ) {
|
||||
$return = [];
|
||||
foreach ( $categories as $category => $unused ) {
|
||||
if ( isset( $fakeResults[$category] ) ) {
|
||||
|
|
@ -1291,7 +1291,7 @@ class OutputPageTest extends MediaWikiIntegrationTestCase {
|
|||
'Variant link' => [
|
||||
[ 'Test' => 'Test', 'Estay' => 'Estay' ],
|
||||
[ 'Test' => (object)[ 'page_title' => 'Test' ] ],
|
||||
function ( &$link, &$title ) {
|
||||
static function ( &$link, &$title ) {
|
||||
if ( $link === 'Estay' ) {
|
||||
$link = 'Test';
|
||||
$title = Title::makeTitleSafe( NS_CATEGORY, $link );
|
||||
|
|
|
|||
|
|
@ -858,7 +858,7 @@ class PermissionManagerTest extends MediaWikiLangTestCase {
|
|||
$this->assertNotContains( 'nukeworld', $rights, 'sanity check' );
|
||||
|
||||
// Add a hook manipluating the rights
|
||||
$this->setTemporaryHook( 'UserGetRights', function ( $user, &$rights ) {
|
||||
$this->setTemporaryHook( 'UserGetRights', static function ( $user, &$rights ) {
|
||||
$rights[] = 'nukeworld';
|
||||
$rights = array_diff( $rights, [ 'writetest' ] );
|
||||
} );
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ class PrefixSearchTest extends MediaWikiLangTestCase {
|
|||
} else {
|
||||
$this->setMwGlobals( 'wgHooks', [
|
||||
'PrefixSearchBackend' => [
|
||||
function ( $namespaces, $search, $limit, &$srchres ) use ( $results ) {
|
||||
static function ( $namespaces, $search, $limit, &$srchres ) use ( $results ) {
|
||||
$srchres = $results;
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ class ContributionsLookupTest extends MediaWikiIntegrationTestCase {
|
|||
$user = $this->getTestUser()->getUser();
|
||||
|
||||
$clock = (int)ConvertibleTimestamp::now( TS_UNIX );
|
||||
ConvertibleTimestamp::setFakeTime( function () use ( &$clock ) {
|
||||
ConvertibleTimestamp::setFakeTime( static function () use ( &$clock ) {
|
||||
return ++$clock;
|
||||
} );
|
||||
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ class MutableRevisionSlotsTest extends RevisionSlotsTest {
|
|||
|
||||
public function testResetCallback() {
|
||||
$counter = 0;
|
||||
$callback = function () use ( &$counter ) {
|
||||
$callback = static function () use ( &$counter ) {
|
||||
$counter++;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ class RenderedRevisionTest extends MediaWikiIntegrationTestCase {
|
|||
->will( $this->returnValue( true ) );
|
||||
$mock->expects( $this->any() )
|
||||
->method( 'equals' )
|
||||
->willReturnCallback( function ( Title $other ) use ( $mock ) {
|
||||
->willReturnCallback( static function ( Title $other ) use ( $mock ) {
|
||||
return $mock->getPrefixedText() === $other->getPrefixedText();
|
||||
} );
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class RevisionRendererTest extends MediaWikiIntegrationTestCase {
|
|||
$mock->expects( $this->any() )
|
||||
->method( 'equals' )
|
||||
->willReturnCallback(
|
||||
function ( Title $other ) use ( $mock ) {
|
||||
static function ( Title $other ) use ( $mock ) {
|
||||
return $mock->getArticleID() === $other->getArticleID();
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -54,17 +54,17 @@ class SlotRecordTest extends \MediaWikiIntegrationTestCase {
|
|||
$row = $this->makeRow( [
|
||||
'content_size' => null, // to be computed
|
||||
'content_sha1' => null, // to be computed
|
||||
'format_name' => function () {
|
||||
'format_name' => static function () {
|
||||
return CONTENT_FORMAT_WIKITEXT;
|
||||
},
|
||||
'slot_revision_id' => '2',
|
||||
'slot_origin' => '2',
|
||||
'slot_content_id' => function () {
|
||||
'slot_content_id' => static function () {
|
||||
return null;
|
||||
},
|
||||
] );
|
||||
|
||||
$content = function () {
|
||||
$content = static function () {
|
||||
return new WikitextContent( 'A' );
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class SlotRoleRegistryTest extends MediaWikiIntegrationTestCase {
|
|||
*/
|
||||
public function testDefineRole() {
|
||||
$registry = $this->newSlotRoleRegistry();
|
||||
$registry->defineRole( 'FOO', function ( $role ) {
|
||||
$registry->defineRole( 'FOO', static function ( $role ) {
|
||||
return new SlotRoleHandler( $role, 'FooModel' );
|
||||
} );
|
||||
|
||||
|
|
@ -78,12 +78,12 @@ class SlotRoleRegistryTest extends MediaWikiIntegrationTestCase {
|
|||
*/
|
||||
public function testDefineRoleFailsForDupe() {
|
||||
$registry = $this->newSlotRoleRegistry();
|
||||
$registry->defineRole( 'foo', function ( $role ) {
|
||||
$registry->defineRole( 'foo', static function ( $role ) {
|
||||
return new SlotRoleHandler( $role, 'FooModel' );
|
||||
} );
|
||||
|
||||
$this->expectException( LogicException::class );
|
||||
$registry->defineRole( 'FOO', function ( $role ) {
|
||||
$registry->defineRole( 'FOO', static function ( $role ) {
|
||||
return new SlotRoleHandler( $role, 'FooModel' );
|
||||
} );
|
||||
}
|
||||
|
|
@ -143,7 +143,7 @@ class SlotRoleRegistryTest extends MediaWikiIntegrationTestCase {
|
|||
*/
|
||||
public function testGetRoleHandlerWithBadInstantiator() {
|
||||
$registry = $this->newSlotRoleRegistry();
|
||||
$registry->defineRole( 'foo', function ( $role ) {
|
||||
$registry->defineRole( 'foo', static function ( $role ) {
|
||||
return 'Not a SlotRoleHandler instance';
|
||||
} );
|
||||
|
||||
|
|
|
|||
|
|
@ -428,41 +428,41 @@ class RevisionDbTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
public function provideNewFromArchiveRow() {
|
||||
yield [
|
||||
function ( $f ) {
|
||||
static function ( $f ) {
|
||||
return $f;
|
||||
},
|
||||
];
|
||||
yield [
|
||||
function ( $f ) {
|
||||
static function ( $f ) {
|
||||
return $f + [ 'ar_namespace', 'ar_title' ];
|
||||
},
|
||||
];
|
||||
yield [
|
||||
function ( $f ) {
|
||||
static function ( $f ) {
|
||||
unset( $f['ar_text_id'] );
|
||||
return $f;
|
||||
},
|
||||
];
|
||||
yield [
|
||||
function ( $f ) {
|
||||
static function ( $f ) {
|
||||
unset( $f['ar_page_id'] );
|
||||
return $f;
|
||||
},
|
||||
];
|
||||
yield [
|
||||
function ( $f ) {
|
||||
static function ( $f ) {
|
||||
unset( $f['ar_parent_id'] );
|
||||
return $f;
|
||||
},
|
||||
];
|
||||
yield [
|
||||
function ( $f ) {
|
||||
static function ( $f ) {
|
||||
unset( $f['ar_rev_id'] );
|
||||
return $f;
|
||||
},
|
||||
];
|
||||
yield [
|
||||
function ( $f ) {
|
||||
static function ( $f ) {
|
||||
unset( $f['ar_sha1'] );
|
||||
return $f;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ class RevisionTest extends MediaWikiIntegrationTestCase {
|
|||
'rev_comment_data' => null,
|
||||
'rev_comment_cid' => null,
|
||||
],
|
||||
function ( RevisionTest $testCase, Revision $rev ) {
|
||||
static function ( RevisionTest $testCase, Revision $rev ) {
|
||||
$testCase->hideDeprecated( 'Revision::getSha1' );
|
||||
$testCase->hideDeprecated( 'Revision::getUserText' );
|
||||
$testCase->hideDeprecated( 'Revision::isMinor' );
|
||||
|
|
@ -250,7 +250,7 @@ class RevisionTest extends MediaWikiIntegrationTestCase {
|
|||
'rev_comment_data' => null,
|
||||
'rev_comment_cid' => null,
|
||||
],
|
||||
function ( RevisionTest $testCase, Revision $rev ) {
|
||||
static function ( RevisionTest $testCase, Revision $rev ) {
|
||||
$testCase->hideDeprecated( 'Revision::getUserText' );
|
||||
$testCase->hideDeprecated( 'Revision::isMinor' );
|
||||
$testCase->hideDeprecated( 'Revision::getParentId' );
|
||||
|
|
|
|||
|
|
@ -741,7 +741,7 @@ class StatusTest extends MediaWikiLangTestCase {
|
|||
->getMockForAbstractClass();
|
||||
$messageLocalizer->expects( $this->atLeastOnce() )
|
||||
->method( 'msg' )
|
||||
->willReturnCallback( function ( $key ) {
|
||||
->willReturnCallback( static function ( $key ) {
|
||||
return new RawMessage( $key );
|
||||
} );
|
||||
/** @var MessageLocalizer $messageLocalizer */
|
||||
|
|
|
|||
|
|
@ -515,7 +515,7 @@ class DerivedPageDataUpdaterTest extends MediaWikiIntegrationTestCase {
|
|||
*/
|
||||
public function testGetPreparedEditAfterPrepareUpdate() {
|
||||
$clock = MWTimestamp::convert( TS_UNIX, '20100101000000' );
|
||||
MWTimestamp::setFakeTime( function () use ( &$clock ) {
|
||||
MWTimestamp::setFakeTime( static function () use ( &$clock ) {
|
||||
return $clock++;
|
||||
} );
|
||||
|
||||
|
|
@ -592,7 +592,7 @@ class DerivedPageDataUpdaterTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$this->mergeMwGlobalArrayValue(
|
||||
'wgContentHandlers', [
|
||||
$name => function () use ( $handler ){
|
||||
$name => static function () use ( $handler ){
|
||||
return $handler;
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class NameTableStoreTest extends MediaWikiIntegrationTestCase {
|
|||
->getMock();
|
||||
$mock->expects( $this->any() )
|
||||
->method( 'getConnectionRef' )
|
||||
->willReturnCallback( function ( $i ) use ( $mock, $db ) {
|
||||
->willReturnCallback( static function ( $i ) use ( $mock, $db ) {
|
||||
return new MaintainableDBConnRef( $mock, $db, $i );
|
||||
} );
|
||||
return $mock;
|
||||
|
|
@ -190,7 +190,7 @@ class NameTableStoreTest extends MediaWikiIntegrationTestCase {
|
|||
yield [
|
||||
'X',
|
||||
'X',
|
||||
function ( $name ) {
|
||||
static function ( $name ) {
|
||||
return $name;
|
||||
}
|
||||
];
|
||||
|
|
@ -350,7 +350,7 @@ class NameTableStoreTest extends MediaWikiIntegrationTestCase {
|
|||
1,
|
||||
1,
|
||||
null,
|
||||
function ( $insertFields ) {
|
||||
static function ( $insertFields ) {
|
||||
$insertFields['role_id'] = 7251;
|
||||
return $insertFields;
|
||||
}
|
||||
|
|
@ -388,7 +388,7 @@ class NameTableStoreTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$db = $this->getProxyDb( 2 );
|
||||
$db->method( 'insert' )
|
||||
->willReturnCallback( function () use ( &$insertCalls, $db ) {
|
||||
->willReturnCallback( static function () use ( &$insertCalls, $db ) {
|
||||
$insertCalls++;
|
||||
switch ( $insertCalls ) {
|
||||
case 1:
|
||||
|
|
@ -447,7 +447,7 @@ class NameTableStoreTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$quuxId = null;
|
||||
$this->db->onTransactionResolution(
|
||||
function () use ( $store1, &$quuxId ) {
|
||||
static function () use ( $store1, &$quuxId ) {
|
||||
$quuxId = $store1->acquireId( 'quux' );
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -460,7 +460,7 @@ class PageUpdaterTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$expectedError = 'aborted-by-test-hook';
|
||||
$this->setTemporaryHook( 'MultiContentSave',
|
||||
function ( RenderedRevision $renderedRevision, User $user,
|
||||
static function ( RenderedRevision $renderedRevision, User $user,
|
||||
$summary, $flags, Status $hookStatus
|
||||
) use ( $expectedError ) {
|
||||
$hookStatus->fatal( $expectedError );
|
||||
|
|
@ -788,35 +788,35 @@ class PageUpdaterTest extends MediaWikiIntegrationTestCase {
|
|||
public function provideMagicWords() {
|
||||
yield 'PAGEID' => [
|
||||
'Test {{PAGEID}} Test',
|
||||
function ( RevisionRecord $rev ) {
|
||||
static function ( RevisionRecord $rev ) {
|
||||
return $rev->getPageId();
|
||||
}
|
||||
];
|
||||
|
||||
yield 'REVISIONID' => [
|
||||
'Test {{REVISIONID}} Test',
|
||||
function ( RevisionRecord $rev ) {
|
||||
static function ( RevisionRecord $rev ) {
|
||||
return $rev->getId();
|
||||
}
|
||||
];
|
||||
|
||||
yield 'REVISIONUSER' => [
|
||||
'Test {{REVISIONUSER}} Test',
|
||||
function ( RevisionRecord $rev ) {
|
||||
static function ( RevisionRecord $rev ) {
|
||||
return $rev->getUser()->getName();
|
||||
}
|
||||
];
|
||||
|
||||
yield 'REVISIONTIMESTAMP' => [
|
||||
'Test {{REVISIONTIMESTAMP}} Test',
|
||||
function ( RevisionRecord $rev ) {
|
||||
static function ( RevisionRecord $rev ) {
|
||||
return $rev->getTimestamp();
|
||||
}
|
||||
];
|
||||
|
||||
yield 'subst:REVISIONUSER' => [
|
||||
'Test {{subst:REVISIONUSER}} Test',
|
||||
function ( RevisionRecord $rev ) {
|
||||
static function ( RevisionRecord $rev ) {
|
||||
return $rev->getUser()->getName();
|
||||
},
|
||||
'subst'
|
||||
|
|
@ -824,7 +824,7 @@ class PageUpdaterTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
yield 'subst:PAGENAME' => [
|
||||
'Test {{subst:PAGENAME}} Test',
|
||||
function ( RevisionRecord $rev ) {
|
||||
static function ( RevisionRecord $rev ) {
|
||||
return 'PageUpdaterTest::testMagicWords';
|
||||
},
|
||||
'subst'
|
||||
|
|
|
|||
|
|
@ -407,12 +407,12 @@ class TitleMethodsTest extends MediaWikiLangTestCase {
|
|||
];
|
||||
|
||||
$interwikiLookup->method( 'fetch' )
|
||||
->willReturnCallback( function ( $interwiki ) use ( $interwikis ) {
|
||||
->willReturnCallback( static function ( $interwiki ) use ( $interwikis ) {
|
||||
return $interwikis[$interwiki] ?? false;
|
||||
} );
|
||||
|
||||
$interwikiLookup->method( 'isValidInterwiki' )
|
||||
->willReturnCallback( function ( $interwiki ) use ( $interwikis ) {
|
||||
->willReturnCallback( static function ( $interwiki ) use ( $interwikis ) {
|
||||
return isset( $interwikis[$interwiki] );
|
||||
} );
|
||||
|
||||
|
|
|
|||
|
|
@ -486,7 +486,7 @@ class TitleTest extends MediaWikiIntegrationTestCase {
|
|||
$interwikiLookup->expects( $this->any() )
|
||||
->method( 'isValidInterwiki' )
|
||||
->willReturnCallback(
|
||||
function ( $prefix ) {
|
||||
static function ( $prefix ) {
|
||||
return $prefix == 'wiki';
|
||||
}
|
||||
);
|
||||
|
|
@ -1039,7 +1039,7 @@ class TitleTest extends MediaWikiIntegrationTestCase {
|
|||
'Interwiki' => [ Title::makeTitle( NS_MAIN, 'Test', '', 'otherwiki' ), false ],
|
||||
'Special page' => [ 'Special:FooBar', false ],
|
||||
'Aborted by hook' => [ 'Hooked in place', false,
|
||||
function ( Title $title, &$result ) {
|
||||
static function ( Title $title, &$result ) {
|
||||
$result = false;
|
||||
}
|
||||
],
|
||||
|
|
|
|||
|
|
@ -399,7 +399,7 @@ class WebRequestTest extends MediaWikiIntegrationTestCase {
|
|||
'wgUsePrivateIPs' => $private,
|
||||
'wgHooks' => [
|
||||
'IsTrustedProxy' => [
|
||||
function ( &$ip, &$trusted ) use ( $xffList ) {
|
||||
static function ( &$ip, &$trusted ) use ( $xffList ) {
|
||||
$trusted = $trusted || in_array( $ip, $xffList );
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ class WatchActionTest extends MediaWikiIntegrationTestCase {
|
|||
$testContext
|
||||
);
|
||||
|
||||
Hooks::register( 'WatchArticle', function () {
|
||||
Hooks::register( 'WatchArticle', static function () {
|
||||
return false;
|
||||
} );
|
||||
|
||||
|
|
@ -173,7 +173,7 @@ class WatchActionTest extends MediaWikiIntegrationTestCase {
|
|||
->getMock();
|
||||
$testOutput = new OutputPage( $testContext );
|
||||
$testContext->setOutput( $testOutput );
|
||||
$testContext->method( 'msg' )->willReturnCallback( function ( $msgKey ) {
|
||||
$testContext->method( 'msg' )->willReturnCallback( static function ( $msgKey ) {
|
||||
return new RawMessage( $msgKey );
|
||||
} );
|
||||
$watchAction = new WatchAction(
|
||||
|
|
@ -198,7 +198,7 @@ class WatchActionTest extends MediaWikiIntegrationTestCase {
|
|||
->getMock();
|
||||
$testOutput = new OutputPage( $testContext );
|
||||
$testContext->method( 'getOutput' )->willReturn( $testOutput );
|
||||
$testContext->method( 'msg' )->willReturnCallback( function ( $msgKey ) {
|
||||
$testContext->method( 'msg' )->willReturnCallback( static function ( $msgKey ) {
|
||||
return new RawMessage( $msgKey );
|
||||
} );
|
||||
$talkPageTitle = Title::newFromText( 'Talk:UTTest' );
|
||||
|
|
@ -371,7 +371,7 @@ class WatchActionTest extends MediaWikiIntegrationTestCase {
|
|||
*/
|
||||
public function testDoUnWatchUserHookAborted() {
|
||||
$permittedUser = $this->getUser( false, null, [ 'editmywatchlist' ] );
|
||||
Hooks::register( 'UnwatchArticle', function () {
|
||||
Hooks::register( 'UnwatchArticle', static function () {
|
||||
return false;
|
||||
} );
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ class ApiCSPReportTest extends MediaWikiIntegrationTestCase {
|
|||
$log = [];
|
||||
$logger = $this->createMock( Psr\Log\AbstractLogger::class );
|
||||
$logger->method( 'warning' )->will( $this->returnCallback(
|
||||
function ( $msg, $ctx ) use ( &$log ) {
|
||||
static function ( $msg, $ctx ) use ( &$log ) {
|
||||
unset( $ctx['csp-report'] );
|
||||
$log[] = [ $msg, $ctx ];
|
||||
}
|
||||
|
|
@ -107,7 +107,7 @@ class ApiCSPReportTest extends MediaWikiIntegrationTestCase {
|
|||
->setMethods( [ 'getParameter', 'getRequest', 'getResult' ] )
|
||||
->getMock();
|
||||
$api->method( 'getParameter' )->will( $this->returnCallback(
|
||||
function ( $key ) use ( $req ) {
|
||||
static function ( $key ) use ( $req ) {
|
||||
return $req->getRawVal( $key );
|
||||
}
|
||||
) );
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ class ApiChangeContentModelTest extends ApiTestCase {
|
|||
);
|
||||
|
||||
$this->setTemporaryHook( 'EditFilterMergedContent',
|
||||
function ( $unused1, $unused2, Status $status ) use ( $customMessage ) {
|
||||
static function ( $unused1, $unused2, Status $status ) use ( $customMessage ) {
|
||||
if ( $customMessage !== false ) {
|
||||
$status->fatal( $customMessage );
|
||||
}
|
||||
|
|
@ -187,7 +187,7 @@ class ApiChangeContentModelTest extends ApiTestCase {
|
|||
);
|
||||
|
||||
$this->setTemporaryHook( 'ContentModelCanBeUsedOn',
|
||||
function ( $unused1, $unused2, &$ok ) {
|
||||
static function ( $unused1, $unused2, &$ok ) {
|
||||
$ok = false;
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ class ApiDeleteTest extends ApiTestCase {
|
|||
$this->editPage( $name, 'Some text' );
|
||||
|
||||
$this->setTemporaryHook( 'ArticleDelete',
|
||||
function () {
|
||||
static function () {
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1040,7 +1040,7 @@ class ApiEditPageTest extends ApiTestCase {
|
|||
$this->expectExceptionMessage( "Can't append to pages using content model testing-nontext." );
|
||||
|
||||
$this->setTemporaryHook( 'ContentHandlerDefaultModelFor',
|
||||
function ( Title $title, &$model ) use ( $name ) {
|
||||
static function ( Title $title, &$model ) use ( $name ) {
|
||||
if ( $title->getPrefixedText() === $name ) {
|
||||
$model = 'testing-nontext';
|
||||
}
|
||||
|
|
@ -1076,7 +1076,7 @@ class ApiEditPageTest extends ApiTestCase {
|
|||
$this->expectExceptionMessage( 'Content serialization failed: Could not unserialize content' );
|
||||
|
||||
$this->setTemporaryHook( 'ContentHandlerDefaultModelFor',
|
||||
function ( Title $title, &$model ) use ( $name ) {
|
||||
static function ( Title $title, &$model ) use ( $name ) {
|
||||
if ( $title->getPrefixedText() === $name ) {
|
||||
$model = 'testing-serialize-error';
|
||||
}
|
||||
|
|
@ -1436,7 +1436,7 @@ class ApiEditPageTest extends ApiTestCase {
|
|||
$name = 'Help:' . ucfirst( __FUNCTION__ );
|
||||
|
||||
$this->setTemporaryHook( 'EditFilterMergedContent',
|
||||
function ( $unused1, $unused2, Status $status ) {
|
||||
static function ( $unused1, $unused2, Status $status ) {
|
||||
$status->apiHookResult = [ 'msg' => 'A message for you!' ];
|
||||
return false;
|
||||
} );
|
||||
|
|
@ -1461,7 +1461,7 @@ class ApiEditPageTest extends ApiTestCase {
|
|||
);
|
||||
|
||||
$this->setTemporaryHook( 'EditFilterMergedContent',
|
||||
function () {
|
||||
static function () {
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ class ApiLoginTest extends ApiTestCase {
|
|||
|
||||
$this->mergeMwGlobalArrayValue( 'wgAuthManagerConfig', [
|
||||
'secondaryauth' => [ [
|
||||
'factory' => function () use ( $mockProvider ) {
|
||||
'factory' => static function () use ( $mockProvider ) {
|
||||
return $mockProvider;
|
||||
},
|
||||
] ],
|
||||
|
|
@ -346,7 +346,7 @@ class ApiLoginTest extends ApiTestCase {
|
|||
}
|
||||
|
||||
public function testBotPasswordLocked() {
|
||||
$this->setTemporaryHook( 'UserIsLocked', function ( User $unused, &$isLocked ) {
|
||||
$this->setTemporaryHook( 'UserIsLocked', static function ( User $unused, &$isLocked ) {
|
||||
$isLocked = true;
|
||||
return true;
|
||||
} );
|
||||
|
|
@ -361,7 +361,7 @@ class ApiLoginTest extends ApiTestCase {
|
|||
|
||||
public function testNoSameOriginSecurity() {
|
||||
$this->setTemporaryHook( 'RequestHasSameOriginSecurity',
|
||||
function () {
|
||||
static function () {
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ class ApiMainTest extends ApiTestCase {
|
|||
$api = new ApiMain( new FauxRequest( [ 'action' => 'testmodule' ] ) );
|
||||
$api->getModuleManager()->addModule( 'testmodule', 'action', [
|
||||
'class' => get_class( $mock ),
|
||||
'factory' => function () use ( $mock ) {
|
||||
'factory' => static function () use ( $mock ) {
|
||||
return $mock;
|
||||
}
|
||||
] );
|
||||
|
|
@ -268,7 +268,7 @@ class ApiMainTest extends ApiTestCase {
|
|||
$api = new ApiMain( new FauxRequest( [ 'action' => 'testmodule' ] ) );
|
||||
$api->getModuleManager()->addModule( 'testmodule', 'action', [
|
||||
'class' => get_class( $mock ),
|
||||
'factory' => function () use ( $mock ) {
|
||||
'factory' => static function () use ( $mock ) {
|
||||
return $mock;
|
||||
}
|
||||
] );
|
||||
|
|
@ -318,7 +318,7 @@ class ApiMainTest extends ApiTestCase {
|
|||
$api = new ApiMain( $req );
|
||||
$api->getModuleManager()->addModule( 'testmodule', 'action', [
|
||||
'class' => get_class( $mock ),
|
||||
'factory' => function () use ( $mock ) {
|
||||
'factory' => static function () use ( $mock ) {
|
||||
return $mock;
|
||||
}
|
||||
] );
|
||||
|
|
@ -530,7 +530,7 @@ class ApiMainTest extends ApiTestCase {
|
|||
->getMockForAbstractClass();
|
||||
$module->expects( $this->any() )
|
||||
->method( 'getConditionalRequestData' )
|
||||
->will( $this->returnCallback( function ( $condition ) use ( $conditions ) {
|
||||
->will( $this->returnCallback( static function ( $condition ) use ( $conditions ) {
|
||||
return $conditions[$condition] ?? null;
|
||||
} ) );
|
||||
|
||||
|
|
@ -661,7 +661,7 @@ class ApiMainTest extends ApiTestCase {
|
|||
->getMockForAbstractClass();
|
||||
$module->expects( $this->any() )
|
||||
->method( 'getConditionalRequestData' )
|
||||
->will( $this->returnCallback( function ( $condition ) use ( $conditions ) {
|
||||
->will( $this->returnCallback( static function ( $condition ) use ( $conditions ) {
|
||||
return $conditions[$condition] ?? null;
|
||||
} ) );
|
||||
$priv->mModule = $module;
|
||||
|
|
@ -767,7 +767,7 @@ class ApiMainTest extends ApiTestCase {
|
|||
$this->expectException( ApiUsageException::class );
|
||||
$this->expectExceptionMessage( 'Main Page' );
|
||||
|
||||
$this->setTemporaryHook( 'ApiCheckCanExecute', function ( $unused1, $unused2, &$message ) {
|
||||
$this->setTemporaryHook( 'ApiCheckCanExecute', static function ( $unused1, $unused2, &$message ) {
|
||||
$message = 'mainpage';
|
||||
return false;
|
||||
} );
|
||||
|
|
@ -824,7 +824,7 @@ class ApiMainTest extends ApiTestCase {
|
|||
|
||||
// Hook
|
||||
$this->mergeMwGlobalArrayValue( 'wgHooks', [
|
||||
'RequestHasSameOriginSecurity' => [ function () {
|
||||
'RequestHasSameOriginSecurity' => [ static function () {
|
||||
return false;
|
||||
} ]
|
||||
] );
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class ApiModuleManagerTest extends MediaWikiIntegrationTestCase {
|
|||
'action',
|
||||
[
|
||||
'class' => ApiLogout::class,
|
||||
'factory' => function ( ApiMain $main, $action, ObjectFactory $objectFactory ) {
|
||||
'factory' => static function ( ApiMain $main, $action, ObjectFactory $objectFactory ) {
|
||||
return new ApiLogout( $main, $action );
|
||||
},
|
||||
'services' => [
|
||||
|
|
@ -115,7 +115,7 @@ class ApiModuleManagerTest extends MediaWikiIntegrationTestCase {
|
|||
],
|
||||
'logout' => [
|
||||
'class' => ApiLogout::class,
|
||||
'factory' => function ( ApiMain $main, $action ) {
|
||||
'factory' => static function ( ApiMain $main, $action ) {
|
||||
return new ApiLogout( $main, $action );
|
||||
},
|
||||
],
|
||||
|
|
@ -150,7 +150,7 @@ class ApiModuleManagerTest extends MediaWikiIntegrationTestCase {
|
|||
],
|
||||
'logout' => [
|
||||
'class' => ApiLogout::class,
|
||||
'factory' => function ( ApiMain $main, $action ) {
|
||||
'factory' => static function ( ApiMain $main, $action ) {
|
||||
return new ApiLogout( $main, $action );
|
||||
},
|
||||
],
|
||||
|
|
@ -372,7 +372,7 @@ class ApiModuleManagerTest extends MediaWikiIntegrationTestCase {
|
|||
'logout',
|
||||
'action',
|
||||
[
|
||||
'factory' => function ( ApiMain $main, $action ) {
|
||||
'factory' => static function ( ApiMain $main, $action ) {
|
||||
return new ApiLogout( $main, $action );
|
||||
},
|
||||
]
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class ApiPageSetTest extends ApiTestCase {
|
|||
],
|
||||
|
||||
'A simple merge policy adds the redirect data in' => [
|
||||
function ( $current, $new ) {
|
||||
static function ( $current, $new ) {
|
||||
if ( !isset( $current['index'] ) || $new['index'] < $current['index'] ) {
|
||||
$current['index'] = $new['index'];
|
||||
}
|
||||
|
|
@ -88,7 +88,7 @@ class ApiPageSetTest extends ApiTestCase {
|
|||
list( $target, $pageSet ) = $this->createPageSetWithRedirect(
|
||||
'#REDIRECT [[UTPageRedirectOne]]'
|
||||
);
|
||||
$pageSet->setRedirectMergePolicy( function ( $cur, $new ) {
|
||||
$pageSet->setRedirectMergePolicy( static function ( $cur, $new ) {
|
||||
throw new \RuntimeException( 'unreachable, no merge when target is redirect loop' );
|
||||
} );
|
||||
// This could infinite loop in a bugged impl, but php doesn't offer
|
||||
|
|
|
|||
|
|
@ -614,7 +614,7 @@ class ApiParseTest extends ApiTestCase {
|
|||
public function testEffectiveLangLinks() {
|
||||
$hookRan = false;
|
||||
$this->setTemporaryHook( 'LanguageLinks',
|
||||
function () use ( &$hookRan ) {
|
||||
static function () use ( &$hookRan ) {
|
||||
$hookRan = true;
|
||||
}
|
||||
);
|
||||
|
|
@ -701,7 +701,7 @@ class ApiParseTest extends ApiTestCase {
|
|||
|
||||
public function testModules() {
|
||||
$this->setTemporaryHook( 'ParserAfterParse',
|
||||
function ( $parser ) {
|
||||
static function ( $parser ) {
|
||||
$output = $parser->getOutput();
|
||||
$output->addModules( [ 'foo', 'bar' ] );
|
||||
$output->addModuleStyles( [ 'aaa', 'zzz' ] );
|
||||
|
|
|
|||
|
|
@ -174,13 +174,13 @@ class ApiParamValidatorCallbacksTest extends ApiUploadTestCase {
|
|||
->setMethods( [ 'addWarning' ] )
|
||||
->getMockForAbstractClass();
|
||||
$module->method( 'addWarning' )->willReturnCallback(
|
||||
function ( $msg, $code, $data ) use ( &$warnings ) {
|
||||
static function ( $msg, $code, $data ) use ( &$warnings ) {
|
||||
$warnings[] = [ $msg, $code, $data ];
|
||||
}
|
||||
);
|
||||
$query->getModuleManager()->addModule( 'test', 'meta', [
|
||||
'class' => get_class( $module ),
|
||||
'factory' => function () use ( $module ) {
|
||||
'factory' => static function () use ( $module ) {
|
||||
return $module;
|
||||
}
|
||||
] );
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class SubmoduleDefTest extends TypeDefTestCase {
|
|||
|
||||
$w->mMainModule->getModuleManager()->addModule( 'testmod', 'action', [
|
||||
'class' => MockApi::class,
|
||||
'factory' => function () use ( $api ) {
|
||||
'factory' => static function () use ( $api ) {
|
||||
return $api;
|
||||
},
|
||||
] );
|
||||
|
|
@ -55,25 +55,25 @@ class SubmoduleDefTest extends TypeDefTestCase {
|
|||
$manager->addModule( 'mod2', 'test', MockApi::class );
|
||||
$manager->addModule( 'dep', 'test', [
|
||||
'class' => MockApi::class,
|
||||
'factory' => function () use ( $dep ) {
|
||||
'factory' => static function () use ( $dep ) {
|
||||
return $dep;
|
||||
},
|
||||
] );
|
||||
$manager->addModule( 'depint', 'test', [
|
||||
'class' => MockApi::class,
|
||||
'factory' => function () use ( $depint ) {
|
||||
'factory' => static function () use ( $depint ) {
|
||||
return $depint;
|
||||
},
|
||||
] );
|
||||
$manager->addModule( 'int', 'test', [
|
||||
'class' => MockApi::class,
|
||||
'factory' => function () use ( $int ) {
|
||||
'factory' => static function () use ( $int ) {
|
||||
return $int;
|
||||
},
|
||||
] );
|
||||
$manager->addModule( 'recurse', 'test', [
|
||||
'class' => MockApi::class,
|
||||
'factory' => function () use ( $api ) {
|
||||
'factory' => static function () use ( $api ) {
|
||||
return $api;
|
||||
},
|
||||
] );
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class ApiFormatBaseTest extends ApiFormatTestBase {
|
|||
'factory' => function ( ApiMain $main, $format ) use ( $options ) {
|
||||
$mock = $this->getMockFormatter( $main, $format );
|
||||
$mock->expects( $this->once() )->method( 'execute' )
|
||||
->willReturnCallback( function () use ( $mock ) {
|
||||
->willReturnCallback( static function () use ( $mock ) {
|
||||
$mock->printText( "Format {$mock->getFormat()}: " );
|
||||
$mock->printText( "<b>ok</b>" );
|
||||
} );
|
||||
|
|
@ -216,7 +216,7 @@ class ApiFormatBaseTest extends ApiFormatTestBase {
|
|||
] );
|
||||
|
||||
$printer = $this->getMockFormatter( null, 'mock' );
|
||||
$printer->method( 'execute' )->willReturnCallback( function () use ( $printer ) {
|
||||
$printer->method( 'execute' )->willReturnCallback( static function () use ( $printer ) {
|
||||
$printer->printText( 'Foo' );
|
||||
} );
|
||||
$this->assertFalse( $printer->isDisabled() );
|
||||
|
|
@ -242,7 +242,7 @@ class ApiFormatBaseTest extends ApiFormatTestBase {
|
|||
] );
|
||||
|
||||
$printer = $this->getMockFormatter( null, 'mock', [ 'getMimeType' ] );
|
||||
$printer->method( 'execute' )->willReturnCallback( function () use ( $printer ) {
|
||||
$printer->method( 'execute' )->willReturnCallback( static function () use ( $printer ) {
|
||||
$printer->printText( 'Foo' );
|
||||
} );
|
||||
$printer->method( 'getMimeType' )->willReturn( null );
|
||||
|
|
@ -259,7 +259,7 @@ class ApiFormatBaseTest extends ApiFormatTestBase {
|
|||
$this->assertNull( $response->getHeader( 'Content-Disposition' ) );
|
||||
|
||||
$printer = $this->getMockFormatter( null, 'mockfm', [ 'getMimeType' ] );
|
||||
$printer->method( 'execute' )->willReturnCallback( function () use ( $printer ) {
|
||||
$printer->method( 'execute' )->willReturnCallback( static function () use ( $printer ) {
|
||||
$printer->printText( 'Foo' );
|
||||
} );
|
||||
$printer->method( 'getMimeType' )->willReturn( null );
|
||||
|
|
@ -375,14 +375,14 @@ class ApiFormatBaseTest extends ApiFormatTestBase {
|
|||
$mm = $printer->getMain()->getModuleManager();
|
||||
$mm->addModule( 'mockfm', 'format', [
|
||||
'class' => ApiFormatBase::class,
|
||||
'factory' => function () {
|
||||
'factory' => static function () {
|
||||
return $mock;
|
||||
}
|
||||
] );
|
||||
if ( $registerNonHtml ) {
|
||||
$mm->addModule( 'mock', 'format', [
|
||||
'class' => ApiFormatBase::class,
|
||||
'factory' => function () {
|
||||
'factory' => static function () {
|
||||
return $mock;
|
||||
}
|
||||
] );
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class ApiFormatRawTest extends ApiFormatTestBase {
|
|||
public static function provideGeneralEncoding() {
|
||||
$options = [
|
||||
'class' => ApiFormatRaw::class,
|
||||
'factory' => function ( ApiMain $main ) {
|
||||
'factory' => static function ( ApiMain $main ) {
|
||||
return new ApiFormatRaw( $main, new ApiFormatJson( $main, 'json' ) );
|
||||
}
|
||||
];
|
||||
|
|
@ -106,7 +106,7 @@ class ApiFormatRawTest extends ApiFormatTestBase {
|
|||
[],
|
||||
[
|
||||
'class' => ApiFormatRaw::class,
|
||||
'factory' => function ( ApiMain $main ) use ( &$apiMain ) {
|
||||
'factory' => static function ( ApiMain $main ) use ( &$apiMain ) {
|
||||
$apiMain = $main;
|
||||
$printer = new ApiFormatRaw( $main, new ApiFormatJson( $main, 'json' ) );
|
||||
$printer->setFailWithHTTPError( true );
|
||||
|
|
|
|||
|
|
@ -30,16 +30,16 @@ class ApiQueryBlockInfoTraitTest extends MediaWikiIntegrationTestCase {
|
|||
->willReturn( MediaWikiServices::getInstance()->getPermissionManager() );
|
||||
$mock->method( 'getUser' )
|
||||
->willReturn( $this->getMutableTestUser()->getUser() );
|
||||
$mock->method( 'addTables' )->willReturnCallback( function ( $v ) use ( &$data ) {
|
||||
$mock->method( 'addTables' )->willReturnCallback( static function ( $v ) use ( &$data ) {
|
||||
$data['tables'] = array_merge( $data['tables'] ?? [], (array)$v );
|
||||
} );
|
||||
$mock->method( 'addFields' )->willReturnCallback( function ( $v ) use ( &$data ) {
|
||||
$mock->method( 'addFields' )->willReturnCallback( static function ( $v ) use ( &$data ) {
|
||||
$data['fields'] = array_merge( $data['fields'] ?? [], (array)$v );
|
||||
} );
|
||||
$mock->method( 'addWhere' )->willReturnCallback( function ( $v ) use ( &$data ) {
|
||||
$mock->method( 'addWhere' )->willReturnCallback( static function ( $v ) use ( &$data ) {
|
||||
$data['where'] = array_merge( $data['where'] ?? [], (array)$v );
|
||||
} );
|
||||
$mock->method( 'addJoinConds' )->willReturnCallback( function ( $v ) use ( &$data ) {
|
||||
$mock->method( 'addJoinConds' )->willReturnCallback( static function ( $v ) use ( &$data ) {
|
||||
$data['joins'] = array_merge( $data['joins'] ?? [], (array)$v );
|
||||
} );
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class ApiQueryLanguageinfoTest extends ApiTestCase {
|
|||
// register custom language names so this test is independent of CLDR
|
||||
$this->setTemporaryHook(
|
||||
'LanguageGetTranslatedLanguageNames',
|
||||
function ( array &$names, $code ) {
|
||||
static function ( array &$names, $code ) {
|
||||
switch ( $code ) {
|
||||
case 'en':
|
||||
$names['sh'] = 'Serbo-Croatian';
|
||||
|
|
@ -41,13 +41,13 @@ class ApiQueryLanguageinfoTest extends ApiTestCase {
|
|||
// so we can call the constructor with the custom $microtimeFunction
|
||||
$this->setTemporaryHook(
|
||||
'ApiQuery::moduleManager',
|
||||
function ( ApiModuleManager $moduleManager ) use ( $microtimeFunction ) {
|
||||
static function ( ApiModuleManager $moduleManager ) use ( $microtimeFunction ) {
|
||||
$moduleManager->addModule(
|
||||
'languageinfo',
|
||||
'meta',
|
||||
[
|
||||
'class' => ApiQueryLanguageinfo::class,
|
||||
'factory' => function ( $parent, $name ) use ( $microtimeFunction ) {
|
||||
'factory' => static function ( $parent, $name ) use ( $microtimeFunction ) {
|
||||
$services = MediaWikiServices::getInstance();
|
||||
return new ApiQueryLanguageinfo(
|
||||
$parent,
|
||||
|
|
@ -122,7 +122,7 @@ class ApiQueryLanguageinfoTest extends ApiTestCase {
|
|||
|
||||
public function testContinuationNecessary() {
|
||||
$time = 0;
|
||||
$microtimeFunction = function () use ( &$time ) {
|
||||
$microtimeFunction = static function () use ( &$time ) {
|
||||
return $time += 0.75;
|
||||
};
|
||||
|
||||
|
|
@ -134,7 +134,7 @@ class ApiQueryLanguageinfoTest extends ApiTestCase {
|
|||
|
||||
public function testContinuationNotNecessary() {
|
||||
$time = 0;
|
||||
$microtimeFunction = function () use ( &$time ) {
|
||||
$microtimeFunction = static function () use ( &$time ) {
|
||||
return $time += 1.5;
|
||||
};
|
||||
|
||||
|
|
@ -147,7 +147,7 @@ class ApiQueryLanguageinfoTest extends ApiTestCase {
|
|||
|
||||
public function testContinuationInAlphabeticalOrderNotParameterOrder() {
|
||||
$time = 0;
|
||||
$microtimeFunction = function () use ( &$time ) {
|
||||
$microtimeFunction = static function () use ( &$time ) {
|
||||
return $time += 0.75;
|
||||
};
|
||||
$params = [ 'licode' => 'en|ru|zh|de|yue' ];
|
||||
|
|
|
|||
|
|
@ -283,7 +283,7 @@ class ApiQuerySiteinfoTest extends ApiTestCase {
|
|||
|
||||
public function testStatistics() {
|
||||
$this->setTemporaryHook( 'APIQuerySiteInfoStatisticsInfo',
|
||||
function ( &$data ) {
|
||||
static function ( &$data ) {
|
||||
$data['addedstats'] = 42;
|
||||
}
|
||||
);
|
||||
|
|
@ -666,7 +666,7 @@ class ApiQuerySiteinfoTest extends ApiTestCase {
|
|||
|
||||
// Make sure there's something to report on
|
||||
$this->setTemporaryHook( 'somehook',
|
||||
function () {
|
||||
static function () {
|
||||
return;
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ class ApiQueryTest extends ApiTestCase {
|
|||
$this->insertPage( $title );
|
||||
|
||||
$this->setTemporaryHook( 'getUserPermissionsErrors',
|
||||
function ( Title $page, &$user, $action, &$result ) use ( $title ) {
|
||||
static function ( Title $page, &$user, $action, &$result ) use ( $title ) {
|
||||
if ( $page->equals( $title ) && $action === 'read' ) {
|
||||
$result = false;
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ class AbstractPasswordPrimaryAuthenticationProviderTest extends \MediaWikiIntegr
|
|||
],
|
||||
],
|
||||
'checks' => [
|
||||
'Check' => function () use ( &$uppCalled, &$uppStatus ) {
|
||||
'Check' => static function () use ( &$uppCalled, &$uppStatus ) {
|
||||
$uppCalled++;
|
||||
return $uppStatus;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
foreach ( [ 'preauth', 'primaryauth', 'secondaryauth' ] as $type ) {
|
||||
$key = $type . 'Mocks';
|
||||
foreach ( $this->$key as $mock ) {
|
||||
$config[$type][$mock->getUniqueId()] = [ 'factory' => function () use ( $mock ) {
|
||||
$config[$type][$mock->getUniqueId()] = [ 'factory' => static function () use ( $mock ) {
|
||||
return $mock;
|
||||
} ];
|
||||
}
|
||||
|
|
@ -268,7 +268,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
->will( $this->returnValue( $canChangeUser ) );
|
||||
}
|
||||
$this->config->set( 'SessionProviders', [
|
||||
[ 'factory' => function () use ( $provider ) {
|
||||
[ 'factory' => static function () use ( $provider ) {
|
||||
return $provider;
|
||||
} ],
|
||||
] );
|
||||
|
|
@ -364,7 +364,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$mutableSession, [ 'provideSessionInfo' ]
|
||||
);
|
||||
$provider->expects( $this->any() )->method( 'provideSessionInfo' )
|
||||
->will( $this->returnCallback( function () use ( $provider, &$provideUser ) {
|
||||
->will( $this->returnCallback( static function () use ( $provider, &$provideUser ) {
|
||||
return new SessionInfo( SessionInfo::MIN_PRIORITY, [
|
||||
'provider' => $provider,
|
||||
'id' => \DummySessionProvider::ID,
|
||||
|
|
@ -480,12 +480,12 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
->with(
|
||||
$this->anything(),
|
||||
$this->anything(),
|
||||
$this->callback( function ( $s ) use ( $session ) {
|
||||
$this->callback( static function ( $s ) use ( $session ) {
|
||||
return $s->getId() === $session->getId();
|
||||
} ),
|
||||
$mutableSession ? $this->equalTo( 500, 1 ) : $this->equalTo( -1 )
|
||||
)
|
||||
->will( $this->returnCallback( function ( &$v ) use ( $hook ) {
|
||||
->will( $this->returnCallback( static function ( &$v ) use ( $hook ) {
|
||||
$v = $hook;
|
||||
return true;
|
||||
} ) );
|
||||
|
|
@ -840,7 +840,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$this->request->getSession()->setSecret( 'AuthManager::authnState', 'test' );
|
||||
$this->managerPriv->createdAccountAuthenticationRequests = [ $reqs[0] ];
|
||||
$this->hook( 'UserLoggedIn', UserLoggedInHook::class, $this->once() )
|
||||
->with( $this->callback( function ( $u ) use ( $user ) {
|
||||
->with( $this->callback( static function ( $u ) use ( $user ) {
|
||||
return $user->getId() === $u->getId() && $user->getName() === $u->getName();
|
||||
} ) );
|
||||
$this->hook( 'AuthManagerLoginAuthenticateAudit',
|
||||
|
|
@ -1085,7 +1085,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$response->status === AuthenticationResponse::PASS;
|
||||
if ( $success ) {
|
||||
$this->hook( 'UserLoggedIn', UserLoggedInHook::class, $this->once() )
|
||||
->with( $this->callback( function ( $user ) use ( $id, $name ) {
|
||||
->with( $this->callback( static function ( $user ) use ( $id, $name ) {
|
||||
return $user->getId() === $id && $user->getName() === $name;
|
||||
} ) );
|
||||
} else {
|
||||
|
|
@ -1668,7 +1668,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
public function testBeginAccountCreation() {
|
||||
$creator = \User::newFromName( 'UTSysop' );
|
||||
$userReq = new UsernameAuthenticationRequest;
|
||||
$this->logger = new \TestLogger( false, function ( $message, $level ) {
|
||||
$this->logger = new \TestLogger( false, static function ( $message, $level ) {
|
||||
return $level === LogLevel::DEBUG ? null : $message;
|
||||
} );
|
||||
$this->initializeManager();
|
||||
|
|
@ -1817,7 +1817,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
public function testContinueAccountCreation() {
|
||||
$creator = \User::newFromName( 'UTSysop' );
|
||||
$username = self::usernameForCreation();
|
||||
$this->logger = new \TestLogger( false, function ( $message, $level ) {
|
||||
$this->logger = new \TestLogger( false, static function ( $message, $level ) {
|
||||
return $level === LogLevel::DEBUG ? null : $message;
|
||||
} );
|
||||
$this->initializeManager();
|
||||
|
|
@ -2093,7 +2093,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$mocks['secondary3'], $mocks['secondary'], $mocks['secondary2']
|
||||
];
|
||||
|
||||
$this->logger = new \TestLogger( true, function ( $message, $level ) {
|
||||
$this->logger = new \TestLogger( true, static function ( $message, $level ) {
|
||||
return $level === LogLevel::DEBUG ? null : $message;
|
||||
} );
|
||||
$expectLog = [];
|
||||
|
|
@ -2134,7 +2134,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$created = true;
|
||||
$this->hook( 'LocalUserCreated', LocalUserCreatedHook::class, $this->once() )
|
||||
->with(
|
||||
$this->callback( function ( $user ) use ( $username ) {
|
||||
$this->callback( static function ( $user ) use ( $username ) {
|
||||
return $user->getName() === $username;
|
||||
} ),
|
||||
$this->equalTo( false )
|
||||
|
|
@ -2483,11 +2483,11 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
|
||||
$good = StatusValue::newGood();
|
||||
$ok = StatusValue::newFatal( 'ok' );
|
||||
$callback = $this->callback( function ( $user ) use ( &$username, &$workaroundPHPUnitBug ) {
|
||||
$callback = $this->callback( static function ( $user ) use ( &$username, &$workaroundPHPUnitBug ) {
|
||||
return $workaroundPHPUnitBug || $user->getName() === $username;
|
||||
} );
|
||||
$callback2 = $this->callback(
|
||||
function ( $source ) use ( &$expectedSource, &$workaroundPHPUnitBug ) {
|
||||
static function ( $source ) use ( &$expectedSource, &$workaroundPHPUnitBug ) {
|
||||
return $workaroundPHPUnitBug || $source === $expectedSource;
|
||||
}
|
||||
);
|
||||
|
|
@ -2540,7 +2540,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$this->initializeManager( true );
|
||||
$session = $this->request->getSession();
|
||||
|
||||
$logger = new \TestLogger( true, function ( $m ) {
|
||||
$logger = new \TestLogger( true, static function ( $m ) {
|
||||
$m = str_replace( 'MediaWiki\\Auth\\AuthManager::autoCreateUser: ', '', $m );
|
||||
return $m;
|
||||
} );
|
||||
|
|
@ -2980,7 +2980,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$mocks[$key]->expects( $this->any() )->method( 'getUniqueId' )
|
||||
->will( $this->returnValue( $key ) );
|
||||
$mocks[$key]->expects( $this->any() )->method( 'getAuthenticationRequests' )
|
||||
->will( $this->returnCallback( function ( $action ) use ( $key, $makeReq ) {
|
||||
->will( $this->returnCallback( static function ( $action ) use ( $key, $makeReq ) {
|
||||
return [ $makeReq( "$key-$action" ), $makeReq( 'generic' ) ];
|
||||
} ) );
|
||||
$mocks[$key]->expects( $this->any() )->method( 'providerAllowsAuthenticationDataChange' )
|
||||
|
|
@ -3005,7 +3005,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$mocks["primary-$type"]->expects( $this->any() )->method( 'accountCreationType' )
|
||||
->will( $this->returnValue( $type ) );
|
||||
$mocks["primary-$type"]->expects( $this->any() )->method( 'getAuthenticationRequests' )
|
||||
->will( $this->returnCallback( function ( $action ) use ( $type, $makeReq ) {
|
||||
->will( $this->returnCallback( static function ( $action ) use ( $type, $makeReq ) {
|
||||
return [ $makeReq( "primary-$type-$action" ), $makeReq( 'generic' ) ];
|
||||
} ) );
|
||||
$mocks["primary-$type"]->expects( $this->any() )
|
||||
|
|
@ -3028,7 +3028,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
->will( $this->returnValue( [] ) );
|
||||
$mocks['primary2']->expects( $this->any() )
|
||||
->method( 'providerAllowsAuthenticationDataChange' )
|
||||
->will( $this->returnCallback( function ( $req ) use ( $good ) {
|
||||
->will( $this->returnCallback( static function ( $req ) use ( $good ) {
|
||||
return $req->key === 'generic' ? StatusValue::newFatal( 'no' ) : $good;
|
||||
} ) );
|
||||
$this->primaryauthMocks[] = $mocks['primary2'];
|
||||
|
|
@ -3187,7 +3187,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$primary1->expects( $this->any() )->method( 'accountCreationType' )
|
||||
->will( $this->returnValue( PrimaryAuthenticationProvider::TYPE_CREATE ) );
|
||||
$primary1->expects( $this->any() )->method( 'getAuthenticationRequests' )
|
||||
->will( $this->returnCallback( function ( $action ) use ( $makeReq ) {
|
||||
->will( $this->returnCallback( static function ( $action ) use ( $makeReq ) {
|
||||
return [
|
||||
$makeReq( "primary-shared", AuthenticationRequest::REQUIRED ),
|
||||
$makeReq( "required", AuthenticationRequest::REQUIRED ),
|
||||
|
|
@ -3204,7 +3204,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$primary2->expects( $this->any() )->method( 'accountCreationType' )
|
||||
->will( $this->returnValue( PrimaryAuthenticationProvider::TYPE_CREATE ) );
|
||||
$primary2->expects( $this->any() )->method( 'getAuthenticationRequests' )
|
||||
->will( $this->returnCallback( function ( $action ) use ( $makeReq ) {
|
||||
->will( $this->returnCallback( static function ( $action ) use ( $makeReq ) {
|
||||
return [
|
||||
$makeReq( "primary-shared", AuthenticationRequest::REQUIRED ),
|
||||
$makeReq( "required2", AuthenticationRequest::REQUIRED ),
|
||||
|
|
@ -3216,7 +3216,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$secondary->expects( $this->any() )->method( 'getUniqueId' )
|
||||
->will( $this->returnValue( 'secondary' ) );
|
||||
$secondary->expects( $this->any() )->method( 'getAuthenticationRequests' )
|
||||
->will( $this->returnCallback( function ( $action ) use ( $makeReq ) {
|
||||
->will( $this->returnCallback( static function ( $action ) use ( $makeReq ) {
|
||||
return [
|
||||
$makeReq( "foo", AuthenticationRequest::OPTIONAL ),
|
||||
$makeReq( "bar", AuthenticationRequest::REQUIRED ),
|
||||
|
|
@ -3274,7 +3274,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$mocks[$key]->expects( $this->any() )->method( 'getUniqueId' )
|
||||
->will( $this->returnValue( $key ) );
|
||||
$mocks[$key]->expects( $this->any() )->method( 'providerAllowsPropertyChange' )
|
||||
->will( $this->returnCallback( function ( $prop ) use ( $key ) {
|
||||
->will( $this->returnCallback( static function ( $prop ) use ( $key ) {
|
||||
return $prop !== $key;
|
||||
} ) );
|
||||
}
|
||||
|
|
@ -3326,7 +3326,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$this->assertSame( 0, \User::newFromName( $username )->getId(),
|
||||
'sanity check' );
|
||||
|
||||
$callback = $this->callback( function ( $user ) use ( $username ) {
|
||||
$callback = $this->callback( static function ( $user ) use ( $username ) {
|
||||
return $user->getName() === $username;
|
||||
} );
|
||||
|
||||
|
|
@ -3593,7 +3593,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
|
||||
$this->preauthMocks = [ $mocks['pre'], $mocks['pre2'] ];
|
||||
$this->primaryauthMocks = [ $mocks['primary3'], $mocks['primary2'], $mocks['primary'] ];
|
||||
$this->logger = new \TestLogger( true, function ( $message, $level ) {
|
||||
$this->logger = new \TestLogger( true, static function ( $message, $level ) {
|
||||
return $level === LogLevel::DEBUG ? null : $message;
|
||||
} );
|
||||
$this->initializeManager( true );
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ class ConfirmLinkSecondaryAuthenticationProviderTest extends \MediaWikiIntegrati
|
|||
] )
|
||||
->getMock();
|
||||
$manager->expects( $this->any() )->method( 'allowsAuthenticationDataChange' )
|
||||
->will( $this->returnCallback( function ( $req ) {
|
||||
->will( $this->returnCallback( static function ( $req ) {
|
||||
return $req->getUniqueId() !== 'BadReq'
|
||||
? \StatusValue::newGood()
|
||||
: \StatusValue::newFatal( 'no' );
|
||||
|
|
@ -219,12 +219,12 @@ class ConfirmLinkSecondaryAuthenticationProviderTest extends \MediaWikiIntegrati
|
|||
->getMock();
|
||||
$provider->expects( $this->never() )->method( 'beginLinkAttempt' );
|
||||
$provider->expects( $this->any() )->method( 'providerAllowsAuthenticationDataChange' )
|
||||
->will( $this->returnCallback( function ( $req ) use ( $reqs ) {
|
||||
->will( $this->returnCallback( static function ( $req ) use ( $reqs ) {
|
||||
return $req->getUniqueId() === 'Request3'
|
||||
? \StatusValue::newFatal( 'foo' ) : \StatusValue::newGood();
|
||||
} ) );
|
||||
$provider->expects( $this->any() )->method( 'providerChangeAuthenticationData' )
|
||||
->will( $this->returnCallback( function ( $req ) use ( &$done ) {
|
||||
->will( $this->returnCallback( static function ( $req ) use ( &$done ) {
|
||||
$done[$req->id] = true;
|
||||
} ) );
|
||||
$config = new \HashConfig( [
|
||||
|
|
@ -232,7 +232,7 @@ class ConfirmLinkSecondaryAuthenticationProviderTest extends \MediaWikiIntegrati
|
|||
'preauth' => [],
|
||||
'primaryauth' => [],
|
||||
'secondaryauth' => [
|
||||
[ 'factory' => function () use ( $provider ) {
|
||||
[ 'factory' => static function () use ( $provider ) {
|
||||
return $provider;
|
||||
} ],
|
||||
],
|
||||
|
|
|
|||
|
|
@ -460,7 +460,7 @@ class LocalPasswordPrimaryAuthenticationProviderTest extends \MediaWikiIntegrati
|
|||
$oldExpiry = $dbw->selectField( 'user', 'user_password_expires', [ 'user_name' => $cuser ] );
|
||||
|
||||
$this->mergeMwGlobalArrayValue( 'wgHooks', [
|
||||
'ResetPasswordExpiration' => [ function ( $user, &$expires ) {
|
||||
'ResetPasswordExpiration' => [ static function ( $user, &$expires ) {
|
||||
$expires = '30001231235959';
|
||||
} ]
|
||||
] );
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class ResetPasswordSecondaryAuthenticationProviderTest extends \MediaWikiIntegra
|
|||
'preauth' => [],
|
||||
'primaryauth' => [],
|
||||
'secondaryauth' => [
|
||||
[ 'factory' => function () use ( $provider ) {
|
||||
[ 'factory' => static function () use ( $provider ) {
|
||||
return $provider;
|
||||
} ],
|
||||
],
|
||||
|
|
|
|||
|
|
@ -430,7 +430,7 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiInteg
|
|||
|
||||
$dbw = wfGetDB( DB_MASTER );
|
||||
$oldHash = $dbw->selectField( 'user', 'user_newpassword', [ 'user_name' => $cuser ] );
|
||||
$cb = new ScopedCallback( function () use ( $dbw, $cuser, $oldHash ) {
|
||||
$cb = new ScopedCallback( static function () use ( $dbw, $cuser, $oldHash ) {
|
||||
$dbw->update( 'user', [ 'user_newpassword' => $oldHash ], [ 'user_name' => $cuser ] );
|
||||
} );
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class BlockManagerTest extends MediaWikiIntegrationTestCase {
|
|||
$onUserGetRightsCalled = false;
|
||||
$this->setTemporaryHook(
|
||||
'UserGetRights',
|
||||
function ( $user, &$rights ) use ( &$onUserGetRightsCalled ) {
|
||||
static function ( $user, &$rights ) use ( &$onUserGetRightsCalled ) {
|
||||
$onUserGetRightsCalled = true;
|
||||
$rights[] = 'ipblock-exempt';
|
||||
return true;
|
||||
|
|
@ -89,7 +89,7 @@ class BlockManagerTest extends MediaWikiIntegrationTestCase {
|
|||
$onGetUserBlockIP = false;
|
||||
$this->setTemporaryHook(
|
||||
'GetUserBlock',
|
||||
function ( $user, $ip, &$block ) use ( &$onGetUserBlockCalled, &$onGetUserBlockIP ) {
|
||||
static function ( $user, $ip, &$block ) use ( &$onGetUserBlockCalled, &$onGetUserBlockIP ) {
|
||||
$onGetUserBlockCalled = true;
|
||||
$onGetUserBlockIP = $ip;
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -137,13 +137,13 @@ class LinkBatchTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$cache->expects( $this->exactly( 2 ) )
|
||||
->method( 'addGoodLinkObjFromRow' )
|
||||
->willReturnCallback( function ( TitleValue $title, $row ) use ( &$good ) {
|
||||
->willReturnCallback( static function ( TitleValue $title, $row ) use ( &$good ) {
|
||||
$good["$title"] = $title;
|
||||
} );
|
||||
|
||||
$cache->expects( $this->exactly( 2 ) )
|
||||
->method( 'addBadLinkObj' )
|
||||
->willReturnCallback( function ( TitleValue $title ) use ( &$bad ) {
|
||||
->willReturnCallback( static function ( TitleValue $title ) use ( &$bad ) {
|
||||
$bad["$title"] = $title;
|
||||
} );
|
||||
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@ class LocalisationCacheTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$mockLangNameUtils = $this->createMock( LanguageNameUtils::class );
|
||||
$mockLangNameUtils->method( 'isValidBuiltInCode' )->will( $this->returnCallback(
|
||||
function ( $code ) {
|
||||
static function ( $code ) {
|
||||
// Copy-paste, but it's only one line
|
||||
return (bool)preg_match( '/^[a-z0-9-]{2,}$/', $code );
|
||||
}
|
||||
) );
|
||||
$mockLangNameUtils->method( 'isSupportedLanguage' )->will( $this->returnCallback(
|
||||
function ( $code ) {
|
||||
static function ( $code ) {
|
||||
return in_array( $code, [
|
||||
'ar',
|
||||
'arz',
|
||||
|
|
@ -47,7 +47,7 @@ class LocalisationCacheTest extends MediaWikiIntegrationTestCase {
|
|||
}
|
||||
) );
|
||||
$mockLangNameUtils->method( 'getMessagesFileName' )->will( $this->returnCallback(
|
||||
function ( $code ) {
|
||||
static function ( $code ) {
|
||||
global $IP;
|
||||
$code = str_replace( '-', '_', ucfirst( $code ) );
|
||||
return "$IP/languages/messages/Messages$code.php";
|
||||
|
|
@ -131,7 +131,7 @@ class LocalisationCacheTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$lc = $this->getMockLocalisationCache( [
|
||||
'LocalisationCacheRecacheFallback' => [
|
||||
function (
|
||||
static function (
|
||||
LocalisationCache $lc,
|
||||
$code,
|
||||
array &$cache
|
||||
|
|
|
|||
|
|
@ -96,13 +96,13 @@ class EnhancedChangesListTest extends MediaWikiLangTestCase {
|
|||
return 'Hello world prefix';
|
||||
} );
|
||||
|
||||
$this->setTemporaryHook( 'EnhancedChangesListModifyLineData', function (
|
||||
$this->setTemporaryHook( 'EnhancedChangesListModifyLineData', static function (
|
||||
$enhancedChangesList, &$data, $block, $rc, &$classes, &$attribs
|
||||
) {
|
||||
$data['recentChangesFlags']['minor'] = 1;
|
||||
} );
|
||||
|
||||
$this->setTemporaryHook( 'EnhancedChangesListModifyBlockLineData', function (
|
||||
$this->setTemporaryHook( 'EnhancedChangesListModifyBlockLineData', static function (
|
||||
$enhancedChangesList, &$data, $rcObj
|
||||
) {
|
||||
$data['recentChangesFlags']['bot'] = 1;
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ class OldChangesListTest extends MediaWikiLangTestCase {
|
|||
$recentChange = $this->getEditChange();
|
||||
$recentChange->mAttribs['ts_tags'] = 'vandalism,newbie';
|
||||
|
||||
$this->setTemporaryHook( 'OldChangesListRecentChangesLine', function (
|
||||
$this->setTemporaryHook( 'OldChangesListRecentChangesLine', static function (
|
||||
$oldChangesList, &$html, $rc, $classes, $attribs
|
||||
) {
|
||||
$html = $html . '/<div>Additional change line </div>/';
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class ConfigFactoryTest extends \MediaWikiIntegrationTestCase {
|
|||
// define new config instance
|
||||
$newFactory = new ConfigFactory();
|
||||
$newFactory->register( 'foo', 'GlobalVarConfig::newInstance' );
|
||||
$newFactory->register( 'bar', function () {
|
||||
$newFactory->register( 'bar', static function () {
|
||||
return new HashConfig();
|
||||
} );
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ class ConfigFactoryTest extends \MediaWikiIntegrationTestCase {
|
|||
*/
|
||||
public function testMakeConfigWithInvalidCallback() {
|
||||
$factory = new ConfigFactory();
|
||||
$factory->register( 'unittest', function () {
|
||||
$factory->register( 'unittest', static function () {
|
||||
return true; // Not a Config object
|
||||
} );
|
||||
$this->expectException( UnexpectedValueException::class );
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class ContentHandlerTest extends MediaWikiIntegrationTestCase {
|
|||
CONTENT_MODEL_CSS => CssContentHandler::class,
|
||||
CONTENT_MODEL_TEXT => TextContentHandler::class,
|
||||
'testing' => DummyContentHandlerForTesting::class,
|
||||
'testing-callbacks' => function ( $modelId ) {
|
||||
'testing-callbacks' => static function ( $modelId ) {
|
||||
return new DummyContentHandlerForTesting( $modelId );
|
||||
}
|
||||
],
|
||||
|
|
@ -428,7 +428,7 @@ class ContentHandlerTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$searchEngine->expects( $this->any() )
|
||||
->method( 'makeSearchFieldMapping' )
|
||||
->will( $this->returnCallback( function ( $name, $type ) {
|
||||
->will( $this->returnCallback( static function ( $name, $type ) {
|
||||
return new DummySearchIndexFieldDefinition( $name, $type );
|
||||
} ) );
|
||||
|
||||
|
|
@ -444,7 +444,7 @@ class ContentHandlerTest extends MediaWikiIntegrationTestCase {
|
|||
$page = new WikiPage( $title );
|
||||
|
||||
$this->setTemporaryHook( 'SearchDataForIndex',
|
||||
function (
|
||||
static function (
|
||||
&$fields,
|
||||
ContentHandler $handler,
|
||||
WikiPage $page,
|
||||
|
|
@ -480,7 +480,7 @@ class ContentHandlerTest extends MediaWikiIntegrationTestCase {
|
|||
* @covers ContentHandler::getContentModels
|
||||
*/
|
||||
public function testGetContentModelsHook() {
|
||||
$this->setTemporaryHook( 'GetContentModels', function ( &$models ) {
|
||||
$this->setTemporaryHook( 'GetContentModels', static function ( &$models ) {
|
||||
$models[] = 'Ferrari';
|
||||
} );
|
||||
$this->assertContains( 'Ferrari', ContentHandler::getContentModels() );
|
||||
|
|
@ -600,7 +600,7 @@ class ContentHandlerTest extends MediaWikiIntegrationTestCase {
|
|||
->disableOriginalConstructor()
|
||||
->getMockForAbstractClass();
|
||||
$this->setTemporaryHook( 'GetSlotDiffRenderer',
|
||||
function ( $handler, &$slotDiffRenderer ) use ( $customSlotDiffRenderer2 ) {
|
||||
static function ( $handler, &$slotDiffRenderer ) use ( $customSlotDiffRenderer2 ) {
|
||||
$slotDiffRenderer = $customSlotDiffRenderer2;
|
||||
} );
|
||||
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ class ContentModelChangeTest extends MediaWikiIntegrationTestCase {
|
|||
);
|
||||
|
||||
$this->setTemporaryHook( 'EditFilterMergedContent',
|
||||
function ( $unused1, $unused2, Status $status ) use ( $customMessage ) {
|
||||
static function ( $unused1, $unused2, Status $status ) use ( $customMessage ) {
|
||||
if ( $customMessage !== false ) {
|
||||
$status->fatal( $customMessage );
|
||||
}
|
||||
|
|
@ -190,7 +190,7 @@ class ContentModelChangeTest extends MediaWikiIntegrationTestCase {
|
|||
);
|
||||
|
||||
$this->setTemporaryHook( 'ContentModelCanBeUsedOn',
|
||||
function ( $unused1, $unused2, &$ok ) {
|
||||
static function ( $unused1, $unused2, &$ok ) {
|
||||
$ok = false;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -301,40 +301,40 @@ class ContentModelChangeTest extends MediaWikiIntegrationTestCase {
|
|||
->withConsecutive(
|
||||
[
|
||||
$this->equalTo( 'editcontentmodel' ),
|
||||
$this->callback( function ( User $userInMock ) use ( $user ) {
|
||||
$this->callback( static function ( User $userInMock ) use ( $user ) {
|
||||
return $user->equals( $userInMock );
|
||||
} ),
|
||||
$this->callback( function ( Title $titleInMock ) use ( $title, $currentContentModel ) {
|
||||
$this->callback( static function ( Title $titleInMock ) use ( $title, $currentContentModel ) {
|
||||
return $title->equals( $titleInMock ) &&
|
||||
$titleInMock->hasContentModel( $currentContentModel );
|
||||
} )
|
||||
],
|
||||
[
|
||||
$this->equalTo( 'edit' ),
|
||||
$this->callback( function ( User $userInMock ) use ( $user ) {
|
||||
$this->callback( static function ( User $userInMock ) use ( $user ) {
|
||||
return $user->equals( $userInMock );
|
||||
} ),
|
||||
$this->callback( function ( Title $titleInMock ) use ( $title, $currentContentModel ) {
|
||||
$this->callback( static function ( Title $titleInMock ) use ( $title, $currentContentModel ) {
|
||||
return $title->equals( $titleInMock ) &&
|
||||
$titleInMock->hasContentModel( $currentContentModel );
|
||||
} )
|
||||
],
|
||||
[
|
||||
$this->equalTo( 'editcontentmodel' ),
|
||||
$this->callback( function ( User $userInMock ) use ( $user ) {
|
||||
$this->callback( static function ( User $userInMock ) use ( $user ) {
|
||||
return $user->equals( $userInMock );
|
||||
} ),
|
||||
$this->callback( function ( Title $titleInMock ) use ( $title, $newContentModel ) {
|
||||
$this->callback( static function ( Title $titleInMock ) use ( $title, $newContentModel ) {
|
||||
return $title->equals( $titleInMock ) &&
|
||||
$titleInMock->hasContentModel( $newContentModel );
|
||||
} )
|
||||
],
|
||||
[
|
||||
$this->equalTo( 'edit' ),
|
||||
$this->callback( function ( User $userInMock ) use ( $user ) {
|
||||
$this->callback( static function ( User $userInMock ) use ( $user ) {
|
||||
return $user->equals( $userInMock );
|
||||
} ),
|
||||
$this->callback( function ( Title $titleInMock ) use ( $title, $newContentModel ) {
|
||||
$this->callback( static function ( Title $titleInMock ) use ( $title, $newContentModel ) {
|
||||
return $title->equals( $titleInMock ) &&
|
||||
$titleInMock->hasContentModel( $newContentModel );
|
||||
} )
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class ObjectFactoryMakeContentHandlerWithSpecsToTest extends MediaWikiIntegratio
|
|||
'typical list' => [
|
||||
[
|
||||
'ExistClassName' => DummyContentHandlerForTesting::class,
|
||||
'ExistCallbackWithExistClassName' => function ( $modelID ) {
|
||||
'ExistCallbackWithExistClassName' => static function ( $modelID ) {
|
||||
return new DummyContentHandlerForTesting( $modelID );
|
||||
},
|
||||
],
|
||||
|
|
@ -82,13 +82,13 @@ class ObjectFactoryMakeContentHandlerWithSpecsToTest extends MediaWikiIntegratio
|
|||
return [
|
||||
'UnexpectedValueException with wrong specs result' => [
|
||||
[
|
||||
'ExistCallbackWithWrongType' => function () {
|
||||
'ExistCallbackWithWrongType' => static function () {
|
||||
return true;
|
||||
},
|
||||
'ExistCallbackWithNull' => function () {
|
||||
'ExistCallbackWithNull' => static function () {
|
||||
return null;
|
||||
},
|
||||
'ExistCallbackWithEmptyString' => function () {
|
||||
'ExistCallbackWithEmptyString' => static function () {
|
||||
return '';
|
||||
},
|
||||
'WrongClassName' => self::class,
|
||||
|
|
@ -108,7 +108,7 @@ class ObjectFactoryMakeContentHandlerWithSpecsToTest extends MediaWikiIntegratio
|
|||
],
|
||||
'Error expected' => [
|
||||
[
|
||||
'ExistCallbackWithNotExistClassName' => function () {
|
||||
'ExistCallbackWithNotExistClassName' => static function () {
|
||||
return \ClassNameNotExist();
|
||||
},
|
||||
],
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class RegistrationContentHandlerFactoryToMediaWikiServicesTest extends MediaWiki
|
|||
CONTENT_MODEL_CSS => CssContentHandler::class,
|
||||
CONTENT_MODEL_TEXT => TextContentHandler::class,
|
||||
'testing' => DummyContentHandlerForTesting::class,
|
||||
'testing-callbacks' => function ( $modelId ) {
|
||||
'testing-callbacks' => static function ( $modelId ) {
|
||||
return new DummyContentHandlerForTesting( $modelId );
|
||||
},
|
||||
],
|
||||
|
|
|
|||
|
|
@ -373,7 +373,7 @@ just a test"
|
|||
$redirectTarget = null;
|
||||
$this->mergeMwGlobalArrayValue( 'wgHooks', [
|
||||
'InternalParseBeforeLinks' => [
|
||||
function ( Parser $parser, $text, $stripState ) use ( &$wikitext, &$redirectTarget ) {
|
||||
static function ( Parser $parser, $text, $stripState ) use ( &$wikitext, &$redirectTarget ) {
|
||||
$wikitext = $text;
|
||||
$redirectTarget = $parser->getOptions()->getRedirectTarget();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,10 +65,10 @@ class DatabaseTestHelper extends Database {
|
|||
'connLogger' => new NullLogger(),
|
||||
'queryLogger' => new NullLogger(),
|
||||
'replLogger' => new NullLogger(),
|
||||
'errorLogger' => function ( Exception $e ) {
|
||||
'errorLogger' => static function ( Exception $e ) {
|
||||
wfWarn( get_class( $e ) . ": {$e->getMessage()}" );
|
||||
},
|
||||
'deprecationLogger' => function ( $msg ) {
|
||||
'deprecationLogger' => static function ( $msg ) {
|
||||
wfWarn( $msg );
|
||||
}
|
||||
] );
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ class LBFactoryTest extends MediaWikiIntegrationTestCase {
|
|||
$called = 0;
|
||||
$countLBsFunc = static function ( LBFactoryMulti $factory ) {
|
||||
$count = 0;
|
||||
$factory->forEachLB( function () use ( &$count ) {
|
||||
$factory->forEachLB( static function () use ( &$count ) {
|
||||
++$count;
|
||||
} );
|
||||
|
||||
|
|
@ -165,7 +165,7 @@ class LBFactoryTest extends MediaWikiIntegrationTestCase {
|
|||
// Test that LoadBalancer instances made during pre-commit callbacks in do not
|
||||
// throw DBTransactionError due to transaction ROUND_* stages being mismatched.
|
||||
$factory->beginMasterChanges( __METHOD__ );
|
||||
$dbw->onTransactionPreCommitOrIdle( function () use ( $factory, &$called ) {
|
||||
$dbw->onTransactionPreCommitOrIdle( static function () use ( $factory, &$called ) {
|
||||
++$called;
|
||||
// Trigger s1 LoadBalancer instantiation during "finalize" stage.
|
||||
// There is no s1wiki DB to select so it is not in getConnection(),
|
||||
|
|
@ -188,7 +188,7 @@ class LBFactoryTest extends MediaWikiIntegrationTestCase {
|
|||
// DBTransactionError due to transaction ROUND_* stages being mismatched.
|
||||
$factory->beginMasterChanges( __METHOD__ );
|
||||
$dbw->query( "SELECT 1 as t", __METHOD__ );
|
||||
$dbw->onTransactionResolution( function () use ( $factory, &$called ) {
|
||||
$dbw->onTransactionResolution( static function () use ( $factory, &$called ) {
|
||||
++$called;
|
||||
// Trigger s1 LoadBalancer instantiation during "finalize" stage.
|
||||
// There is no s1wiki DB to select so it is not in getConnection(),
|
||||
|
|
@ -205,7 +205,7 @@ class LBFactoryTest extends MediaWikiIntegrationTestCase {
|
|||
$dbw = $factory->getMainLB()->getConnection( DB_MASTER );
|
||||
// DBTransactionError should not be thrown
|
||||
$ran = 0;
|
||||
$dbw->onTransactionPreCommitOrIdle( function () use ( &$ran ) {
|
||||
$dbw->onTransactionPreCommitOrIdle( static function () use ( &$ran ) {
|
||||
++$ran;
|
||||
} );
|
||||
$factory->commitAll( __METHOD__ );
|
||||
|
|
@ -278,7 +278,7 @@ class LBFactoryTest extends MediaWikiIntegrationTestCase {
|
|||
$lb1->method( 'hasStreamingReplicaServers' )->willReturn( true );
|
||||
$lb1->method( 'getAnyOpenConnection' )->willReturn( $mockDB1 );
|
||||
$lb1->method( 'hasOrMadeRecentMasterChanges' )->will( $this->returnCallback(
|
||||
function () use ( $mockDB1 ) {
|
||||
static function () use ( $mockDB1 ) {
|
||||
$p = 0;
|
||||
$p |= $mockDB1->writesOrCallbacksPending();
|
||||
$p |= $mockDB1->lastDoneWrites();
|
||||
|
|
@ -307,7 +307,7 @@ class LBFactoryTest extends MediaWikiIntegrationTestCase {
|
|||
$lb2->method( 'hasStreamingReplicaServers' )->willReturn( true );
|
||||
$lb2->method( 'getAnyOpenConnection' )->willReturn( $mockDB2 );
|
||||
$lb2->method( 'hasOrMadeRecentMasterChanges' )->will( $this->returnCallback(
|
||||
function () use ( $mockDB2 ) {
|
||||
static function () use ( $mockDB2 ) {
|
||||
$p = 0;
|
||||
$p |= $mockDB2->writesOrCallbacksPending();
|
||||
$p |= $mockDB2->lastDoneWrites();
|
||||
|
|
@ -689,7 +689,7 @@ class LBFactoryTest extends MediaWikiIntegrationTestCase {
|
|||
$factory->redefineLocalDomain( $domain );
|
||||
|
||||
$n = 0;
|
||||
$lb->forEachOpenConnection( function () use ( &$n ) {
|
||||
$lb->forEachOpenConnection( static function () use ( &$n ) {
|
||||
++$n;
|
||||
} );
|
||||
$this->assertSame( 0, $n, "Connections closed" );
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class LoadBalancerTest extends MediaWikiIntegrationTestCase {
|
|||
'servers' => [ $this->makeServerConfig( DBO_TRX ) ],
|
||||
'queryLogger' => MediaWiki\Logger\LoggerFactory::getInstance( 'DBQuery' ),
|
||||
'localDomain' => new DatabaseDomain( $wgDBname, null, $this->dbPrefix() ),
|
||||
'chronologyCallback' => function () use ( &$called ) {
|
||||
'chronologyCallback' => static function () use ( &$called ) {
|
||||
$called = true;
|
||||
}
|
||||
] );
|
||||
|
|
@ -521,25 +521,25 @@ class LoadBalancerTest extends MediaWikiIntegrationTestCase {
|
|||
$conn2 = $lb->openConnection( $lb->getWriterIndex(), '' );
|
||||
|
||||
$count = 0;
|
||||
$lb->forEachOpenMasterConnection( function () use ( &$count ) {
|
||||
$lb->forEachOpenMasterConnection( static function () use ( &$count ) {
|
||||
++$count;
|
||||
} );
|
||||
$this->assertEquals( 2, $count, 'Connection handle count' );
|
||||
|
||||
$tlCalls = 0;
|
||||
$lb->setTransactionListener( 'test-listener', function () use ( &$tlCalls ) {
|
||||
$lb->setTransactionListener( 'test-listener', static function () use ( &$tlCalls ) {
|
||||
++$tlCalls;
|
||||
} );
|
||||
|
||||
$lb->beginMasterChanges( __METHOD__ );
|
||||
$bc = array_fill_keys( [ 'a', 'b', 'c', 'd' ], 0 );
|
||||
$conn1->onTransactionPreCommitOrIdle( function () use ( &$bc, $conn1, $conn2 ) {
|
||||
$conn1->onTransactionPreCommitOrIdle( static function () use ( &$bc, $conn1, $conn2 ) {
|
||||
$bc['a'] = 1;
|
||||
$conn2->onTransactionPreCommitOrIdle( function () use ( &$bc, $conn1, $conn2 ) {
|
||||
$conn2->onTransactionPreCommitOrIdle( static function () use ( &$bc, $conn1, $conn2 ) {
|
||||
$bc['b'] = 1;
|
||||
$conn1->onTransactionPreCommitOrIdle( function () use ( &$bc, $conn1, $conn2 ) {
|
||||
$conn1->onTransactionPreCommitOrIdle( static function () use ( &$bc, $conn1, $conn2 ) {
|
||||
$bc['c'] = 1;
|
||||
$conn1->onTransactionPreCommitOrIdle( function () use ( &$bc, $conn1, $conn2 ) {
|
||||
$conn1->onTransactionPreCommitOrIdle( static function () use ( &$bc, $conn1, $conn2 ) {
|
||||
$bc['d'] = 1;
|
||||
} );
|
||||
} );
|
||||
|
|
@ -557,13 +557,13 @@ class LoadBalancerTest extends MediaWikiIntegrationTestCase {
|
|||
$tlCalls = 0;
|
||||
$lb->beginMasterChanges( __METHOD__ );
|
||||
$ac = array_fill_keys( [ 'a', 'b', 'c', 'd' ], 0 );
|
||||
$conn1->onTransactionCommitOrIdle( function () use ( &$ac, $conn1, $conn2 ) {
|
||||
$conn1->onTransactionCommitOrIdle( static function () use ( &$ac, $conn1, $conn2 ) {
|
||||
$ac['a'] = 1;
|
||||
$conn2->onTransactionCommitOrIdle( function () use ( &$ac, $conn1, $conn2 ) {
|
||||
$conn2->onTransactionCommitOrIdle( static function () use ( &$ac, $conn1, $conn2 ) {
|
||||
$ac['b'] = 1;
|
||||
$conn1->onTransactionCommitOrIdle( function () use ( &$ac, $conn1, $conn2 ) {
|
||||
$conn1->onTransactionCommitOrIdle( static function () use ( &$ac, $conn1, $conn2 ) {
|
||||
$ac['c'] = 1;
|
||||
$conn1->onTransactionCommitOrIdle( function () use ( &$ac, $conn1, $conn2 ) {
|
||||
$conn1->onTransactionCommitOrIdle( static function () use ( &$ac, $conn1, $conn2 ) {
|
||||
$ac['d'] = 1;
|
||||
} );
|
||||
} );
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class TestDeprecatedClass {
|
|||
}
|
||||
);
|
||||
$this->deprecatePublicPropertyFallback( 'fallbackGetterOnly', '1.25',
|
||||
function () {
|
||||
static function () {
|
||||
return 1;
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class DeferredUpdatesTest extends MediaWikiIntegrationTestCase {
|
|||
$this->setMwGlobals( 'wgCommandLineMode', true );
|
||||
|
||||
$ran = 0;
|
||||
DeferredUpdates::addCallableUpdate( function () use ( &$ran ) {
|
||||
DeferredUpdates::addCallableUpdate( static function () use ( &$ran ) {
|
||||
$ran++;
|
||||
} );
|
||||
DeferredUpdates::doUpdates();
|
||||
|
|
@ -112,43 +112,43 @@ class DeferredUpdatesTest extends MediaWikiIntegrationTestCase {
|
|||
'3-2-1' => "deferred update 1 within deferred update 2 with deferred update 3;\n",
|
||||
];
|
||||
DeferredUpdates::addCallableUpdate(
|
||||
function () use ( $updates ) {
|
||||
static function () use ( $updates ) {
|
||||
echo $updates['1'];
|
||||
}
|
||||
);
|
||||
DeferredUpdates::addCallableUpdate(
|
||||
function () use ( $updates ) {
|
||||
static function () use ( $updates ) {
|
||||
echo $updates['2'];
|
||||
DeferredUpdates::addCallableUpdate(
|
||||
function () use ( $updates ) {
|
||||
static function () use ( $updates ) {
|
||||
echo $updates['2-1'];
|
||||
}
|
||||
);
|
||||
DeferredUpdates::addCallableUpdate(
|
||||
function () use ( $updates ) {
|
||||
static function () use ( $updates ) {
|
||||
echo $updates['2-2'];
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
DeferredUpdates::addCallableUpdate(
|
||||
function () use ( $updates ) {
|
||||
static function () use ( $updates ) {
|
||||
echo $updates['3'];
|
||||
DeferredUpdates::addCallableUpdate(
|
||||
function () use ( $updates ) {
|
||||
static function () use ( $updates ) {
|
||||
echo $updates['3-1'];
|
||||
DeferredUpdates::addCallableUpdate(
|
||||
function () use ( $updates ) {
|
||||
static function () use ( $updates ) {
|
||||
echo $updates['3-1-1'];
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
DeferredUpdates::addCallableUpdate(
|
||||
function () use ( $updates ) {
|
||||
static function () use ( $updates ) {
|
||||
echo $updates['3-2'];
|
||||
DeferredUpdates::addCallableUpdate(
|
||||
function () use ( $updates ) {
|
||||
static function () use ( $updates ) {
|
||||
echo $updates['3-2-1'];
|
||||
}
|
||||
);
|
||||
|
|
@ -166,13 +166,13 @@ class DeferredUpdatesTest extends MediaWikiIntegrationTestCase {
|
|||
$x = null;
|
||||
$y = null;
|
||||
DeferredUpdates::addCallableUpdate(
|
||||
function () use ( &$x ) {
|
||||
static function () use ( &$x ) {
|
||||
$x = 'Sherity';
|
||||
},
|
||||
DeferredUpdates::PRESEND
|
||||
);
|
||||
DeferredUpdates::addCallableUpdate(
|
||||
function () use ( &$y ) {
|
||||
static function () use ( &$y ) {
|
||||
$y = 'Marychu';
|
||||
},
|
||||
DeferredUpdates::POSTSEND
|
||||
|
|
@ -214,43 +214,43 @@ class DeferredUpdatesTest extends MediaWikiIntegrationTestCase {
|
|||
$lbFactory->commitMasterChanges( __METHOD__ );
|
||||
|
||||
DeferredUpdates::addCallableUpdate(
|
||||
function () use ( $updates ) {
|
||||
static function () use ( $updates ) {
|
||||
echo $updates['1'];
|
||||
}
|
||||
);
|
||||
DeferredUpdates::addCallableUpdate(
|
||||
function () use ( $updates ) {
|
||||
static function () use ( $updates ) {
|
||||
echo $updates['2'];
|
||||
DeferredUpdates::addCallableUpdate(
|
||||
function () use ( $updates ) {
|
||||
static function () use ( $updates ) {
|
||||
echo $updates['2-1'];
|
||||
}
|
||||
);
|
||||
DeferredUpdates::addCallableUpdate(
|
||||
function () use ( $updates ) {
|
||||
static function () use ( $updates ) {
|
||||
echo $updates['2-2'];
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
DeferredUpdates::addCallableUpdate(
|
||||
function () use ( $updates ) {
|
||||
static function () use ( $updates ) {
|
||||
echo $updates['3'];
|
||||
DeferredUpdates::addCallableUpdate(
|
||||
function () use ( $updates ) {
|
||||
static function () use ( $updates ) {
|
||||
echo $updates['3-1'];
|
||||
DeferredUpdates::addCallableUpdate(
|
||||
function () use ( $updates ) {
|
||||
static function () use ( $updates ) {
|
||||
echo $updates['3-1-1'];
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
DeferredUpdates::addCallableUpdate(
|
||||
function () use ( $updates ) {
|
||||
static function () use ( $updates ) {
|
||||
echo $updates['3-2'];
|
||||
DeferredUpdates::addCallableUpdate(
|
||||
function () use ( $updates ) {
|
||||
static function () use ( $updates ) {
|
||||
echo $updates['3-2-1'];
|
||||
}
|
||||
);
|
||||
|
|
@ -280,10 +280,10 @@ class DeferredUpdatesTest extends MediaWikiIntegrationTestCase {
|
|||
$lbFactory->commitMasterChanges( __METHOD__ );
|
||||
|
||||
DeferredUpdates::addCallableUpdate(
|
||||
function () use ( &$x, &$y ) {
|
||||
static function () use ( &$x, &$y ) {
|
||||
$x = true;
|
||||
DeferredUpdates::addCallableUpdate(
|
||||
function () use ( &$y ) {
|
||||
static function () use ( &$y ) {
|
||||
$y = true;
|
||||
},
|
||||
DeferredUpdates::PRESEND
|
||||
|
|
@ -391,7 +391,7 @@ class DeferredUpdatesTest extends MediaWikiIntegrationTestCase {
|
|||
$called = false;
|
||||
DeferredUpdates::attemptUpdate(
|
||||
new MWCallableUpdate(
|
||||
function () use ( $lbFactory, $fname, &$called ) {
|
||||
static function () use ( $lbFactory, $fname, &$called ) {
|
||||
$lbFactory->flushReplicaSnapshots( $fname );
|
||||
$lbFactory->commitMasterChanges( $fname );
|
||||
$called = true;
|
||||
|
|
@ -439,7 +439,7 @@ class DeferredUpdatesTest extends MediaWikiIntegrationTestCase {
|
|||
$this->assertSame( 2, DeferredUpdates::getRecursiveExecutionStackDepth() );
|
||||
|
||||
// Add update to subqueue of in-progress top-queue job (not recursive)
|
||||
DeferredUpdates::addCallableUpdate( function () use ( &$resSubSub ) {
|
||||
DeferredUpdates::addCallableUpdate( static function () use ( &$resSubSub ) {
|
||||
$resSubSub = 'b';
|
||||
} );
|
||||
|
||||
|
|
@ -460,7 +460,7 @@ class DeferredUpdatesTest extends MediaWikiIntegrationTestCase {
|
|||
$this->assertSame( 1, DeferredUpdates::pendingUpdatesCount() );
|
||||
$this->assertSame( 0, DeferredUpdates::getRecursiveExecutionStackDepth() );
|
||||
|
||||
DeferredUpdates::addCallableUpdate( function () use ( &$resA ) {
|
||||
DeferredUpdates::addCallableUpdate( static function () use ( &$resA ) {
|
||||
$resA = 93;
|
||||
} );
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class RefreshSecondaryDataUpdateTest extends MediaWikiIntegrationTestCase {
|
|||
->getMock();
|
||||
$goodTrxFname = get_class( $goodUpdate ) . '::doUpdate';
|
||||
$goodUpdate->method( 'doUpdate' )
|
||||
->willReturnCallback( function () use ( &$goodCalls, $lbFactory, $goodTrxFname ) {
|
||||
->willReturnCallback( static function () use ( &$goodCalls, $lbFactory, $goodTrxFname ) {
|
||||
// Update can commit since it owns the transaction
|
||||
$lbFactory->commitMasterChanges( $goodTrxFname );
|
||||
++$goodCalls;
|
||||
|
|
@ -85,7 +85,7 @@ class RefreshSecondaryDataUpdateTest extends MediaWikiIntegrationTestCase {
|
|||
->getMock();
|
||||
$goodTrxFname = get_class( $goodUpdate ) . '::doUpdate';
|
||||
$goodUpdate->method( 'doUpdate' )
|
||||
->willReturnCallback( function () use ( &$goodCalls, $lbFactory, $goodTrxFname ) {
|
||||
->willReturnCallback( static function () use ( &$goodCalls, $lbFactory, $goodTrxFname ) {
|
||||
// Update can commit since it owns the transaction
|
||||
$lbFactory->commitMasterChanges( $goodTrxFname );
|
||||
++$goodCalls;
|
||||
|
|
@ -101,7 +101,7 @@ class RefreshSecondaryDataUpdateTest extends MediaWikiIntegrationTestCase {
|
|||
$badUpdate->expects( $this->once() )
|
||||
->method( 'setTransactionTicket' );
|
||||
$badUpdate->method( 'doUpdate' )
|
||||
->willReturnCallback( function () use ( &$badCalls, $lbFactory, $badTrxFname ) {
|
||||
->willReturnCallback( static function () use ( &$badCalls, $lbFactory, $badTrxFname ) {
|
||||
// Update can commit since it owns the transaction
|
||||
$lbFactory->commitMasterChanges( $badTrxFname );
|
||||
++$badCalls;
|
||||
|
|
@ -190,7 +190,7 @@ class RefreshSecondaryDataUpdateTest extends MediaWikiIntegrationTestCase {
|
|||
->setMethods( [ 'doUpdate' ] )
|
||||
->getMock();
|
||||
$goodUpdate->method( 'doUpdate' )
|
||||
->willReturnCallback( function () use ( &$goodCalls ) {
|
||||
->willReturnCallback( static function () use ( &$goodCalls ) {
|
||||
++$goodCalls;
|
||||
} );
|
||||
|
||||
|
|
@ -199,7 +199,7 @@ class RefreshSecondaryDataUpdateTest extends MediaWikiIntegrationTestCase {
|
|||
->setMethods( [ 'getSecondaryDataUpdates' ] )
|
||||
->getMock();
|
||||
$updater->method( 'getSecondaryDataUpdates' )
|
||||
->willReturnCallback( function () use ( $dbw, $fname, $goodUpdate ) {
|
||||
->willReturnCallback( static function () use ( $dbw, $fname, $goodUpdate ) {
|
||||
$dbw->selectRow( 'page', '*', '', $fname );
|
||||
$dbw->onTransactionResolution( static function () {
|
||||
}, $fname );
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class UnsupportedSlotDiffRendererTest extends MediaWikiIntegrationTestCase {
|
|||
$localizer = $this->createMock( MessageLocalizer::class );
|
||||
|
||||
$localizer->method( 'msg' )
|
||||
->willReturnCallback( function ( $key, ...$params ) {
|
||||
->willReturnCallback( static function ( $key, ...$params ) {
|
||||
return new RawMessage( "($key)", $params );
|
||||
} );
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class HTMLRestrictionsFieldTest extends PHPUnit\Framework\TestCase {
|
|||
$context = new DerivativeContext( RequestContext::getMain() );
|
||||
$context->setRequest( $request );
|
||||
$form->setContext( $context );
|
||||
$form->setTitle( Title::newFromText( 'Main Page' ) )->setSubmitCallback( function () {
|
||||
$form->setTitle( Title::newFromText( 'Main Page' ) )->setSubmitCallback( static function () {
|
||||
return true;
|
||||
} )->prepareForm();
|
||||
$status = $form->trySubmit();
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ EOF
|
|||
$source = new ImportStringSource( $xml );
|
||||
|
||||
$redirect = null;
|
||||
$callback = function ( Title $title, ForeignTitle $foreignTitle, $revCount,
|
||||
$callback = static function ( Title $title, ForeignTitle $foreignTitle, $revCount,
|
||||
$sRevCount, $pageInfo ) use ( &$redirect ) {
|
||||
if ( array_key_exists( 'redirect', $pageInfo ) ) {
|
||||
$redirect = $pageInfo['redirect'];
|
||||
|
|
@ -171,7 +171,7 @@ EOF
|
|||
$source = new ImportStringSource( $xml );
|
||||
|
||||
$importNamespaces = null;
|
||||
$callback = function ( array $siteinfo, $innerImporter ) use ( &$importNamespaces ) {
|
||||
$callback = static function ( array $siteinfo, $innerImporter ) use ( &$importNamespaces ) {
|
||||
$importNamespaces = $siteinfo['_namespaces'];
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ class JobTest extends MediaWikiIntegrationTestCase {
|
|||
public function provideTestJobFactory() {
|
||||
return [
|
||||
'class name' => [ 'NullJob' ],
|
||||
'closure' => [ function ( Title $title, array $params ) {
|
||||
'closure' => [ static function ( Title $title, array $params ) {
|
||||
return Job::factory( 'null', $title, $params );
|
||||
} ],
|
||||
'function' => [ [ $this, 'newNullJob' ] ],
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ abstract class GenericArrayObjectTest extends PHPUnit\Framework\TestCase {
|
|||
|
||||
$this->assertEquals( $listSize, $list->count() );
|
||||
|
||||
$this->checkTypeChecks( function ( GenericArrayObject $list, $element ) {
|
||||
$this->checkTypeChecks( static function ( GenericArrayObject $list, $element ) {
|
||||
$list->append( $element );
|
||||
} );
|
||||
}
|
||||
|
|
@ -248,7 +248,7 @@ abstract class GenericArrayObjectTest extends PHPUnit\Framework\TestCase {
|
|||
|
||||
$this->assertEquals( count( $elements ), $list->count() );
|
||||
|
||||
$this->checkTypeChecks( function ( GenericArrayObject $list, $element ) {
|
||||
$this->checkTypeChecks( static function ( GenericArrayObject $list, $element ) {
|
||||
$list->offsetSet( mt_rand(), $element );
|
||||
} );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,12 +126,12 @@ class ParamValidatorTest extends \PHPUnit\Framework\TestCase {
|
|||
->setConstructorArgs( [ $callbacks ] )
|
||||
->setMethods( [ 'normalizeSettings' ] );
|
||||
$mock1 = $mb->getMockForAbstractClass();
|
||||
$mock1->method( 'normalizeSettings' )->willReturnCallback( function ( $s ) {
|
||||
$mock1->method( 'normalizeSettings' )->willReturnCallback( static function ( $s ) {
|
||||
$s['foo'] = 'FooBar!';
|
||||
return $s;
|
||||
} );
|
||||
$mock2 = $mb->getMockForAbstractClass();
|
||||
$mock2->method( 'normalizeSettings' )->willReturnCallback( function ( $s ) {
|
||||
$mock2->method( 'normalizeSettings' )->willReturnCallback( static function ( $s ) {
|
||||
$s['bar'] = 'FooBar!';
|
||||
return $s;
|
||||
} );
|
||||
|
|
@ -171,7 +171,7 @@ class ParamValidatorTest extends \PHPUnit\Framework\TestCase {
|
|||
->setMethods( [ 'checkSettings' ] );
|
||||
$mock1 = $mb->getMockForAbstractClass();
|
||||
$mock1->method( 'checkSettings' )->willReturnCallback(
|
||||
function ( string $name, $settings, array $options, array $ret ) {
|
||||
static function ( string $name, $settings, array $options, array $ret ) {
|
||||
$ret['allowedKeys'][] = 'XXX-test';
|
||||
if ( isset( $settings['XXX-test'] ) ) {
|
||||
$ret['issues']['XXX-test'] = 'XXX-test was ' . $settings['XXX-test'];
|
||||
|
|
@ -181,7 +181,7 @@ class ParamValidatorTest extends \PHPUnit\Framework\TestCase {
|
|||
);
|
||||
$mock2 = $mb->getMockForAbstractClass();
|
||||
$mock2->method( 'checkSettings' )->willReturnCallback(
|
||||
function ( string $name, $settings, array $options, array $ret ) {
|
||||
static function ( string $name, $settings, array $options, array $ret ) {
|
||||
return $ret;
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ class UploadedFileStreamTest extends UploadedFileTestBase {
|
|||
->setConstructorArgs( [ $filename ] )
|
||||
->setMethods( [ 'getContents' ] )
|
||||
->getMock();
|
||||
$stream->method( 'getContents' )->willReturnCallback( function () {
|
||||
$stream->method( 'getContents' )->willReturnCallback( static function () {
|
||||
throw new \Error( 'Bogus' );
|
||||
} );
|
||||
$this->assertSame( '', (string)$stream );
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ class MimeAnalyzerTest extends PHPUnit\Framework\TestCase {
|
|||
'infoFile' => MimeAnalyzer::USE_INTERNAL,
|
||||
'typeFile' => MimeAnalyzer::USE_INTERNAL,
|
||||
'xmlTypes' => [],
|
||||
'initCallback' => function ( $instance ) {
|
||||
'initCallback' => static function ( $instance ) {
|
||||
$instance->addExtraTypes( 'fake/mime fake_extension' );
|
||||
$instance->addExtraInfo( 'fake/mime [OFFICE]' );
|
||||
$instance->mExtToMime[ 'no_such_extension' ] = 'fake/mime';
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ abstract class BagOStuffTestBase extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$calls = 0;
|
||||
$casRace = false; // emulate a race
|
||||
$callback = function ( BagOStuff $cache, $key, $oldVal, &$expiry ) use ( &$calls, &$casRace ) {
|
||||
$callback = static function ( BagOStuff $cache, $key, $oldVal, &$expiry ) use ( &$calls, &$casRace ) {
|
||||
++$calls;
|
||||
if ( $casRace ) {
|
||||
// Uses CAS instead?
|
||||
|
|
@ -259,7 +259,7 @@ abstract class BagOStuffTestBase extends MediaWikiIntegrationTestCase {
|
|||
$value = $cache->getWithSetCallback(
|
||||
$key,
|
||||
30,
|
||||
function ( &$ttl ) {
|
||||
static function ( &$ttl ) {
|
||||
$ttl = 10;
|
||||
|
||||
return 'hello kitty';
|
||||
|
|
@ -387,7 +387,7 @@ abstract class BagOStuffTestBase extends MediaWikiIntegrationTestCase {
|
|||
// 64 * 8 * 32768 = 16777216 bytes
|
||||
$big = str_repeat( wfRandomString( 32 ) . '-' . wfRandomString( 32 ), 32768 );
|
||||
|
||||
$callback = function ( $cache, $key, $oldValue ) {
|
||||
$callback = static function ( $cache, $key, $oldValue ) {
|
||||
return $oldValue . '!';
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class MultiWriteBagOStuffTest extends MediaWikiIntegrationTestCase {
|
|||
public function testSyncMerge() {
|
||||
$key = 'keyA';
|
||||
$value = 'value';
|
||||
$func = function () use ( $value ) {
|
||||
$func = static function () use ( $value ) {
|
||||
return $value;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ class ArticleViewTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$this->setTemporaryHook(
|
||||
'ContentHandlerForModelID',
|
||||
function ( $id, &$handler ) use ( $mockHandler ) {
|
||||
static function ( $id, &$handler ) use ( $mockHandler ) {
|
||||
$handler = $mockHandler;
|
||||
}
|
||||
);
|
||||
|
|
@ -481,7 +481,7 @@ class ArticleViewTest extends MediaWikiIntegrationTestCase {
|
|||
// use ArticleViewHeader hook to bypass the parser cache
|
||||
$this->setTemporaryHook(
|
||||
'ArticleViewHeader',
|
||||
function ( Article $articlePage, &$outputDone, &$useParserCache ) use ( $article ) {
|
||||
static function ( Article $articlePage, &$outputDone, &$useParserCache ) use ( $article ) {
|
||||
$useParserCache = false;
|
||||
}
|
||||
);
|
||||
|
|
@ -540,7 +540,7 @@ class ArticleViewTest extends MediaWikiIntegrationTestCase {
|
|||
// use ArticleViewHeader hook to bypass the parser cache
|
||||
$this->setTemporaryHook(
|
||||
'ArticleViewHeader',
|
||||
function ( Article $articlePage, &$outputDone, &$useParserCache ) use ( $article ) {
|
||||
static function ( Article $articlePage, &$outputDone, &$useParserCache ) use ( $article ) {
|
||||
$useParserCache = false;
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -864,7 +864,7 @@ class WikiPageDbTest extends MediaWikiLangTestCase {
|
|||
|
||||
$this->mergeMwGlobalArrayValue(
|
||||
'wgContentHandlers', [
|
||||
$name => function () use ( $handler ){
|
||||
$name => static function () use ( $handler ){
|
||||
return $handler;
|
||||
}
|
||||
]
|
||||
|
|
@ -2633,7 +2633,7 @@ more stuff
|
|||
|
||||
$this->setTemporaryHook(
|
||||
'WikiPageFactory',
|
||||
function ( $title, &$page ) use ( &$isCalled, $expectedWikiPage ) {
|
||||
static function ( $title, &$page ) use ( &$isCalled, $expectedWikiPage ) {
|
||||
$page = $expectedWikiPage;
|
||||
$isCalled = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -98,13 +98,13 @@ abstract class ParserCacheSerializationTestCases {
|
|||
],
|
||||
'usedOptions' => [
|
||||
'instance' => $cacheTimeWithUsedOptions,
|
||||
'assertions' => function ( MediaWikiIntegrationTestCase $testCase, CacheTime $object ) {
|
||||
'assertions' => static function ( MediaWikiIntegrationTestCase $testCase, CacheTime $object ) {
|
||||
$testCase->assertArrayEquals( [ 'optA', 'optX' ], $object->getUsedOptions() );
|
||||
}
|
||||
],
|
||||
'cacheTime' => [
|
||||
'instance' => $cacheTimeWithTime,
|
||||
'assertions' => function (
|
||||
'assertions' => static function (
|
||||
MediaWikiIntegrationTestCase $testCase, CacheTime $object
|
||||
) use ( $cacheTimestamp ) {
|
||||
$testCase->assertSame( $cacheTimestamp, $object->getCacheTime() );
|
||||
|
|
@ -112,7 +112,7 @@ abstract class ParserCacheSerializationTestCases {
|
|||
],
|
||||
'cacheExpiry' => [
|
||||
'instance' => $cacheTimeWithExpiry,
|
||||
'assertions' => function (
|
||||
'assertions' => static function (
|
||||
MediaWikiIntegrationTestCase $testCase, CacheTime $object
|
||||
) use ( $cacheExpiry ) {
|
||||
$testCase->assertSame( $cacheExpiry, $object->getCacheExpiry() );
|
||||
|
|
@ -120,7 +120,7 @@ abstract class ParserCacheSerializationTestCases {
|
|||
],
|
||||
'cacheRevisionId' => [
|
||||
'instance' => $cacheTimeWithRevId,
|
||||
'assertions' => function (
|
||||
'assertions' => static function (
|
||||
MediaWikiIntegrationTestCase $testCase, CacheTime $object
|
||||
) use ( $cacheRevisionId ) {
|
||||
$testCase->assertSame( $cacheRevisionId, $object->getCacheRevisionId() );
|
||||
|
|
@ -267,7 +267,7 @@ abstract class ParserCacheSerializationTestCases {
|
|||
],
|
||||
'text' => [
|
||||
'instance' => new ParserOutput( 'Lorem Ipsum' ),
|
||||
'assertions' => function ( MediaWikiIntegrationTestCase $testCase, ParserOutput $object ) {
|
||||
'assertions' => static function ( MediaWikiIntegrationTestCase $testCase, ParserOutput $object ) {
|
||||
$testCase->assertTrue( $object->hasText() );
|
||||
$testCase->assertSame( 'Lorem Ipsum', $object->getRawText() );
|
||||
$testCase->assertSame( 'Lorem Ipsum', $object->getText() );
|
||||
|
|
@ -275,7 +275,7 @@ abstract class ParserCacheSerializationTestCases {
|
|||
],
|
||||
'usedOptions' => [
|
||||
'instance' => $parserOutputWithUsedOptions,
|
||||
'assertions' => function ( MediaWikiIntegrationTestCase $testCase, ParserOutput $object ) {
|
||||
'assertions' => static function ( MediaWikiIntegrationTestCase $testCase, ParserOutput $object ) {
|
||||
$testCase->assertArrayEquals( [ 'optA', 'optX' ], $object->getUsedOptions() );
|
||||
}
|
||||
],
|
||||
|
|
@ -370,7 +370,7 @@ abstract class ParserCacheSerializationTestCases {
|
|||
],
|
||||
'withMetadataPost1_31' => [
|
||||
'instance' => $parserOutputWithMetadataPost1_31,
|
||||
'assertions' => function ( MediaWikiIntegrationTestCase $testCase, ParserOutput $object ) {
|
||||
'assertions' => static function ( MediaWikiIntegrationTestCase $testCase, ParserOutput $object ) {
|
||||
$testCase->assertSame( 'test_wrapper', $object->getWrapperDivClass() );
|
||||
$testCase->assertSame( 4242, $object->getSpeculativePageIdUsed() );
|
||||
$testCase->assertSame(
|
||||
|
|
@ -383,7 +383,7 @@ abstract class ParserCacheSerializationTestCases {
|
|||
],
|
||||
'withMetadataPost1_34' => [
|
||||
'instance' => $parserOutputWithMetadataPost1_34,
|
||||
'assertions' => function ( MediaWikiIntegrationTestCase $testCase, ParserOutput $object ) {
|
||||
'assertions' => static function ( MediaWikiIntegrationTestCase $testCase, ParserOutput $object ) {
|
||||
$testCase->assertArrayEquals( [ 'default1' ], $object->getExtraCSPDefaultSrcs() );
|
||||
$testCase->assertArrayEquals( [ 'script1' ], $object->getExtraCSPScriptSrcs() );
|
||||
$testCase->assertArrayEquals( [ 'style1' ], $object->getExtraCSPStyleSrcs() );
|
||||
|
|
@ -411,10 +411,10 @@ abstract class ParserCacheSerializationTestCases {
|
|||
$jsonCodec = new JsonCodec();
|
||||
$serializationFormats[] = [
|
||||
'ext' => 'json',
|
||||
'serializer' => function ( JsonSerializable $obj ) use ( $jsonCodec ) {
|
||||
'serializer' => static function ( JsonSerializable $obj ) use ( $jsonCodec ) {
|
||||
return $jsonCodec->serialize( $obj );
|
||||
},
|
||||
'deserializer' => function ( $data ) use ( $jsonCodec ) {
|
||||
'deserializer' => static function ( $data ) use ( $jsonCodec ) {
|
||||
return $jsonCodec->unserialize( $data );
|
||||
}
|
||||
];
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ class ParserMethodsTest extends MediaWikiLangTestCase {
|
|||
$oldRevision->setContent( SlotRecord::MAIN, new WikitextContent( 'FAUX' ) );
|
||||
|
||||
$po = new ParserOptions( $frank );
|
||||
$po->setCurrentRevisionRecordCallback( function () use ( $oldRevision ) {
|
||||
$po->setCurrentRevisionRecordCallback( static function () use ( $oldRevision ) {
|
||||
return $oldRevision;
|
||||
} );
|
||||
|
||||
|
|
@ -271,7 +271,7 @@ class ParserMethodsTest extends MediaWikiLangTestCase {
|
|||
|
||||
$po = new ParserOptions( $frank );
|
||||
$po->setIsPreview( true );
|
||||
$po->setCurrentRevisionRecordCallback( function () use ( $newRevision ) {
|
||||
$po->setCurrentRevisionRecordCallback( static function () use ( $newRevision ) {
|
||||
return $newRevision;
|
||||
} );
|
||||
|
||||
|
|
@ -284,7 +284,7 @@ class ParserMethodsTest extends MediaWikiLangTestCase {
|
|||
];
|
||||
|
||||
$po = new ParserOptions( $frank );
|
||||
$po->setCurrentRevisionRecordCallback( function () use ( $newRevision ) {
|
||||
$po->setCurrentRevisionRecordCallback( static function () use ( $newRevision ) {
|
||||
return $newRevision;
|
||||
} );
|
||||
|
||||
|
|
@ -306,7 +306,7 @@ class ParserMethodsTest extends MediaWikiLangTestCase {
|
|||
|
||||
$po = new ParserOptions( $frank );
|
||||
$po->setIsPreview( true );
|
||||
$po->setCurrentRevisionRecordCallback( function () use ( $newRevision ) {
|
||||
$po->setCurrentRevisionRecordCallback( static function () use ( $newRevision ) {
|
||||
return $newRevision;
|
||||
} );
|
||||
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ class ParserOptionsTest extends MediaWikiLangTestCase {
|
|||
$classWrapper = TestingAccessWrapper::newFromClass( ParserOptions::class );
|
||||
$oldDefaults = $classWrapper->defaults;
|
||||
$oldLazy = $classWrapper->lazyOptions;
|
||||
$reset = new ScopedCallback( function () use ( $classWrapper, $oldDefaults, $oldLazy ) {
|
||||
$reset = new ScopedCallback( static function () use ( $classWrapper, $oldDefaults, $oldLazy ) {
|
||||
$classWrapper->defaults = $oldDefaults;
|
||||
$classWrapper->lazyOptions = $oldLazy;
|
||||
} );
|
||||
|
|
@ -300,7 +300,7 @@ class ParserOptionsTest extends MediaWikiLangTestCase {
|
|||
|
||||
$ctr = 0;
|
||||
$classWrapper->defaults += [ __METHOD__ => null ];
|
||||
$classWrapper->lazyOptions += [ __METHOD__ => function () use ( &$ctr ) {
|
||||
$classWrapper->lazyOptions += [ __METHOD__ => static function () use ( &$ctr ) {
|
||||
return ++$ctr;
|
||||
} ];
|
||||
$popt1 = ParserOptions::newCanonical( 'canonical' );
|
||||
|
|
@ -346,7 +346,7 @@ class ParserOptionsTest extends MediaWikiLangTestCase {
|
|||
|
||||
self::clearCache();
|
||||
|
||||
$this->setTemporaryHook( 'ParserOptionsRegister', function ( &$defaults, &$inCacheKey ) {
|
||||
$this->setTemporaryHook( 'ParserOptionsRegister', static function ( &$defaults, &$inCacheKey ) {
|
||||
$defaults += [
|
||||
'foo' => 'foo',
|
||||
'bar' => 'bar',
|
||||
|
|
@ -369,7 +369,7 @@ class ParserOptionsTest extends MediaWikiLangTestCase {
|
|||
$this->assertFalse( $options->getSpeculativeRevId() );
|
||||
|
||||
$counter = 0;
|
||||
$options->setSpeculativeRevIdCallback( function () use( &$counter ) {
|
||||
$options->setSpeculativeRevIdCallback( static function () use( &$counter ) {
|
||||
return ++$counter;
|
||||
} );
|
||||
|
||||
|
|
|
|||
|
|
@ -984,7 +984,7 @@ EOF
|
|||
*/
|
||||
public function testGetCacheTime() {
|
||||
$clock = MWTimestamp::convert( TS_UNIX, '20100101000000' );
|
||||
MWTimestamp::setFakeTime( function () use ( &$clock ) {
|
||||
MWTimestamp::setFakeTime( static function () use ( &$clock ) {
|
||||
return $clock++;
|
||||
} );
|
||||
|
||||
|
|
|
|||
|
|
@ -117,25 +117,25 @@ class PoolWorkArticleViewTest extends MediaWikiIntegrationTestCase {
|
|||
public function provideMagicWords() {
|
||||
yield 'PAGEID' => [
|
||||
'Test {{PAGEID}} Test',
|
||||
function ( RevisionRecord $rev ) {
|
||||
static function ( RevisionRecord $rev ) {
|
||||
return $rev->getPageId();
|
||||
}
|
||||
];
|
||||
yield 'REVISIONID' => [
|
||||
'Test {{REVISIONID}} Test',
|
||||
function ( RevisionRecord $rev ) {
|
||||
static function ( RevisionRecord $rev ) {
|
||||
return $rev->getId();
|
||||
}
|
||||
];
|
||||
yield 'REVISIONUSER' => [
|
||||
'Test {{REVISIONUSER}} Test',
|
||||
function ( RevisionRecord $rev ) {
|
||||
static function ( RevisionRecord $rev ) {
|
||||
return $rev->getUser()->getName();
|
||||
}
|
||||
];
|
||||
yield 'REVISIONTIMESTAMP' => [
|
||||
'Test {{REVISIONTIMESTAMP}} Test',
|
||||
function ( RevisionRecord $rev ) {
|
||||
static function ( RevisionRecord $rev ) {
|
||||
return $rev->getTimestamp();
|
||||
}
|
||||
];
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ class DerivativeResourceLoaderContextTest extends MediaWikiIntegrationTestCase {
|
|||
$derived = new DerivativeResourceLoaderContext( self::makeContext() );
|
||||
$this->assertNull( $derived->getContentOverrideCallback(), 'default' );
|
||||
|
||||
$override = function ( Title $t ) {
|
||||
$override = static function ( Title $t ) {
|
||||
return null;
|
||||
};
|
||||
$derived->setContentOverrideCallback( $override );
|
||||
|
|
|
|||
|
|
@ -455,40 +455,40 @@ class ResourceLoaderFileModuleTest extends ResourceLoaderTestCase {
|
|||
yield 'identical Less variables' => [ $x, $x, true ];
|
||||
|
||||
$a = [
|
||||
'packageFiles' => [ [ 'name' => 'data.json', 'callback' => function () {
|
||||
'packageFiles' => [ [ 'name' => 'data.json', 'callback' => static function () {
|
||||
return [ 'aaa' ];
|
||||
} ] ]
|
||||
];
|
||||
$b = [
|
||||
'packageFiles' => [ [ 'name' => 'data.json', 'callback' => function () {
|
||||
'packageFiles' => [ [ 'name' => 'data.json', 'callback' => static function () {
|
||||
return [ 'bbb' ];
|
||||
} ] ]
|
||||
];
|
||||
yield 'packageFiles with different callback' => [ $a, $b, false ];
|
||||
|
||||
$a = [
|
||||
'packageFiles' => [ [ 'name' => 'aaa.json', 'callback' => function () {
|
||||
'packageFiles' => [ [ 'name' => 'aaa.json', 'callback' => static function () {
|
||||
return [ 'x' ];
|
||||
} ] ]
|
||||
];
|
||||
$b = [
|
||||
'packageFiles' => [ [ 'name' => 'bbb.json', 'callback' => function () {
|
||||
'packageFiles' => [ [ 'name' => 'bbb.json', 'callback' => static function () {
|
||||
return [ 'x' ];
|
||||
} ] ]
|
||||
];
|
||||
yield 'packageFiles with different file name and a callback' => [ $a, $b, false ];
|
||||
|
||||
$a = [
|
||||
'packageFiles' => [ [ 'name' => 'data.json', 'versionCallback' => function () {
|
||||
'packageFiles' => [ [ 'name' => 'data.json', 'versionCallback' => static function () {
|
||||
return [ 'A-version' ];
|
||||
}, 'callback' => function () {
|
||||
}, 'callback' => static function () {
|
||||
throw new Exception( 'Unexpected computation' );
|
||||
} ] ]
|
||||
];
|
||||
$b = [
|
||||
'packageFiles' => [ [ 'name' => 'data.json', 'versionCallback' => function () {
|
||||
'packageFiles' => [ [ 'name' => 'data.json', 'versionCallback' => static function () {
|
||||
return [ 'B-version' ];
|
||||
}, 'callback' => function () {
|
||||
}, 'callback' => static function () {
|
||||
throw new Exception( 'Unexpected computation' );
|
||||
} ] ]
|
||||
];
|
||||
|
|
@ -496,20 +496,20 @@ class ResourceLoaderFileModuleTest extends ResourceLoaderTestCase {
|
|||
|
||||
$a = [
|
||||
'packageFiles' => [ [ 'name' => 'aaa.json',
|
||||
'versionCallback' => function () {
|
||||
'versionCallback' => static function () {
|
||||
return [ 'X-version' ];
|
||||
},
|
||||
'callback' => function () {
|
||||
'callback' => static function () {
|
||||
throw new Exception( 'Unexpected computation' );
|
||||
}
|
||||
] ]
|
||||
];
|
||||
$b = [
|
||||
'packageFiles' => [ [ 'name' => 'bbb.json',
|
||||
'versionCallback' => function () {
|
||||
'versionCallback' => static function () {
|
||||
return [ 'X-version' ];
|
||||
},
|
||||
'callback' => function () {
|
||||
'callback' => static function () {
|
||||
throw new Exception( 'Unexpected computation' );
|
||||
}
|
||||
] ]
|
||||
|
|
@ -623,7 +623,7 @@ class ResourceLoaderFileModuleTest extends ResourceLoaderTestCase {
|
|||
[ 'name' => 'bar.js', 'content' => "console.log('Hello');" ],
|
||||
[
|
||||
'name' => 'data.json',
|
||||
'callback' => function ( $context, $config, $extra ) {
|
||||
'callback' => static function ( $context, $config, $extra ) {
|
||||
return [ 'langCode' => $context->getLanguage(), 'extra' => $extra ];
|
||||
},
|
||||
'callbackParam' => [ 'a' => 'b' ],
|
||||
|
|
@ -672,10 +672,10 @@ class ResourceLoaderFileModuleTest extends ResourceLoaderTestCase {
|
|||
[ 'name' => 'bar.js', 'content' => "console.log('Hello');" ],
|
||||
[
|
||||
'name' => 'data.json',
|
||||
'versionCallback' => function ( $context ) {
|
||||
'versionCallback' => static function ( $context ) {
|
||||
return 'x';
|
||||
},
|
||||
'callback' => function ( $context, $config, $extra ) {
|
||||
'callback' => static function ( $context, $config, $extra ) {
|
||||
return [ 'langCode' => $context->getLanguage(), 'extra' => $extra ];
|
||||
},
|
||||
'callbackParam' => [ 'A', 'B' ]
|
||||
|
|
@ -702,7 +702,7 @@ class ResourceLoaderFileModuleTest extends ResourceLoaderTestCase {
|
|||
'package file with callback that returns a file (1)' => [
|
||||
$base + [
|
||||
'packageFiles' => [
|
||||
[ 'name' => 'dynamic.js', 'callback' => function ( $context ) {
|
||||
[ 'name' => 'dynamic.js', 'callback' => static function ( $context ) {
|
||||
$file = $context->getLanguage() === 'fy' ? 'script-comment.js' : 'script-nosemi.js';
|
||||
return new ResourceLoaderFilePath( $file );
|
||||
} ]
|
||||
|
|
@ -724,7 +724,7 @@ class ResourceLoaderFileModuleTest extends ResourceLoaderTestCase {
|
|||
'package file with callback that returns a file (2)' => [
|
||||
$base + [
|
||||
'packageFiles' => [
|
||||
[ 'name' => 'dynamic.js', 'callback' => function ( $context ) {
|
||||
[ 'name' => 'dynamic.js', 'callback' => static function ( $context ) {
|
||||
$file = $context->getLanguage() === 'fy' ? 'script-comment.js' : 'script-nosemi.js';
|
||||
return new ResourceLoaderFilePath( $file );
|
||||
} ]
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class ResourceLoaderTest extends ResourceLoaderTestCase {
|
|||
$ranHook = 0;
|
||||
$this->setMwGlobals( 'wgHooks', [
|
||||
'ResourceLoaderRegisterModules' => [
|
||||
function ( &$resourceLoader ) use ( &$ranHook ) {
|
||||
static function ( &$resourceLoader ) use ( &$ranHook ) {
|
||||
$ranHook++;
|
||||
}
|
||||
]
|
||||
|
|
@ -155,14 +155,14 @@ class ResourceLoaderTest extends ResourceLoaderTestCase {
|
|||
return [
|
||||
'factory ignored' => [ false,
|
||||
[
|
||||
'factory' => function () {
|
||||
'factory' => static function () {
|
||||
return new ResourceLoaderTestModule();
|
||||
}
|
||||
]
|
||||
],
|
||||
'factory ignored (actual FileModule)' => [ false,
|
||||
[
|
||||
'factory' => function () use ( $fileModuleObj ) {
|
||||
'factory' => static function () use ( $fileModuleObj ) {
|
||||
return $fileModuleObj;
|
||||
}
|
||||
]
|
||||
|
|
@ -1125,7 +1125,7 @@ END
|
|||
] )
|
||||
->getMock();
|
||||
$rl->register( 'test', [
|
||||
'factory' => function () use ( $module ) {
|
||||
'factory' => static function () use ( $module ) {
|
||||
return $module;
|
||||
}
|
||||
] );
|
||||
|
|
@ -1184,7 +1184,7 @@ END
|
|||
] )
|
||||
->getMock();
|
||||
$rl->register( 'test', [
|
||||
'factory' => function () use ( $module ) {
|
||||
'factory' => static function () use ( $module ) {
|
||||
return $module;
|
||||
}
|
||||
] );
|
||||
|
|
|
|||
|
|
@ -382,7 +382,7 @@ class ResourceLoaderWikiModuleTest extends ResourceLoaderTestCase {
|
|||
$context = new DerivativeResourceLoaderContext(
|
||||
new ResourceLoaderContext( $rl, new FauxRequest() )
|
||||
);
|
||||
$context->setContentOverrideCallback( function ( Title $t ) {
|
||||
$context->setContentOverrideCallback( static function ( Title $t ) {
|
||||
if ( $t->getPrefixedText() === 'MediaWiki:Common.css' ) {
|
||||
return new CssContent( '.override{}' );
|
||||
}
|
||||
|
|
@ -396,7 +396,7 @@ class ResourceLoaderWikiModuleTest extends ResourceLoaderTestCase {
|
|||
]
|
||||
], $module->getStyles( $context ) );
|
||||
|
||||
$context->setContentOverrideCallback( function ( Title $t ) {
|
||||
$context->setContentOverrideCallback( static function ( Title $t ) {
|
||||
if ( $t->getPrefixedText() === 'MediaWiki:Skin.css' ) {
|
||||
return new CssContent( '.override{}' );
|
||||
}
|
||||
|
|
@ -417,7 +417,7 @@ class ResourceLoaderWikiModuleTest extends ResourceLoaderTestCase {
|
|||
->willReturn( [
|
||||
'MediaWiki:Redirect.js' => [ 'type' => 'script' ]
|
||||
] );
|
||||
$context->setContentOverrideCallback( function ( Title $title ) {
|
||||
$context->setContentOverrideCallback( static function ( Title $title ) {
|
||||
if ( $title->getPrefixedText() === 'MediaWiki:Redirect.js' ) {
|
||||
$handler = new JavaScriptContentHandler();
|
||||
return $handler->makeRedirectContent(
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class SearchEnginePrefixTest extends MediaWikiLangTestCase {
|
|||
} else {
|
||||
$this->setMwGlobals( 'wgHooks', [
|
||||
'PrefixSearchBackend' => [
|
||||
function ( $namespaces, $search, $limit, &$srchres ) use ( $results ) {
|
||||
static function ( $namespaces, $search, $limit, &$srchres ) use ( $results ) {
|
||||
$srchres = $results;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -340,7 +340,7 @@ class SearchEnginePrefixTest extends MediaWikiLangTestCase {
|
|||
$search = $this->mockSearchWithResults( $case['provision'] );
|
||||
$results = $search->completionSearch( $case['query'] );
|
||||
|
||||
$results = $results->map( function ( SearchSuggestion $s ) {
|
||||
$results = $results->map( static function ( SearchSuggestion $s ) {
|
||||
return $s->getText();
|
||||
} );
|
||||
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ class SearchEngineTest extends MediaWikiLangTestCase {
|
|||
|
||||
// Not using mock since PHPUnit mocks do not work properly with references in params
|
||||
$this->setTemporaryHook( 'SearchIndexFields',
|
||||
function ( &$fields, SearchEngine $engine ) use ( $mockFieldBuilder ) {
|
||||
static function ( &$fields, SearchEngine $engine ) use ( $mockFieldBuilder ) {
|
||||
$fields['testField'] =
|
||||
$mockFieldBuilder( "testField", SearchIndexField::INDEX_TYPE_TEXT );
|
||||
return true;
|
||||
|
|
@ -354,7 +354,7 @@ class SearchEngineTest extends MediaWikiLangTestCase {
|
|||
$setAugmentor = $this->createMock( ResultSetAugmentor::class );
|
||||
$setAugmentor->expects( $this->once() )
|
||||
->method( 'augmentAll' )
|
||||
->willReturnCallback( function ( ISearchResultSet $resultSet ) {
|
||||
->willReturnCallback( static function ( ISearchResultSet $resultSet ) {
|
||||
$data = [];
|
||||
/** @var SearchResult $result */
|
||||
foreach ( $resultSet as $result ) {
|
||||
|
|
@ -368,7 +368,7 @@ class SearchEngineTest extends MediaWikiLangTestCase {
|
|||
$rowAugmentor = $this->createMock( ResultAugmentor::class );
|
||||
$rowAugmentor->expects( $this->exactly( 2 ) )
|
||||
->method( 'augment' )
|
||||
->willReturnCallback( function ( SearchResult $result ) {
|
||||
->willReturnCallback( static function ( SearchResult $result ) {
|
||||
$id = $result->getTitle()->getArticleID();
|
||||
return "Result2:$id:" . $result->getTitle()->getText();
|
||||
} );
|
||||
|
|
@ -491,7 +491,7 @@ class SearchEngineTest extends MediaWikiLangTestCase {
|
|||
* @dataProvider provideDataForParseNamespacePrefix
|
||||
*/
|
||||
public function testParseNamespacePrefix( array $params, $expected ) {
|
||||
$this->setTemporaryHook( 'PrefixSearchExtractNamespace', function ( &$namespaces, &$query ) {
|
||||
$this->setTemporaryHook( 'PrefixSearchExtractNamespace', static function ( &$namespaces, &$query ) {
|
||||
if ( strpos( $query, 'hélp:' ) === 0 ) {
|
||||
$namespaces = [ NS_HELP ];
|
||||
$query = substr( $query, strlen( 'hélp:' ) );
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue