From f42a804c9666e77f9bdefc3a6ebee7c1f0a0f0c7 Mon Sep 17 00:00:00 2001 From: colemanw Date: Thu, 24 Aug 2023 13:42:03 -0400 Subject: [PATCH] REF/CRM - Simplify inline conditionals with Elvis --- CRM/Activity/BAO/Activity.php | 4 ++-- CRM/Admin/Form/RelationshipType.php | 4 ++-- CRM/Campaign/Form/Survey/Results.php | 2 +- CRM/Campaign/Form/Survey/TabHeader.php | 4 ++-- CRM/Contact/BAO/Contact.php | 2 +- CRM/Contact/BAO/Relationship.php | 2 +- CRM/Contact/Form/Task/EmailTrait.php | 2 +- CRM/Contribute/Form/AdditionalInfo.php | 2 +- CRM/Contribute/Form/ContributionBase.php | 2 +- CRM/Contribute/Form/ContributionPage/TabHeader.php | 2 +- CRM/Core/BAO/Country.php | 2 +- CRM/Core/BAO/Domain.php | 2 +- CRM/Core/Form.php | 4 ++-- CRM/Core/I18n.php | 2 +- CRM/Core/Lock.php | 2 +- CRM/Core/Menu.php | 2 +- CRM/Core/Page/AJAX/Location.php | 4 ++-- CRM/Core/Payment/PayPalIPN.php | 2 +- CRM/Core/Payment/PayPalProIPN.php | 2 +- CRM/Core/PseudoConstant.php | 2 +- CRM/Core/Selector/Controller.php | 4 ++-- CRM/Core/Session.php | 4 ++-- CRM/Event/Form/ManageEvent/TabHeader.php | 2 +- CRM/Event/Form/Registration.php | 4 ++-- CRM/Event/PseudoConstant.php | 4 ++-- CRM/Logging/ReportDetail.php | 2 +- CRM/Mailing/PseudoConstant.php | 2 +- CRM/Mailing/Selector/Browse.php | 2 +- CRM/PCP/Page/PCPInfo.php | 2 +- CRM/Pledge/BAO/Pledge.php | 2 +- CRM/Profile/Form.php | 6 +++--- CRM/Profile/Page/Dynamic.php | 4 ++-- CRM/Profile/Page/Listings.php | 4 ++-- CRM/Profile/Page/View.php | 4 ++-- CRM/Report/Form.php | 4 ++-- CRM/Report/Form/Contribute/RecurSummary.php | 4 ++-- CRM/Report/Form/Contribute/TopDonor.php | 2 +- CRM/SMS/Form/Upload.php | 2 +- CRM/Utils/Mail.php | 4 ++-- CRM/Utils/Mail/Incoming.php | 2 +- 40 files changed, 57 insertions(+), 57 deletions(-) diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index 3d7993b5fb..37ece7b6fd 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -922,7 +922,7 @@ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity { $details = "-ALTERNATIVE ITEM 0-\n{$html}{$additionalDetails}\n-ALTERNATIVE ITEM 1-\n{$text}{$additionalDetails}\n-ALTERNATIVE END-\n"; } else { - $details = $html ? $html : $text; + $details = $html ?: $text; $details .= $additionalDetails; } @@ -1703,7 +1703,7 @@ WHERE activity.id IN ($activityIds)"; 'parent_id' ); - $parentActivities[$activityId] = $parentId ? $parentId : FALSE; + $parentActivities[$activityId] = $parentId ?: FALSE; } return $parentActivities[$activityId]; diff --git a/CRM/Admin/Form/RelationshipType.php b/CRM/Admin/Form/RelationshipType.php index 391b52304c..ce43206171 100644 --- a/CRM/Admin/Form/RelationshipType.php +++ b/CRM/Admin/Form/RelationshipType.php @@ -159,8 +159,8 @@ class CRM_Admin_Form_RelationshipType extends CRM_Admin_Form { $params['contact_type_a'] = $cTypeA[0]; $params['contact_type_b'] = $cTypeB[0]; - $params['contact_sub_type_a'] = $cTypeA[1] ? $cTypeA[1] : 'null'; - $params['contact_sub_type_b'] = $cTypeB[1] ? $cTypeB[1] : 'null'; + $params['contact_sub_type_a'] = $cTypeA[1] ?: 'null'; + $params['contact_sub_type_b'] = $cTypeB[1] ?: 'null'; if (!strlen(trim($params['label_b_a'] ?? ''))) { $params['label_b_a'] = $params['label_a_b'] ?? NULL; diff --git a/CRM/Campaign/Form/Survey/Results.php b/CRM/Campaign/Form/Survey/Results.php index c7054f570f..a12e609326 100644 --- a/CRM/Campaign/Form/Survey/Results.php +++ b/CRM/Campaign/Form/Survey/Results.php @@ -397,7 +397,7 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey { $activityStatus = array_flip($activityStatus); $this->_params = [ 'name' => "survey_{$survey->id}", - 'title' => $params['report_title'] ? $params['report_title'] : $this->_values['title'], + 'title' => $params['report_title'] ?: $this->_values['title'], 'status_id_op' => 'eq', // reserved status 'status_id_value' => $activityStatus['Scheduled'], diff --git a/CRM/Campaign/Form/Survey/TabHeader.php b/CRM/Campaign/Form/Survey/TabHeader.php index e7bfd2fa56..2856c09a3e 100644 --- a/CRM/Campaign/Form/Survey/TabHeader.php +++ b/CRM/Campaign/Form/Survey/TabHeader.php @@ -137,7 +137,7 @@ class CRM_Campaign_Form_Survey_TabHeader { } } - $current = $current ? $current : 'main'; + $current = $current ?: 'main'; return $current; } @@ -166,7 +166,7 @@ class CRM_Campaign_Form_Survey_TabHeader { } } - $next = $next ? $next : 'main'; + $next = $next ?: 'main'; return $next; } diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index a925762dd4..d54041d393 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -1135,7 +1135,7 @@ WHERE civicrm_contact.id = " . CRM_Utils_Type::escape($id, 'Integer'); $cid = CRM_Utils_Request::retrieve('cid', 'Positive'); // retrieve contact id in case of Profile context $id = CRM_Utils_Request::retrieve('id', 'Positive'); - $cid = $cid ? $cid : $id; + $cid = $cid ?: $id; if ($action & CRM_Core_Action::DELETE) { if (CRM_Utils_Request::retrieve('confirmed', 'Boolean')) { CRM_Contact_BAO_Contact::deleteContactImage($cid); diff --git a/CRM/Contact/BAO/Relationship.php b/CRM/Contact/BAO/Relationship.php index eb45476e86..03b91fbf66 100644 --- a/CRM/Contact/BAO/Relationship.php +++ b/CRM/Contact/BAO/Relationship.php @@ -2040,7 +2040,7 @@ AND cc.sort_name LIKE '%$name%'"; */ public static function isCurrentEmployerNeedingToBeCleared($params, $relationshipId, $updatedRelTypeID = NULL) { $existingTypeID = (int) CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Relationship', $relationshipId, 'relationship_type_id'); - $updatedRelTypeID = $updatedRelTypeID ? $updatedRelTypeID : $existingTypeID; + $updatedRelTypeID = $updatedRelTypeID ?: $existingTypeID; $currentEmployerID = (int) civicrm_api3('Contact', 'getvalue', ['return' => 'current_employer_id', 'id' => $params['contact_id_a']]); if ($currentEmployerID !== (int) $params['contact_id_b'] || !self::isRelationshipTypeCurrentEmployer($existingTypeID)) { diff --git a/CRM/Contact/Form/Task/EmailTrait.php b/CRM/Contact/Form/Task/EmailTrait.php index 04a1b7bd57..1755bbc232 100644 --- a/CRM/Contact/Form/Task/EmailTrait.php +++ b/CRM/Contact/Form/Task/EmailTrait.php @@ -838,7 +838,7 @@ trait CRM_Contact_Form_Task_EmailTrait { $details = "-ALTERNATIVE ITEM 0-\n{$html}{$additionalDetails}\n-ALTERNATIVE ITEM 1-\n{$text}{$additionalDetails}\n-ALTERNATIVE END-\n"; } else { - $details = $html ? $html : $text; + $details = $html ?: $text; $details .= $additionalDetails; } diff --git a/CRM/Contribute/Form/AdditionalInfo.php b/CRM/Contribute/Form/AdditionalInfo.php index 2d451f782c..86b0e94572 100644 --- a/CRM/Contribute/Form/AdditionalInfo.php +++ b/CRM/Contribute/Form/AdditionalInfo.php @@ -255,7 +255,7 @@ class CRM_Contribute_Form_AdditionalInfo { $noteID = []; if ($contributionNoteID) { $noteID = ["id" => $contributionNoteID]; - $noteParams['note'] = $noteParams['note'] ? $noteParams['note'] : "null"; + $noteParams['note'] = $noteParams['note'] ?: "null"; } CRM_Core_BAO_Note::add($noteParams, $noteID); } diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index b423a4b41c..b1972d0060 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -1089,7 +1089,7 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { */ public function overrideExtraTemplateFileName() { $fileName = $this->checkTemplateFileExists('extra.'); - return $fileName ? $fileName : parent::overrideExtraTemplateFileName(); + return $fileName ?: parent::overrideExtraTemplateFileName(); } /** diff --git a/CRM/Contribute/Form/ContributionPage/TabHeader.php b/CRM/Contribute/Form/ContributionPage/TabHeader.php index c103759321..1344cbb441 100644 --- a/CRM/Contribute/Form/ContributionPage/TabHeader.php +++ b/CRM/Contribute/Form/ContributionPage/TabHeader.php @@ -179,7 +179,7 @@ class CRM_Contribute_Form_ContributionPage_TabHeader { } } - $current = $current ? $current : 'settings'; + $current = $current ?: 'settings'; return $current; } diff --git a/CRM/Core/BAO/Country.php b/CRM/Core/BAO/Country.php index d81958f09d..8d53a8bf8a 100644 --- a/CRM/Core/BAO/Country.php +++ b/CRM/Core/BAO/Country.php @@ -174,7 +174,7 @@ class CRM_Core_BAO_Country extends CRM_Core_DAO_Country { public static function defaultCurrencySymbol($defaultCurrency = NULL) { static $cachedSymbol = NULL; if (!$cachedSymbol || $defaultCurrency) { - $currency = $defaultCurrency ? $defaultCurrency : Civi::settings()->get('defaultCurrency'); + $currency = $defaultCurrency ?: Civi::settings()->get('defaultCurrency'); if ($currency) { $currencySymbols = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'currency', [ 'labelColumn' => 'symbol', diff --git a/CRM/Core/BAO/Domain.php b/CRM/Core/BAO/Domain.php index 1462718c86..548baffdc6 100644 --- a/CRM/Core/BAO/Domain.php +++ b/CRM/Core/BAO/Domain.php @@ -273,7 +273,7 @@ class CRM_Core_BAO_Domain extends CRM_Core_DAO_Domain { $title, 'id', 'title', TRUE ); } - return $groupID ? $groupID : FALSE; + return $groupID ?: FALSE; } /** diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index e29b8fcb22..76a7baaf79 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -489,7 +489,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { // Fudge some extra types that quickform doesn't support $inputType = $type; if ($type == 'wysiwyg' || in_array($type, self::$html5Types)) { - $attributes = ($attributes ? $attributes : []) + ['class' => '']; + $attributes = ($attributes ?: []) + ['class' => '']; $attributes['class'] = ltrim($attributes['class'] . " crm-form-$type"); if ($type == 'wysiwyg' && isset($attributes['preset'])) { $attributes['data-preset'] = $attributes['preset']; @@ -1397,7 +1397,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { */ public function &addRadio($name, $title, $values, $attributes = [], $separator = NULL, $required = FALSE, $optionAttributes = []) { $options = []; - $attributes = $attributes ? $attributes : []; + $attributes = $attributes ?: []; $allowClear = !empty($attributes['allowClear']); unset($attributes['allowClear']); $attributes['id_suffix'] = $name; diff --git a/CRM/Core/I18n.php b/CRM/Core/I18n.php index 7484564f5b..2c789e152e 100644 --- a/CRM/Core/I18n.php +++ b/CRM/Core/I18n.php @@ -774,7 +774,7 @@ class CRM_Core_I18n { */ public static function getLocale() { global $tsLocale; - return $tsLocale ? $tsLocale : 'en_US'; + return $tsLocale ?: 'en_US'; } /** diff --git a/CRM/Core/Lock.php b/CRM/Core/Lock.php index f72c655d59..129e5db599 100644 --- a/CRM/Core/Lock.php +++ b/CRM/Core/Lock.php @@ -175,7 +175,7 @@ class CRM_Core_Lock implements \Civi\Core\Lock\LockInterface { $query = "SELECT GET_LOCK( %1, %2 )"; $params = [ 1 => [$this->_id, 'String'], - 2 => [$timeout ? $timeout : $this->_timeout, 'Integer'], + 2 => [$timeout ?: $this->_timeout, 'Integer'], ]; $res = CRM_Core_DAO::singleValueQuery($query, $params); if ($res) { diff --git a/CRM/Core/Menu.php b/CRM/Core/Menu.php index d22073f07b..774aaf5b96 100644 --- a/CRM/Core/Menu.php +++ b/CRM/Core/Menu.php @@ -522,7 +522,7 @@ class CRM_Core_Menu { 'id', 'name' ); } - $menu[$path]['component_id'] = $componentId ? $componentId : NULL; + $menu[$path]['component_id'] = $componentId ?: NULL; $cache[$compPath] = $menu[$path]['component_id']; } } diff --git a/CRM/Core/Page/AJAX/Location.php b/CRM/Core/Page/AJAX/Location.php index 2faae46bf2..0e47c0a466 100644 --- a/CRM/Core/Page/AJAX/Location.php +++ b/CRM/Core/Page/AJAX/Location.php @@ -226,7 +226,7 @@ class CRM_Core_Page_AJAX_Location { } $fld = "address[1][{$element}]"; $value = $location['address'][1][$element] ?? NULL; - $value = $value ? $value : ""; + $value = $value ?: ""; $result[str_replace([ '][', '[', @@ -244,7 +244,7 @@ class CRM_Core_Page_AJAX_Location { for ($i = 1; $i < 3; $i++) { $fld = "{$block}[{$i}][{$element}]"; $value = $location[$block][$i][$element] ?? NULL; - $value = $value ? $value : ""; + $value = $value ?: ""; $result[str_replace([ '][', '[', diff --git a/CRM/Core/Payment/PayPalIPN.php b/CRM/Core/Payment/PayPalIPN.php index 369e4c176a..23be16e1af 100644 --- a/CRM/Core/Payment/PayPalIPN.php +++ b/CRM/Core/Payment/PayPalIPN.php @@ -308,7 +308,7 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN { ]; foreach ($lookup as $name => $paypalName) { $value = $this->retrieve($paypalName, 'String', FALSE); - $input[$name] = $value ? $value : NULL; + $input[$name] = $value ?: NULL; } $input['is_test'] = $this->retrieve('test_ipn', 'Integer', FALSE); diff --git a/CRM/Core/Payment/PayPalProIPN.php b/CRM/Core/Payment/PayPalProIPN.php index 5b039d3b41..2106e136d4 100644 --- a/CRM/Core/Payment/PayPalProIPN.php +++ b/CRM/Core/Payment/PayPalProIPN.php @@ -480,7 +480,7 @@ class CRM_Core_Payment_PayPalProIPN extends CRM_Core_Payment_BaseIPN { ]; foreach ($lookup as $name => $paypalName) { $value = $this->retrieve($paypalName, 'String', FALSE); - $input[$name] = $value ? $value : NULL; + $input[$name] = $value ?: NULL; } $input['is_test'] = $this->retrieve('test_ipn', 'Integer', FALSE); diff --git a/CRM/Core/PseudoConstant.php b/CRM/Core/PseudoConstant.php index 35bc3cae68..e355265f0b 100644 --- a/CRM/Core/PseudoConstant.php +++ b/CRM/Core/PseudoConstant.php @@ -801,7 +801,7 @@ WHERE id = %1"; */ public static function allGroup($groupType = NULL, $excludeHidden = TRUE) { $condition = CRM_Contact_BAO_Group::groupTypeCondition($groupType, $excludeHidden); - $groupKey = ($groupType ? $groupType : 'null') . !empty($excludeHidden); + $groupKey = ($groupType ?: 'null') . !empty($excludeHidden); if (!isset(Civi::$statics[__CLASS__]['groups']['allGroup'][$groupKey])) { self::populate(Civi::$statics[__CLASS__]['groups']['allGroup'][$groupKey], 'CRM_Contact_DAO_Group', FALSE, 'title', 'is_active', $condition); diff --git a/CRM/Core/Selector/Controller.php b/CRM/Core/Selector/Controller.php index a3723979b1..c2cc8d196a 100644 --- a/CRM/Core/Selector/Controller.php +++ b/CRM/Core/Selector/Controller.php @@ -183,8 +183,8 @@ class CRM_Core_Selector_Controller { public function __construct($object, $pageID, $sortID, $action, $store = NULL, $output = self::TEMPLATE, $prefix = NULL, $case = NULL) { $this->_object = $object; - $this->_pageID = $pageID ? $pageID : 1; - $this->_sortID = $sortID ? $sortID : NULL; + $this->_pageID = $pageID ?: 1; + $this->_sortID = $sortID ?: NULL; $this->_action = $action; $this->_store = $store; $this->_output = $output; diff --git a/CRM/Core/Session.php b/CRM/Core/Session.php index 3f0011cc78..fa6003c784 100644 --- a/CRM/Core/Session.php +++ b/CRM/Core/Session.php @@ -325,7 +325,7 @@ class CRM_Core_Session { $ts = $this->get($name, 'timer'); if (!$ts || $ts < time() - $expire) { $this->set($name, time(), 'timer'); - return $ts ? $ts : 'not set'; + return $ts ?: 'not set'; } return FALSE; } @@ -502,7 +502,7 @@ class CRM_Core_Session { 'text' => $text, 'title' => $title, 'type' => $type, - 'options' => $options ? $options : NULL, + 'options' => $options ?: NULL, ]; } } diff --git a/CRM/Event/Form/ManageEvent/TabHeader.php b/CRM/Event/Form/ManageEvent/TabHeader.php index af32097768..8c159a7c39 100644 --- a/CRM/Event/Form/ManageEvent/TabHeader.php +++ b/CRM/Event/Form/ManageEvent/TabHeader.php @@ -227,7 +227,7 @@ WHERE e.id = %1 } } - $current = $current ? $current : 'settings'; + $current = $current ?: 'settings'; return $current; } diff --git a/CRM/Event/Form/Registration.php b/CRM/Event/Form/Registration.php index 26b938cf46..595ee19e88 100644 --- a/CRM/Event/Form/Registration.php +++ b/CRM/Event/Form/Registration.php @@ -1126,7 +1126,7 @@ class CRM_Event_Form_Registration extends CRM_Core_Form { */ public function getTemplateFileName() { $fileName = $this->checkTemplateFileExists(); - return $fileName ? $fileName : parent::getTemplateFileName(); + return $fileName ?: parent::getTemplateFileName(); } /** @@ -1136,7 +1136,7 @@ class CRM_Event_Form_Registration extends CRM_Core_Form { */ public function overrideExtraTemplateFileName() { $fileName = $this->checkTemplateFileExists('extra.'); - return $fileName ? $fileName : parent::overrideExtraTemplateFileName(); + return $fileName ?: parent::overrideExtraTemplateFileName(); } /** diff --git a/CRM/Event/PseudoConstant.php b/CRM/Event/PseudoConstant.php index ca1ad28386..b8bd9f11a6 100644 --- a/CRM/Event/PseudoConstant.php +++ b/CRM/Event/PseudoConstant.php @@ -124,7 +124,7 @@ class CRM_Event_PseudoConstant extends CRM_Core_PseudoConstant { self::$participantStatus = []; } - $index = $cond ? $cond : 'No Condition'; + $index = $cond ?: 'No Condition'; $index = "{$index}_{$retColumn}"; if (empty(self::$participantStatus[$index])) { self::$participantStatus[$index] = []; @@ -183,7 +183,7 @@ class CRM_Event_PseudoConstant extends CRM_Core_PseudoConstant { * array reference of all participant roles if any */ public static function &participantRole($id = NULL, $cond = NULL) { - $index = $cond ? $cond : 'No Condition'; + $index = $cond ?: 'No Condition'; if (empty(self::$participantRole[$index])) { self::$participantRole[$index] = []; diff --git a/CRM/Logging/ReportDetail.php b/CRM/Logging/ReportDetail.php index a8cb03d610..8df6ec89e5 100644 --- a/CRM/Logging/ReportDetail.php +++ b/CRM/Logging/ReportDetail.php @@ -455,7 +455,7 @@ class CRM_Logging_ReportDetail extends CRM_Report_Form { unset($_POST['crmPID_B'], $_POST['crmPID']); } - $pageId = $pageId ? $pageId : 1; + $pageId = $pageId ?: 1; $offset = ($pageId - 1) * $rowCount; $offset = CRM_Utils_Type::escape($offset, 'Int'); diff --git a/CRM/Mailing/PseudoConstant.php b/CRM/Mailing/PseudoConstant.php index cd8064400c..ea347de44e 100644 --- a/CRM/Mailing/PseudoConstant.php +++ b/CRM/Mailing/PseudoConstant.php @@ -135,7 +135,7 @@ class CRM_Mailing_PseudoConstant extends CRM_Core_PseudoConstant { * array reference of all mailing components */ public static function &component($type = NULL) { - $name = $type ? $type : 'ALL'; + $name = $type ?: 'ALL'; if (!self::$component || !array_key_exists($name, self::$component)) { if (!self::$component) { diff --git a/CRM/Mailing/Selector/Browse.php b/CRM/Mailing/Selector/Browse.php index 603eb9084c..c5253d53db 100644 --- a/CRM/Mailing/Selector/Browse.php +++ b/CRM/Mailing/Selector/Browse.php @@ -439,7 +439,7 @@ LEFT JOIN civicrm_contact scheduledContact ON ( $mailing.scheduled_id = schedul $actionMask, [ 'mid' => $row['id'], - 'hashOrMid' => $hash ? $hash : $row['id'], + 'hashOrMid' => $hash ?: $row['id'], ], "more", FALSE, diff --git a/CRM/PCP/Page/PCPInfo.php b/CRM/PCP/Page/PCPInfo.php index c20e94e56c..18496ef20e 100644 --- a/CRM/PCP/Page/PCPInfo.php +++ b/CRM/PCP/Page/PCPInfo.php @@ -211,7 +211,7 @@ class CRM_PCP_Page_PCPInfo extends CRM_Core_Page { } $this->assign('honor', $honor); - $this->assign('total', $totalAmount ? $totalAmount : '0.0'); + $this->assign('total', $totalAmount ?: '0.0'); $this->assign('achieved', $achieved <= 100 ? $achieved : 100); if ($achieved <= 100) { diff --git a/CRM/Pledge/BAO/Pledge.php b/CRM/Pledge/BAO/Pledge.php index c665dc2b1a..1279c56a33 100644 --- a/CRM/Pledge/BAO/Pledge.php +++ b/CRM/Pledge/BAO/Pledge.php @@ -922,7 +922,7 @@ SELECT pledge.contact_id as contact_id, // 2. send acknowledgement mail if ($toEmail && !($doNotEmail || $onHold)) { // assign value to template - $template->assign('amount_paid', $details['amount_paid'] ? $details['amount_paid'] : 0); + $template->assign('amount_paid', $details['amount_paid'] ?: 0); $template->assign('next_payment', $details['scheduled_date']); $template->assign('amount_due', $details['amount_due']); $template->assign('checksumValue', $details['checksumValue']); diff --git a/CRM/Profile/Form.php b/CRM/Profile/Form.php index 9ba8bc0ee7..19c7667761 100644 --- a/CRM/Profile/Form.php +++ b/CRM/Profile/Form.php @@ -770,7 +770,7 @@ class CRM_Profile_Form extends CRM_Core_Form { $return = TRUE; if (!$statusMessage) { $statusMessage = ts("This profile is configured for contact type '%1'. It cannot be used to edit contacts of other types.", - [1 => $profileSubType ? $profileSubType : $profileType]); + [1 => $profileSubType ?: $profileType]); } } } @@ -1367,7 +1367,7 @@ class CRM_Profile_Form extends CRM_Core_Form { */ public function getTemplateFileName() { $fileName = $this->checkTemplateFileExists(); - return $fileName ? $fileName : parent::getTemplateFileName(); + return $fileName ?: parent::getTemplateFileName(); } /** @@ -1378,7 +1378,7 @@ class CRM_Profile_Form extends CRM_Core_Form { */ public function overrideExtraTemplateFileName() { $fileName = $this->checkTemplateFileExists('extra.'); - return $fileName ? $fileName : parent::overrideExtraTemplateFileName(); + return $fileName ?: parent::overrideExtraTemplateFileName(); } /** diff --git a/CRM/Profile/Page/Dynamic.php b/CRM/Profile/Page/Dynamic.php index d17f37d43f..d6009aa02d 100644 --- a/CRM/Profile/Page/Dynamic.php +++ b/CRM/Profile/Page/Dynamic.php @@ -420,7 +420,7 @@ class CRM_Profile_Page_Dynamic extends CRM_Core_Page { */ public function getTemplateFileName() { $fileName = $this->checkTemplateFileExists(); - return $fileName ? $fileName : parent::getTemplateFileName(); + return $fileName ?: parent::getTemplateFileName(); } /** @@ -431,7 +431,7 @@ class CRM_Profile_Page_Dynamic extends CRM_Core_Page { */ public function overrideExtraTemplateFileName() { $fileName = $this->checkTemplateFileExists('extra.'); - return $fileName ? $fileName : parent::overrideExtraTemplateFileName(); + return $fileName ?: parent::overrideExtraTemplateFileName(); } /** diff --git a/CRM/Profile/Page/Listings.php b/CRM/Profile/Page/Listings.php index 4ad6a75771..9bfcebd601 100644 --- a/CRM/Profile/Page/Listings.php +++ b/CRM/Profile/Page/Listings.php @@ -483,7 +483,7 @@ class CRM_Profile_Page_Listings extends CRM_Core_Page { */ public function getTemplateFileName() { $fileName = $this->checkTemplateFileExists(); - return $fileName ? $fileName : parent::getTemplateFileName(); + return $fileName ?: parent::getTemplateFileName(); } /** @@ -494,7 +494,7 @@ class CRM_Profile_Page_Listings extends CRM_Core_Page { */ public function overrideExtraTemplateFileName() { $fileName = $this->checkTemplateFileExists('extra.'); - return $fileName ? $fileName : parent::overrideExtraTemplateFileName(); + return $fileName ?: parent::overrideExtraTemplateFileName(); } } diff --git a/CRM/Profile/Page/View.php b/CRM/Profile/Page/View.php index 90d8351496..5ecdb3b58f 100644 --- a/CRM/Profile/Page/View.php +++ b/CRM/Profile/Page/View.php @@ -195,7 +195,7 @@ class CRM_Profile_Page_View extends CRM_Core_Page { */ public function getTemplateFileName() { $fileName = $this->checkTemplateFileExists(); - return $fileName ? $fileName : parent::getTemplateFileName(); + return $fileName ?: parent::getTemplateFileName(); } /** @@ -206,7 +206,7 @@ class CRM_Profile_Page_View extends CRM_Core_Page { */ public function overrideExtraTemplateFileName() { $fileName = $this->checkTemplateFileExists('extra.'); - return $fileName ? $fileName : parent::overrideExtraTemplateFileName(); + return $fileName ?: parent::overrideExtraTemplateFileName(); } } diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 6c5e14cf46..5078254988 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -3711,7 +3711,7 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND unset($_POST['crmPID_B'], $_POST['crmPID']); } - $pageId = $pageId ? $pageId : 1; + $pageId = $pageId ?: 1; $this->set(CRM_Utils_Pager::PAGE_ID, $pageId); $offset = ($pageId - 1) * $rowCount; @@ -5118,7 +5118,7 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a * @param string $table */ public function setEntityRefDefaults(&$field, $table) { - $field['attributes'] = $field['attributes'] ? $field['attributes'] : []; + $field['attributes'] = $field['attributes'] ?: []; $field['attributes'] += [ 'entity' => CRM_Core_DAO_AllCoreTables::getEntityNameForTable($table), 'multiple' => TRUE, diff --git a/CRM/Report/Form/Contribute/RecurSummary.php b/CRM/Report/Form/Contribute/RecurSummary.php index 74d2bc35e6..7cb5190442 100644 --- a/CRM/Report/Form/Contribute/RecurSummary.php +++ b/CRM/Report/Form/Contribute/RecurSummary.php @@ -225,10 +225,10 @@ class CRM_Report_Form_Contribute_RecurSummary extends CRM_Report_Form { $startDateRelative = $this->_params["start_date_relative"] ?? NULL; $startedDateSql = $this->dateClause('start_date', $startDateRelative, $startDateFrom, $startDateTo); - $startedDateSql = $startedDateSql ? $startedDateSql : " ( 1 ) "; + $startedDateSql = $startedDateSql ?: " ( 1 ) "; $cancelledDateSql = $this->dateClause('cancel_date', $startDateRelative, $startDateFrom, $startDateTo); - $cancelledDateSql = $cancelledDateSql ? $cancelledDateSql : " ( cancel_date IS NOT NULL ) "; + $cancelledDateSql = $cancelledDateSql ?: " ( cancel_date IS NOT NULL ) "; $started = $cancelled = $active = $total = 0; diff --git a/CRM/Report/Form/Contribute/TopDonor.php b/CRM/Report/Form/Contribute/TopDonor.php index fa40ee3d8b..7666485e9c 100644 --- a/CRM/Report/Form/Contribute/TopDonor.php +++ b/CRM/Report/Form/Contribute/TopDonor.php @@ -362,7 +362,7 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form { } } - $pageId = $pageId ? $pageId : 1; + $pageId = $pageId ?: 1; $this->set(CRM_Utils_Pager::PAGE_ID, $pageId); $offset = ($pageId - 1) * $rowCount; diff --git a/CRM/SMS/Form/Upload.php b/CRM/SMS/Form/Upload.php index da40e49a7a..ae52483822 100644 --- a/CRM/SMS/Form/Upload.php +++ b/CRM/SMS/Form/Upload.php @@ -56,7 +56,7 @@ class CRM_SMS_Form_Upload extends CRM_Core_Form { // We don't want to retrieve template details once it is // set in session. $templateId = $this->get('template'); - $this->assign('templateSelected', $templateId ? $templateId : 0); + $this->assign('templateSelected', $templateId ?: 0); if (isset($defaults['msg_template_id']) && !$templateId) { $defaults['SMStemplate'] = $defaults['msg_template_id']; $messageTemplate = new CRM_Core_DAO_MessageTemplate(); diff --git a/CRM/Utils/Mail.php b/CRM/Utils/Mail.php index f3a0559381..76263cce00 100644 --- a/CRM/Utils/Mail.php +++ b/CRM/Utils/Mail.php @@ -43,8 +43,8 @@ class CRM_Utils_Mail { throw new CRM_Core_Exception(ts('There is no valid smtp server setting. Click Administer >> System Setting >> Outbound Email to set the SMTP Server.', [1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1')])); } - $params['host'] = $mailingInfo['smtpServer'] ? $mailingInfo['smtpServer'] : 'localhost'; - $params['port'] = $mailingInfo['smtpPort'] ? $mailingInfo['smtpPort'] : 25; + $params['host'] = $mailingInfo['smtpServer'] ?: 'localhost'; + $params['port'] = $mailingInfo['smtpPort'] ?: 25; if ($mailingInfo['smtpAuth']) { $params['username'] = $mailingInfo['smtpUsername']; diff --git a/CRM/Utils/Mail/Incoming.php b/CRM/Utils/Mail/Incoming.php index a1a941f160..d3cf5bf0b8 100644 --- a/CRM/Utils/Mail/Incoming.php +++ b/CRM/Utils/Mail/Incoming.php @@ -377,7 +377,7 @@ class CRM_Utils_Mail_Incoming { $createContact, $mail ); - $subParam['id'] = $contactID ? $contactID : NULL; + $subParam['id'] = $contactID ?: NULL; } /** -- 2.25.1