Merge "Rename CiteParserTagHooks::initialize to register"

This commit is contained in:
jenkins-bot 2019-12-11 15:35:32 +00:00 committed by Gerrit Code Review
commit 0dafe64305
3 changed files with 10 additions and 10 deletions

View file

@ -18,7 +18,7 @@ class CiteParserHooks {
*/
public static function onParserFirstCallInit( Parser $parser ) {
$parser->extCite = new Cite();
CiteParserTagHooks::initialize( $parser );
CiteParserTagHooks::register( $parser );
}
/**
@ -44,7 +44,7 @@ class CiteParserHooks {
$cite = $parser->extCite;
$cite->clearState( 'force' );
CiteParserTagHooks::initialize( $parser );
CiteParserTagHooks::register( $parser );
}
/**

View file

@ -16,9 +16,9 @@ class CiteParserTagHooks {
*
* @param Parser $parser
*/
public static function initialize( Parser $parser ) {
$parser->setHook( 'ref', __CLASS__ . '::ref' );
$parser->setHook( 'references', __CLASS__ . '::references' );
public static function register( Parser $parser ) {
$parser->setHook( 'ref', [ __CLASS__, 'ref' ] );
$parser->setHook( 'references', [ __CLASS__, 'references' ] );
}
/**
@ -34,7 +34,6 @@ class CiteParserTagHooks {
public static function ref( $content, array $attributes, Parser $parser, PPFrame $frame ) {
/** @var Cite $cite */
$cite = $parser->extCite;
// @phan-suppress-next-line SecurityCheck-XSS False positive
$result = $cite->ref( $content, $attributes, $parser );
if ( $result === false ) {
@ -46,6 +45,7 @@ class CiteParserTagHooks {
$parserOutput->addModuleStyles( 'ext.cite.styles' );
$frame->setVolatile();
// @phan-suppress-next-line SecurityCheck-XSS False positive
return $result;
}
@ -62,7 +62,6 @@ class CiteParserTagHooks {
public static function references( $content, array $attributes, Parser $parser, PPFrame $frame ) {
/** @var Cite $cite */
$cite = $parser->extCite;
// @phan-suppress-next-line SecurityCheck-XSS False positive
$result = $cite->references( $content, $attributes, $parser );
if ( $result === false ) {
@ -73,6 +72,7 @@ class CiteParserTagHooks {
}
$frame->setVolatile();
// @phan-suppress-next-line SecurityCheck-XSS False positive
return $result;
}

View file

@ -16,9 +16,9 @@ use PPFrame;
class CiteParserTagHooksTest extends \MediaWikiUnitTestCase {
/**
* @covers ::initialize
* @covers ::register
*/
public function testInitialize() {
public function testRegister() {
$parser = $this->createMock( Parser::class );
$parser->expects( $this->exactly( 2 ) )
->method( 'setHook' )
@ -27,7 +27,7 @@ class CiteParserTagHooksTest extends \MediaWikiUnitTestCase {
[ 'references', $this->isType( 'callable' ) ]
);
CiteParserTagHooks::initialize( $parser );
CiteParserTagHooks::register( $parser );
}
/**