From 65b11b8fee51508d0c307e7bec809ba0b3672aaf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Mon, 3 Sep 2018 19:57:23 +0200 Subject: [PATCH] Use PHP 7 '??' operator instead of '?:' (round 2) A few issues have snuck in since I33b421c8cb11cdd4ce896488c9ff5313f03a38cf. Change-Id: Ib75470a7a3c19e2d48f498b396eee6ed733690e4 --- includes/api/SearchApi.php | 2 +- includes/htmlform/HTMLFormField.php | 2 +- includes/htmlform/fields/HTMLCheckMatrix.php | 6 ++--- includes/libs/rdbms/ChronologyProtector.php | 5 ++-- includes/widget/CheckMatrixWidget.php | 27 +++++++------------- 5 files changed, 15 insertions(+), 27 deletions(-) diff --git a/includes/api/SearchApi.php b/includes/api/SearchApi.php index fc6eddf800..70942f8eb2 100644 --- a/includes/api/SearchApi.php +++ b/includes/api/SearchApi.php @@ -156,7 +156,7 @@ trait SearchApi { $searchEngine = MediaWikiServices::getInstance()->getSearchEngineFactory()->create( $type ); $limit = $params['limit']; $searchEngine->setNamespaces( $params['namespace'] ); - $offset = isset( $params['offset'] ) ? $params['offset'] : null; + $offset = $params['offset'] ?? null; $searchEngine->setLimitOffset( $limit, $offset ); // Initialize requested search profiles. diff --git a/includes/htmlform/HTMLFormField.php b/includes/htmlform/HTMLFormField.php index a88ab9934d..890299525e 100644 --- a/includes/htmlform/HTMLFormField.php +++ b/includes/htmlform/HTMLFormField.php @@ -871,7 +871,7 @@ abstract class HTMLFormField { * @return bool */ public function isHelpInline() { - return isset( $this->mParams['help-inline'] ) ? $this->mParams['help-inline'] : true; + return $this->mParams['help-inline'] ?? true; } /** diff --git a/includes/htmlform/fields/HTMLCheckMatrix.php b/includes/htmlform/fields/HTMLCheckMatrix.php index a679e45951..e5e5cdd1dd 100644 --- a/includes/htmlform/fields/HTMLCheckMatrix.php +++ b/includes/htmlform/fields/HTMLCheckMatrix.php @@ -159,10 +159,8 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable { 'rows' => $this->mParams['rows'], 'columns' => $this->mParams['columns'], 'tooltips' => $this->mParams['tooltips'], - 'forcedOff' => isset( $this->mParams['force-options-off'] ) ? - $this->mParams['force-options-off'] : [], - 'forcedOn' => isset( $this->mParams['force-options-on'] ) ? - $this->mParams['force-options-on'] : [], + 'forcedOff' => $this->mParams['force-options-off'] ?? [], + 'forcedOn' => $this->mParams['force-options-on'] ?? [], 'values' => $value ] + OOUI\Element::configFromHtmlAttributes( $attribs ) ); diff --git a/includes/libs/rdbms/ChronologyProtector.php b/includes/libs/rdbms/ChronologyProtector.php index 45179cc835..938e5345db 100644 --- a/includes/libs/rdbms/ChronologyProtector.php +++ b/includes/libs/rdbms/ChronologyProtector.php @@ -78,9 +78,8 @@ class ChronologyProtector implements LoggerAwareInterface { */ public function __construct( BagOStuff $store, array $client, $posIndex = null ) { $this->store = $store; - $this->clientId = isset( $client['clientId'] ) - ? $client['clientId'] - : md5( $client['ip'] . "\n" . $client['agent'] ); + $this->clientId = $client['clientId'] ?? + md5( $client['ip'] . "\n" . $client['agent'] ); $this->key = $store->makeGlobalKey( __CLASS__, $this->clientId, 'v2' ); $this->waitForPosIndex = $posIndex; diff --git a/includes/widget/CheckMatrixWidget.php b/includes/widget/CheckMatrixWidget.php index 7783f31852..510b352719 100644 --- a/includes/widget/CheckMatrixWidget.php +++ b/includes/widget/CheckMatrixWidget.php @@ -45,26 +45,18 @@ class CheckMatrixWidget extends \OOUI\Widget { parent::__construct( $config ); - $this->name = isset( $config['name'] ) ? - $config[ 'name' ] : null; - $this->id = isset( $config['id'] ) ? - $config['id'] : null; + $this->name = $config['name'] ?? null; + $this->id = $config['id'] ?? null; // Properties - $this->rows = isset( $config['rows'] ) ? - $config['rows'] : []; - $this->columns = isset( $config['columns'] ) ? - $config['columns'] : []; - $this->tooltips = isset( $config['tooltips'] ) ? - $config['tooltips'] : []; + $this->rows = $config['rows'] ?? []; + $this->columns = $config['columns'] ?? []; + $this->tooltips = $config['tooltips'] ?? []; - $this->values = isset( $config['values'] ) ? - $config['values'] : []; + $this->values = $config['values'] ?? []; - $this->forcedOn = isset( $config['forcedOn'] ) ? - $config['forcedOn'] : []; - $this->forcedOff = isset( $config['forcedOff'] ) ? - $config['forcedOff'] : []; + $this->forcedOn = $config['forcedOn'] ?? []; + $this->forcedOff = $config['forcedOff'] ?? []; // Build the table $table = new \OOUI\Tag( 'table' ); @@ -180,8 +172,7 @@ class CheckMatrixWidget extends \OOUI\Widget { * @return string Tooltip. Null if none is available. */ private function getTooltip( $label ) { - return isset( $this->tooltips[ $label ] ) ? - $this->tooltips[ $label ] : null; + return $this->tooltips[ $label ] ?? null; } protected function getJavaScriptClassName() { -- 2.20.1