Merge "Remove unused class fields in LinkRenderer"

This commit is contained in:
jenkins-bot 2021-11-01 16:22:24 +00:00 committed by Gerrit Code Review
commit bba758a65c
5 changed files with 16 additions and 38 deletions

View file

@ -818,7 +818,6 @@ return [
return new LinkRendererFactory(
$services->getTitleFormatter(),
$services->getLinkCache(),
$services->getNamespaceInfo(),
$services->getSpecialPageFactory(),
$services->getHookContainer()
);

View file

@ -27,7 +27,6 @@ use MediaWiki\HookContainer\HookContainer;
use MediaWiki\HookContainer\HookRunner;
use MediaWiki\Page\PageReference;
use MediaWiki\SpecialPage\SpecialPageFactory;
use NamespaceInfo;
use Sanitizer;
use Title;
use TitleFormatter;
@ -66,14 +65,6 @@ class LinkRenderer {
*/
private $linkCache;
/**
* @var NamespaceInfo
*/
private $nsInfo;
/** @var HookContainer */
private $hookContainer;
/** @var HookRunner */
private $hookRunner;
@ -86,22 +77,18 @@ class LinkRenderer {
* @internal For use by LinkRendererFactory
* @param TitleFormatter $titleFormatter
* @param LinkCache $linkCache
* @param NamespaceInfo $nsInfo
* @param SpecialPageFactory $specialPageFactory
* @param HookContainer $hookContainer
*/
public function __construct(
TitleFormatter $titleFormatter,
LinkCache $linkCache,
NamespaceInfo $nsInfo,
SpecialPageFactory $specialPageFactory,
HookContainer $hookContainer
) {
$this->titleFormatter = $titleFormatter;
$this->linkCache = $linkCache;
$this->nsInfo = $nsInfo;
$this->specialPageFactory = $specialPageFactory;
$this->hookContainer = $hookContainer;
$this->hookRunner = new HookRunner( $hookContainer );
}

View file

@ -24,7 +24,6 @@ use LinkCache;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\SpecialPage\SpecialPageFactory;
use MediaWiki\User\UserIdentity;
use NamespaceInfo;
use TitleFormatter;
/**
@ -43,11 +42,6 @@ class LinkRendererFactory {
*/
private $linkCache;
/**
* @var NamespaceInfo
*/
private $nsInfo;
/**
* @var HookContainer
*/
@ -62,20 +56,17 @@ class LinkRendererFactory {
* @internal For use by core ServiceWiring
* @param TitleFormatter $titleFormatter
* @param LinkCache $linkCache
* @param NamespaceInfo $nsInfo
* @param SpecialPageFactory $specialPageFactory
* @param HookContainer $hookContainer
*/
public function __construct(
TitleFormatter $titleFormatter,
LinkCache $linkCache,
NamespaceInfo $nsInfo,
SpecialPageFactory $specialPageFactory,
HookContainer $hookContainer
) {
$this->titleFormatter = $titleFormatter;
$this->linkCache = $linkCache;
$this->nsInfo = $nsInfo;
$this->specialPageFactory = $specialPageFactory;
$this->hookContainer = $hookContainer;
}
@ -85,7 +76,7 @@ class LinkRendererFactory {
*/
public function create() {
return new LinkRenderer(
$this->titleFormatter, $this->linkCache, $this->nsInfo, $this->specialPageFactory,
$this->titleFormatter, $this->linkCache, $this->specialPageFactory,
$this->hookContainer
);
}

View file

@ -204,7 +204,6 @@ class LinkRendererTest extends MediaWikiLangTestCase {
public function testGetLinkClasses( $foobarTitle, $redirectTitle, $userTitle ) {
$services = MediaWikiServices::getInstance();
$titleFormatter = $services->getTitleFormatter();
$nsInfo = $services->getNamespaceInfo();
$specialPageFactory = $services->getSpecialPageFactory();
$hookContainer = $services->getHookContainer();
$linkCache = $services->getLinkCache();
@ -228,8 +227,12 @@ class LinkRendererTest extends MediaWikiLangTestCase {
}
$this->addGoodLinkObject( 3, $cacheTitle, 10, 0 );
$linkRenderer = new LinkRenderer( $titleFormatter, $linkCache,
$nsInfo, $specialPageFactory, $hookContainer );
$linkRenderer = new LinkRenderer(
$titleFormatter,
$linkCache,
$specialPageFactory,
$hookContainer
);
$this->assertSame(
'',
$linkRenderer->getLinkClasses( $foobarTitle )

View file

@ -20,11 +20,6 @@ class LinkRendererFactoryTest extends MediaWikiUnitTestCase {
*/
private $linkCache;
/**
* @var NamespaceInfo
*/
private $nsInfo;
/**
* @var SpecialPageFactory
*/
@ -40,7 +35,6 @@ class LinkRendererFactoryTest extends MediaWikiUnitTestCase {
$this->titleFormatter = $this->createMock( TitleFormatter::class );
$this->linkCache = $this->createMock( LinkCache::class );
$this->nsInfo = $this->createMock( NamespaceInfo::class );
$this->specialPageFactory = $this->createMock( SpecialPageFactory::class );
$this->hookContainer = $this->createMock( HookContainer::class );
}
@ -70,9 +64,11 @@ class LinkRendererFactoryTest extends MediaWikiUnitTestCase {
*/
public function testCreateFromLegacyOptions( $options, $func, $val ) {
$factory = new LinkRendererFactory(
$this->titleFormatter, $this->linkCache, $this->nsInfo,
$this->specialPageFactory, $this->hookContainer
);
$this->titleFormatter,
$this->linkCache,
$this->specialPageFactory,
$this->hookContainer
);
$linkRenderer = $factory->createFromLegacyOptions(
$options
);
@ -82,8 +78,10 @@ class LinkRendererFactoryTest extends MediaWikiUnitTestCase {
public function testCreate() {
$factory = new LinkRendererFactory(
$this->titleFormatter, $this->linkCache, $this->nsInfo,
$this->specialPageFactory, $this->hookContainer
$this->titleFormatter,
$this->linkCache,
$this->specialPageFactory,
$this->hookContainer
);
$this->assertInstanceOf( LinkRenderer::class, $factory->create() );
}