Use PHP 7 '??' operator instead of '?:' (round 2)
authorBartosz Dziewoński <matma.rex@gmail.com>
Mon, 3 Sep 2018 17:57:23 +0000 (19:57 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Mon, 3 Sep 2018 18:48:10 +0000 (20:48 +0200)
A few issues have snuck in since I33b421c8cb11cdd4ce896488c9ff5313f03a38cf.

Change-Id: Ib75470a7a3c19e2d48f498b396eee6ed733690e4

includes/api/SearchApi.php
includes/htmlform/HTMLFormField.php
includes/htmlform/fields/HTMLCheckMatrix.php
includes/libs/rdbms/ChronologyProtector.php
includes/widget/CheckMatrixWidget.php

index fc6eddf..70942f8 100644 (file)
@@ -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.
index a88ab99..8902995 100644 (file)
@@ -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;
        }
 
        /**
index a679e45..e5e5cdd 100644 (file)
@@ -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 )
                );
index 45179cc..938e534 100644 (file)
@@ -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;
 
index 7783f31..510b352 100644 (file)
@@ -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() {