From e996b5391357ab03d53f0347854ec42a9b091a53 Mon Sep 17 00:00:00 2001 From: Zoranzoki21 Date: Sun, 14 Apr 2019 12:15:06 +0200 Subject: [PATCH] Split StubObject.php to have one class in one file Change-Id: If00625b700962a1c6d6412c6de30c28fa3df9f81 --- .phpcs.xml | 2 +- autoload.php | 2 +- includes/StubObject.php | 35 ------------------------- includes/StubUserLang.php | 54 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 37 deletions(-) create mode 100644 includes/StubUserLang.php diff --git a/.phpcs.xml b/.phpcs.xml index 7037ea7fdc..86d37ad52f 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -215,7 +215,6 @@ */includes/parser/Preprocessor_Hash\.php */includes/parser/Preprocessor\.php */includes/profiler/SectionProfiler\.php - */includes/StubObject\.php */includes/utils/AutoloadGenerator\.php */maintenance/dumpIterator\.php */maintenance/Maintenance\.php @@ -234,6 +233,7 @@ */includes/StubObject\.php + */includes/StubUserLang\.php */tests/phpunit/*\.php diff --git a/autoload.php b/autoload.php index be4a1de25c..139f8d57d4 100644 --- a/autoload.php +++ b/autoload.php @@ -1452,7 +1452,7 @@ $wgAutoloadLocalClasses = [ 'StringUtils' => __DIR__ . '/includes/libs/StringUtils.php', 'StripState' => __DIR__ . '/includes/parser/StripState.php', 'StubObject' => __DIR__ . '/includes/StubObject.php', - 'StubUserLang' => __DIR__ . '/includes/StubObject.php', + 'StubUserLang' => __DIR__ . '/includes/StubUserLang.php', 'SubmitAction' => __DIR__ . '/includes/actions/SubmitAction.php', 'SubpageImportTitleFactory' => __DIR__ . '/includes/title/SubpageImportTitleFactory.php', 'SvgHandler' => __DIR__ . '/includes/media/SvgHandler.php', diff --git a/includes/StubObject.php b/includes/StubObject.php index 92130761a6..1583dbf9f7 100644 --- a/includes/StubObject.php +++ b/includes/StubObject.php @@ -171,38 +171,3 @@ class StubObject { } } } - -/** - * Stub object for the user language. Assigned to the $wgLang global. - */ -class StubUserLang extends StubObject { - - public function __construct() { - parent::__construct( 'wgLang' ); - } - - /** - * Call Language::findVariantLink after unstubbing $wgLang. - * - * This method is implemented with a full signature rather than relying on - * __call so that the pass-by-reference signature of the proxied method is - * honored. - * - * @param string &$link The name of the link - * @param Title &$nt The title object of the link - * @param bool $ignoreOtherCond To disable other conditions when - * we need to transclude a template or update a category's link - */ - public function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) { - global $wgLang; - $this->_unstub( 'findVariantLink', 3 ); - $wgLang->findVariantLink( $link, $nt, $ignoreOtherCond ); - } - - /** - * @return Language - */ - public function _newObject() { - return RequestContext::getMain()->getLanguage(); - } -} diff --git a/includes/StubUserLang.php b/includes/StubUserLang.php new file mode 100644 index 0000000000..6f7bed61fc --- /dev/null +++ b/includes/StubUserLang.php @@ -0,0 +1,54 @@ +_unstub( 'findVariantLink', 3 ); + $wgLang->findVariantLink( $link, $nt, $ignoreOtherCond ); + } + + /** + * @return Language + */ + public function _newObject() { + return RequestContext::getMain()->getLanguage(); + } +} -- 2.20.1