Merge "Make use of the …::class feature whenever possible"
This commit is contained in:
commit
ec99401072
|
@ -94,5 +94,5 @@ class MathGenerateTests extends Maintenance {
|
|||
}
|
||||
}
|
||||
|
||||
$maintClass = 'MathGenerateTests';
|
||||
$maintClass = MathGenerateTests::class;
|
||||
require_once RUN_MAINTENANCE_IF_MAIN;
|
||||
|
|
|
@ -171,10 +171,10 @@ class MathHooks {
|
|||
* @return bool true
|
||||
*/
|
||||
static function onParserFirstCallInit( $parser ) {
|
||||
$parser->setHook( 'math', [ 'MathHooks', 'mathTagHook' ] );
|
||||
$parser->setHook( 'math', [ self::class, 'mathTagHook' ] );
|
||||
// @deprecated the ce tag is deprecated in favour of chem cf. T153606
|
||||
$parser->setHook( 'ce', [ 'MathHooks', 'chemTagHook' ] );
|
||||
$parser->setHook( 'chem', [ 'MathHooks', 'chemTagHook' ] );
|
||||
$parser->setHook( 'ce', [ self::class, 'chemTagHook' ] );
|
||||
$parser->setHook( 'chem', [ self::class, 'chemTagHook' ] );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -373,7 +373,7 @@ class MathHooks {
|
|||
MathMathML::batchEvaluate( self::$tags );
|
||||
}
|
||||
foreach ( self::$tags as $key => $tag ) {
|
||||
$value = call_user_func_array( [ "MathHooks", "mathPostTagHook" ], $tag );
|
||||
$value = call_user_func_array( [ self::class, 'mathPostTagHook' ], $tag );
|
||||
// Workaround for https://phabricator.wikimedia.org/T103269
|
||||
$text = preg_replace( '/(<mw:editsection[^>]*>.*?)' . preg_quote( $key ) .
|
||||
'(.*?)<\/mw:editsection>/',
|
||||
|
|
|
@ -12,7 +12,7 @@ class MathInputCheckTest extends MediaWikiTestCase {
|
|||
* @covers MathInputCheck::isValid
|
||||
*/
|
||||
public function testIsValid() {
|
||||
$InputCheck = $this->getMockBuilder( 'MathInputCheck' )->getMock();
|
||||
$InputCheck = $this->getMockBuilder( MathInputCheck::class )->getMock();
|
||||
$this->assertEquals( $InputCheck->IsValid(), false );
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ class MathInputCheckTest extends MediaWikiTestCase {
|
|||
* @todo Implement testGetError().
|
||||
*/
|
||||
public function testGetError() {
|
||||
$InputCheck = $this->getMockBuilder( 'MathInputCheck' )->getMock();
|
||||
$InputCheck = $this->getMockBuilder( MathInputCheck::class )->getMock();
|
||||
$this->assertNull( $InputCheck->getError() );
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ class MathInputCheckTest extends MediaWikiTestCase {
|
|||
* @covers MathInputCheck::getValidTex
|
||||
*/
|
||||
public function testGetValidTex() {
|
||||
$InputCheck = $this->getMockBuilder( 'MathInputCheck' )
|
||||
$InputCheck = $this->getMockBuilder( MathInputCheck::class )
|
||||
->setConstructorArgs( [ 'some tex input' ] )
|
||||
->getMock();
|
||||
$this->assertNull( $InputCheck->getValidTex() );
|
||||
|
|
|
@ -23,7 +23,7 @@ class MathLaTeXMLDatabaseTest extends MediaWikiTestCase {
|
|||
* @return ReflectionMethod
|
||||
*/
|
||||
protected static function getMethod( $name ) {
|
||||
$class = new ReflectionClass( 'MathLaTeXML' );
|
||||
$class = new ReflectionClass( MathLaTeXML::class );
|
||||
$method = $class->getMethod( $name );
|
||||
$method->setAccessible( true );
|
||||
return $method;
|
||||
|
|
|
@ -16,7 +16,7 @@ class MathLaTeXMLTest extends MediaWikiTestCase {
|
|||
* @covers MathLaTeXML::serializeSettings
|
||||
*/
|
||||
public function testSerializeSettings() {
|
||||
$renderer = $this->getMockBuilder( 'MathLaTeXML' )
|
||||
$renderer = $this->getMockBuilder( MathLaTeXML::class )
|
||||
->setMethods( null )
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
|
|
@ -65,12 +65,14 @@ class MathMathMLTest extends MediaWikiTestCase {
|
|||
self::setMockValues( false, false, false );
|
||||
$url = 'http://example.com/invalid';
|
||||
|
||||
$renderer = $this->getMockBuilder( 'MathMathML' )
|
||||
$renderer = $this->getMockBuilder( MathMathML::class )
|
||||
->setMethods( null )
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
/** @var MathMathML $renderer */
|
||||
$requestReturn = $renderer->makeRequest( $url, 'a+b', $res, $error,
|
||||
'MathMLHttpRequestTester' );
|
||||
MathMLHttpRequestTester::class );
|
||||
$this->assertEquals( false, $requestReturn,
|
||||
"requestReturn is false if HTTP::post returns false." );
|
||||
$this->assertEquals( false, $res,
|
||||
|
@ -89,13 +91,14 @@ class MathMathMLTest extends MediaWikiTestCase {
|
|||
self::setMockValues( true, true, false );
|
||||
self::$content = 'test content';
|
||||
$url = 'http://example.com/valid';
|
||||
/** @var MathMathML */
|
||||
$renderer = $this->getMockBuilder( 'MathMathML' )
|
||||
$renderer = $this->getMockBuilder( MathMathML::class )
|
||||
->setMethods( null )
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
/** @var MathMathML $renderer */
|
||||
$requestReturn = $renderer->makeRequest( $url, 'a+b', $res, $error,
|
||||
'MathMLHttpRequestTester' );
|
||||
MathMLHttpRequestTester::class );
|
||||
$this->assertEquals( true, $requestReturn, "successful call return" );
|
||||
$this->assertEquals( 'test content', $res, 'successful call' );
|
||||
$this->assertEquals( $error, '', "successful call error-message" );
|
||||
|
@ -109,12 +112,14 @@ class MathMathMLTest extends MediaWikiTestCase {
|
|||
public function testMakeRequestTimeout() {
|
||||
self::setMockValues( false, true, true );
|
||||
$url = 'http://example.com/timeout';
|
||||
$renderer = $this->getMockBuilder( 'MathMathML' )
|
||||
$renderer = $this->getMockBuilder( MathMathML::class )
|
||||
->setMethods( null )
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
/** @var MathMathML $renderer */
|
||||
$requestReturn = $renderer->makeRequest(
|
||||
$url, '$\longcommand$', $res, $error, 'MathMLHttpRequestTester'
|
||||
$url, '$\longcommand$', $res, $error, MathMLHttpRequestTester::class
|
||||
);
|
||||
$this->assertEquals( false, $requestReturn, "timeout call return" );
|
||||
$this->assertEquals( false, $res, "timeout call return" );
|
||||
|
@ -130,12 +135,14 @@ class MathMathMLTest extends MediaWikiTestCase {
|
|||
public function testMakeRequestGetPostData() {
|
||||
self::setMockValues( false, true, true );
|
||||
$url = 'http://example.com/timeout';
|
||||
$renderer = $this->getMockBuilder( 'MathMathML' )
|
||||
$renderer = $this->getMockBuilder( MathMathML::class )
|
||||
->setMethods( [ 'getPostData' ] )
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$renderer->expects( $this->once() )->method( 'getPostData' );
|
||||
$renderer->makeRequest( $url, false, $res, $error, 'MathMLHttpRequestTester' );
|
||||
|
||||
/** @var MathMathML $renderer */
|
||||
$renderer->makeRequest( $url, false, $res, $error, MathMLHttpRequestTester::class );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -146,12 +153,14 @@ class MathMathMLTest extends MediaWikiTestCase {
|
|||
public function testMakeRequestGetHost() {
|
||||
self::setMockValues( false, true, true );
|
||||
$url = 'http://example.com/timeout';
|
||||
$renderer = $this->getMockBuilder( 'MathMathML' )
|
||||
$renderer = $this->getMockBuilder( MathMathML::class )
|
||||
->setMethods( [ 'getPostData', 'pickHost' ] )
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$renderer->expects( $this->once() )->method( 'pickHost' );
|
||||
$renderer->makeRequest( false, false, $res, $error, 'MathMLHttpRequestTester' );
|
||||
|
||||
/** @var MathMathML $renderer */
|
||||
$renderer->makeRequest( false, false, $res, $error, MathMLHttpRequestTester::class );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -159,7 +168,7 @@ class MathMathMLTest extends MediaWikiTestCase {
|
|||
* @covers MathMathML::isValidMathML
|
||||
*/
|
||||
public function testisValidMathML() {
|
||||
$renderer = $this->getMockBuilder( 'MathMathML' )
|
||||
$renderer = $this->getMockBuilder( MathMathML::class )
|
||||
->setMethods( null )
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
@ -175,7 +184,7 @@ class MathMathMLTest extends MediaWikiTestCase {
|
|||
* @covers MathMathML::isValidMathML
|
||||
*/
|
||||
public function testInvalidXml() {
|
||||
$renderer = $this->getMockBuilder( 'MathMathML' )
|
||||
$renderer = $this->getMockBuilder( MathMathML::class )
|
||||
->setMethods( null )
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
@ -213,7 +222,7 @@ class MathMathMLTest extends MediaWikiTestCase {
|
|||
public function testPickHost() {
|
||||
$hosts = [ 'a', 'b', 'c' ];
|
||||
$this->setMwGlobals( 'wgMathMathMLUrl', $hosts );
|
||||
$class = new ReflectionClass( 'MathMathML' );
|
||||
$class = new ReflectionClass( MathMathML::class );
|
||||
$method = $class->getMethod( 'pickHost' );
|
||||
$method->setAccessible( true );
|
||||
srand( 0 ); // Make array_rand always return the same elements
|
||||
|
@ -239,7 +248,7 @@ class MathMathMLTest extends MediaWikiTestCase {
|
|||
class MathMLHttpRequestTester {
|
||||
|
||||
public static function factory() {
|
||||
return new MathMLHttpRequestTester();
|
||||
return new self();
|
||||
}
|
||||
|
||||
public static function execute() {
|
||||
|
|
|
@ -38,7 +38,7 @@ class MathRendererTest extends MediaWikiTestCase {
|
|||
* @covers MathRenderer::__construct()
|
||||
*/
|
||||
public function testBasics() {
|
||||
$renderer = $this->getMockForAbstractClass( 'MathRenderer', [ self::SOME_TEX ] );
|
||||
$renderer = $this->getMockForAbstractClass( MathRenderer::class, [ self::SOME_TEX ] );
|
||||
// check if the TeX input was corretly passed to the class
|
||||
$this->assertEquals( self::SOME_TEX, $renderer->getTex(), "test getTex" );
|
||||
$this->assertEquals( $renderer->isChanged(), false, "test if changed is initially false" );
|
||||
|
@ -50,7 +50,7 @@ class MathRendererTest extends MediaWikiTestCase {
|
|||
*/
|
||||
public function testWriteCacheSkip() {
|
||||
$renderer =
|
||||
$this->getMockBuilder( 'MathRenderer' )->setMethods( [
|
||||
$this->getMockBuilder( MathRenderer::class )->setMethods( [
|
||||
'writeToDatabase',
|
||||
'render',
|
||||
'getMathTableName',
|
||||
|
@ -66,7 +66,7 @@ class MathRendererTest extends MediaWikiTestCase {
|
|||
*/
|
||||
public function testWriteCache() {
|
||||
$renderer =
|
||||
$this->getMockBuilder( 'MathRenderer' )->setMethods( [
|
||||
$this->getMockBuilder( MathRenderer::class )->setMethods( [
|
||||
'writeToDatabase',
|
||||
'render',
|
||||
'getMathTableName',
|
||||
|
@ -78,7 +78,7 @@ class MathRendererTest extends MediaWikiTestCase {
|
|||
|
||||
public function testSetPurge() {
|
||||
$renderer =
|
||||
$this->getMockBuilder( 'MathRenderer' )->setMethods( [
|
||||
$this->getMockBuilder( MathRenderer::class )->setMethods( [
|
||||
'render',
|
||||
'getMathTableName',
|
||||
'getHtmlOutput'
|
||||
|
@ -90,7 +90,7 @@ class MathRendererTest extends MediaWikiTestCase {
|
|||
public function testDisableCheckingAlways() {
|
||||
$this->setMwGlobals( "wgMathDisableTexFilter", 'never' );
|
||||
$renderer =
|
||||
$this->getMockBuilder( 'MathRenderer' )->setMethods( [
|
||||
$this->getMockBuilder( MathRenderer::class )->setMethods( [
|
||||
'render',
|
||||
'getMathTableName',
|
||||
'getHtmlOutput',
|
||||
|
@ -108,7 +108,7 @@ class MathRendererTest extends MediaWikiTestCase {
|
|||
public function testDisableCheckingNever() {
|
||||
$this->setMwGlobals( "wgMathDisableTexFilter", 'always' );
|
||||
$renderer =
|
||||
$this->getMockBuilder( 'MathRenderer' )->setMethods( [
|
||||
$this->getMockBuilder( MathRenderer::class )->setMethods( [
|
||||
'render',
|
||||
'getMathTableName',
|
||||
'getHtmlOutput',
|
||||
|
@ -124,7 +124,7 @@ class MathRendererTest extends MediaWikiTestCase {
|
|||
public function testCheckingNewUnknown() {
|
||||
$this->setMwGlobals( "wgMathDisableTexFilter", 'new' );
|
||||
$renderer =
|
||||
$this->getMockBuilder( 'MathRenderer' )->setMethods( [
|
||||
$this->getMockBuilder( MathRenderer::class )->setMethods( [
|
||||
'render',
|
||||
'getMathTableName',
|
||||
'getHtmlOutput',
|
||||
|
@ -143,7 +143,7 @@ class MathRendererTest extends MediaWikiTestCase {
|
|||
public function testCheckingNewKnown() {
|
||||
$this->setMwGlobals( "wgMathDisableTexFilter", 'new' );
|
||||
$renderer =
|
||||
$this->getMockBuilder( 'MathRenderer' )->setMethods( [
|
||||
$this->getMockBuilder( MathRenderer::class )->setMethods( [
|
||||
'render',
|
||||
'getMathTableName',
|
||||
'getHtmlOutput',
|
||||
|
|
Loading…
Reference in New Issue