diff --git a/includes/Linker.php b/includes/Linker.php index 4718b87..0065896 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -76,8 +76,8 @@ class Linker { $limitReached = false; $newLinks = false; // whether or not new links were added $newText = $source->getText(); - $splitter = Splitter::default( $this->config ); - $targets = Targets::default( $source->getTitle(), $this->config ); + $splitter = Splitter::singleton( $this->config ); + $targets = Targets::singleton( $source->getTitle(), $this->config ); // Iterate through the target page titles foreach( $targets->queryResult as $row ) { diff --git a/includes/Splitter.php b/includes/Splitter.php index c13952c..349f1b8 100644 --- a/includes/Splitter.php +++ b/includes/Splitter.php @@ -52,7 +52,7 @@ class Splitter { * * @param Config|null $config LinkTitles configuration. */ - public static function default( Config &$config = null ) { + public static function singleton( Config &$config = null ) { if ( self::$instance === null ) { if ( $config === null ) { $config = new Config(); diff --git a/includes/Targets.php b/includes/Targets.php index 144c056..d129d72 100644 --- a/includes/Targets.php +++ b/includes/Targets.php @@ -40,7 +40,7 @@ class Targets { * @param String $sourceNamespace The namespace of the current page. * @param Config $config LinkTitles configuration. */ - public static function default( \Title $title, Config $config ) { + public static function singleton( \Title $title, Config $config ) { if ( ( self::$instance === null ) || ( self::$instance->sourceNamespace != $title->getNamespace() ) ) { self::$instance = new Targets( $title, $config ); } @@ -48,7 +48,7 @@ class Targets { } /** - * Invalidates the cache; the next call of Targets::default() will trigger + * Invalidates the cache; the next call of Targets::singleton() will trigger * a database query. * * Use this in unit tests which are performed in a single request cycle so that diff --git a/tests/phpunit/SplitterTest.php b/tests/phpunit/SplitterTest.php index c503b73..5557335 100644 --- a/tests/phpunit/SplitterTest.php +++ b/tests/phpunit/SplitterTest.php @@ -34,7 +34,7 @@ class SplitterTest extends MediaWikiTestCase { $config->skipTemplates = $skipTemplates; $config->parseHeadings = $parseHeadings; LinkTitles\Splitter::invalidate(); - $splitter = LinkTitles\Splitter::default( $config ); + $splitter = LinkTitles\Splitter::singleton( $config ); $this->assertSame( $skipTemplates, $splitter->config->skipTemplates, 'Splitter has incorrect skipTemplates config'); $this->assertSame( $parseHeadings, $splitter->config->parseHeadings, 'Splitter has incorrect parseHeadings config'); $this->assertSame( $expectedOutput, $splitter->split( $input ) ); diff --git a/tests/phpunit/TargetsTest.php b/tests/phpunit/TargetsTest.php index 0638cee..351a0b2 100644 --- a/tests/phpunit/TargetsTest.php +++ b/tests/phpunit/TargetsTest.php @@ -34,7 +34,7 @@ class TargetsTest extends LinkTitles\TestCase { */ public function testTargets() { $title = \Title::newFromText( 'link target' ); - $targets = LinkTitles\Targets::default( $title, new LinkTitles\Config() ); + $targets = LinkTitles\Targets::singleton( $title, new LinkTitles\Config() ); // Count number of articles: Inspired by updateArticleCount.php maintenance // script: https://doc.wikimedia.org/mediawiki-core/master/php/updateArticleCount_8php_source.html