diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index 3d7993b5fbff..37ece7b6fdd6 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -922,7 +922,7 @@ public static function createEmailActivity($sourceContactID, $subject, $html, $t $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 @@ public static function getParentActivity($activityId) { '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 391b52304c47..ce4320617155 100644 --- a/CRM/Admin/Form/RelationshipType.php +++ b/CRM/Admin/Form/RelationshipType.php @@ -159,8 +159,8 @@ public function postProcess() { $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 c7054f570fa8..a12e609326e3 100644 --- a/CRM/Campaign/Form/Survey/Results.php +++ b/CRM/Campaign/Form/Survey/Results.php @@ -397,7 +397,7 @@ public function postProcess() { $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 e7bfd2fa569f..2856c09a3e7a 100644 --- a/CRM/Campaign/Form/Survey/TabHeader.php +++ b/CRM/Campaign/Form/Survey/TabHeader.php @@ -137,7 +137,7 @@ public static function getCurrentTab($tabs) { } } - $current = $current ? $current : 'main'; + $current = $current ?: 'main'; return $current; } @@ -166,7 +166,7 @@ public static function getNextTab(&$form) { } } - $next = $next ? $next : 'main'; + $next = $next ?: 'main'; return $next; } diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index a925762dd469..d54041d393b5 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -1135,7 +1135,7 @@ public static function processImage() { $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 eb45476e8684..03b91fbf66e2 100644 --- a/CRM/Contact/BAO/Relationship.php +++ b/CRM/Contact/BAO/Relationship.php @@ -2040,7 +2040,7 @@ public static function buildOptions($fieldName, $context = NULL, $props = []) { */ 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 04a1b7bd575e..1755bbc2327f 100644 --- a/CRM/Contact/Form/Task/EmailTrait.php +++ b/CRM/Contact/Form/Task/EmailTrait.php @@ -838,7 +838,7 @@ protected function createEmailActivity($sourceContactID, $subject, $html, $text, $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 2d451f782ce0..86b0e9457265 100644 --- a/CRM/Contribute/Form/AdditionalInfo.php +++ b/CRM/Contribute/Form/AdditionalInfo.php @@ -255,7 +255,7 @@ public static function processNote($params, $contactID, $contributionID, $contri $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 b423a4b41ca0..b1972d0060e9 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -1089,7 +1089,7 @@ public function getTemplateFileName() { */ 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 c103759321bc..1344cbb441ef 100644 --- a/CRM/Contribute/Form/ContributionPage/TabHeader.php +++ b/CRM/Contribute/Form/ContributionPage/TabHeader.php @@ -179,7 +179,7 @@ public static function getCurrentTab($tabs) { } } - $current = $current ? $current : 'settings'; + $current = $current ?: 'settings'; return $current; } diff --git a/CRM/Core/BAO/Country.php b/CRM/Core/BAO/Country.php index d81958f09dbe..8d53a8bf8ac2 100644 --- a/CRM/Core/BAO/Country.php +++ b/CRM/Core/BAO/Country.php @@ -174,7 +174,7 @@ public static function defaultContactCountryName() { 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 1462718c86cc..548baffdc68a 100644 --- a/CRM/Core/BAO/Domain.php +++ b/CRM/Core/BAO/Domain.php @@ -273,7 +273,7 @@ public static function getGroupId() { $title, 'id', 'title', TRUE ); } - return $groupID ? $groupID : FALSE; + return $groupID ?: FALSE; } /** diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index e29b8fcb22c7..76a7baaf79ad 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -489,7 +489,7 @@ public function &add( // 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 @@ public function get_template_vars($name = NULL) { */ 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 7484564f5bf5..2c789e152ec8 100644 --- a/CRM/Core/I18n.php +++ b/CRM/Core/I18n.php @@ -774,7 +774,7 @@ public static function getContactDefaultLanguage() { */ 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 f72c655d59ff..129e5db5998d 100644 --- a/CRM/Core/Lock.php +++ b/CRM/Core/Lock.php @@ -175,7 +175,7 @@ public function acquire($timeout = NULL) { $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 d22073f07b03..774aaf5b9686 100644 --- a/CRM/Core/Menu.php +++ b/CRM/Core/Menu.php @@ -522,7 +522,7 @@ public static function fillComponentIds(&$menu, $path) { '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 2faae46bf279..0e47c0a46600 100644 --- a/CRM/Core/Page/AJAX/Location.php +++ b/CRM/Core/Page/AJAX/Location.php @@ -226,7 +226,7 @@ public static function getLocBlock() { } $fld = "address[1][{$element}]"; $value = $location['address'][1][$element] ?? NULL; - $value = $value ? $value : ""; + $value = $value ?: ""; $result[str_replace([ '][', '[', @@ -244,7 +244,7 @@ public static function getLocBlock() { 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 369e4c176ae5..23be16e1afd0 100644 --- a/CRM/Core/Payment/PayPalIPN.php +++ b/CRM/Core/Payment/PayPalIPN.php @@ -308,7 +308,7 @@ public function getInput(&$input) { ]; 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 5b039d3b4136..2106e136d425 100644 --- a/CRM/Core/Payment/PayPalProIPN.php +++ b/CRM/Core/Payment/PayPalProIPN.php @@ -480,7 +480,7 @@ public function getInput(&$input) { ]; 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 35bc3cae6839..e355265f0b1c 100644 --- a/CRM/Core/PseudoConstant.php +++ b/CRM/Core/PseudoConstant.php @@ -801,7 +801,7 @@ public static function &countryIsoCode($id = FALSE) { */ 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 a3723979b13e..c2cc8d196aa6 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 3f0011cc78cc..fa6003c784d3 100644 --- a/CRM/Core/Session.php +++ b/CRM/Core/Session.php @@ -325,7 +325,7 @@ public function timer($name, $expire) { $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 @@ public static function setStatus($text, $title = '', $type = 'alert', $options = '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 af32097768d4..8c159a7c3978 100644 --- a/CRM/Event/Form/ManageEvent/TabHeader.php +++ b/CRM/Event/Form/ManageEvent/TabHeader.php @@ -227,7 +227,7 @@ public static function getCurrentTab($tabs) { } } - $current = $current ? $current : 'settings'; + $current = $current ?: 'settings'; return $current; } diff --git a/CRM/Event/Form/Registration.php b/CRM/Event/Form/Registration.php index 26b938cf46b4..595ee19e88df 100644 --- a/CRM/Event/Form/Registration.php +++ b/CRM/Event/Form/Registration.php @@ -1126,7 +1126,7 @@ public function checkTemplateFileExists($suffix = NULL) { */ public function getTemplateFileName() { $fileName = $this->checkTemplateFileExists(); - return $fileName ? $fileName : parent::getTemplateFileName(); + return $fileName ?: parent::getTemplateFileName(); } /** @@ -1136,7 +1136,7 @@ public function getTemplateFileName() { */ 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 ca1ad28386c2..b8bd9f11a62b 100644 --- a/CRM/Event/PseudoConstant.php +++ b/CRM/Event/PseudoConstant.php @@ -124,7 +124,7 @@ public static function &participantStatus($id = NULL, $cond = NULL, $retColumn = 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 @@ public static function &participantStatusClass() { * 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 a8cb03d610b1..8df6ec89e5b6 100644 --- a/CRM/Logging/ReportDetail.php +++ b/CRM/Logging/ReportDetail.php @@ -455,7 +455,7 @@ public function getLimit($rowCount = self::ROW_COUNT_LIMIT) { 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 cd8064400c7f..ea347de44e21 100644 --- a/CRM/Mailing/PseudoConstant.php +++ b/CRM/Mailing/PseudoConstant.php @@ -135,7 +135,7 @@ public static function mailingTypes() { * 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 603eb9084ce8..c5253d53dba0 100644 --- a/CRM/Mailing/Selector/Browse.php +++ b/CRM/Mailing/Selector/Browse.php @@ -439,7 +439,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $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 c20e94e56c5d..18496ef20e59 100644 --- a/CRM/PCP/Page/PCPInfo.php +++ b/CRM/PCP/Page/PCPInfo.php @@ -211,7 +211,7 @@ public function run() { } $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 c665dc2b1af1..1279c56a3305 100644 --- a/CRM/Pledge/BAO/Pledge.php +++ b/CRM/Pledge/BAO/Pledge.php @@ -922,7 +922,7 @@ public static function updatePledgeStatus(array $params): array { // 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 9ba8bc0ee7ad..19c766776142 100644 --- a/CRM/Profile/Form.php +++ b/CRM/Profile/Form.php @@ -770,7 +770,7 @@ public function buildQuickForm(): void { $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 @@ public function checkTemplateFileExists($suffix = NULL) { */ public function getTemplateFileName() { $fileName = $this->checkTemplateFileExists(); - return $fileName ? $fileName : parent::getTemplateFileName(); + return $fileName ?: parent::getTemplateFileName(); } /** @@ -1378,7 +1378,7 @@ public function getTemplateFileName() { */ 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 d17f37d43f39..d6009aa02d80 100644 --- a/CRM/Profile/Page/Dynamic.php +++ b/CRM/Profile/Page/Dynamic.php @@ -420,7 +420,7 @@ public function checkTemplateFileExists($suffix = NULL) { */ public function getTemplateFileName() { $fileName = $this->checkTemplateFileExists(); - return $fileName ? $fileName : parent::getTemplateFileName(); + return $fileName ?: parent::getTemplateFileName(); } /** @@ -431,7 +431,7 @@ public function getTemplateFileName() { */ 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 4ad6a75771eb..9bfcebd60189 100644 --- a/CRM/Profile/Page/Listings.php +++ b/CRM/Profile/Page/Listings.php @@ -483,7 +483,7 @@ public function checkTemplateFileExists($suffix = NULL) { */ public function getTemplateFileName() { $fileName = $this->checkTemplateFileExists(); - return $fileName ? $fileName : parent::getTemplateFileName(); + return $fileName ?: parent::getTemplateFileName(); } /** @@ -494,7 +494,7 @@ public function getTemplateFileName() { */ 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 90d835149640..5ecdb3b58f5d 100644 --- a/CRM/Profile/Page/View.php +++ b/CRM/Profile/Page/View.php @@ -195,7 +195,7 @@ public function checkTemplateFileExists($suffix = NULL) { */ public function getTemplateFileName() { $fileName = $this->checkTemplateFileExists(); - return $fileName ? $fileName : parent::getTemplateFileName(); + return $fileName ?: parent::getTemplateFileName(); } /** @@ -206,7 +206,7 @@ public function getTemplateFileName() { */ 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 6c5e14cf46fd..5078254988e6 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -3711,7 +3711,7 @@ public function limit($rowCount = NULL) { 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 @@ public function add2group($groupID) { * @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 74d2bc35e607..7cb5190442b7 100644 --- a/CRM/Report/Form/Contribute/RecurSummary.php +++ b/CRM/Report/Form/Contribute/RecurSummary.php @@ -225,10 +225,10 @@ public function alterDisplay(&$rows) { $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 fa40ee3d8b62..7666485e9c75 100644 --- a/CRM/Report/Form/Contribute/TopDonor.php +++ b/CRM/Report/Form/Contribute/TopDonor.php @@ -362,7 +362,7 @@ public function limit($rowCount = NULL) { } } - $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 da40e49a7a0c..ae52483822f2 100644 --- a/CRM/SMS/Form/Upload.php +++ b/CRM/SMS/Form/Upload.php @@ -56,7 +56,7 @@ public function setDefaultValues() { // 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 f3a055938113..76263cce0073 100644 --- a/CRM/Utils/Mail.php +++ b/CRM/Utils/Mail.php @@ -43,8 +43,8 @@ public static function createMailer() { 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 a1a941f16048..d3cf5bf0b886 100644 --- a/CRM/Utils/Mail/Incoming.php +++ b/CRM/Utils/Mail/Incoming.php @@ -377,7 +377,7 @@ private static function parseAddress(&$address, &$params, &$subParam, &$mail, $c $createContact, $mail ); - $subParam['id'] = $contactID ? $contactID : NULL; + $subParam['id'] = $contactID ?: NULL; } /** diff --git a/Civi/Angular/Manager.php b/Civi/Angular/Manager.php index 3fb77b0f5d60..9daf7ca62223 100644 --- a/Civi/Angular/Manager.php +++ b/Civi/Angular/Manager.php @@ -56,7 +56,7 @@ class Manager { */ public function __construct($res, \CRM_Utils_Cache_Interface $cache = NULL) { $this->res = $res; - $this->cache = $cache ? $cache : new \CRM_Utils_Cache_ArrayCache([]); + $this->cache = $cache ?: new \CRM_Utils_Cache_ArrayCache([]); } /** diff --git a/Civi/Core/Themes.php b/Civi/Core/Themes.php index ebf698222746..05469ba93710 100644 --- a/Civi/Core/Themes.php +++ b/Civi/Core/Themes.php @@ -57,7 +57,7 @@ class Themes extends \Civi\Core\Service\AutoService { * @param \CRM_Utils_Cache_Interface $cache */ public function __construct($cache = NULL) { - $this->cache = $cache ? $cache : Civi::cache('long'); + $this->cache = $cache ?: Civi::cache('long'); } /** diff --git a/Civi/Test/DbTestTrait.php b/Civi/Test/DbTestTrait.php index ff81b0e0d532..bdfcbfe9a809 100644 --- a/Civi/Test/DbTestTrait.php +++ b/Civi/Test/DbTestTrait.php @@ -111,7 +111,7 @@ public function assertDBNull($daoName, $searchValue, $returnColumn, $searchColum * @param null $message */ public function assertDBRowNotExist($daoName, $id, $message = NULL) { - $message = $message ? $message : "$daoName (#$id) should not exist"; + $message = $message ?: "$daoName (#$id) should not exist"; $value = \CRM_Core_DAO::getFieldValue($daoName, $id, 'id', 'id', TRUE); $this->assertNull($value, $message); } @@ -123,7 +123,7 @@ public function assertDBRowNotExist($daoName, $id, $message = NULL) { * @param null $message */ public function assertDBRowExist($daoName, $id, $message = NULL) { - $message = $message ? $message : "$daoName (#$id) should exist"; + $message = $message ?: "$daoName (#$id) should exist"; $value = \CRM_Core_DAO::getFieldValue($daoName, $id, 'id', 'id', TRUE); $this->assertEquals($id, $value, $message); } diff --git a/api/v3/Activity.php b/api/v3/Activity.php index 6d95e7ca2aab..89ce4e5842c4 100644 --- a/api/v3/Activity.php +++ b/api/v3/Activity.php @@ -641,7 +641,7 @@ function _civicrm_api3_activity_check_params(&$params) { $activityTypeId = $params['activity_type_id'] ?? NULL; if ($activityName || $activityLabel) { - $activityTypeIdInList = array_search(($activityName ? $activityName : $activityLabel), $activityTypes); + $activityTypeIdInList = array_search(($activityName ?: $activityLabel), $activityTypes); if (!$activityTypeIdInList) { $errorString = $activityName ? "Invalid Activity Name : $activityName" : "Invalid Activity Type Label"; diff --git a/api/v3/CustomValue.php b/api/v3/CustomValue.php index f3b127c177cd..252adeb0f68f 100644 --- a/api/v3/CustomValue.php +++ b/api/v3/CustomValue.php @@ -345,14 +345,14 @@ function civicrm_api3_custom_value_gettree($params) { $result = []; foreach ($tree as $group) { $result[$group['name']] = []; - $groupToReturn = $toReturn['custom_group'] ? $toReturn['custom_group'] : array_keys($group); + $groupToReturn = $toReturn['custom_group'] ?: array_keys($group); foreach ($groupToReturn as $item) { $result[$group['name']][$item] = $group[$item] ?? NULL; } $result[$group['name']]['fields'] = []; foreach ($group['fields'] as $fieldInfo) { $field = ['value' => NULL]; - $fieldToReturn = $toReturn['custom_field'] ? $toReturn['custom_field'] : array_keys($fieldInfo); + $fieldToReturn = $toReturn['custom_field'] ?: array_keys($fieldInfo); foreach ($fieldToReturn as $item) { $field[$item] = $fieldInfo[$item] ?? NULL; } diff --git a/ext/authx/Civi/Authx/Backdrop.php b/ext/authx/Civi/Authx/Backdrop.php index c2d248f18038..1252f92f963a 100644 --- a/ext/authx/Civi/Authx/Backdrop.php +++ b/ext/authx/Civi/Authx/Backdrop.php @@ -19,7 +19,7 @@ class Backdrop implements AuthxInterface { public function checkPassword(string $username, string $password) { $uid = user_authenticate($username, $password); // Ensure strict nullness. - return $uid ? $uid : NULL; + return $uid ?: NULL; } /** diff --git a/ext/authx/Civi/Authx/Drupal.php b/ext/authx/Civi/Authx/Drupal.php index e9722cab205a..f43e5b14a8af 100644 --- a/ext/authx/Civi/Authx/Drupal.php +++ b/ext/authx/Civi/Authx/Drupal.php @@ -19,7 +19,7 @@ class Drupal implements AuthxInterface { public function checkPassword(string $username, string $password) { $uid = user_authenticate($username, $password); // Ensure strict nullness. - return $uid ? $uid : NULL; + return $uid ?: NULL; } /** diff --git a/ext/authx/Civi/Authx/Drupal8.php b/ext/authx/Civi/Authx/Drupal8.php index 54f8c122a697..89ff2d8d0771 100644 --- a/ext/authx/Civi/Authx/Drupal8.php +++ b/ext/authx/Civi/Authx/Drupal8.php @@ -19,7 +19,7 @@ class Drupal8 implements AuthxInterface { public function checkPassword(string $username, string $password) { $uid = \Drupal::service('user.auth')->authenticate($username, $password); // Ensure strict nullness. - return $uid ? $uid : NULL; + return $uid ?: NULL; } /** diff --git a/ext/flexmailer/src/FlexMailer.php b/ext/flexmailer/src/FlexMailer.php index c46160a73801..844ee666598b 100644 --- a/ext/flexmailer/src/FlexMailer.php +++ b/ext/flexmailer/src/FlexMailer.php @@ -133,7 +133,7 @@ public static function createAndRun($job, $deprecatedMessageMailer, $deprecatedT */ public function __construct($context = array(), EventDispatcherInterface $dispatcher = NULL) { $this->context = $context; - $this->dispatcher = $dispatcher ? $dispatcher : \Civi::service('dispatcher'); + $this->dispatcher = $dispatcher ?: \Civi::service('dispatcher'); } /** diff --git a/ext/flexmailer/src/Validator.php b/ext/flexmailer/src/Validator.php index 455d6f053881..549d028e3c3c 100644 --- a/ext/flexmailer/src/Validator.php +++ b/ext/flexmailer/src/Validator.php @@ -54,7 +54,7 @@ public static function createAndRun(array $params): array { * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher */ public function __construct(EventDispatcherInterface $dispatcher = NULL) { - $this->dispatcher = $dispatcher ? $dispatcher : \Civi::service('dispatcher'); + $this->dispatcher = $dispatcher ?: \Civi::service('dispatcher'); } /** diff --git a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom.php b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom.php index 2e5d19a28e65..942cfea4aab4 100644 --- a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom.php +++ b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom.php @@ -138,7 +138,7 @@ public function getTemplateFileName() { $fileName = $this->_customClass->templateFile(); } - return $fileName ? $fileName : parent::getTemplateFileName(); + return $fileName ?: parent::getTemplateFileName(); } public function postProcess() { diff --git a/setup/src/Setup.php b/setup/src/Setup.php index 18e38b89641e..1d7ead79db97 100644 --- a/setup/src/Setup.php +++ b/setup/src/Setup.php @@ -77,7 +77,7 @@ public static function init($modelValues = array(), $pluginCallback = NULL, $log '/^civi\.setupui\./' => 'run', '/./' => 'fail', ]); - self::$instance->log = $log ? $log : new NullLogger(); + self::$instance->log = $log ?: new NullLogger(); $pluginDir = dirname(__DIR__) . '/plugins'; $pluginFiles = array(); diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 973a120a5f43..08b5e7eadffb 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -1430,7 +1430,7 @@ public function CustomGroupMultipleCreateWithFields($params = []) { public function entityCustomGroupWithSingleFieldCreate($function, $filename): array { $params = ['title' => $function]; $entity = substr(basename($filename), 0, strlen(basename($filename)) - 8); - $params['extends'] = $entity ? $entity : 'Contact'; + $params['extends'] = $entity ?: 'Contact'; $customGroup = $this->customGroupCreate($params); $customField = $this->customFieldCreate(['custom_group_id' => $customGroup['id'], 'label' => $function]); CRM_Core_PseudoConstant::flush(); @@ -1453,7 +1453,7 @@ public function entityCustomGroupWithSingleFieldCreate($function, $filename): ar public function entityCustomGroupWithSingleStringMultiSelectFieldCreate($function, $filename) { $params = ['title' => $function]; $entity = substr(basename($filename), 0, strlen(basename($filename)) - 8); - $params['extends'] = $entity ? $entity : 'Contact'; + $params['extends'] = $entity ?: 'Contact'; $customGroup = $this->customGroupCreate($params); $customField = $this->customFieldCreate(['custom_group_id' => $customGroup['id'], 'label' => $function, 'html_type' => 'Multi-Select', 'default_value' => 1]); CRM_Core_PseudoConstant::flush();