diff --git a/includes/Extension.php b/includes/Extension.php index 7a8d1d0..1c28a37 100644 --- a/includes/Extension.php +++ b/includes/Extension.php @@ -29,6 +29,7 @@ use CommentStoreComment; use MediaWiki\MediaWikiServices; use MediaWiki\Revision\RenderedRevision; use MediaWiki\Revision\SlotRecord; +use MediaWiki\Title\Title; use Status; use WikiPage; use User; @@ -102,11 +103,11 @@ class Extension { * * Entry point for the SpecialLinkTitles class and the LinkTitlesJob class. * - * @param \MediaWiki\Title\Title $title Title object. + * @param Title $title Title object. * @param \RequestContext $context Current request context. If in doubt, call MediaWiki's `RequestContext::getMain()` to obtain such an object. * @return bool True if the page exists, false if the page does not exist */ - public static function processPage( \MediaWiki\Title\Title $title, \RequestContext $context ) { + public static function processPage( Title $title, \RequestContext $context ) { $config = new Config(); $source = Source::createFromTitle( $title, $config ); if ( $source->hasContent() ) { diff --git a/includes/Linker.php b/includes/Linker.php index b62839a..2e91999 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -24,6 +24,8 @@ */ namespace LinkTitles; +use MediaWiki\Title\Title; + /** * Performs the actual linking of content to existing pages. */ @@ -66,7 +68,7 @@ class Linker { * callbacks in the Extension class do not always get a WikiPage object in the * first place. * - * @param \MediaWiki\Title\Title &$title Title object for the current page. + * @param Title &$title Title object for the current page. * @param String $text String that holds the article content * @return String|null Source page text with links to target pages, or null if no links were added */ diff --git a/includes/Source.php b/includes/Source.php index a98aeb6..d199172 100644 --- a/includes/Source.php +++ b/includes/Source.php @@ -25,6 +25,7 @@ namespace LinkTitles; use MediaWiki\MediaWikiServices; +use MediaWiki\Title\Title; /** * Represents a page that is a potential link target. @@ -46,11 +47,11 @@ class Source { private $content; /** - * Creates a Source object from a \MediaWiki\Title\Title. - * @param \MediaWiki\Title\Title $title Title object from which to create the Source. + * Creates a Source object from a Title. + * @param Title $title Title object from which to create the Source. * @return Source Source object created from the title. */ - public static function createFromTitle( \MediaWiki\Title\Title $title, Config $config ) { + public static function createFromTitle( Title $title, Config $config ) { $source = new Source( $config ); $source->title = $title; return $source; @@ -62,12 +63,12 @@ class Source { * This factory can be called e.g. from a onPageContentSave event handler * which knows both these parameters. * - * @param \MediaWiki\Title\Title $title Title of the source page + * @param Title $title Title of the source page * @param String $text String representation of the page content * @param Config $config LinkTitles configuration * @return Source Source object created from the title and the text */ - public static function createFromTitleAndText( \MediaWiki\Title\Title $title, $text, Config $config ) { + public static function createFromTitleAndText( Title $title, $text, Config $config ) { $source = Source::createFromTitle( $title, $config); $source->text = $text; return $source; @@ -158,7 +159,7 @@ class Source { /** * Gets the title. * - * @return \MediaWiki\Title\Title Title of the source page. + * @return Title Title of the source page. */ public function getTitle() { if ( $this->title === null ) { @@ -249,7 +250,7 @@ class Source { /** * Obtain a WikiPage object. * Workaround for MediaWiki 1.36+ which deprecated Wikipage::factory. - * @param \MediaWiki\Title\Title $title + * @param Title $title * @return WikiPage object */ private static function getPageObject( $title ) { diff --git a/includes/Target.php b/includes/Target.php index f373128..b500b1b 100644 --- a/includes/Target.php +++ b/includes/Target.php @@ -33,7 +33,7 @@ use MediaWiki\Title\Title; class Target { /** * A Title object for the target page currently being examined. - * @var \MediaWiki\Title\Title $title + * @var Title $title */ private $title; @@ -77,7 +77,7 @@ class Target { * @param String &$title Title of the target page */ public function __construct( $namespace, $title, Config &$config ) { - $this->title = \MediaWiki\Title\Title::makeTitleSafe( $namespace, $title ); + $this->title = Title::makeTitleSafe( $namespace, $title ); $this->titleValue = $this->title->getTitleValue(); $this->config = $config; @@ -253,7 +253,7 @@ class Target { /** * Obtain a page's content. * Workaround for MediaWiki 1.36+ which deprecated Wikipage::factory. - * @param \MediaWiki\Title\Title $title + * @param Title $title * @return Content content object of the page */ private static function getPageContents( $title ) { diff --git a/linktitles-cli.php b/linktitles-cli.php index 66f0bfd..da88126 100755 --- a/linktitles-cli.php +++ b/linktitles-cli.php @@ -23,6 +23,8 @@ */ namespace LinkTitles; +use MediaWiki\Title\Title; + // Attempt to include the maintenance base class from: // $wgScriptPath/maintenance/Maintenance.php // Our script is normally located at: @@ -143,7 +145,7 @@ class Cli extends \Maintenance { private function singlePage() { $pageName = strval( $this->getOption( 'page' ) ); $this->output( "Processing single page: '$pageName'\n" ); - $title = \MediaWiki\Title\Title::newFromText( $pageName ); + $title = Title::newFromText( $pageName ); $success = Extension::processPage( $title, \RequestContext::getMain() ); if ( $success ) { $this->output( "Finished.\n" ); @@ -184,7 +186,7 @@ class Cli extends \Maintenance { $numProcessed = 0; foreach ( $res as $row ) { - $title = \MediaWiki\Title\Title::makeTitleSafe( $row->page_namespace, $row->page_title ); + $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title ); $numProcessed += 1; $index += 1; if ( $verbose ) { diff --git a/tests/phpunit/TargetsTest.php b/tests/phpunit/TargetsTest.php index 35e0663..29af658 100644 --- a/tests/phpunit/TargetsTest.php +++ b/tests/phpunit/TargetsTest.php @@ -36,7 +36,7 @@ class TargetsTest extends LinkTitles\TestCase { // LinkTitlesLinkerTest::testLinkContentTargetNamespaces() is every changed, // this test will fail. $config->targetNamespaces = [ 4000 ]; - $title = \MediaWiki\Title\Title::newFromText( 'link target' ); + $title = Title::newFromText( 'link target' ); $targets = LinkTitles\Targets::singleton( $title, $config ); // Count number of articles: Inspired by updateArticleCount.php maintenance