Merge "Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient"

This commit is contained in:
jenkins-bot 2018-05-31 19:01:07 +00:00 committed by Gerrit Code Review
commit 5a6c78c441
235 changed files with 633 additions and 955 deletions

View file

@ -76,7 +76,7 @@ class AjaxDispatcher {
switch ( $this->mode ) {
case 'get':
$this->func_name = isset( $_GET["rs"] ) ? $_GET["rs"] : '';
$this->func_name = $_GET["rs"] ?? '';
if ( !empty( $_GET["rsargs"] ) ) {
$this->args = $_GET["rsargs"];
} else {
@ -84,7 +84,7 @@ class AjaxDispatcher {
}
break;
case 'post':
$this->func_name = isset( $_POST["rs"] ) ? $_POST["rs"] : '';
$this->func_name = $_POST["rs"] ?? '';
if ( !empty( $_POST["rsargs"] ) ) {
$this->args = $_POST["rsargs"];
} else {

View file

@ -458,7 +458,7 @@ class Block {
protected function initFromRow( $row ) {
$this->setTarget( $row->ipb_address );
$this->setBlocker( User::newFromAnyId(
$row->ipb_by, $row->ipb_by_text, isset( $row->ipb_by_actor ) ? $row->ipb_by_actor : null
$row->ipb_by, $row->ipb_by_text, $row->ipb_by_actor ?? null
) );
$this->mTimestamp = wfTimestamp( TS_MW, $row->ipb_timestamp );

View file

@ -261,7 +261,7 @@ class CommentStore {
private function getCommentInternal( IDatabase $db = null, $key, $row, $fallback = false ) {
$row = (array)$row;
if ( array_key_exists( "{$key}_text", $row ) && array_key_exists( "{$key}_data", $row ) ) {
$cid = isset( $row["{$key}_cid"] ) ? $row["{$key}_cid"] : null;
$cid = $row["{$key}_cid"] ?? null;
$text = $row["{$key}_text"];
$data = $row["{$key}_data"];
} elseif ( $this->stage === MIGRATION_OLD ) {

View file

@ -1578,7 +1578,7 @@ class EditPage {
$query = $query . '&' . $extraQueryRedirect;
}
}
$anchor = isset( $resultDetails['sectionanchor'] ) ? $resultDetails['sectionanchor'] : '';
$anchor = $resultDetails['sectionanchor'] ?? '';
$out->redirect( $this->mTitle->getFullURL( $query ) . $anchor );
return false;
@ -4195,7 +4195,7 @@ ERROR;
$checkboxesDef = $this->getCheckboxesDefinition( $checked );
foreach ( $checkboxesDef as $name => $options ) {
$legacyName = isset( $options['legacy-name'] ) ? $options['legacy-name'] : $name;
$legacyName = $options['legacy-name'] ?? $name;
$title = null;
$accesskey = null;
@ -4221,7 +4221,7 @@ ERROR;
'align' => 'inline',
'label' => new OOUI\HtmlSnippet( $this->context->msg( $options['label-message'] )->parse() ),
'title' => $title,
'id' => isset( $options['label-id'] ) ? $options['label-id'] : null,
'id' => $options['label-id'] ?? null,
]
);
}

View file

@ -121,7 +121,7 @@ class FauxRequest extends WebRequest {
$prefix = $wgCookiePrefix;
}
$name = $prefix . $key;
return isset( $this->cookies[$name] ) ? $this->cookies[$name] : $default;
return $this->cookies[$name] ?? $default;
}
/**

View file

@ -1516,7 +1516,7 @@ function wfBacktrace( $raw = null ) {
$frames = array_map( function ( $frame ) use ( $frameFormat ) {
$file = !empty( $frame['file'] ) ? basename( $frame['file'] ) : '-';
$line = isset( $frame['line'] ) ? $frame['line'] : '-';
$line = $frame['line'] ?? '-';
$call = $frame['function'];
if ( !empty( $frame['class'] ) ) {
$call = $frame['class'] . $frame['type'] . $call;
@ -2241,7 +2241,7 @@ function wfShellExec( $cmd, &$retval = null, $environ = [],
}
$includeStderr = isset( $options['duplicateStderr'] ) && $options['duplicateStderr'];
$profileMethod = isset( $options['profileMethod'] ) ? $options['profileMethod'] : wfGetCaller();
$profileMethod = $options['profileMethod'] ?? wfGetCaller();
try {
$result = Shell::command( [] )

View file

@ -391,8 +391,8 @@ class Html {
unset( $attribs['type'] );
}
if ( $element === 'input' ) {
$type = isset( $attribs['type'] ) ? $attribs['type'] : null;
$value = isset( $attribs['value'] ) ? $attribs['value'] : null;
$type = $attribs['type'] ?? null;
$value = $attribs['value'] ?? null;
if ( $type === 'checkbox' || $type === 'radio' ) {
// The default value for checkboxes and radio buttons is 'on'
// not ''. By stripping value="" we break radio boxes that
@ -925,7 +925,7 @@ class Html {
if ( isset( $params['label'] ) ) {
$ret .= self::element(
'label', [
'for' => isset( $selectAttribs['id'] ) ? $selectAttribs['id'] : null,
'for' => $selectAttribs['id'] ?? null,
], $params['label']
) . ' ';
}

View file

@ -338,7 +338,7 @@ class Linker {
}
// Clean up parameters
$page = isset( $handlerParams['page'] ) ? $handlerParams['page'] : false;
$page = $handlerParams['page'] ?? false;
if ( !isset( $frameParams['align'] ) ) {
$frameParams['align'] = '';
}
@ -442,7 +442,7 @@ class Linker {
$params = [
'alt' => $frameParams['alt'],
'title' => $frameParams['title'],
'valign' => isset( $frameParams['valign'] ) ? $frameParams['valign'] : false,
'valign' => $frameParams['valign'] ?? false,
'img-class' => $frameParams['class'] ];
if ( isset( $frameParams['border'] ) ) {
$params['img-class'] .= ( $params['img-class'] !== '' ? ' ' : '' ) . 'thumbborder';
@ -535,7 +535,7 @@ class Linker {
) {
$exists = $file && $file->exists();
$page = isset( $handlerParams['page'] ) ? $handlerParams['page'] : false;
$page = $handlerParams['page'] ?? false;
if ( !isset( $frameParams['align'] ) ) {
$frameParams['align'] = 'right';
}

View file

@ -472,9 +472,7 @@ class MWNamespace {
*/
public static function getNamespaceContentModel( $index ) {
global $wgNamespaceContentModels;
return isset( $wgNamespaceContentModels[$index] )
? $wgNamespaceContentModels[$index]
: null;
return $wgNamespaceContentModels[$index] ?? null;
}
/**

View file

@ -939,7 +939,7 @@ class MediaWiki {
try {
$statsdServer = explode( ':', $config->get( 'StatsdServer' ) );
$statsdHost = $statsdServer[0];
$statsdPort = isset( $statsdServer[1] ) ? $statsdServer[1] : 8125;
$statsdPort = $statsdServer[1] ?? 8125;
$statsdSender = new SocketSender( $statsdHost, $statsdPort );
$statsdClient = new SamplingStatsdClient( $statsdSender, true, false );
$statsdClient->setSamplingRates( $config->get( 'StatsdSamplingRates' ) );

View file

@ -52,7 +52,7 @@ try {
echo $templateParser->processTemplate(
'NoLocalSettings',
[
'wgVersion' => ( isset( $wgVersion ) ? $wgVersion : 'VERSION' ),
'wgVersion' => ( $wgVersion ?? 'VERSION' ),
'path' => $path,
'localSettingsExists' => file_exists( MW_CONFIG_FILE ),
'installerStarted' => $installerStarted

View file

@ -642,9 +642,7 @@ class OutputPage extends ContextSource {
// Register a callback for $this->contentOverrides on the first call
$this->addContentOverrideCallback( function ( LinkTarget $target ) {
$key = $target->getNamespace() . ':' . $target->getDBkey();
return isset( $this->contentOverrides[$key] )
? $this->contentOverrides[$key]
: null;
return $this->contentOverrides[$key] ?? null;
} );
}
@ -1516,9 +1514,7 @@ class OutputPage extends ContextSource {
if ( $type == ResourceLoaderModule::TYPE_COMBINED ) {
return min( array_values( $this->mAllowedModules ) );
} else {
return isset( $this->mAllowedModules[$type] )
? $this->mAllowedModules[$type]
: ResourceLoaderModule::ORIGIN_ALL;
return $this->mAllowedModules[$type] ?? ResourceLoaderModule::ORIGIN_ALL;
}
}
@ -3904,7 +3900,7 @@ class OutputPage extends ContextSource {
*/
public static function setupOOUI( $skinName = 'default', $dir = 'ltr' ) {
$themes = ResourceLoaderOOUIModule::getSkinThemeMap();
$theme = isset( $themes[$skinName] ) ? $themes[$skinName] : $themes['default'];
$theme = $themes[$skinName] ?? $themes['default'];
// For example, 'OOUI\WikimediaUITheme'.
$themeClass = "OOUI\\{$theme}Theme";
OOUI\Theme::setSingleton( new $themeClass() );

View file

@ -211,7 +211,7 @@ abstract class PrefixSearch {
$searchParts = explode( '/', $search, 2 );
$searchKey = $searchParts[0];
$subpageSearch = isset( $searchParts[1] ) ? $searchParts[1] : null;
$subpageSearch = $searchParts[1] ?? null;
// Handle subpage search separately.
if ( $subpageSearch !== null ) {

View file

@ -581,11 +581,11 @@ class Revision implements IDBAccessObject {
return $row['title'];
}
$pageId = isset( $row['page'] ) ? $row['page'] : 0;
$revId = isset( $row['id'] ) ? $row['id'] : 0;
$pageId = $row['page'] ?? 0;
$revId = $row['id'] ?? 0;
} else {
$pageId = isset( $row->rev_page ) ? $row->rev_page : 0;
$revId = isset( $row->rev_id ) ? $row->rev_id : 0;
$pageId = $row->rev_page ?? 0;
$revId = $row->rev_id ?? 0;
}
try {

View file

@ -415,9 +415,7 @@ return [
foreach ( $config['paths'] as $prefix => $serviceConfig ) {
$class = $serviceConfig['class'];
// Merge in the global defaults
$constructArg = isset( $serviceConfig['options'] )
? $serviceConfig['options']
: [];
$constructArg = $serviceConfig['options'] ?? [];
$constructArg += $config['global'];
// Make the VRS service available at the mount point
$vrsClient->mount( $prefix, [ 'class' => $class, 'config' => $constructArg ] );

View file

@ -1117,9 +1117,9 @@ class RevisionStore
try {
$user = User::newFromAnyId(
isset( $row->ar_user ) ? $row->ar_user : null,
isset( $row->ar_user_text ) ? $row->ar_user_text : null,
isset( $row->ar_actor ) ? $row->ar_actor : null
$row->ar_user ?? null,
$row->ar_user_text ?? null,
$row->ar_actor ?? null
);
} catch ( InvalidArgumentException $ex ) {
wfWarn( __METHOD__ . ': ' . $ex->getMessage() );
@ -1153,8 +1153,8 @@ class RevisionStore
Assert::parameterType( 'object', $row, '$row' );
if ( !$title ) {
$pageId = isset( $row->rev_page ) ? $row->rev_page : 0; // XXX: also check page_id?
$revId = isset( $row->rev_id ) ? $row->rev_id : 0;
$pageId = $row->rev_page ?? 0; // XXX: also check page_id?
$revId = $row->rev_id ?? 0;
$title = $this->getTitle( $pageId, $revId, $queryFlags );
}
@ -1168,9 +1168,9 @@ class RevisionStore
try {
$user = User::newFromAnyId(
isset( $row->rev_user ) ? $row->rev_user : null,
isset( $row->rev_user_text ) ? $row->rev_user_text : null,
isset( $row->rev_actor ) ? $row->rev_actor : null
$row->rev_user ?? null,
$row->rev_user_text ?? null,
$row->rev_actor ?? null
);
} catch ( InvalidArgumentException $ex ) {
wfWarn( __METHOD__ . ': ' . $ex->getMessage() );
@ -1230,8 +1230,8 @@ class RevisionStore
}
if ( !$title ) {
$pageId = isset( $fields['page'] ) ? $fields['page'] : 0;
$revId = isset( $fields['id'] ) ? $fields['id'] : 0;
$pageId = $fields['page'] ?? 0;
$revId = $fields['id'] ?? 0;
$title = $this->getTitle( $pageId, $revId, $queryFlags );
}
@ -1258,7 +1258,7 @@ class RevisionStore
isset( $fields['comment'] )
&& !( $fields['comment'] instanceof CommentStoreComment )
) {
$commentData = isset( $fields['comment_data'] ) ? $fields['comment_data'] : null;
$commentData = $fields['comment_data'] ?? null;
if ( $fields['comment'] instanceof Message ) {
$fields['comment'] = CommentStoreComment::newUnsavedComment(
@ -1299,9 +1299,9 @@ class RevisionStore
} else {
try {
$user = User::newFromAnyId(
isset( $fields['user'] ) ? $fields['user'] : null,
isset( $fields['user_text'] ) ? $fields['user_text'] : null,
isset( $fields['actor'] ) ? $fields['actor'] : null
$fields['user'] ?? null,
$fields['user_text'] ?? null,
$fields['actor'] ?? null
);
} catch ( InvalidArgumentException $ex ) {
$user = null;

View file

@ -3086,9 +3086,7 @@ class Title implements LinkTarget {
if ( !$this->mRestrictionsLoaded ) {
$this->loadRestrictions();
}
return isset( $this->mRestrictions[$action] )
? $this->mRestrictions[$action]
: [];
return $this->mRestrictions[$action] ?? [];
}
/**
@ -3116,7 +3114,7 @@ class Title implements LinkTarget {
if ( !$this->mRestrictionsLoaded ) {
$this->loadRestrictions();
}
return isset( $this->mRestrictionsExpiry[$action] ) ? $this->mRestrictionsExpiry[$action] : false;
return $this->mRestrictionsExpiry[$action] ?? false;
}
/**

View file

@ -129,7 +129,7 @@ class WebRequest {
$a = parse_url( $url );
Wikimedia\restoreWarnings();
if ( $a ) {
$path = isset( $a['path'] ) ? $a['path'] : '';
$path = $a['path'] ?? '';
global $wgScript;
if ( $path == $wgScript && $want !== 'all' ) {
@ -275,8 +275,7 @@ class WebRequest {
// This method is called from various error handlers and should be kept simple.
if ( !self::$reqId ) {
self::$reqId = isset( $_SERVER['UNIQUE_ID'] )
? $_SERVER['UNIQUE_ID'] : wfRandomString( 24 );
self::$reqId = $_SERVER['UNIQUE_ID'] ?? wfRandomString( 24 );
}
return self::$reqId;
@ -458,7 +457,7 @@ class WebRequest {
* @return mixed Old value if one was present, null otherwise
*/
public function setVal( $key, $value ) {
$ret = isset( $this->data[$key] ) ? $this->data[$key] : null;
$ret = $this->data[$key] ?? null;
$this->data[$key] = $value;
return $ret;
}
@ -714,7 +713,7 @@ class WebRequest {
* @return string
*/
public function getMethod() {
return isset( $_SERVER['REQUEST_METHOD'] ) ? $_SERVER['REQUEST_METHOD'] : 'GET';
return $_SERVER['REQUEST_METHOD'] ?? 'GET';
}
/**

View file

@ -104,7 +104,7 @@ class WikiMap {
$path .= '?' . $urlParts['query'];
}
$canonicalServer = isset( $urlParts['scheme'] ) ? $urlParts['scheme'] : 'http';
$canonicalServer = $urlParts['scheme'] ?? 'http';
$canonicalServer .= '://' . $urlParts['host'];
return new WikiReference( $canonicalServer, $path );

View file

@ -711,9 +711,7 @@ class HistoryPager extends ReverseChronologicalPager {
# Sometimes rev_len isn't populated
if ( $rev->getSize() !== null ) {
# Size is always public data
$prevSize = isset( $this->parentLens[$row->rev_parent_id] )
? $this->parentLens[$row->rev_parent_id]
: 0;
$prevSize = $this->parentLens[$row->rev_parent_id] ?? 0;
$sDiff = ChangesList::showCharacterDifference( $prevSize, $rev->getSize() );
$fSize = Linker::formatRevisionSize( $rev->getSize() );
$s .= ' <span class="mw-changeslist-separator">. .</span> ' . "$fSize $sDiff";

View file

@ -48,7 +48,7 @@ class ApiAuthManagerHelper {
$this->module = $module;
$params = $module->extractRequestParams();
$this->messageFormat = isset( $params['messageformat'] ) ? $params['messageformat'] : 'wikitext';
$this->messageFormat = $params['messageformat'] ?? 'wikitext';
}
/**

View file

@ -1156,36 +1156,16 @@ abstract class ApiBase extends ContextSource {
];
}
$default = isset( $paramSettings[self::PARAM_DFLT] )
? $paramSettings[self::PARAM_DFLT]
: null;
$multi = isset( $paramSettings[self::PARAM_ISMULTI] )
? $paramSettings[self::PARAM_ISMULTI]
: false;
$multiLimit1 = isset( $paramSettings[self::PARAM_ISMULTI_LIMIT1] )
? $paramSettings[self::PARAM_ISMULTI_LIMIT1]
: null;
$multiLimit2 = isset( $paramSettings[self::PARAM_ISMULTI_LIMIT2] )
? $paramSettings[self::PARAM_ISMULTI_LIMIT2]
: null;
$type = isset( $paramSettings[self::PARAM_TYPE] )
? $paramSettings[self::PARAM_TYPE]
: null;
$dupes = isset( $paramSettings[self::PARAM_ALLOW_DUPLICATES] )
? $paramSettings[self::PARAM_ALLOW_DUPLICATES]
: false;
$deprecated = isset( $paramSettings[self::PARAM_DEPRECATED] )
? $paramSettings[self::PARAM_DEPRECATED]
: false;
$deprecatedValues = isset( $paramSettings[self::PARAM_DEPRECATED_VALUES] )
? $paramSettings[self::PARAM_DEPRECATED_VALUES]
: [];
$required = isset( $paramSettings[self::PARAM_REQUIRED] )
? $paramSettings[self::PARAM_REQUIRED]
: false;
$allowAll = isset( $paramSettings[self::PARAM_ALL] )
? $paramSettings[self::PARAM_ALL]
: false;
$default = $paramSettings[self::PARAM_DFLT] ?? null;
$multi = $paramSettings[self::PARAM_ISMULTI] ?? false;
$multiLimit1 = $paramSettings[self::PARAM_ISMULTI_LIMIT1] ?? null;
$multiLimit2 = $paramSettings[self::PARAM_ISMULTI_LIMIT2] ?? null;
$type = $paramSettings[self::PARAM_TYPE] ?? null;
$dupes = $paramSettings[self::PARAM_ALLOW_DUPLICATES] ?? false;
$deprecated = $paramSettings[self::PARAM_DEPRECATED] ?? false;
$deprecatedValues = $paramSettings[self::PARAM_DEPRECATED_VALUES] ?? [];
$required = $paramSettings[self::PARAM_REQUIRED] ?? false;
$allowAll = $paramSettings[self::PARAM_ALL] ?? false;
// When type is not given, and no choices, the type is the same as $default
if ( !isset( $type ) ) {
@ -1313,10 +1293,9 @@ abstract class ApiBase extends ContextSource {
}
break;
case 'integer': // Force everything using intval() and optionally validate limits
$min = isset( $paramSettings[self::PARAM_MIN] ) ? $paramSettings[self::PARAM_MIN] : null;
$max = isset( $paramSettings[self::PARAM_MAX] ) ? $paramSettings[self::PARAM_MAX] : null;
$enforceLimits = isset( $paramSettings[self::PARAM_RANGE_ENFORCE] )
? $paramSettings[self::PARAM_RANGE_ENFORCE] : false;
$min = $paramSettings[self::PARAM_MIN] ?? null;
$max = $paramSettings[self::PARAM_MAX] ?? null;
$enforceLimits = $paramSettings[self::PARAM_RANGE_ENFORCE] ?? false;
if ( is_array( $value ) ) {
$value = array_map( 'intval', $value );
@ -1348,7 +1327,7 @@ abstract class ApiBase extends ContextSource {
if ( $multi ) {
self::dieDebug( __METHOD__, "Multi-values not supported for $encParamName" );
}
$min = isset( $paramSettings[self::PARAM_MIN] ) ? $paramSettings[self::PARAM_MIN] : 0;
$min = $paramSettings[self::PARAM_MIN] ?? 0;
if ( $value == 'max' ) {
$value = $this->getMain()->canApiHighLimits()
? $paramSettings[self::PARAM_MAX2]
@ -2335,7 +2314,7 @@ abstract class ApiBase extends ContextSource {
'api-help-param-token',
$this->needsToken(),
],
] + ( isset( $params['token'] ) ? $params['token'] : [] );
] + ( $params['token'] ?? [] );
}
// Avoid PHP 7.1 warning of passing $this by reference
@ -2375,7 +2354,7 @@ abstract class ApiBase extends ContextSource {
$settings = [];
}
$d = isset( $desc[$param] ) ? $desc[$param] : '';
$d = $desc[$param] ?? '';
if ( is_array( $d ) ) {
// Special handling for prop parameters
$d = array_map( function ( $line ) {
@ -2457,9 +2436,7 @@ abstract class ApiBase extends ContextSource {
}
$valueMsgs = $settings[self::PARAM_HELP_MSG_PER_VALUE];
$deprecatedValues = isset( $settings[self::PARAM_DEPRECATED_VALUES] )
? $settings[self::PARAM_DEPRECATED_VALUES]
: [];
$deprecatedValues = $settings[self::PARAM_DEPRECATED_VALUES] ?? [];
foreach ( $settings[self::PARAM_TYPE] as $value ) {
if ( isset( $valueMsgs[$value] ) ) {
@ -2811,7 +2788,7 @@ abstract class ApiBase extends ContextSource {
if ( !$msg instanceof IApiMessage ) {
$key = $msg->getKey();
$params = $msg->getParams();
array_unshift( $params, isset( self::$messageMap[$key] ) ? self::$messageMap[$key] : $key );
array_unshift( $params, self::$messageMap[$key] ?? $key );
$msg = ApiMessage::create( $params );
}

View file

@ -176,8 +176,8 @@ class ApiCSPReport extends ApiBase {
$flagText = '[' . implode( ', ', $flags ) . ']';
}
$blockedFile = isset( $report['blocked-uri'] ) ? $report['blocked-uri'] : 'n/a';
$page = isset( $report['document-uri'] ) ? $report['document-uri'] : 'n/a';
$blockedFile = $report['blocked-uri'] ?? 'n/a';
$page = $report['document-uri'] ?? 'n/a';
$line = isset( $report['line-number'] ) ? ':' . $report['line-number'] : '';
$warningText = $flagText .
' Received CSP report: <' . $blockedFile .

View file

@ -203,7 +203,7 @@ class ApiErrorFormatter {
public function formatException( $exception, array $options = [] ) {
return $this->formatMessage(
$this->getMessageFromException( $exception, $options ),
isset( $options['format'] ) ? $options['format'] : null
$options['format'] ?? null
);
}

View file

@ -144,7 +144,7 @@ class ApiFeedWatchlist extends ApiBase {
' [' . $this->getConfig()->get( 'LanguageCode' ) . ']';
$feedUrl = SpecialPage::getTitleFor( 'Watchlist' )->getFullURL();
$feedFormat = isset( $params['feedformat'] ) ? $params['feedformat'] : 'rss';
$feedFormat = $params['feedformat'] ?? 'rss';
$msg = wfMessage( 'watchlist' )->inContentLanguage()->escaped();
$feed = new $feedClasses[$feedFormat] ( $feedTitle, $msg, $feedUrl );
@ -201,7 +201,7 @@ class ApiFeedWatchlist extends ApiBase {
} else {
$titleUrl = $title->getFullURL( $curidParam );
}
$comment = isset( $info['comment'] ) ? $info['comment'] : null;
$comment = $info['comment'] ?? null;
// Create an anchor to section.
// The anchor won't work for sections that have dupes on page

View file

@ -104,26 +104,18 @@ class ApiFormatXml extends ApiFormatBase {
$value = (array)$value;
}
if ( is_array( $value ) ) {
$contentKey = isset( $value[ApiResult::META_CONTENT] )
? $value[ApiResult::META_CONTENT]
: '*';
$subelementKeys = isset( $value[ApiResult::META_SUBELEMENTS] )
? $value[ApiResult::META_SUBELEMENTS]
: [];
$contentKey = $value[ApiResult::META_CONTENT] ?? '*';
$subelementKeys = $value[ApiResult::META_SUBELEMENTS] ?? [];
if ( isset( $value[ApiResult::META_BC_SUBELEMENTS] ) ) {
$subelementKeys = array_merge(
$subelementKeys, $value[ApiResult::META_BC_SUBELEMENTS]
);
}
$preserveKeys = isset( $value[ApiResult::META_PRESERVE_KEYS] )
? $value[ApiResult::META_PRESERVE_KEYS]
: [];
$preserveKeys = $value[ApiResult::META_PRESERVE_KEYS] ?? [];
$indexedTagName = isset( $value[ApiResult::META_INDEXED_TAG_NAME] )
? self::mangleName( $value[ApiResult::META_INDEXED_TAG_NAME], $preserveKeys )
: '_v';
$bcBools = isset( $value[ApiResult::META_BC_BOOLS] )
? $value[ApiResult::META_BC_BOOLS]
: [];
$bcBools = $value[ApiResult::META_BC_BOOLS] ?? [];
$indexSubelements = isset( $value[ApiResult::META_TYPE] )
? $value[ApiResult::META_TYPE] !== 'array'
: false;

View file

@ -149,7 +149,7 @@ class ApiHelp extends ApiBase {
}
$out->addHTML( $html );
$helptitle = isset( $options['helptitle'] ) ? $options['helptitle'] : null;
$helptitle = $options['helptitle'] ?? null;
$html = self::fixHelpLinks( $out->getHTML(), $helptitle, $haveModules );
$out->clearHTML();
$out->addHTML( $html );
@ -482,9 +482,7 @@ class ApiHelp extends ApiBase {
// Type documentation
if ( !isset( $settings[ApiBase::PARAM_TYPE] ) ) {
$dflt = isset( $settings[ApiBase::PARAM_DFLT] )
? $settings[ApiBase::PARAM_DFLT]
: null;
$dflt = $settings[ApiBase::PARAM_DFLT] ?? null;
if ( is_bool( $dflt ) ) {
$settings[ApiBase::PARAM_TYPE] = 'boolean';
} elseif ( is_string( $dflt ) || is_null( $dflt ) ) {
@ -503,12 +501,8 @@ class ApiHelp extends ApiBase {
if ( is_array( $type ) ) {
$count = count( $type );
$deprecatedValues = isset( $settings[ApiBase::PARAM_DEPRECATED_VALUES] )
? $settings[ApiBase::PARAM_DEPRECATED_VALUES]
: [];
$links = isset( $settings[ApiBase::PARAM_VALUE_LINKS] )
? $settings[ApiBase::PARAM_VALUE_LINKS]
: [];
$deprecatedValues = $settings[ApiBase::PARAM_DEPRECATED_VALUES] ?? [];
$links = $settings[ApiBase::PARAM_VALUE_LINKS] ?? [];
$values = array_map( function ( $v ) use ( $links, $deprecatedValues ) {
$attr = [];
if ( $v !== '' ) {
@ -707,9 +701,7 @@ class ApiHelp extends ApiBase {
$info[] = implode( ' ', $extra );
}
$allowAll = isset( $settings[ApiBase::PARAM_ALL] )
? $settings[ApiBase::PARAM_ALL]
: false;
$allowAll = $settings[ApiBase::PARAM_ALL] ?? false;
if ( $allowAll || $settings[ApiBase::PARAM_TYPE] === 'namespace' ) {
if ( $settings[ApiBase::PARAM_TYPE] === 'namespace' ) {
$allSpecifier = ApiBase::ALL_DEFAULT_STRING;
@ -733,9 +725,7 @@ class ApiHelp extends ApiBase {
}
// Add default
$default = isset( $settings[ApiBase::PARAM_DFLT] )
? $settings[ApiBase::PARAM_DFLT]
: null;
$default = $settings[ApiBase::PARAM_DFLT] ?? null;
if ( $default === '' ) {
$info[] = $context->msg( 'api-help-param-default-empty' )
->parse();

View file

@ -96,7 +96,7 @@ class ApiModuleManager extends ContextSource {
foreach ( $modules as $name => $moduleSpec ) {
if ( is_array( $moduleSpec ) ) {
$class = $moduleSpec['class'];
$factory = ( isset( $moduleSpec['factory'] ) ? $moduleSpec['factory'] : null );
$factory = ( $moduleSpec['factory'] ?? null );
} else {
$class = $moduleSpec;
$factory = null;

View file

@ -65,11 +65,11 @@ class ApiOptions extends ApiBase {
if ( $params['change'] ) {
foreach ( $params['change'] as $entry ) {
$array = explode( '=', $entry, 2 );
$changes[$array[0]] = isset( $array[1] ) ? $array[1] : null;
$changes[$array[0]] = $array[1] ?? null;
}
}
if ( isset( $params['optionname'] ) ) {
$newValue = isset( $params['optionvalue'] ) ? $params['optionvalue'] : null;
$newValue = $params['optionvalue'] ?? null;
$changes[$params['optionname']] = $newValue;
}
if ( !$changed && !count( $changes ) ) {

View file

@ -339,9 +339,7 @@ class ApiParamInfo extends ApiBase {
}
if ( !isset( $settings[ApiBase::PARAM_TYPE] ) ) {
$dflt = isset( $settings[ApiBase::PARAM_DFLT] )
? $settings[ApiBase::PARAM_DFLT]
: null;
$dflt = $settings[ApiBase::PARAM_DFLT] ?? null;
if ( is_bool( $dflt ) ) {
$settings[ApiBase::PARAM_TYPE] = 'boolean';
} elseif ( is_string( $dflt ) || is_null( $dflt ) ) {
@ -445,9 +443,7 @@ class ApiParamInfo extends ApiBase {
$allowAll = true;
$allSpecifier = ApiBase::ALL_DEFAULT_STRING;
} else {
$allowAll = isset( $settings[ApiBase::PARAM_ALL] )
? $settings[ApiBase::PARAM_ALL]
: false;
$allowAll = $settings[ApiBase::PARAM_ALL] ?? false;
$allSpecifier = ( is_string( $allowAll ) ? $allowAll : ApiBase::ALL_DEFAULT_STRING );
}
if ( $allowAll && $item['multi'] &&

View file

@ -419,7 +419,7 @@ class ApiQueryBacklinksprop extends ApiQueryGeneratorBase {
$settings = self::$settings[$this->getModuleName()];
$name = $this->getModuleName();
$path = $this->getModulePath();
$title = isset( $settings['exampletitle'] ) ? $settings['exampletitle'] : 'Main Page';
$title = $settings['exampletitle'] ?? 'Main Page';
$etitle = rawurlencode( $title );
return [

View file

@ -66,7 +66,7 @@ class ApiQueryExternalLinks extends ApiQueryBase {
}
$this->addOption( 'LIMIT', $params['limit'] + 1 );
$offset = isset( $params['offset'] ) ? $params['offset'] : 0;
$offset = $params['offset'] ?? 0;
if ( $offset ) {
$this->addOption( 'OFFSET', $params['offset'] );
}

View file

@ -54,7 +54,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
$fit = $this->appendMagicWords( $p );
break;
case 'interwikimap':
$filteriw = isset( $params['filteriw'] ) ? $params['filteriw'] : false;
$filteriw = $params['filteriw'] ?? false;
$fit = $this->appendInterwikiMap( $p, $filteriw );
break;
case 'dbrepllag':
@ -387,7 +387,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
}
$params = $this->extractRequestParams();
$langCode = isset( $params['inlanguagecode'] ) ? $params['inlanguagecode'] : '';
$langCode = $params['inlanguagecode'] ?? '';
$langNames = Language::fetchLanguageNames( $langCode );
$getPrefixes = MediaWikiServices::getInstance()->getInterwikiLookup()->getAllPrefixes( $local );
@ -629,7 +629,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
}
if ( SpecialVersion::getExtLicenseFileName( $extensionPath ) ) {
$ret['license-name'] = isset( $ext['license-name'] ) ? $ext['license-name'] : '';
$ret['license-name'] = $ext['license-name'] ?? '';
$ret['license'] = SpecialPage::getTitleFor(
'Version',
"License/{$ext['name']}"
@ -699,7 +699,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
public function appendLanguages( $property ) {
$params = $this->extractRequestParams();
$langCode = isset( $params['inlanguagecode'] ) ? $params['inlanguagecode'] : '';
$langCode = $params['inlanguagecode'] ?? '';
$langNames = Language::fetchLanguageNames( $langCode );
$data = [];

View file

@ -691,9 +691,7 @@ class ApiQueryUserContribs extends ApiQueryBase {
&& !is_null( $row->rev_len )
&& !is_null( $row->rev_parent_id )
) {
$parentLen = isset( $this->parentLens[$row->rev_parent_id] )
? $this->parentLens[$row->rev_parent_id]
: 0;
$parentLen = $this->parentLens[$row->rev_parent_id] ?? 0;
$vals['sizediff'] = intval( $row->rev_len - $parentLen );
}

View file

@ -804,11 +804,11 @@ class ApiResult implements ApiSerializable {
* @return array|object
*/
protected static function applyTransformations( array $dataIn, array $transforms ) {
$strip = isset( $transforms['Strip'] ) ? $transforms['Strip'] : 'none';
$strip = $transforms['Strip'] ?? 'none';
if ( $strip === 'base' ) {
$transforms['Strip'] = 'none';
}
$transformTypes = isset( $transforms['Types'] ) ? $transforms['Types'] : null;
$transformTypes = $transforms['Types'] ?? null;
if ( $transformTypes !== null && !is_array( $transformTypes ) ) {
throw new InvalidArgumentException( __METHOD__ . ':Value for "Types" must be an array' );
}
@ -954,9 +954,7 @@ class ApiResult implements ApiSerializable {
case 'kvp':
case 'BCkvp':
$key = isset( $metadata[self::META_KVP_KEY_NAME] )
? $metadata[self::META_KVP_KEY_NAME]
: $transformTypes['ArmorKVP'];
$key = $metadata[self::META_KVP_KEY_NAME] ?? $transformTypes['ArmorKVP'];
$valKey = isset( $transforms['BC'] ) ? '*' : 'value';
$assocAsObject = !empty( $transformTypes['AssocAsObject'] );
$merge = !empty( $metadata[self::META_KVP_MERGE] );

View file

@ -120,7 +120,7 @@ class ApiRsd extends ApiBase {
'name' => $name,
'preferred' => wfBoolToStr( $name == 'MediaWiki' ),
'apiLink' => $info['apiLink'],
'blogID' => isset( $info['blogID'] ) ? $info['blogID'] : '',
'blogID' => $info['blogID'] ?? '',
];
$settings = [];
if ( isset( $info['docs'] ) ) {

View file

@ -65,7 +65,7 @@ class ApiUndelete extends ApiBase {
$pa = new PageArchive( $titleObj, $this->getConfig() );
$retval = $pa->undelete(
( isset( $params['timestamps'] ) ? $params['timestamps'] : [] ),
( $params['timestamps'] ?? [] ),
$params['reason'],
$params['fileids'],
false,

View file

@ -682,9 +682,7 @@ class ApiUpload extends ApiBase {
$warning = $warnings['exists'];
unset( $warnings['exists'] );
/** @var LocalFile $localFile */
$localFile = isset( $warning['normalizedFile'] )
? $warning['normalizedFile']
: $warning['file'];
$localFile = $warning['normalizedFile'] ?? $warning['file'];
$warnings[$warning['warning']] = $localFile->getName();
}

View file

@ -134,7 +134,7 @@ class ApiUserrights extends ApiBase {
$this->requireOnlyOneParameter( $params, 'user', 'userid' );
$user = isset( $params['user'] ) ? $params['user'] : '#' . $params['userid'];
$user = $params['user'] ?? '#' . $params['userid'];
$form = $this->getUserRightsPage();
$form->setContext( $this->getContext() );

View file

@ -150,7 +150,7 @@ trait SearchApi {
*/
public function buildSearchEngine( array $params = null ) {
if ( $params != null ) {
$type = isset( $params['backend'] ) ? $params['backend'] : null;
$type = $params['backend'] ?? null;
if ( $type === self::$BACKEND_NULL_PARAM ) {
$type = null;
}

View file

@ -1675,7 +1675,7 @@ class AuthManager implements LoggerAwareInterface {
}
// Checks passed, create the user...
$from = isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : 'CLI';
$from = $_SERVER['REQUEST_URI'] ?? 'CLI';
$this->logger->info( __METHOD__ . ': creating new user ({username}) - from: {from}', [
'username' => $username,
'from' => $from,

View file

@ -96,7 +96,7 @@ class ResetPasswordSecondaryAuthenticationProvider extends AbstractSecondaryAuth
}
}
$needReq = isset( $data->req ) ? $data->req : new PasswordAuthenticationRequest();
$needReq = $data->req ?? new PasswordAuthenticationRequest();
if ( !$needReq->action ) {
$needReq->action = AuthManager::ACTION_CHANGE;
}

View file

@ -58,8 +58,7 @@ class ThrottlePreAuthenticationProvider extends AbstractPreAuthenticationProvide
public function __construct( $params = [] ) {
$this->throttleSettings = array_intersect_key( $params,
[ 'accountCreationThrottle' => true, 'passwordAttemptThrottle' => true ] );
$this->cache = isset( $params['cache'] ) ? $params['cache'] :
\ObjectCache::getLocalClusterInstance();
$this->cache = $params['cache'] ?? \ObjectCache::getLocalClusterInstance();
}
public function setConfig( Config $config ) {

View file

@ -85,7 +85,7 @@ class GenderCache {
/* Undefined if there is a valid username which for some reason doesn't
* exist in the database.
*/
return isset( $this->cache[$username] ) ? $this->cache[$username] : $this->getDefault();
return $this->cache[$username] ?? $this->getDefault();
}
/**

View file

@ -727,7 +727,7 @@ class MessageCache {
$this->wanCache->makeKey( 'messages', $code, 'hash', 'v1' ),
[
'hash' => $cache['HASH'],
'latest' => isset( $cache['LATEST'] ) ? $cache['LATEST'] : 0
'latest' => $cache['LATEST'] ?? 0
],
WANObjectCache::TTL_INDEFINITE
);

View file

@ -56,9 +56,7 @@ class UserCache {
$this->doQuery( [ $userId ] ); // cache miss
}
return isset( $this->cache[$userId][$prop] )
? $this->cache[$userId][$prop]
: false; // user does not exist?
return $this->cache[$userId][$prop] ?? false; // user does not exist?
}
/**

View file

@ -236,7 +236,7 @@ class ChangesList extends ContextSource {
$flagInfos[$key]['letter'] = $value['letter'];
$flagInfos[$key]['title'] = $value['title'];
// Allow customized class name, fall back to flag name
$flagInfos[$key]['class'] = isset( $value['class'] ) ? $value['class'] : $key;
$flagInfos[$key]['class'] = $value['class'] ?? $key;
}
}
@ -646,7 +646,7 @@ class ChangesList extends ContextSource {
'id' => $rc->mAttribs['rc_this_oldid'],
'user' => $rc->mAttribs['rc_user'],
'user_text' => $rc->mAttribs['rc_user_text'],
'actor' => isset( $rc->mAttribs['rc_actor'] ) ? $rc->mAttribs['rc_actor'] : null,
'actor' => $rc->mAttribs['rc_actor'] ?? null,
'deleted' => $rc->mAttribs['rc_deleted']
] );
$s .= ' ' . Linker::generateRollback( $rev, $this->getContext() );

View file

@ -322,7 +322,7 @@ abstract class ChangesListFilterGroup {
* @return ChangesListFilter|null Specified filter, or null if it is not registered
*/
public function getFilter( $name ) {
return isset( $this->filters[$name] ) ? $this->filters[$name] : null;
return $this->filters[$name] ?? null;
}
/**

View file

@ -203,8 +203,7 @@ class EnhancedChangesList extends ChangesList {
# Default values for RC flags
$collectedRcFlags = [];
foreach ( $recentChangesFlags as $key => $value ) {
$flagGrouping = ( isset( $recentChangesFlags[$key]['grouping'] ) ?
$recentChangesFlags[$key]['grouping'] : 'any' );
$flagGrouping = ( $recentChangesFlags[$key]['grouping'] ?? 'any' );
switch ( $flagGrouping ) {
case 'all':
$collectedRcFlags[$key] = true;
@ -277,8 +276,7 @@ class EnhancedChangesList extends ChangesList {
// Roll up flags
foreach ( $line['recentChangesFlagsRaw'] as $key => $value ) {
$flagGrouping = ( isset( $recentChangesFlags[$key]['grouping'] ) ?
$recentChangesFlags[$key]['grouping'] : 'any' );
$flagGrouping = ( $recentChangesFlags[$key]['grouping'] ?? 'any' );
switch ( $flagGrouping ) {
case 'all':
if ( !$value ) {

View file

@ -420,9 +420,9 @@ class RecentChange {
# Convert mAttribs['rc_user'] etc for ActorMigration
$user = User::newFromAnyId(
isset( $row['rc_user'] ) ? $row['rc_user'] : null,
isset( $row['rc_user_text'] ) ? $row['rc_user_text'] : null,
isset( $row['rc_actor'] ) ? $row['rc_actor'] : null
$row['rc_user'] ?? null,
$row['rc_user_text'] ?? null,
$row['rc_actor'] ?? null
);
unset( $row['rc_user'], $row['rc_user_text'], $row['rc_actor'] );
$row += ActorMigration::newMigration()->getInsertValues( $dbw, 'rc_user', $user );
@ -1024,7 +1024,7 @@ class RecentChange {
*/
public function getParam( $name ) {
$params = $this->parseParams();
return isset( $params[$name] ) ? $params[$name] : null;
return $params[$name] ?? null;
}
/**
@ -1055,9 +1055,9 @@ class RecentChange {
$this->mAttribs['rc_comment_data'] = null;
$user = User::newFromAnyId(
isset( $this->mAttribs['rc_user'] ) ? $this->mAttribs['rc_user'] : null,
isset( $this->mAttribs['rc_user_text'] ) ? $this->mAttribs['rc_user_text'] : null,
isset( $this->mAttribs['rc_actor'] ) ? $this->mAttribs['rc_actor'] : null
$this->mAttribs['rc_user'] ?? null,
$this->mAttribs['rc_user_text'] ?? null,
$this->mAttribs['rc_actor'] ?? null
);
$this->mAttribs['rc_user'] = $user->getId();
$this->mAttribs['rc_user_text'] = $user->getName();
@ -1078,9 +1078,9 @@ class RecentChange {
if ( $name === 'rc_user' || $name === 'rc_user_text' || $name === 'rc_actor' ) {
$user = User::newFromAnyId(
isset( $this->mAttribs['rc_user'] ) ? $this->mAttribs['rc_user'] : null,
isset( $this->mAttribs['rc_user_text'] ) ? $this->mAttribs['rc_user_text'] : null,
isset( $this->mAttribs['rc_actor'] ) ? $this->mAttribs['rc_actor'] : null
$this->mAttribs['rc_user'] ?? null,
$this->mAttribs['rc_user_text'] ?? null,
$this->mAttribs['rc_actor'] ?? null
);
if ( $name === 'rc_user' ) {
return $user->getId();
@ -1093,7 +1093,7 @@ class RecentChange {
}
}
return isset( $this->mAttribs[$name] ) ? $this->mAttribs[$name] : null;
return $this->mAttribs[$name] ?? null;
}
/**

View file

@ -1268,7 +1268,7 @@ class ChangeTags {
// store the tag usage statistics
$tagUsage = self::tagUsageStatistics();
$hitcount = isset( $tagUsage[$tag] ) ? $tagUsage[$tag] : 0;
$hitcount = $tagUsage[$tag] ?? 0;
// do it!
$deleteResult = self::deleteTagEverywhere( $tag );

View file

@ -73,7 +73,7 @@ class SquidPurgeClient {
public function __construct( $server, $options = [] ) {
$parts = explode( ':', $server, 2 );
$this->host = $parts[0];
$this->port = isset( $parts[1] ) ? $parts[1] : 80;
$this->port = $parts[1] ?? 80;
}
/**

View file

@ -179,9 +179,7 @@ class MonologSpi implements Spi {
if ( !isset( $this->singletons['loggers'][$channel] ) ) {
// Fallback to using the '@default' configuration if an explict
// configuration for the requested channel isn't found.
$spec = isset( $this->config['loggers'][$channel] ) ?
$this->config['loggers'][$channel] :
$this->config['loggers']['@default'];
$spec = $this->config['loggers'][$channel] ?? $this->config['loggers']['@default'];
$monolog = $this->createLogger( $channel, $spec );
$this->singletons['loggers'][$channel] = $monolog;

View file

@ -164,7 +164,7 @@ class LineFormatter extends MonologLineFormatter {
);
}
$prev = isset( $prev['previous'] ) ? $prev['previous'] : null;
$prev = $prev['previous'] ?? null;
}
}
return $str;

View file

@ -128,7 +128,7 @@ class ExternalStoreDB extends ExternalStoreMedium {
public function getSlave( $cluster ) {
global $wgDefaultExternalStore;
$wiki = isset( $this->params['wiki'] ) ? $this->params['wiki'] : false;
$wiki = $this->params['wiki'] ?? false;
$lb = $this->getLoadBalancer( $cluster );
if ( !in_array( "DB://" . $cluster, (array)$wgDefaultExternalStore ) ) {
@ -151,7 +151,7 @@ class ExternalStoreDB extends ExternalStoreMedium {
* @return MaintainableDBConnRef
*/
public function getMaster( $cluster ) {
$wiki = isset( $this->params['wiki'] ) ? $this->params['wiki'] : false;
$wiki = $this->params['wiki'] ?? false;
$lb = $this->getLoadBalancer( $cluster );
$db = $lb->getMaintenanceConnectionRef( DB_MASTER, [], $wiki );
@ -301,7 +301,7 @@ class ExternalStoreDB extends ExternalStoreMedium {
return [
$path[2], // cluster
$path[3], // id
isset( $path[4] ) ? $path[4] : false // itemID
$path[4] ?? false // itemID
];
}
}

View file

@ -81,7 +81,7 @@ class ExternalStoreMwstore extends ExternalStoreMedium {
// Make sure ID is roughly lexicographically increasing for performance
$id = str_pad( UIDGenerator::newTimestampedUID128( 32 ), 26, '0', STR_PAD_LEFT );
// Segregate items by wiki ID for the sake of bookkeeping
$wiki = isset( $this->params['wiki'] ) ? $this->params['wiki'] : wfWikiID();
$wiki = $this->params['wiki'] ?? wfWikiID();
$url = $be->getContainerStoragePath( 'data' ) . '/' . rawurlencode( $wiki );
$url .= ( $be instanceof FSFileBackend )

View file

@ -79,15 +79,9 @@ class FileBackendGroup {
$repoName = $info['name'];
// Local vars that used to be FSRepo members...
$directory = $info['directory'];
$deletedDir = isset( $info['deletedDir'] )
? $info['deletedDir']
: false; // deletion disabled
$thumbDir = isset( $info['thumbDir'] )
? $info['thumbDir']
: "{$directory}/thumb";
$transcodedDir = isset( $info['transcodedDir'] )
? $info['transcodedDir']
: "{$directory}/transcoded";
$deletedDir = $info['deletedDir'] ?? false; // deletion disabled
$thumbDir = $info['thumbDir'] ?? "{$directory}/thumb";
$transcodedDir = $info['transcodedDir'] ?? "{$directory}/transcoded";
// Get the FS backend configuration
$autoBackends[] = [
'name' => $backendName,
@ -100,7 +94,7 @@ class FileBackendGroup {
"{$repoName}-deleted" => $deletedDir,
"{$repoName}-temp" => "{$directory}/temp"
],
'fileMode' => isset( $info['fileMode'] ) ? $info['fileMode'] : 0644,
'fileMode' => $info['fileMode'] ?? 0644,
'directoryMode' => $wgDirectoryMode,
];
}

View file

@ -171,30 +171,20 @@ class FileRepo {
}
// Optional settings that have a default
$this->initialCapital = isset( $info['initialCapital'] )
? $info['initialCapital']
: MWNamespace::isCapitalized( NS_FILE );
$this->url = isset( $info['url'] )
? $info['url']
: false; // a subclass may set the URL (e.g. ForeignAPIRepo)
$this->initialCapital = $info['initialCapital'] ?? MWNamespace::isCapitalized( NS_FILE );
$this->url = $info['url'] ?? false; // a subclass may set the URL (e.g. ForeignAPIRepo)
if ( isset( $info['thumbUrl'] ) ) {
$this->thumbUrl = $info['thumbUrl'];
} else {
$this->thumbUrl = $this->url ? "{$this->url}/thumb" : false;
}
$this->hashLevels = isset( $info['hashLevels'] )
? $info['hashLevels']
: 2;
$this->deletedHashLevels = isset( $info['deletedHashLevels'] )
? $info['deletedHashLevels']
: $this->hashLevels;
$this->hashLevels = $info['hashLevels'] ?? 2;
$this->deletedHashLevels = $info['deletedHashLevels'] ?? $this->hashLevels;
$this->transformVia404 = !empty( $info['transformVia404'] );
$this->abbrvThreshold = isset( $info['abbrvThreshold'] )
? $info['abbrvThreshold']
: 255;
$this->abbrvThreshold = $info['abbrvThreshold'] ?? 255;
$this->isPrivate = !empty( $info['isPrivate'] );
// Give defaults for the basic zones...
$this->zones = isset( $info['zones'] ) ? $info['zones'] : [];
$this->zones = $info['zones'] ?? [];
foreach ( [ 'public', 'thumb', 'transcoded', 'temp', 'deleted' ] as $zone ) {
if ( !isset( $this->zones[$zone]['container'] ) ) {
$this->zones[$zone]['container'] = "{$this->name}-{$zone}";
@ -428,7 +418,7 @@ class FileRepo {
if ( isset( $options['bypassCache'] ) ) {
$options['latest'] = $options['bypassCache']; // b/c
}
$time = isset( $options['time'] ) ? $options['time'] : false;
$time = $options['time'] ?? false;
$flags = !empty( $options['latest'] ) ? File::READ_LATEST : 0;
# First try the current version of the file to see if it precedes the timestamp
$img = $this->newFile( $title );
@ -534,7 +524,7 @@ class FileRepo {
* @return File|bool False on failure
*/
public function findFileFromKey( $sha1, $options = [] ) {
$time = isset( $options['time'] ) ? $options['time'] : false;
$time = $options['time'] ?? false;
# First try to find a matching current version of a file...
if ( !$this->fileFactoryKey ) {
return false; // find-by-sha1 not supported
@ -690,7 +680,7 @@ class FileRepo {
*/
public function getTempHashPath( $suffix ) {
$parts = explode( '!', $suffix, 2 ); // format is <timestamp>!<name> or just <name>
$name = isset( $parts[1] ) ? $parts[1] : $suffix; // hash path is not based on timestamp
$name = $parts[1] ?? $suffix; // hash path is not based on timestamp
return self::getHashPathForLevel( $name, $this->hashLevels );
}
@ -1225,7 +1215,7 @@ class FileRepo {
list( $src, $dstRel, $archiveRel ) = $ntuple;
$srcPath = ( $src instanceof FSFile ) ? $src->getPath() : $src;
$options = isset( $ntuple[3] ) ? $ntuple[3] : [];
$options = $ntuple[3] ?? [];
// Resolve source to a storage path if virtual
$srcPath = $this->resolveToStoragePath( $srcPath );
if ( !$this->validateFilename( $dstRel ) ) {
@ -1250,7 +1240,7 @@ class FileRepo {
}
// Set any desired headers to be use in GET/HEAD responses
$headers = isset( $options['headers'] ) ? $options['headers'] : [];
$headers = $options['headers'] ?? [];
// Archive destination file if it exists.
// This will check if the archive file also exists and fail if does.

View file

@ -75,7 +75,7 @@ class ForeignAPIRepo extends FileRepo {
parent::__construct( $info );
// https://commons.wikimedia.org/w/api.php
$this->mApiBase = isset( $info['apibase'] ) ? $info['apibase'] : null;
$this->mApiBase = $info['apibase'] ?? null;
if ( isset( $info['apiThumbCacheExpiry'] ) ) {
$this->apiThumbCacheExpiry = $info['apiThumbCacheExpiry'];

View file

@ -140,7 +140,7 @@ class RepoGroup {
&& empty( $options['private'] )
&& empty( $options['latest'] )
) {
$time = isset( $options['time'] ) ? $options['time'] : '';
$time = $options['time'] ?? '';
if ( $this->cache->has( $dbkey, $time, 60 ) ) {
return $this->cache->get( $dbkey, $time );
}

View file

@ -933,7 +933,7 @@ abstract class File implements IDBAccessObject {
*/
function getUnscaledThumb( $handlerParams = [] ) {
$hp =& $handlerParams;
$page = isset( $hp['page'] ) ? $hp['page'] : false;
$page = $hp['page'] ?? false;
$width = $this->getWidth( $page );
if ( !$width ) {
return $this->iconThumb();

View file

@ -128,8 +128,8 @@ class ForeignAPIFile extends File {
// Note, the this->canRender() check above implies
// that we have a handler, and it can do makeParamString.
$otherParams = $this->handler->makeParamString( $params );
$width = isset( $params['width'] ) ? $params['width'] : -1;
$height = isset( $params['height'] ) ? $params['height'] : -1;
$width = $params['width'] ?? -1;
$height = $params['height'] ?? -1;
$thumbUrl = $this->repo->getThumbUrlFromCache(
$this->getName(),
@ -311,9 +311,7 @@ class ForeignAPIFile extends File {
* @return bool|string
*/
function getDescriptionUrl() {
return isset( $this->mInfo['descriptionurl'] )
? $this->mInfo['descriptionurl']
: false;
return $this->mInfo['descriptionurl'] ?? false;
}
/**

View file

@ -583,9 +583,9 @@ class LocalFile extends File {
->getComment( 'description', (object)$decoded )->text;
$decoded['user'] = User::newFromAnyId(
isset( $decoded['user'] ) ? $decoded['user'] : null,
isset( $decoded['user_text'] ) ? $decoded['user_text'] : null,
isset( $decoded['actor'] ) ? $decoded['actor'] : null
$decoded['user'] ?? null,
$decoded['user_text'] ?? null,
$decoded['actor'] ?? null
);
unset( $decoded['user_text'], $decoded['actor'] );
@ -772,9 +772,9 @@ class LocalFile extends File {
if ( isset( $info['user'] ) || isset( $info['user_text'] ) || isset( $info['actor'] ) ) {
$this->user = User::newFromAnyId(
isset( $info['user'] ) ? $info['user'] : null,
isset( $info['user_text'] ) ? $info['user_text'] : null,
isset( $info['actor'] ) ? $info['actor'] : null
$info['user'] ?? null,
$info['user_text'] ?? null,
$info['actor'] ?? null
);
}

View file

@ -35,7 +35,7 @@ class TraditionalImageGallery extends ImageGalleryBase {
function toHTML() {
if ( $this->mPerRow > 0 ) {
$maxwidth = $this->mPerRow * ( $this->mWidths + $this->getAllPadding() );
$oldStyle = isset( $this->mAttribs['style'] ) ? $this->mAttribs['style'] : '';
$oldStyle = $this->mAttribs['style'] ?? '';
# _width is ignored by any sane browser. IE6 doesn't know max-width
# so it uses _width instead
$this->mAttribs['style'] = "max-width: {$maxwidth}px;_width: {$maxwidth}px;" .

View file

@ -333,9 +333,7 @@ class HTMLForm extends ContextSource {
$this->mFlatFields = [];
foreach ( $descriptor as $fieldname => $info ) {
$section = isset( $info['section'] )
? $info['section']
: '';
$section = $info['section'] ?? '';
if ( isset( $info['type'] ) && $info['type'] === 'file' ) {
$this->mUseMultipart = true;
@ -805,7 +803,7 @@ class HTMLForm extends ContextSource {
if ( $section === null ) {
return $this->mHeader;
} else {
return isset( $this->mSectionHeaders[$section] ) ? $this->mSectionHeaders[$section] : '';
return $this->mSectionHeaders[$section] ?? '';
}
}
@ -860,7 +858,7 @@ class HTMLForm extends ContextSource {
if ( $section === null ) {
return $this->mFooter;
} else {
return isset( $this->mSectionFooters[$section] ) ? $this->mSectionFooters[$section] : '';
return $this->mSectionFooters[$section] ?? '';
}
}
@ -959,8 +957,8 @@ class HTMLForm extends ContextSource {
$data = [
'name' => $args[0],
'value' => $args[1],
'id' => isset( $args[2] ) ? $args[2] : null,
'attribs' => isset( $args[3] ) ? $args[3] : null,
'id' => $args[2] ?? null,
'attribs' => $args[3] ?? null,
];
} else {
if ( !isset( $data['name'] ) ) {

View file

@ -13,8 +13,8 @@ trait HTMLFormElement {
public function initializeHTMLFormElement( array $config = [] ) {
// Properties
$this->hideIf = isset( $config['hideIf'] ) ? $config['hideIf'] : null;
$this->modules = isset( $config['modules'] ) ? $config['modules'] : [];
$this->hideIf = $config['hideIf'] ?? null;
$this->modules = $config['modules'] ?? [];
// Initialization
if ( $this->hideIf ) {

View file

@ -546,8 +546,7 @@ abstract class HTMLFormField {
'mw-htmlform-nolabel' => ( $label === '' )
];
$horizontalLabel = isset( $this->mParams['horizontal-label'] )
? $this->mParams['horizontal-label'] : false;
$horizontalLabel = $this->mParams['horizontal-label'] ?? false;
if ( $horizontalLabel ) {
$field = '&#160;' . $inputHtml . "\n$errors";
@ -950,8 +949,7 @@ abstract class HTMLFormField {
$displayFormat = $this->mParent->getDisplayFormat();
$html = '';
$horizontalLabel = isset( $this->mParams['horizontal-label'] )
? $this->mParams['horizontal-label'] : false;
$horizontalLabel = $this->mParams['horizontal-label'] ?? false;
if ( $displayFormat === 'table' ) {
$html =

View file

@ -56,7 +56,7 @@ class HTMLExpiryField extends HTMLFormField {
$this->relativeField->getInputOOUI( $value ),
[
'id' => $this->mID,
'required' => isset( $this->mParams['required'] ) ? $this->mParams['required'] : false,
'required' => $this->mParams['required'] ?? false,
]
);
}

View file

@ -5,7 +5,7 @@
*/
class HTMLFloatField extends HTMLTextField {
public function getSize() {
return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 20;
return $this->mParams['size'] ?? 20;
}
public function validate( $value, $alldata ) {

View file

@ -273,9 +273,7 @@ class HTMLFormFieldCloner extends HTMLFormField {
* @return string
*/
protected function getInputHTMLForKey( $key, array $values ) {
$displayFormat = isset( $this->mParams['format'] )
? $this->mParams['format']
: $this->mParent->getDisplayFormat();
$displayFormat = $this->mParams['format'] ?? $this->mParent->getDisplayFormat();
// Conveniently, PHP method names are case-insensitive.
$getFieldHtmlMethod = $displayFormat == 'table' ? 'getTableRow' : ( 'get' . $displayFormat );
@ -306,9 +304,7 @@ class HTMLFormFieldCloner extends HTMLFormField {
if ( !isset( $fields['delete'] ) ) {
$name = "{$this->mName}[$key][delete]";
$label = isset( $this->mParams['delete-button-message'] )
? $this->mParams['delete-button-message']
: 'htmlform-cloner-delete';
$label = $this->mParams['delete-button-message'] ?? 'htmlform-cloner-delete';
$field = HTMLForm::loadInputFromParameters( $name, [
'type' => 'submit',
'formnovalidate' => true,
@ -379,9 +375,7 @@ class HTMLFormFieldCloner extends HTMLFormField {
], $html );
$name = "{$this->mName}[create]";
$label = isset( $this->mParams['create-button-message'] )
? $this->mParams['create-button-message']
: 'htmlform-cloner-create';
$label = $this->mParams['create-button-message'] ?? 'htmlform-cloner-create';
$field = HTMLForm::loadInputFromParameters( $name, [
'type' => 'submit',
'formnovalidate' => true,

View file

@ -126,8 +126,7 @@ class HTMLSelectAndOtherField extends HTMLSelectField {
'or' => false,
'classes' => [ 'mw-htmlform-select-and-other-field' ],
'data' => [
'maxlengthUnit' => isset( $this->mParams['maxlength-unit'] )
? $this->mParams['maxlength-unit'] : 'bytes'
'maxlengthUnit' => $this->mParams['maxlength-unit'] ?? 'bytes'
],
] );
}
@ -177,7 +176,7 @@ class HTMLSelectAndOtherField extends HTMLSelectField {
}
public function getSize() {
return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 45;
return $this->mParams['size'] ?? 45;
}
public function validate( $value, $alldata ) {

View file

@ -12,9 +12,7 @@ class HTMLSelectOrOtherField extends HTMLTextField {
$this->getOptions();
if ( !in_array( 'other', $this->mOptions, true ) ) {
$msg =
isset( $params['other'] )
? $params['other']
: wfMessage( 'htmlform-selectorother-other' )->text();
$params['other'] ?? wfMessage( 'htmlform-selectorother-other' )->text();
// Have 'other' always as first element
$this->mOptions = [ $msg => 'other' ] + $this->mOptions;
}

View file

@ -10,7 +10,7 @@
*/
class HTMLSizeFilterField extends HTMLIntField {
public function getSize() {
return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 9;
return $this->mParams['size'] ?? 9;
}
public function getInputHTML( $value ) {

View file

@ -29,15 +29,15 @@ class HTMLTextAreaField extends HTMLFormField {
}
public function getCols() {
return isset( $this->mParams['cols'] ) ? $this->mParams['cols'] : static::DEFAULT_COLS;
return $this->mParams['cols'] ?? static::DEFAULT_COLS;
}
public function getRows() {
return isset( $this->mParams['rows'] ) ? $this->mParams['rows'] : static::DEFAULT_ROWS;
return $this->mParams['rows'] ?? static::DEFAULT_ROWS;
}
public function getSpellCheck() {
$val = isset( $this->mParams['spellcheck'] ) ? $this->mParams['spellcheck'] : null;
$val = $this->mParams['spellcheck'] ?? null;
if ( is_bool( $val ) ) {
// "spellcheck" attribute literally requires "true" or "false" to work.
return $val === true ? 'true' : 'false';

View file

@ -38,11 +38,11 @@ class HTMLTextField extends HTMLFormField {
}
public function getSize() {
return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 45;
return $this->mParams['size'] ?? 45;
}
public function getSpellCheck() {
$val = isset( $this->mParams['spellcheck'] ) ? $this->mParams['spellcheck'] : null;
$val = $this->mParams['spellcheck'] ?? null;
if ( is_bool( $val ) ) {
// "spellcheck" attribute literally requires "true" or "false" to work.
return $val === true ? 'true' : 'false';
@ -107,7 +107,7 @@ class HTMLTextField extends HTMLFormField {
}
protected function getType( &$attribs ) {
$type = isset( $attribs['type'] ) ? $attribs['type'] : 'text';
$type = $attribs['type'] ?? 'text';
unset( $attribs['type'] );
# Implement tiny differences between some field variants

View file

@ -784,7 +784,7 @@ class WikiImporter {
} elseif ( $tag == 'revision' || $tag == 'upload' ) {
if ( !isset( $title ) ) {
$title = $this->processTitle( $pageInfo['title'],
isset( $pageInfo['ns'] ) ? $pageInfo['ns'] : null );
$pageInfo['ns'] ?? null );
// $title is either an array of two titles or false.
if ( is_array( $title ) ) {
@ -1015,7 +1015,7 @@ class WikiImporter {
*/
private function processUpload( $pageInfo, $uploadInfo ) {
$revision = new WikiRevision( $this->config );
$text = isset( $uploadInfo['text'] ) ? $uploadInfo['text'] : '';
$text = $uploadInfo['text'] ?? '';
$revision->setTitle( $pageInfo['_title'] );
$revision->setID( $pageInfo['id'] );

View file

@ -97,7 +97,7 @@ class CliInstaller extends Installer {
$this->setVar( '_InstallUser',
$option['installdbuser'] );
$this->setVar( '_InstallPassword',
isset( $option['installdbpass'] ) ? $option['installdbpass'] : "" );
$option['installdbpass'] ?? "" );
// Assume that if we're given the installer user, we'll create the account.
$this->setVar( '_CreateDBAccount', true );

View file

@ -180,9 +180,7 @@ class WebInstallerExistingWiki extends WebInstallerPage {
// Copy $wgAuthenticationTokenVersion too, if it exists
$this->setVar( 'wgAuthenticationTokenVersion',
isset( $vars['wgAuthenticationTokenVersion'] )
? $vars['wgAuthenticationTokenVersion']
: null
$vars['wgAuthenticationTokenVersion'] ?? null
);
return $status;

View file

@ -314,10 +314,10 @@ class ClassicInterwikiLookup implements InterwikiLookup {
private function loadFromArray( $mc ) {
if ( isset( $mc['iw_url'] ) ) {
$url = $mc['iw_url'];
$local = isset( $mc['iw_local'] ) ? $mc['iw_local'] : 0;
$trans = isset( $mc['iw_trans'] ) ? $mc['iw_trans'] : 0;
$api = isset( $mc['iw_api'] ) ? $mc['iw_api'] : '';
$wikiId = isset( $mc['iw_wikiid'] ) ? $mc['iw_wikiid'] : '';
$local = $mc['iw_local'] ?? 0;
$trans = $mc['iw_trans'] ?? 0;
$api = $mc['iw_api'] ?? '';
$wikiId = $mc['iw_wikiid'] ?? '';
return new Interwiki( null, $url, $api, $wikiId, $local, $trans );
}

View file

@ -170,9 +170,7 @@ abstract class Job implements IJobSpecification {
* @since 1.27
*/
public function getRequestId() {
return isset( $this->params['requestId'] )
? $this->params['requestId']
: null;
return $this->params['requestId'] ?? null;
}
/**
@ -280,12 +278,8 @@ abstract class Job implements IJobSpecification {
*/
public function getRootJobParams() {
return [
'rootJobSignature' => isset( $this->params['rootJobSignature'] )
? $this->params['rootJobSignature']
: null,
'rootJobTimestamp' => isset( $this->params['rootJobTimestamp'] )
? $this->params['rootJobTimestamp']
: null
'rootJobSignature' => $this->params['rootJobSignature'] ?? null,
'rootJobTimestamp' => $this->params['rootJobTimestamp'] ?? null
];
}

View file

@ -58,8 +58,8 @@ abstract class JobQueue {
protected function __construct( array $params ) {
$this->wiki = $params['wiki'];
$this->type = $params['type'];
$this->claimTTL = isset( $params['claimTTL'] ) ? $params['claimTTL'] : 0;
$this->maxTries = isset( $params['maxTries'] ) ? $params['maxTries'] : 3;
$this->claimTTL = $params['claimTTL'] ?? 0;
$this->maxTries = $params['maxTries'] ?? 3;
if ( isset( $params['order'] ) && $params['order'] !== 'any' ) {
$this->order = $params['order'];
} else {
@ -69,12 +69,8 @@ abstract class JobQueue {
throw new MWException( __CLASS__ . " does not support '{$this->order}' order." );
}
$this->dupCache = wfGetCache( CACHE_ANYTHING );
$this->aggr = isset( $params['aggregator'] )
? $params['aggregator']
: new JobQueueAggregatorNull( [] );
$this->readOnlyReason = isset( $params['readOnlyReason'] )
? $params['readOnlyReason']
: false;
$this->aggr = $params['aggregator'] ?? new JobQueueAggregatorNull( [] );
$this->readOnlyReason = $params['readOnlyReason'] ?? false;
}
/**

View file

@ -55,7 +55,7 @@ class JobQueueDB extends JobQueue {
protected function __construct( array $params ) {
parent::__construct( $params );
$this->cluster = isset( $params['cluster'] ) ? $params['cluster'] : false;
$this->cluster = $params['cluster'] ?? false;
$this->cache = ObjectCache::getMainWANInstance();
}

View file

@ -73,15 +73,11 @@ class JobQueueFederated extends JobQueue {
*/
protected function __construct( array $params ) {
parent::__construct( $params );
$section = isset( $params['sectionsByWiki'][$this->wiki] )
? $params['sectionsByWiki'][$this->wiki]
: 'default';
$section = $params['sectionsByWiki'][$this->wiki] ?? 'default';
if ( !isset( $params['partitionsBySection'][$section] ) ) {
throw new MWException( "No configuration for section '$section'." );
}
$this->maxPartitionsTry = isset( $params['maxPartitionsTry'] )
? $params['maxPartitionsTry']
: 2;
$this->maxPartitionsTry = $params['maxPartitionsTry'] ?? 2;
// Get the full partition map
$partitionMap = $params['partitionsBySection'][$section];
arsort( $partitionMap, SORT_NUMERIC );

View file

@ -93,7 +93,7 @@ class JobQueueRedis extends JobQueue {
parent::__construct( $params );
$params['redisConfig']['serializer'] = 'none'; // make it easy to use Lua
$this->server = $params['redisServer'];
$this->compression = isset( $params['compression'] ) ? $params['compression'] : 'none';
$this->compression = $params['compression'] ?? 'none';
$this->redisPool = RedisConnectionPool::singleton( $params['redisConfig'] );
if ( empty( $params['daemonized'] ) ) {
throw new InvalidArgumentException(

View file

@ -44,7 +44,7 @@ class JobQueueSecondTestQueue extends JobQueue {
$conf = [ 'wiki' => $params['wiki'], 'type' => $params['type'] ];
$this->mainQueue = JobQueue::factory( $params['mainqueue'] + $conf );
$this->debugQueue = JobQueue::factory( $params['debugqueue'] + $conf );
$this->onlyWriteToDebugQueue = isset( $params['readonly'] ) ? $params['readonly'] : false;
$this->onlyWriteToDebugQueue = $params['readonly'] ?? false;
// We need to construct parent after creating the main and debug queue
// because super constructor calls some methods we delegate to the main queue.

View file

@ -109,9 +109,9 @@ class JobRunner implements LoggerAwareInterface {
$response = [ 'jobs' => [], 'reached' => 'none-ready' ];
$type = isset( $options['type'] ) ? $options['type'] : false;
$maxJobs = isset( $options['maxJobs'] ) ? $options['maxJobs'] : false;
$maxTime = isset( $options['maxTime'] ) ? $options['maxTime'] : false;
$type = $options['type'] ?? false;
$maxJobs = $options['maxJobs'] ?? false;
$maxTime = $options['maxTime'] ?? false;
$noThrottle = isset( $options['throttle'] ) && !$options['throttle'];
// Bail if job type is invalid

View file

@ -186,12 +186,8 @@ class JobSpecification implements IJobSpecification {
public function getRootJobParams() {
return [
'rootJobSignature' => isset( $this->params['rootJobSignature'] )
? $this->params['rootJobSignature']
: null,
'rootJobTimestamp' => isset( $this->params['rootJobTimestamp'] )
? $this->params['rootJobTimestamp']
: null
'rootJobSignature' => $this->params['rootJobSignature'] ?? null,
'rootJobTimestamp' => $this->params['rootJobTimestamp'] ?? null
];
}

View file

@ -49,9 +49,7 @@ class JobQueueAggregatorRedis extends JobQueueAggregator {
*/
public function __construct( array $params ) {
parent::__construct( $params );
$this->servers = isset( $params['redisServers'] )
? $params['redisServers']
: [ $params['redisServer'] ]; // b/c
$this->servers = $params['redisServers'] ?? [ $params['redisServer'] ]; // b/c
$params['redisConfig']['serializer'] = 'none';
$this->redisPool = RedisConnectionPool::singleton( $params['redisConfig'] );
$this->logger = \MediaWiki\Logger\LoggerFactory::getInstance( 'redis' );

View file

@ -55,7 +55,7 @@ class DeleteLinksJob extends Job {
}
$factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
$timestamp = isset( $this->params['timestamp'] ) ? $this->params['timestamp'] : null;
$timestamp = $this->params['timestamp'] ?? null;
$page = WikiPage::factory( $this->title ); // title when deleted
$update = new LinksDeletionUpdate( $page, $pageId, $timestamp );

View file

@ -128,9 +128,7 @@ class HTMLCacheUpdateJob extends Job {
// not expected to invalidate these cache entries too often.
$touchTimestamp = wfTimestampNow();
// If page_touched is higher than this, then something else already bumped it after enqueue
$condTimestamp = isset( $this->params['rootJobTimestamp'] )
? $this->params['rootJobTimestamp']
: $touchTimestamp;
$condTimestamp = $this->params['rootJobTimestamp'] ?? $touchTimestamp;
$dbw = wfGetDB( DB_MASTER );
$factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();

View file

@ -84,7 +84,7 @@ class PublishStashedFileJob extends Job {
$this->params['text'],
$this->params['watch'],
$user,
isset( $this->params['tags'] ) ? $this->params['tags'] : []
$this->params['tags'] ?? []
);
if ( !$status->isGood() ) {
UploadBase::setSessionStatus(

View file

@ -103,7 +103,7 @@ class BacklinkJobUtils {
$realBSize = $bSize;
}
$extraParams = isset( $opts['params'] ) ? $opts['params'] : [];
$extraParams = $opts['params'] ?? [];
$jobs = [];
// Combine the first range (of size $bSize) backlinks into leaf jobs

View file

@ -84,7 +84,7 @@ class HttpStatus {
507 => 'Insufficient Storage',
511 => 'Network Authentication Required',
];
return isset( $statusMessage[$code] ) ? $statusMessage[$code] : null;
return $statusMessage[$code] ?? null;
}
/**

View file

@ -575,7 +575,7 @@ class JavaScriptMinifier {
// Now get the token type from our type array
$token = substr( $s, $pos, $end - $pos ); // so $end - $pos == strlen( $token )
$type = isset( $tokenTypes[$token] ) ? $tokenTypes[$token] : self::TYPE_LITERAL;
$type = $tokenTypes[$token] ?? self::TYPE_LITERAL;
if ( $newlineFound && isset( $semicolon[$state][$type] ) ) {
// This token triggers the semicolon insertion mechanism of javascript. While we

View file

@ -60,7 +60,7 @@ class MappedIterator extends FilterIterator {
}
parent::__construct( $baseIterator );
$this->vCallback = $vCallback;
$this->aCallback = isset( $options['accept'] ) ? $options['accept'] : null;
$this->aCallback = $options['accept'] ?? null;
}
public function next() {

View file

@ -172,7 +172,7 @@ class MultiHttpClient implements LoggerAwareInterface {
throw new Exception( "Request has no 'url' field set." );
}
$this->logger->debug( "{$req['method']}: {$req['url']}" );
$req['query'] = isset( $req['query'] ) ? $req['query'] : [];
$req['query'] = $req['query'] ?? [];
$headers = []; // normalized headers
if ( isset( $req['headers'] ) ) {
foreach ( $req['headers'] as $name => $value ) {
@ -184,7 +184,7 @@ class MultiHttpClient implements LoggerAwareInterface {
$req['body'] = '';
$req['headers']['content-length'] = 0;
}
$req['flags'] = isset( $req['flags'] ) ? $req['flags'] : [];
$req['flags'] = $req['flags'] ?? [];
$handles[$index] = $this->getCurlHandle( $req, $opts );
if ( count( $reqs ) > 1 ) {
// https://github.com/guzzle/guzzle/issues/349
@ -286,10 +286,10 @@ class MultiHttpClient implements LoggerAwareInterface {
$ch = curl_init();
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT,
isset( $opts['connTimeout'] ) ? $opts['connTimeout'] : $this->connTimeout );
curl_setopt( $ch, CURLOPT_PROXY, isset( $req['proxy'] ) ? $req['proxy'] : $this->proxy );
$opts['connTimeout'] ?? $this->connTimeout );
curl_setopt( $ch, CURLOPT_PROXY, $req['proxy'] ?? $this->proxy );
curl_setopt( $ch, CURLOPT_TIMEOUT,
isset( $opts['reqTimeout'] ) ? $opts['reqTimeout'] : $this->reqTimeout );
$opts['reqTimeout'] ?? $this->reqTimeout );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
curl_setopt( $ch, CURLOPT_MAXREDIRS, 4 );
curl_setopt( $ch, CURLOPT_HEADER, 0 );

View file

@ -52,7 +52,7 @@ class Timing implements LoggerAwareInterface {
public function __construct( array $params = [] ) {
$this->clearMarks();
$this->setLogger( isset( $params['logger'] ) ? $params['logger'] : new NullLogger() );
$this->setLogger( $params['logger'] ?? new NullLogger() );
}
/**
@ -188,6 +188,6 @@ class Timing implements LoggerAwareInterface {
* @return array|null Entry named $name or null if it does not exist.
*/
public function getEntryByName( $name ) {
return isset( $this->entries[$name] ) ? $this->entries[$name] : null;
return $this->entries[$name] ?? null;
}
}

View file

@ -54,7 +54,7 @@ class UDPTransport {
// IPv6 bracketed host
$host = $m[1];
$port = intval( $m[2] );
$prefix = isset( $m[3] ) ? $m[3] : false;
$prefix = $m[3] ?? false;
$domain = AF_INET6;
} elseif ( preg_match( '!^udp:(?://)?([a-zA-Z0-9.-]+):(\d+)(?:/(.*))?$!', $info, $m ) ) {
$host = $m[1];
@ -62,7 +62,7 @@ class UDPTransport {
$host = gethostbyname( $host );
}
$port = intval( $m[2] );
$prefix = isset( $m[3] ) ? $m[3] : false;
$prefix = $m[3] ?? false;
$domain = AF_INET;
} else {
throw new InvalidArgumentException( __METHOD__ . ': Invalid UDP specification' );

View file

@ -26,9 +26,9 @@ class ComposerInstalled {
$deps[$installed['name']] = [
'version' => ComposerJson::normalizeVersion( $installed['version'] ),
'type' => $installed['type'],
'licenses' => isset( $installed['license'] ) ? $installed['license'] : [],
'authors' => isset( $installed['authors'] ) ? $installed['authors'] : [],
'description' => isset( $installed['description'] ) ? $installed['description'] : '',
'licenses' => $installed['license'] ?? [],
'authors' => $installed['authors'] ?? [],
'description' => $installed['description'] ?? '',
];
}

View file

@ -26,9 +26,9 @@ class ComposerLock {
$deps[$installed['name']] = [
'version' => ComposerJson::normalizeVersion( $installed['version'] ),
'type' => $installed['type'],
'licenses' => isset( $installed['license'] ) ? $installed['license'] : [],
'authors' => isset( $installed['authors'] ) ? $installed['authors'] : [],
'description' => isset( $installed['description'] ) ? $installed['description'] : '',
'licenses' => $installed['license'] ?? [],
'authors' => $installed['authors'] ?? [],
'description' => $installed['description'] ?? '',
];
}

Some files were not shown because too many files have changed in this diff Show more