$this->mId = $id;
$this->mSynonyms = (array)$syn;
$this->mCaseSensitive = $cs;
- $this->contLang = $contLang;
-
- if ( !$contLang ) {
- $this->contLang = MediaWikiServices::getInstance()->getContentLanguage();
- }
+ $this->contLang = $contLang ?: MediaWikiServices::getInstance()->getContentLanguage();
}
/**
*/
public function __construct( $names = [], MagicWordFactory $factory = null ) {
$this->names = $names;
- $this->factory = $factory;
- if ( !$factory ) {
- $this->factory = MediaWikiServices::getInstance()->getMagicWordFactory();
- }
+ $this->factory = $factory ?: MediaWikiServices::getInstance()->getMagicWordFactory();
}
/**
*/
public function __construct( ApiMain $main, ApiFormatBase $errorFallback = null ) {
parent::__construct( $main, 'raw' );
- if ( $errorFallback === null ) {
- $this->errorFallback = $main->createPrinterByName( $main->getParameter( 'format' ) );
- } else {
- $this->errorFallback = $errorFallback;
- }
+ $this->errorFallback = $errorFallback ?:
+ $main->createPrinterByName( $main->getParameter( 'format' ) );
}
public function getMimeType() {
$this->file = $file;
$this->reason = $reason;
$this->suppress = $suppress;
- if ( $user ) {
- $this->user = $user;
- } else {
- global $wgUser;
- $this->user = $wgUser;
- }
+ global $wgUser;
+ $this->user = $user ?: $wgUser;
$this->status = $file->repo->newGood();
}
* @param IDatabase|null $db The database to search from
*/
public function __construct( IDatabase $db = null ) {
- if ( $db ) {
- $this->db = $db;
- } else {
- $this->db = wfGetDB( DB_REPLICA );
- }
+ $this->db = $db ?: wfGetDB( DB_REPLICA );
}
/**
// if a user was passed, use it. otherwise, attempt to use the global.
// this keeps FileRepo from breaking when it creates an UploadStash object
- if ( $user ) {
- $this->user = $user;
- } else {
- global $wgUser;
- $this->user = $wgUser;
- }
+ global $wgUser;
+ $this->user = $user ?: $wgUser;
if ( is_object( $this->user ) ) {
$this->userId = $this->user->getId();
*/
class MagicWordFactoryTest extends MediaWikiTestCase {
private function makeMagicWordFactory( Language $contLang = null ) {
- if ( $contLang === null ) {
- return new MagicWordFactory( Language::factory( 'en' ) );
- }
- return new MagicWordFactory( $contLang );
+ return new MagicWordFactory( $contLang ?: Language::factory( 'en' ) );
}
public function testGetContentLanguage() {