From 33ba3bea023e4c0dee6dc3211ae2aee564271457 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Tue, 8 Mar 2016 08:27:13 +0100 Subject: [PATCH] Use Elvis operator where possible in API Change-Id: I0a26c04cf2ded2c1bd74d8dabd131ae8e20117f3 --- includes/api/ApiParse.php | 5 ++--- includes/api/ApiQueryRevisionsBase.php | 2 +- includes/api/ApiQuerySiteinfo.php | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 872876dfcc..ca3521e02e 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -275,7 +275,7 @@ class ApiParse extends ApiBase { $result_array = []; $result_array['title'] = $titleObj->getPrefixedText(); - $result_array['pageid'] = $pageid ? $pageid : $pageObj->getId(); + $result_array['pageid'] = $pageid ?: $pageObj->getId(); if ( !is_null( $oldid ) ) { $result_array['revid'] = intval( $oldid ); @@ -341,8 +341,7 @@ class ApiParse extends ApiBase { } if ( isset( $prop['displaytitle'] ) ) { - $result_array['displaytitle'] = $p_result->getDisplayTitle() ? - $p_result->getDisplayTitle() : + $result_array['displaytitle'] = $p_result->getDisplayTitle() ?: $titleObj->getPrefixedText(); } diff --git a/includes/api/ApiQueryRevisionsBase.php b/includes/api/ApiQueryRevisionsBase.php index c12393da94..5f5d1575cd 100644 --- a/includes/api/ApiQueryRevisionsBase.php +++ b/includes/api/ApiQueryRevisionsBase.php @@ -332,7 +332,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { } if ( $text === null ) { - $format = $this->contentFormat ? $this->contentFormat : $content->getDefaultFormat(); + $format = $this->contentFormat ?: $content->getDefaultFormat(); $model = $content->getModel(); if ( !$content->isSupportedFormat( $format ) ) { diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index 4befad66c7..f05556eca3 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -652,8 +652,8 @@ class ApiQuerySiteinfo extends ApiQueryBase { } $data = [ - 'url' => $url ? $url : '', - 'text' => $text ? $text : '' + 'url' => $url ?: '', + 'text' => $text ?: '' ]; return $this->getResult()->addValue( 'query', $property, $data ); -- 2.20.1