From 73f94fd8cd0a737da2eacbeb39357c0acf95d9e5 Mon Sep 17 00:00:00 2001 From: Fomafix Date: Wed, 4 Oct 2017 21:02:29 +0200 Subject: [PATCH] Add type hint Language where possible Also use ?? instead of ?: to check for null. Change-Id: I058b61d7e06cdefecdafa82f60109cc386e2a809 --- includes/filerepo/file/File.php | 6 +++--- includes/filerepo/file/ForeignDBFile.php | 4 ++-- includes/filerepo/file/LocalFile.php | 2 +- includes/logging/BlockLogFormatter.php | 4 ++-- includes/parser/DateFormatter.php | 2 +- includes/specials/SpecialBlock.php | 2 +- includes/specials/pagers/AllMessagesTablePager.php | 4 ++-- languages/FakeConverter.php | 2 +- languages/LanguageConverter.php | 2 +- languages/classes/LanguageCrh.php | 2 +- languages/classes/LanguageGan.php | 2 +- languages/classes/LanguageKk.php | 2 +- languages/classes/LanguageZh.php | 2 +- 13 files changed, 18 insertions(+), 18 deletions(-) diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php index 370ebb406b..5a0cf6a621 100644 --- a/includes/filerepo/file/File.php +++ b/includes/filerepo/file/File.php @@ -2051,17 +2051,17 @@ abstract class File implements IDBAccessObject { /** * Get the HTML text of the description page, if available * - * @param bool|Language $lang Optional language to fetch description in + * @param Language|null $lang Optional language to fetch description in * @return string|false */ - function getDescriptionText( $lang = false ) { + function getDescriptionText( Language $lang = null ) { global $wgLang; if ( !$this->repo || !$this->repo->fetchDescription ) { return false; } - $lang = $lang ?: $wgLang; + $lang = $lang ?? $wgLang; $renderUrl = $this->repo->getDescriptionRenderUrl( $this->getName(), $lang->getCode() ); if ( $renderUrl ) { diff --git a/includes/filerepo/file/ForeignDBFile.php b/includes/filerepo/file/ForeignDBFile.php index 7a982bd34f..ee4df1d351 100644 --- a/includes/filerepo/file/ForeignDBFile.php +++ b/includes/filerepo/file/ForeignDBFile.php @@ -126,14 +126,14 @@ class ForeignDBFile extends LocalFile { * @param Language|null $lang Optional language to fetch description in. * @return string|false */ - function getDescriptionText( $lang = null ) { + function getDescriptionText( Language $lang = null ) { global $wgLang; if ( !$this->repo->fetchDescription ) { return false; } - $lang = $lang ?: $wgLang; + $lang = $lang ?? $wgLang; $renderUrl = $this->repo->getDescriptionRenderUrl( $this->getName(), $lang->getCode() ); if ( !$renderUrl ) { return false; diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index 742d78d3bb..1fc6bd05cc 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -2115,7 +2115,7 @@ class LocalFile extends File { * @param Language|null $lang What language to get description in (Optional) * @return string|false */ - function getDescriptionText( $lang = null ) { + function getDescriptionText( Language $lang = null ) { $revision = Revision::newFromTitle( $this->title, false, Revision::READ_NORMAL ); if ( !$revision ) { return false; diff --git a/includes/logging/BlockLogFormatter.php b/includes/logging/BlockLogFormatter.php index 0d22382785..3762d62787 100644 --- a/includes/logging/BlockLogFormatter.php +++ b/includes/logging/BlockLogFormatter.php @@ -130,7 +130,7 @@ class BlockLogFormatter extends LogFormatter { * @param Language $lang * @return string */ - public static function formatBlockFlags( $flags, $lang ) { + public static function formatBlockFlags( $flags, Language $lang ) { $flags = trim( $flags ); if ( $flags === '' ) { return ''; // nothing to do @@ -153,7 +153,7 @@ class BlockLogFormatter extends LogFormatter { * @param Language $lang Language object to use * @return string */ - public static function formatBlockFlag( $flag, $lang ) { + public static function formatBlockFlag( $flag, Language $lang ) { static $messages = []; if ( !isset( $messages[$flag] ) ) { diff --git a/includes/parser/DateFormatter.php b/includes/parser/DateFormatter.php index 3be4353e29..de02861b3c 100644 --- a/includes/parser/DateFormatter.php +++ b/includes/parser/DateFormatter.php @@ -135,7 +135,7 @@ class DateFormatter { public static function getInstance( Language $lang = null ) { global $wgMainCacheType; - $lang = $lang ?: MediaWikiServices::getInstance()->getContentLanguage(); + $lang = $lang ?? MediaWikiServices::getInstance()->getContentLanguage(); $cache = ObjectCache::getLocalServerInstance( $wgMainCacheType ); static $dateFormatter = false; diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index 3b25c6c2af..a60595abe1 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -858,7 +858,7 @@ class SpecialBlock extends FormSpecialPage { * suggestions * @return array */ - public static function getSuggestedDurations( $lang = null, $includeOther = true ) { + public static function getSuggestedDurations( Language $lang = null, $includeOther = true ) { $a = []; $msg = $lang === null ? wfMessage( 'ipboptions' )->inContentLanguage()->text() diff --git a/includes/specials/pagers/AllMessagesTablePager.php b/includes/specials/pagers/AllMessagesTablePager.php index 2e451ecd0f..6d5f64b7a2 100644 --- a/includes/specials/pagers/AllMessagesTablePager.php +++ b/includes/specials/pagers/AllMessagesTablePager.php @@ -44,7 +44,7 @@ class AllMessagesTablePager extends TablePager { */ public $custom; - function __construct( $page, $conds, $langObj = null ) { + function __construct( $page, $conds, Language $langObj = null ) { parent::__construct( $page->getContext() ); $this->mIndexField = 'am_title'; $this->mPage = $page; @@ -56,7 +56,7 @@ class AllMessagesTablePager extends TablePager { $this->talk = $this->msg( 'talkpagelinktext' )->escaped(); $contLang = MediaWikiServices::getInstance()->getContentLanguage(); - $this->lang = $langObj ?: $contLang; + $this->lang = $langObj ?? $contLang; $this->langcode = $this->lang->getCode(); $this->foreign = !$this->lang->equals( $contLang ); diff --git a/languages/FakeConverter.php b/languages/FakeConverter.php index 22377c28be..c4ec6382e5 100644 --- a/languages/FakeConverter.php +++ b/languages/FakeConverter.php @@ -37,7 +37,7 @@ class FakeConverter { */ public $mLang; - function __construct( $langobj ) { + function __construct( Language $langobj ) { $this->mLang = $langobj; } diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index 6ab6e8f852..c098518a96 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -85,7 +85,7 @@ class LanguageConverter { * @param array $flags Defining the custom strings that maps to the flags * @param array $manualLevel Limit for supported variants */ - public function __construct( $langobj, $maincode, $variants = [], + public function __construct( Language $langobj, $maincode, $variants = [], $variantfallbacks = [], $flags = [], $manualLevel = [] ) { global $wgDisabledVariants; diff --git a/languages/classes/LanguageCrh.php b/languages/classes/LanguageCrh.php index e652a52751..27af14bdd5 100644 --- a/languages/classes/LanguageCrh.php +++ b/languages/classes/LanguageCrh.php @@ -63,7 +63,7 @@ class CrhConverter extends LanguageConverter { * @param array $variantfallbacks * @param array $flags */ - function __construct( $langobj, $maincode, + function __construct( Language $langobj, $maincode, $variants = [], $variantfallbacks = [], $flags = [] ) { diff --git a/languages/classes/LanguageGan.php b/languages/classes/LanguageGan.php index d6f90df633..f315473601 100644 --- a/languages/classes/LanguageGan.php +++ b/languages/classes/LanguageGan.php @@ -32,7 +32,7 @@ class GanConverter extends LanguageConverter { * @param array $flags * @param array $manualLevel */ - function __construct( $langobj, $maincode, + function __construct( Language $langobj, $maincode, $variants = [], $variantfallbacks = [], $flags = [], diff --git a/languages/classes/LanguageKk.php b/languages/classes/LanguageKk.php index 1a1438c6b2..dc8a9f892f 100644 --- a/languages/classes/LanguageKk.php +++ b/languages/classes/LanguageKk.php @@ -44,7 +44,7 @@ class KkConverter extends LanguageConverter { * @param array $variantfallbacks * @param array $flags */ - function __construct( $langobj, $maincode, + function __construct( Language $langobj, $maincode, $variants = [], $variantfallbacks = [], $flags = [] ) { diff --git a/languages/classes/LanguageZh.php b/languages/classes/LanguageZh.php index e1099f8867..27d6972cd2 100644 --- a/languages/classes/LanguageZh.php +++ b/languages/classes/LanguageZh.php @@ -33,7 +33,7 @@ class ZhConverter extends LanguageConverter { * @param array $flags * @param array $manualLevel */ - function __construct( $langobj, $maincode, + function __construct( Language $langobj, $maincode, $variants = [], $variantfallbacks = [], $flags = [], -- 2.20.1