Use PHP 7 '??' operator instead of if-then-else
Change-Id: Ia86f8433f30a166d38ee63d0d1745b26740767b9
This commit is contained in:
parent
3c25fc54a0
commit
512aa4e551
13 changed files with 16 additions and 73 deletions
|
|
@ -2038,10 +2038,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
|
|||
$options = [ $options ];
|
||||
}
|
||||
|
||||
$fh = null;
|
||||
if ( isset( $options['fileHandle'] ) ) {
|
||||
$fh = $options['fileHandle'];
|
||||
}
|
||||
$fh = $options['fileHandle'] ?? null;
|
||||
$options = $this->makeInsertOptions( $options );
|
||||
|
||||
if ( isset( $a[0] ) && is_array( $a[0] ) ) {
|
||||
|
|
|
|||
|
|
@ -399,11 +399,7 @@ class ConverterRule {
|
|||
case 'N':
|
||||
// process N flag: output current variant name
|
||||
$ruleVar = trim( $rules );
|
||||
if ( isset( $this->mConverter->mVariantNames[$ruleVar] ) ) {
|
||||
$this->mRuleDisplay = $this->mConverter->mVariantNames[$ruleVar];
|
||||
} else {
|
||||
$this->mRuleDisplay = '';
|
||||
}
|
||||
$this->mRuleDisplay = $this->mConverter->mVariantNames[$ruleVar] ?? '';
|
||||
break;
|
||||
case 'D':
|
||||
// process D flag: output rules description
|
||||
|
|
|
|||
|
|
@ -3227,12 +3227,8 @@ class Language {
|
|||
$this->doMagicHook();
|
||||
}
|
||||
|
||||
if ( isset( $this->mMagicExtensions[$mw->mId] ) ) {
|
||||
$rawEntry = $this->mMagicExtensions[$mw->mId];
|
||||
} else {
|
||||
$rawEntry = self::$dataCache->getSubitem(
|
||||
$this->mCode, 'magicWords', $mw->mId );
|
||||
}
|
||||
$rawEntry = $this->mMagicExtensions[$mw->mId] ??
|
||||
self::$dataCache->getSubitem( $this->mCode, 'magicWords', $mw->mId );
|
||||
|
||||
if ( !is_array( $rawEntry ) ) {
|
||||
wfWarn( "\"$rawEntry\" is not a valid magic word for \"$mw->mId\"" );
|
||||
|
|
@ -5063,10 +5059,6 @@ class Language {
|
|||
public function getPluralRuleType( $number ) {
|
||||
$index = $this->getPluralRuleIndexNumber( $number );
|
||||
$pluralRuleTypes = $this->getPluralRuleTypes();
|
||||
if ( isset( $pluralRuleTypes[$index] ) ) {
|
||||
return $pluralRuleTypes[$index];
|
||||
} else {
|
||||
return 'other';
|
||||
}
|
||||
return $pluralRuleTypes[$index] ?? 'other';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,10 +163,7 @@ class LanguageCode {
|
|||
* @since 1.30
|
||||
*/
|
||||
public static function replaceDeprecatedCodes( $code ) {
|
||||
if ( isset( self::$deprecatedLanguageCodeMapping[$code] ) ) {
|
||||
return self::$deprecatedLanguageCodeMapping[$code];
|
||||
}
|
||||
return $code;
|
||||
return self::$deprecatedLanguageCodeMapping[$code] ?? $code;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -140,10 +140,7 @@ class LanguageConverter {
|
|||
* main code if there is no fallback
|
||||
*/
|
||||
public function getVariantFallbacks( $variant ) {
|
||||
if ( isset( $this->mVariantFallbacks[$variant] ) ) {
|
||||
return $this->mVariantFallbacks[$variant];
|
||||
}
|
||||
return $this->mMainLanguageCode;
|
||||
return $this->mVariantFallbacks[$variant] ?? $this->mMainLanguageCode;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -247,11 +247,7 @@ class GenerateCollationData extends Maintenance {
|
|||
if ( $weight !== $prevWeight ) {
|
||||
$this->groups[$prevWeight] = $group;
|
||||
$prevWeight = $weight;
|
||||
if ( isset( $this->groups[$weight] ) ) {
|
||||
$group = $this->groups[$weight];
|
||||
} else {
|
||||
$group = [];
|
||||
}
|
||||
$group = $this->groups[$weight] ?? [];
|
||||
}
|
||||
$group[] = $cp;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,11 +29,7 @@ if ( !defined( 'MEDIAWIKI' ) ) {
|
|||
|
||||
$cs = new CheckStorage;
|
||||
$fix = isset( $options['fix'] );
|
||||
if ( isset( $args[0] ) ) {
|
||||
$xml = $args[0];
|
||||
} else {
|
||||
$xml = false;
|
||||
}
|
||||
$xml = $args[0] ?? false;
|
||||
$cs->check( $fix, $xml );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -255,11 +255,7 @@ class FixT22757 extends Maintenance {
|
|||
|
||||
function findTextIdInPage( $pageId, $textId ) {
|
||||
$ids = $this->getRevTextMap( $pageId );
|
||||
if ( !isset( $ids[$textId] ) ) {
|
||||
return null;
|
||||
} else {
|
||||
return $ids[$textId];
|
||||
}
|
||||
return $ids[$textId] ?? null;
|
||||
}
|
||||
|
||||
function getRevTextMap( $pageId ) {
|
||||
|
|
|
|||
|
|
@ -38,11 +38,7 @@ if ( !defined( 'MEDIAWIKI' ) ) {
|
|||
$cluster = $args[0];
|
||||
$dbw = wfGetDB( DB_MASTER );
|
||||
|
||||
if ( isset( $options['e'] ) ) {
|
||||
$maxID = $options['e'];
|
||||
} else {
|
||||
$maxID = $dbw->selectField( 'text', 'MAX(old_id)', '', $fname );
|
||||
}
|
||||
$maxID = $options['e'] ?? $dbw->selectField( 'text', 'MAX(old_id)', '', $fname );
|
||||
$minID = $options['s'] ?? 1;
|
||||
|
||||
moveToExternal( $cluster, $maxID, $minID );
|
||||
|
|
|
|||
|
|
@ -304,11 +304,7 @@ TEXT
|
|||
if ( $raw !== '' ) {
|
||||
$raw .= ', ';
|
||||
}
|
||||
if ( !isset( $this->sizeHistogram[$i] ) ) {
|
||||
$val = 0;
|
||||
} else {
|
||||
$val = $this->sizeHistogram[$i];
|
||||
}
|
||||
$val = $this->sizeHistogram[$i] ?? 0;
|
||||
for ( $coarseIndex = 0; $coarseIndex < $numBins - 1; $coarseIndex++ ) {
|
||||
if ( $coarseBoundaries[$coarseIndex] > $i ) {
|
||||
$coarseHistogram[$coarseIndex] += $val;
|
||||
|
|
@ -327,11 +323,7 @@ TEXT
|
|||
$scale = 60 / $maxBinVal;
|
||||
$prevBoundary = 0;
|
||||
for ( $coarseIndex = 0; $coarseIndex < $numBins; $coarseIndex++ ) {
|
||||
if ( !isset( $coarseHistogram[$coarseIndex] ) ) {
|
||||
$val = 0;
|
||||
} else {
|
||||
$val = $coarseHistogram[$coarseIndex];
|
||||
}
|
||||
$val = $coarseHistogram[$coarseIndex] ?? 0;
|
||||
$boundary = $coarseBoundaries[$coarseIndex];
|
||||
$this->output( sprintf( "%-10s %-10d |%s\n",
|
||||
$prevBoundary . '-' . ( $boundary - 1 ) . ': ',
|
||||
|
|
|
|||
|
|
@ -338,11 +338,7 @@ $res = $dbr->select(
|
|||
[ 'ORDER BY' => 'pf_name ASC' ]
|
||||
);
|
||||
|
||||
if ( isset( $_REQUEST['filter'] ) ) {
|
||||
$filter = $_REQUEST['filter'];
|
||||
} else {
|
||||
$filter = '';
|
||||
}
|
||||
$filter = $_REQUEST['filter'] ?? '';
|
||||
|
||||
?>
|
||||
<form method="get" action="profileinfo.php">
|
||||
|
|
|
|||
|
|
@ -230,11 +230,7 @@ spl_autoload_register( function ( $class ) {
|
|||
'PHPUnit_Framework_Error' => 'PHPUnit\Framework\Error\Error',
|
||||
];
|
||||
|
||||
if ( isset( $map[$class] ) ) {
|
||||
$newForm = $map[$class];
|
||||
} else {
|
||||
$newForm = str_replace( '_', '\\', $class );
|
||||
}
|
||||
$newForm = $map[$class] ?? str_replace( '_', '\\', $class );
|
||||
|
||||
if ( class_exists( $newForm ) || interface_exists( $newForm ) ) {
|
||||
// If the new class name exists, alias
|
||||
|
|
|
|||
|
|
@ -49,11 +49,7 @@ class ParserTestParserHook {
|
|||
&& $argv['action'] === 'flush' && $in === null
|
||||
) {
|
||||
// Clear the buffer, we probably don't need to
|
||||
if ( isset( $parser->static_tag_buf ) ) {
|
||||
$tmp = $parser->static_tag_buf;
|
||||
} else {
|
||||
$tmp = '';
|
||||
}
|
||||
$tmp = $parser->static_tag_buf ?? '';
|
||||
$parser->static_tag_buf = null;
|
||||
return $tmp;
|
||||
} else { // wtf?
|
||||
|
|
|
|||
Loading…
Reference in a new issue