aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--includes/BootstrapHelperFunctions.php4
-rw-r--r--includes/ResourceLoader/FileModule.php6
-rw-r--r--includes/ResourceLoader/WikiModule.php7
-rw-r--r--includes/Rest/Handler/Helper/HtmlOutputRendererHelper.php4
-rw-r--r--includes/api/ApiDelete.php7
-rw-r--r--includes/historyblob/DiffHistoryBlob.php6
-rw-r--r--includes/htmlform/fields/HTMLTitleTextField.php4
-rw-r--r--includes/htmlform/fields/HTMLUserTextField.php4
-rw-r--r--includes/jobqueue/jobs/UploadJobTrait.php4
-rw-r--r--includes/language/Language.php4
-rw-r--r--includes/libs/rdbms/exception/DBQueryDisconnectedError.php10
-rw-r--r--includes/libs/rdbms/exception/DBQueryError.php8
-rw-r--r--includes/media/WebPHandler.php8
-rw-r--r--includes/parser/Parser.php4
-rw-r--r--includes/parser/Parsoid/Config/SiteConfig.php12
-rw-r--r--includes/parser/Parsoid/ParsoidOutputAccess.php4
-rw-r--r--includes/preferences/DefaultPreferencesFactory.php4
-rw-r--r--includes/site/MediaWikiSite.php5
-rw-r--r--includes/skins/SkinTemplate.php12
-rw-r--r--includes/specialpage/LoginSignupSpecialPage.php4
-rw-r--r--includes/specials/SpecialPrefixIndex.php4
-rw-r--r--includes/specials/SpecialUndelete.php2
-rw-r--r--includes/specials/SpecialWhatLinksHere.php4
-rw-r--r--includes/specials/pagers/ImageListPager.php4
-rw-r--r--includes/title/Title.php8
-rw-r--r--includes/user/BotPasswordStore.php4
-rw-r--r--includes/user/Options/UserOptionsManager.php4
-rw-r--r--includes/utils/ZipDirectoryReader.php4
-rw-r--r--includes/watchlist/WatchedItemStore.php5
-rw-r--r--includes/xml/Xml.php4
-rw-r--r--maintenance/includes/BackupDumper.php8
-rw-r--r--maintenance/includes/Maintenance.php4
-rw-r--r--maintenance/includes/TextPassDumper.php6
-rw-r--r--maintenance/storage/moveToExternal.php11
34 files changed, 56 insertions, 137 deletions
diff --git a/includes/BootstrapHelperFunctions.php b/includes/BootstrapHelperFunctions.php
index ff694151fd8b..6b34ba6e86e6 100644
--- a/includes/BootstrapHelperFunctions.php
+++ b/includes/BootstrapHelperFunctions.php
@@ -32,9 +32,7 @@ function wfDetectLocalSettingsFile( ?string $installationPath = null ): string {
return MW_CONFIG_FILE;
}
- if ( $installationPath === null ) {
- $installationPath = wfDetectInstallPath();
- }
+ $installationPath ??= wfDetectInstallPath();
// We could look for LocalSettings.yaml and LocalSettings.json,
// and use them if they exist. But having them in a web accessible
diff --git a/includes/ResourceLoader/FileModule.php b/includes/ResourceLoader/FileModule.php
index bf173afd3dc0..2ac864514505 100644
--- a/includes/ResourceLoader/FileModule.php
+++ b/includes/ResourceLoader/FileModule.php
@@ -281,10 +281,8 @@ class FileModule extends Module {
// The different ways these checks are done, and their ordering, look very silly,
// but were preserved for backwards-compatibility just in case. Tread lightly.
- if ( $remoteBasePath === null ) {
- $remoteBasePath = MediaWikiServices::getInstance()->getMainConfig()
- ->get( MainConfigNames::ResourceBasePath );
- }
+ $remoteBasePath ??= MediaWikiServices::getInstance()->getMainConfig()
+ ->get( MainConfigNames::ResourceBasePath );
if ( isset( $options['remoteExtPath'] ) ) {
$extensionAssetsPath = MediaWikiServices::getInstance()->getMainConfig()
diff --git a/includes/ResourceLoader/WikiModule.php b/includes/ResourceLoader/WikiModule.php
index a5f28169805a..ebb0aa401d7a 100644
--- a/includes/ResourceLoader/WikiModule.php
+++ b/includes/ResourceLoader/WikiModule.php
@@ -352,8 +352,7 @@ class WikiModule extends Module {
/**
* @param Context $context
- * @return array
- * @phan-return array{main:string,files:string[][]}
+ * @return array{main:?string,files:array<string,array>}
*/
private function getPackageFiles( Context $context ): array {
$main = null;
@@ -373,9 +372,7 @@ class WikiModule extends Module {
'content' => $script,
];
// First script becomes the "main" script
- if ( $main === null ) {
- $main = $fileKey;
- }
+ $main ??= $fileKey;
} elseif ( $options['type'] === 'data' ) {
$data = FormatJson::decode( $content );
if ( $data == null ) {
diff --git a/includes/Rest/Handler/Helper/HtmlOutputRendererHelper.php b/includes/Rest/Handler/Helper/HtmlOutputRendererHelper.php
index c8fc5dfff17c..8ce580a4f2da 100644
--- a/includes/Rest/Handler/Helper/HtmlOutputRendererHelper.php
+++ b/includes/Rest/Handler/Helper/HtmlOutputRendererHelper.php
@@ -843,9 +843,7 @@ class HtmlOutputRendererHelper implements HtmlOutputHelper {
}
}
- if ( $revision === null ) {
- $revision = $page->getLatest();
- }
+ $revision ??= $page->getLatest();
if ( is_int( $revision ) ) {
$revId = $revision;
diff --git a/includes/api/ApiDelete.php b/includes/api/ApiDelete.php
index 762a583eb36b..3c2c0bea3753 100644
--- a/includes/api/ApiDelete.php
+++ b/includes/api/ApiDelete.php
@@ -248,15 +248,12 @@ class ApiDelete extends ApiBase {
}
}
- if ( $reason === null ) { // Log and RC don't like null reasons
- $reason = '';
- }
-
return FileDeleteForm::doDelete(
$title,
$file,
$oldimage,
- $reason,
+ // Log and RC don't like null reasons
+ $reason ?? '',
$suppress,
$this->getUser(),
$tags,
diff --git a/includes/historyblob/DiffHistoryBlob.php b/includes/historyblob/DiffHistoryBlob.php
index 1168567e6c64..b1ce7f443d88 100644
--- a/includes/historyblob/DiffHistoryBlob.php
+++ b/includes/historyblob/DiffHistoryBlob.php
@@ -260,10 +260,8 @@ class DiffHistoryBlob implements HistoryBlob {
* @return string
*/
public function xdiffAdler32( $s ) {
- static $init;
- if ( $init === null ) {
- $init = str_repeat( "\xf0", 205 ) . "\xee" . str_repeat( "\xf0", 67 ) . "\x02";
- }
+ static $init = null;
+ $init ??= str_repeat( "\xf0", 205 ) . "\xee" . str_repeat( "\xf0", 67 ) . "\x02";
// The real Adler-32 checksum of $init is zero, so it initialises the
// state to zero, as it is at the start of LibXDiff's checksum
diff --git a/includes/htmlform/fields/HTMLTitleTextField.php b/includes/htmlform/fields/HTMLTitleTextField.php
index 6ae38c12b4d9..6cffa5ccd54b 100644
--- a/includes/htmlform/fields/HTMLTitleTextField.php
+++ b/includes/htmlform/fields/HTMLTitleTextField.php
@@ -51,9 +51,7 @@ class HTMLTitleTextField extends HTMLTextField {
throw new InvalidArgumentException( 'relative and interwiki may not be used together' );
}
// Default value (from getDefault()) is null, which breaks Title::newFromTextThrow() below
- if ( $value === null ) {
- $value = '';
- }
+ $value ??= '';
if ( !$this->mParams['required'] && $value === '' ) {
// If this field is not required and the value is empty, that's okay, skip validation
diff --git a/includes/htmlform/fields/HTMLUserTextField.php b/includes/htmlform/fields/HTMLUserTextField.php
index 1dc797967a88..0478c167d931 100644
--- a/includes/htmlform/fields/HTMLUserTextField.php
+++ b/includes/htmlform/fields/HTMLUserTextField.php
@@ -47,9 +47,7 @@ class HTMLUserTextField extends HTMLTextField {
public function validate( $value, $alldata ) {
// If the value is null, reset it to an empty string which is what is expected by the parent.
- if ( $value === null ) {
- $value = '';
- }
+ $value ??= '';
// If the value is empty, there are no additional checks that can be performed.
if ( $value === '' ) {
diff --git a/includes/jobqueue/jobs/UploadJobTrait.php b/includes/jobqueue/jobs/UploadJobTrait.php
index b249de9a7bce..0b312626b07b 100644
--- a/includes/jobqueue/jobs/UploadJobTrait.php
+++ b/includes/jobqueue/jobs/UploadJobTrait.php
@@ -169,9 +169,7 @@ trait UploadJobTrait {
if ( $this->user === null ) {
return;
}
- if ( $status === null ) {
- $status = Status::newGood();
- }
+ $status ??= Status::newGood();
$info = [ 'result' => $result, 'stage' => $stage, 'status' => $status ];
$info += $additionalInfo;
UploadBase::setSessionStatus(
diff --git a/includes/language/Language.php b/includes/language/Language.php
index 92f9bbfbd25d..8527b1324627 100644
--- a/includes/language/Language.php
+++ b/includes/language/Language.php
@@ -2173,9 +2173,7 @@ class Language implements Bcp47Code {
int $timestamp2,
?int $precision = null
): string {
- if ( $precision === null ) {
- $precision = count( self::DURATION_INTERVALS );
- }
+ $precision ??= count( self::DURATION_INTERVALS );
$sortedTimestamps = [ $timestamp1, $timestamp2 ];
sort( $sortedTimestamps );
diff --git a/includes/libs/rdbms/exception/DBQueryDisconnectedError.php b/includes/libs/rdbms/exception/DBQueryDisconnectedError.php
index 9d7f248691e3..7415266759ed 100644
--- a/includes/libs/rdbms/exception/DBQueryDisconnectedError.php
+++ b/includes/libs/rdbms/exception/DBQueryDisconnectedError.php
@@ -36,12 +36,10 @@ class DBQueryDisconnectedError extends DBQueryError {
* @param string|null $message Optional message, intended for subclasses (optional)
*/
public function __construct( IDatabase $db, $error, $errno, $sql, $fname, $message = null ) {
- if ( $message === null ) {
- $message = "A connection error occurred during a query. \n" .
- "Query: $sql\n" .
- "Function: $fname\n" .
- "Error: $errno $error\n";
- }
+ $message ??= "A connection error occurred during a query. \n" .
+ "Query: $sql\n" .
+ "Function: $fname\n" .
+ "Error: $errno $error\n";
parent::__construct( $db, $error, $errno, $sql, $fname, $message );
}
diff --git a/includes/libs/rdbms/exception/DBQueryError.php b/includes/libs/rdbms/exception/DBQueryError.php
index b0b7d7899e73..af57a82da18b 100644
--- a/includes/libs/rdbms/exception/DBQueryError.php
+++ b/includes/libs/rdbms/exception/DBQueryError.php
@@ -43,11 +43,9 @@ class DBQueryError extends DBExpectedError {
* @param string|null $message Optional message, intended for subclasses (optional)
*/
public function __construct( IDatabase $db, $error, $errno, $sql, $fname, $message = null ) {
- if ( $message === null ) {
- $message = "Error $errno: $error\n" .
- "Function: $fname\n" .
- "Query: $sql\n";
- }
+ $message ??= "Error $errno: $error\n" .
+ "Function: $fname\n" .
+ "Query: $sql\n";
parent::__construct( $db, $message );
diff --git a/includes/media/WebPHandler.php b/includes/media/WebPHandler.php
index c20572a828a7..1e6e0cbd22a7 100644
--- a/includes/media/WebPHandler.php
+++ b/includes/media/WebPHandler.php
@@ -166,15 +166,11 @@ class WebPHandler extends BitmapHandler {
break;
case 'EXIF':
// Spec says ignore all but first one
- if ( $exifData === null ) {
- $exifData = self::extractChunk( $chunk, $filename );
- }
+ $exifData ??= self::extractChunk( $chunk, $filename );
break;
case 'XMP ':
case "XMP\0":
- if ( $xmpData === null ) {
- $xmpData = self::extractChunk( $chunk, $filename );
- }
+ $xmpData ??= self::extractChunk( $chunk, $filename );
break;
}
}
diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php
index 1b5962222f97..3733b64acd26 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -4749,9 +4749,7 @@ class Parser {
$nickname = $this->userOptionsLookup->getOption( $user, 'nickname' );
}
- if ( $fancySig === null ) {
- $fancySig = $this->userOptionsLookup->getBoolOption( $user, 'fancysig' );
- }
+ $fancySig ??= $this->userOptionsLookup->getBoolOption( $user, 'fancysig' );
if ( $nickname === null || $nickname === '' ) {
// Empty value results in the default signature (even when fancysig is enabled)
diff --git a/includes/parser/Parsoid/Config/SiteConfig.php b/includes/parser/Parsoid/Config/SiteConfig.php
index 18582d081d11..663f1a39bf00 100644
--- a/includes/parser/Parsoid/Config/SiteConfig.php
+++ b/includes/parser/Parsoid/Config/SiteConfig.php
@@ -244,13 +244,11 @@ class SiteConfig extends ISiteConfig {
public function metrics(): ?StatsdDataFactoryInterface {
// TODO: inject
static $prefixedMetrics = null;
- if ( $prefixedMetrics === null ) {
- $prefixedMetrics = new PrefixingStatsdDataFactoryProxy(
- // Our stats will also get prefixed with 'MediaWiki.'
- $this->stats,
- $this->getStatsPrefix()
- );
- }
+ $prefixedMetrics ??= new PrefixingStatsdDataFactoryProxy(
+ // Our stats will also get prefixed with 'MediaWiki.'
+ $this->stats,
+ $this->getStatsPrefix()
+ );
return $prefixedMetrics;
}
diff --git a/includes/parser/Parsoid/ParsoidOutputAccess.php b/includes/parser/Parsoid/ParsoidOutputAccess.php
index 6f40ac0fef42..2a57d7491b5a 100644
--- a/includes/parser/Parsoid/ParsoidOutputAccess.php
+++ b/includes/parser/Parsoid/ParsoidOutputAccess.php
@@ -218,9 +218,7 @@ class ParsoidOutputAccess {
}
}
- if ( $revision === null ) {
- $revision = $page->getLatest();
- }
+ $revision ??= $page->getLatest();
if ( is_int( $revision ) ) {
$revId = $revision;
diff --git a/includes/preferences/DefaultPreferencesFactory.php b/includes/preferences/DefaultPreferencesFactory.php
index 3dbfafcd3826..edc0da81658b 100644
--- a/includes/preferences/DefaultPreferencesFactory.php
+++ b/includes/preferences/DefaultPreferencesFactory.php
@@ -2102,9 +2102,7 @@ class DefaultPreferencesFactory implements PreferencesFactory {
public function getResetKinds(
User $user, IContextSource $context, $options = null
): array {
- if ( $options === null ) {
- $options = $this->userOptionsManager->loadUserOptions( $user );
- }
+ $options ??= $this->userOptionsManager->loadUserOptions( $user );
$prefs = $this->getFormDescriptor( $user, $context );
$mapping = [];
diff --git a/includes/site/MediaWikiSite.php b/includes/site/MediaWikiSite.php
index 181b04185ccc..03597f4ac1d1 100644
--- a/includes/site/MediaWikiSite.php
+++ b/includes/site/MediaWikiSite.php
@@ -93,10 +93,7 @@ class MediaWikiSite extends Site {
return $t->getPrefixedText();
} else {
static $mediaWikiPageNameNormalizer = null;
-
- if ( $mediaWikiPageNameNormalizer === null ) {
- $mediaWikiPageNameNormalizer = new MediaWikiPageNameNormalizer();
- }
+ $mediaWikiPageNameNormalizer ??= new MediaWikiPageNameNormalizer();
return $mediaWikiPageNameNormalizer->normalizePageName(
$pageName,
diff --git a/includes/skins/SkinTemplate.php b/includes/skins/SkinTemplate.php
index f386d07c22e1..2afc1d4543f1 100644
--- a/includes/skins/SkinTemplate.php
+++ b/includes/skins/SkinTemplate.php
@@ -365,18 +365,14 @@ class SkinTemplate extends Skin {
* @return string
*/
public function makePersonalToolsList( $personalTools = null, $options = [] ) {
- $html = '';
-
- if ( $personalTools === null ) {
- $personalTools = $this->getPersonalToolsForMakeListItem(
- $this->buildPersonalUrls()
- );
- }
+ $personalTools ??= $this->getPersonalToolsForMakeListItem(
+ $this->buildPersonalUrls()
+ );
+ $html = '';
foreach ( $personalTools as $key => $item ) {
$html .= $this->makeListItem( $key, $item, $options );
}
-
return $html;
}
diff --git a/includes/specialpage/LoginSignupSpecialPage.php b/includes/specialpage/LoginSignupSpecialPage.php
index cc87f421d00b..3fb374eae458 100644
--- a/includes/specialpage/LoginSignupSpecialPage.php
+++ b/includes/specialpage/LoginSignupSpecialPage.php
@@ -648,9 +648,7 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage {
$this->getHookRunner()->onSpecialCreateAccountBenefits(
$benefitsContainerHtml, $info, $options
);
- if ( $benefitsContainerHtml === null ) {
- $benefitsContainerHtml = $this->getBenefitsContainerHtml();
- }
+ $benefitsContainerHtml ??= $this->getBenefitsContainerHtml();
$formAndBenefits = $options['beforeForm']
? ( $benefitsContainerHtml . $formBlock )
: ( $formBlock . $benefitsContainerHtml );
diff --git a/includes/specials/SpecialPrefixIndex.php b/includes/specials/SpecialPrefixIndex.php
index b542358b1b56..c48c74e0ff5d 100644
--- a/includes/specials/SpecialPrefixIndex.php
+++ b/includes/specials/SpecialPrefixIndex.php
@@ -166,9 +166,7 @@ class SpecialPrefixIndex extends SpecialAllPages {
* @param string|null $from List all pages from this name (default false)
*/
protected function showPrefixChunk( $namespace, $prefix, $from = null ) {
- if ( $from === null ) {
- $from = $prefix;
- }
+ $from ??= $prefix;
$fromList = $this->getNamespaceKeyAndText( $namespace, $from );
$prefixList = $this->getNamespaceKeyAndText( $namespace, $prefix );
diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php
index 9e054d634049..8999b515e0c7 100644
--- a/includes/specials/SpecialUndelete.php
+++ b/includes/specials/SpecialUndelete.php
@@ -290,7 +290,7 @@ class SpecialUndelete extends SpecialPage {
* @return bool
*/
protected function isAllowed( $permission, User $user = null ) {
- $user = $user ?: $this->getUser();
+ $user ??= $this->getUser();
$block = $user->getBlock();
if ( $this->mTargetObj !== null ) {
diff --git a/includes/specials/SpecialWhatLinksHere.php b/includes/specials/SpecialWhatLinksHere.php
index 1edc52607fd5..040c33e5f20f 100644
--- a/includes/specials/SpecialWhatLinksHere.php
+++ b/includes/specials/SpecialWhatLinksHere.php
@@ -585,9 +585,7 @@ class SpecialWhatLinksHere extends FormSpecialPage {
protected function wlhLink( Title $target, $text, $editText ) {
static $title = null;
- if ( $title === null ) {
- $title = $this->getPageTitle();
- }
+ $title ??= $this->getPageTitle();
$linkRenderer = $this->getLinkRenderer();
diff --git a/includes/specials/pagers/ImageListPager.php b/includes/specials/pagers/ImageListPager.php
index 56a7b9802063..df3d60f22739 100644
--- a/includes/specials/pagers/ImageListPager.php
+++ b/includes/specials/pagers/ImageListPager.php
@@ -474,9 +474,7 @@ class ImageListPager extends TablePager {
return htmlspecialchars( $this->getLanguage()->userTimeAndDate( $value, $this->getUser() ) );
case 'img_name':
static $imgfile = null;
- if ( $imgfile === null ) {
- $imgfile = $this->msg( 'imgfile' )->text();
- }
+ $imgfile ??= $this->msg( 'imgfile' )->text();
// Weird files can maybe exist? T24227
$filePage = Title::makeTitleSafe( NS_FILE, $value );
diff --git a/includes/title/Title.php b/includes/title/Title.php
index 2266ade83c21..e1b06995f84e 100644
--- a/includes/title/Title.php
+++ b/includes/title/Title.php
@@ -1386,9 +1386,7 @@ class Title implements Stringable, LinkTarget, PageIdentity {
public function isMainPage() {
/** @var Title|null */
static $cachedMainPage;
- if ( $cachedMainPage === null ) {
- $cachedMainPage = self::newMainPage();
- }
+ $cachedMainPage ??= self::newMainPage();
return $this->equals( $cachedMainPage );
}
@@ -2733,9 +2731,7 @@ class Title implements Stringable, LinkTarget, PageIdentity {
* @throws MalformedTitleException On malformed titles
*/
private function secureAndSplit( $text, $defaultNamespace = null ) {
- if ( $defaultNamespace === null ) {
- $defaultNamespace = self::DEFAULT_NAMESPACE;
- }
+ $defaultNamespace ??= self::DEFAULT_NAMESPACE;
// @note: splitTitleString() is a temporary hack to allow MediaWikiTitleCodec to share
// the parsing code with Title, while avoiding massive refactoring.
diff --git a/includes/user/BotPasswordStore.php b/includes/user/BotPasswordStore.php
index 43860d993bbd..ed83ef8f44ad 100644
--- a/includes/user/BotPasswordStore.php
+++ b/includes/user/BotPasswordStore.php
@@ -222,9 +222,7 @@ class BotPasswordStore {
return $res;
}
- if ( $password === null ) {
- $password = PasswordFactory::newInvalidPassword();
- }
+ $password ??= PasswordFactory::newInvalidPassword();
$dbw = $this->getPrimaryDatabase();
$dbw->newInsertQueryBuilder()
diff --git a/includes/user/Options/UserOptionsManager.php b/includes/user/Options/UserOptionsManager.php
index b1a888fb870c..4a4ad5f3aa26 100644
--- a/includes/user/Options/UserOptionsManager.php
+++ b/includes/user/Options/UserOptionsManager.php
@@ -254,9 +254,7 @@ class UserOptionsManager extends UserOptionsLookup {
$global = self::GLOBAL_IGNORE
) {
// Explicitly NULL values should refer to defaults
- if ( $val === null ) {
- $val = $this->defaultOptionsLookup->getDefaultOption( $oname, $user );
- }
+ $val ??= $this->defaultOptionsLookup->getDefaultOption( $oname, $user );
$userKey = $this->getCacheKey( $user );
$info = $this->cache[$userKey] ??= new UserOptionsCacheEntry;
$info->modifiedValues[$oname] = $val;
diff --git a/includes/utils/ZipDirectoryReader.php b/includes/utils/ZipDirectoryReader.php
index b77071b718af..84f59a41e398 100644
--- a/includes/utils/ZipDirectoryReader.php
+++ b/includes/utils/ZipDirectoryReader.php
@@ -540,9 +540,7 @@ class ZipDirectoryReader {
$this->error( 'zip-bad', "getBlock() requested position $start, " .
"file length is $fileLength" );
}
- if ( $length === null ) {
- $length = $fileLength - $start;
- }
+ $length ??= $fileLength - $start;
$end = $start + $length;
if ( $end > $fileLength ) {
$this->error( 'zip-bad', "getBlock() requested end position $end, " .
diff --git a/includes/watchlist/WatchedItemStore.php b/includes/watchlist/WatchedItemStore.php
index 5f344356fbd9..924ea26b076b 100644
--- a/includes/watchlist/WatchedItemStore.php
+++ b/includes/watchlist/WatchedItemStore.php
@@ -1565,10 +1565,7 @@ class WatchedItemStore implements WatchedItemStoreInterface {
return null;
}
- if ( $item === null ) {
- $item = $this->loadWatchedItem( $user, $title );
- }
-
+ $item ??= $this->loadWatchedItem( $user, $title );
if ( !$item ) {
// This can only happen if $force is enabled.
return null;
diff --git a/includes/xml/Xml.php b/includes/xml/Xml.php
index c048592c7d87..43202ab9f002 100644
--- a/includes/xml/Xml.php
+++ b/includes/xml/Xml.php
@@ -258,9 +258,7 @@ class Xml {
$attrs = [ 'id' => 'wpUserLanguage', 'name' => 'wpUserLanguage' ];
$attrs = array_merge( $attrs, $overrideAttrs );
- if ( $msg === null ) {
- $msg = wfMessage( 'yourlanguage' );
- }
+ $msg ??= wfMessage( 'yourlanguage' );
return [
self::label( $msg->text(), $attrs['id'] ),
self::tags( 'select', $attrs, $options )
diff --git a/maintenance/includes/BackupDumper.php b/maintenance/includes/BackupDumper.php
index d98fc098b97d..60aa9944b9f4 100644
--- a/maintenance/includes/BackupDumper.php
+++ b/maintenance/includes/BackupDumper.php
@@ -259,9 +259,7 @@ abstract class BackupDumper extends Maintenance {
break;
case 'filter':
- if ( $sink === null ) {
- $sink = new DumpOutput();
- }
+ $sink ??= new DumpOutput();
$split = explode( ':', $param, 2 );
$key = $split[0];
@@ -303,9 +301,7 @@ abstract class BackupDumper extends Maintenance {
$this->server = $this->getOption( 'server' );
}
- if ( $sink === null ) {
- $sink = new DumpOutput();
- }
+ $sink ??= new DumpOutput();
$sinks[] = $sink;
if ( count( $sinks ) > 1 ) {
diff --git a/maintenance/includes/Maintenance.php b/maintenance/includes/Maintenance.php
index 21b92d11e502..afb9f74db4e5 100644
--- a/maintenance/includes/Maintenance.php
+++ b/maintenance/includes/Maintenance.php
@@ -1258,9 +1258,7 @@ abstract class Maintenance {
*/
public static function readconsole( $prompt = '> ' ) {
static $isatty = null;
- if ( $isatty === null ) {
- $isatty = self::posix_isatty( 0 /*STDIN*/ );
- }
+ $isatty ??= self::posix_isatty( 0 /*STDIN*/ );
if ( $isatty && function_exists( 'readline' ) ) {
return readline( $prompt );
diff --git a/maintenance/includes/TextPassDumper.php b/maintenance/includes/TextPassDumper.php
index f0941f8a0c11..2acaf8b77d30 100644
--- a/maintenance/includes/TextPassDumper.php
+++ b/maintenance/includes/TextPassDumper.php
@@ -631,11 +631,7 @@ TEXT
(int)$this->thisPage,
(int)$this->thisRev,
trim( $this->thisRole )
- );
-
- if ( $text === null ) {
- $text = false;
- }
+ ) ?? false;
if ( is_string( $text ) && $model !== null ) {
// Apply export transformation to text coming from an old dump.
diff --git a/maintenance/storage/moveToExternal.php b/maintenance/storage/moveToExternal.php
index 3483ccc23218..906a633eaf25 100644
--- a/maintenance/storage/moveToExternal.php
+++ b/maintenance/storage/moveToExternal.php
@@ -84,13 +84,10 @@ class MoveToExternal extends Maintenance {
$this->esLocation = $this->getArg( 1 ); // e.g. "cluster12" or "global-swift"
$dbw = $this->getPrimaryDB();
- $maxID = $this->getOption( 'end' );
- if ( $maxID === null ) {
- $maxID = $dbw->newSelectQueryBuilder()
- ->select( 'MAX(old_id)' )
- ->from( 'text' )
- ->caller( __METHOD__ )->fetchField();
- }
+ $maxID = $this->getOption( 'end' ) ?? $dbw->newSelectQueryBuilder()
+ ->select( 'MAX(old_id)' )
+ ->from( 'text' )
+ ->caller( __METHOD__ )->fetchField();
$this->maxID = (int)$maxID;
$this->minID = (int)$this->getOption( 'start', 1 );