From 1c1f21f45fbcd55bb87a7e2c50d79f0c69417ee6 Mon Sep 17 00:00:00 2001 From: colemanw Date: Fri, 21 Jul 2023 19:57:06 -0700 Subject: [PATCH] (REF) Replace CRM_Utils_Array with equivalent `?? NULL` --- CRM/Admin/Form/ScheduleReminders.php | 2 +- CRM/Badge/BAO/Badge.php | 2 +- CRM/Case/Form/Activity.php | 2 +- CRM/Contribute/BAO/ContributionRecur.php | 2 +- CRM/Contribute/Form/Contribution.php | 2 +- CRM/Contribute/Form/Task/Batch.php | 2 +- CRM/Core/BAO/Block.php | 4 ++-- CRM/Core/BAO/File.php | 2 +- CRM/Core/Form.php | 2 +- CRM/Event/Form/ManageEvent/Fee.php | 2 +- CRM/Event/Form/Participant.php | 2 +- CRM/Event/Form/ParticipantFeeSelection.php | 2 +- CRM/Report/Form.php | 4 ++-- CRM/Report/Form/Contribute/RecurSummary.php | 2 +- CRM/Report/Form/Contribute/Summary.php | 4 ++-- CRM/Report/Form/Member/Summary.php | 2 +- CRM/Report/Utils/Get.php | 2 +- api/v3/Relationship.php | 2 +- api/v3/utils.php | 4 ++-- 19 files changed, 23 insertions(+), 23 deletions(-) diff --git a/CRM/Admin/Form/ScheduleReminders.php b/CRM/Admin/Form/ScheduleReminders.php index d2c4dd580e..1f1237790d 100644 --- a/CRM/Admin/Form/ScheduleReminders.php +++ b/CRM/Admin/Form/ScheduleReminders.php @@ -321,7 +321,7 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $errors['sms_text_message'] = ts('The SMS message is a required field.'); } - if (empty($self->getContext()) && CRM_Utils_System::isNull(CRM_Utils_Array::value(1, $fields['entity']))) { + if (empty($self->getContext()) && CRM_Utils_System::isNull($fields['entity'][1] ?? NULL)) { $errors['entity'] = ts('Please select entity value'); } diff --git a/CRM/Badge/BAO/Badge.php b/CRM/Badge/BAO/Badge.php index b83929b180..d3486b13ff 100644 --- a/CRM/Badge/BAO/Badge.php +++ b/CRM/Badge/BAO/Badge.php @@ -199,7 +199,7 @@ class CRM_Badge_BAO_Badge { if (!empty($formattedRow['participant_image'])) { $imageAlign = 0; - switch (CRM_Utils_Array::value('alignment_participant_image', $formattedRow)) { + switch ($formattedRow['alignment_participant_image'] ?? NULL) { case 'R': $imageAlign = 68; break; diff --git a/CRM/Case/Form/Activity.php b/CRM/Case/Form/Activity.php index c0dfe15a80..affa4e4458 100644 --- a/CRM/Case/Form/Activity.php +++ b/CRM/Case/Form/Activity.php @@ -398,7 +398,7 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { } //set parent id if its edit mode - if ($parentId = CRM_Utils_Array::value('parent_id', $this->_defaults)) { + if ($parentId = $this->_defaults['parent_id'] ?? NULL) { $params['parent_id'] = $parentId; } diff --git a/CRM/Contribute/BAO/ContributionRecur.php b/CRM/Contribute/BAO/ContributionRecur.php index 6d74fa4f07..23d39173ed 100644 --- a/CRM/Contribute/BAO/ContributionRecur.php +++ b/CRM/Contribute/BAO/ContributionRecur.php @@ -849,7 +849,7 @@ INNER JOIN civicrm_contribution con ON ( con.id = mp.contribution_id ) $form->assign('contribution_recur_pane_open', FALSE); foreach (self::getRecurringFields() as $key) { if ($key === 'contribution_recur_payment_made' && !empty($form->_formValues) && - !CRM_Utils_System::isNull(CRM_Utils_Array::value($key, $form->_formValues)) + !CRM_Utils_System::isNull($form->_formValues[$key] ?? NULL) ) { $form->assign('contribution_recur_pane_open', TRUE); break; diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index 5e73cd0983..2577e1289c 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -1741,7 +1741,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP if (CRM_Contribute_BAO_Contribution::isContributionStatusNegative($params['contribution_status_id']) ) { - if (CRM_Utils_System::isNull(CRM_Utils_Array::value('cancel_date', $params))) { + if (CRM_Utils_System::isNull($params['cancel_date'] ?? NULL)) { $params['cancel_date'] = date('YmdHis'); } } diff --git a/CRM/Contribute/Form/Task/Batch.php b/CRM/Contribute/Form/Task/Batch.php index 4d50e0b5a0..c06896771d 100644 --- a/CRM/Contribute/Form/Task/Batch.php +++ b/CRM/Contribute/Form/Task/Batch.php @@ -143,7 +143,7 @@ class CRM_Contribute_Form_Task_Batch extends CRM_Contribute_Form_Task { } if (!empty($entityColumnValue[$typeId]) || - CRM_Utils_System::isNull(CRM_Utils_Array::value($typeId, $entityColumnValue)) + CRM_Utils_System::isNull($entityColumnValue[$typeId] ?? NULL) ) { CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $contributionId); } diff --git a/CRM/Core/BAO/Block.php b/CRM/Core/BAO/Block.php index a5abbe73c8..bd80441e14 100644 --- a/CRM/Core/BAO/Block.php +++ b/CRM/Core/BAO/Block.php @@ -118,7 +118,7 @@ class CRM_Core_BAO_Block { */ public static function dataExists($blockFields, &$params) { foreach ($blockFields as $field) { - if (CRM_Utils_System::isNull(CRM_Utils_Array::value($field, $params))) { + if (CRM_Utils_System::isNull($params[$field] ?? NULL)) { return FALSE; } } @@ -232,7 +232,7 @@ class CRM_Core_BAO_Block { // if in some cases (eg. email used in Online Conribution Page, Profiles, etc.) id is not set // lets try to add using the previous method to avoid any false creation of existing data. foreach ($blockIds as $blockId => $blockValue) { - if (empty($value['id']) && $blockValue['locationTypeId'] == CRM_Utils_Array::value('location_type_id', $value) && !$isIdSet) { + if (empty($value['id']) && $blockValue['locationTypeId'] == ($value['location_type_id'] ?? NULL) && !$isIdSet) { $valueId = FALSE; if ($blockName == 'phone') { $phoneTypeBlockValue = $blockValue['phoneTypeId'] ?? NULL; diff --git a/CRM/Core/BAO/File.php b/CRM/Core/BAO/File.php index 1786f71c8a..b1672b4aa0 100644 --- a/CRM/Core/BAO/File.php +++ b/CRM/Core/BAO/File.php @@ -42,7 +42,7 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File { $op = empty($params['id']) ? 'create' : 'edit'; - CRM_Utils_Hook::pre($op, 'File', CRM_Utils_Array::value('id', $params), $params); + CRM_Utils_Hook::pre($op, 'File', $params['id'] ?? NULL, $params); $fileDAO->copyValues($params); diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index a57ebe8dbf..bc34cb2ed8 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -2381,7 +2381,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { */ public static function validateMandatoryFields($fields, $values, &$errors) { foreach ($fields as $name => $fld) { - if (!empty($fld['is_required']) && CRM_Utils_System::isNull(CRM_Utils_Array::value($name, $values))) { + if (!empty($fld['is_required']) && CRM_Utils_System::isNull($values[$name] ?? NULL)) { $errors[$name] = ts('%1 is a required field.', [1 => $fld['title']]); } } diff --git a/CRM/Event/Form/ManageEvent/Fee.php b/CRM/Event/Form/ManageEvent/Fee.php index caf14a29d8..52eb1eb987 100644 --- a/CRM/Event/Form/ManageEvent/Fee.php +++ b/CRM/Event/Form/ManageEvent/Fee.php @@ -666,7 +666,7 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent { $discountOptions = []; for ($i = 1; $i < self::NUM_OPTION; $i++) { if (!empty($labels[$i]) && - !CRM_Utils_System::isNull(CRM_Utils_Array::value($j, $values[$i])) + !CRM_Utils_System::isNull($values[$i][$j] ?? NULL) ) { $discountOptions[] = [ 'label' => trim($labels[$i]), diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index cf7e54c1e9..2331084417 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -1450,7 +1450,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment CRM_Event_Form_Registration_Register::buildAmount($form, TRUE, $form->_discountId); $lineItem = []; $totalTaxAmount = 0; - if (!CRM_Utils_System::isNull(CRM_Utils_Array::value('line_items', $form->_values))) { + if (!CRM_Utils_System::isNull($form->_values['line_items'] ?? NULL)) { $lineItem[] = $form->_values['line_items']; foreach ($form->_values['line_items'] as $key => $value) { $totalTaxAmount = $value['tax_amount'] + $totalTaxAmount; diff --git a/CRM/Event/Form/ParticipantFeeSelection.php b/CRM/Event/Form/ParticipantFeeSelection.php index 865e791c53..c42cdc721f 100644 --- a/CRM/Event/Form/ParticipantFeeSelection.php +++ b/CRM/Event/Form/ParticipantFeeSelection.php @@ -175,7 +175,7 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form { CRM_Event_Form_Registration::initEventFee($this, $event['id'], $this->_action !== CRM_Core_Action::UPDATE); CRM_Event_Form_Registration_Register::buildAmount($this, TRUE); - if (!CRM_Utils_System::isNull(CRM_Utils_Array::value('line_items', $this->_values))) { + if (!CRM_Utils_System::isNull($this->_values['line_items'] ?? NULL)) { $lineItem[] = $this->_values['line_items']; } $this->assign('lineItem', empty($lineItem) ? FALSE : $lineItem); diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index cbb5d16531..95b08b81de 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -897,7 +897,7 @@ class CRM_Report_Form extends CRM_Core_Form { if ($fieldGrp == 'filters') { // fill operator types if (!array_key_exists('operatorType', $this->_columns[$tableName][$fieldGrp][$fieldName])) { - switch (CRM_Utils_Array::value('type', $this->_columns[$tableName][$fieldGrp][$fieldName])) { + switch ($this->_columns[$tableName][$fieldGrp][$fieldName]['type'] ?? NULL) { case CRM_Utils_Type::T_MONEY: case CRM_Utils_Type::T_FLOAT: $this->_columns[$tableName][$fieldGrp][$fieldName]['operatorType'] = CRM_Report_Form::OP_FLOAT; @@ -2834,7 +2834,7 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND !empty($this->_params['group_bys'][$fieldName]) && !empty($this->_params['group_bys_freq']) ) { - switch (CRM_Utils_Array::value($fieldName, $this->_params['group_bys_freq'])) { + switch ($this->_params['group_bys_freq'][$fieldName] ?? NULL) { case 'YEARWEEK': $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL WEEKDAY({$field['dbAlias']}) DAY) AS {$tableName}_{$fieldName}_start"; $select[] = "YEARWEEK({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; diff --git a/CRM/Report/Form/Contribute/RecurSummary.php b/CRM/Report/Form/Contribute/RecurSummary.php index 21d6883cd4..758d7bac7d 100644 --- a/CRM/Report/Form/Contribute/RecurSummary.php +++ b/CRM/Report/Form/Contribute/RecurSummary.php @@ -84,7 +84,7 @@ class CRM_Report_Form_Contribute_RecurSummary extends CRM_Report_Form { if (array_key_exists('group_bys', $table)) { foreach ($table['group_bys'] as $fieldName => $field) { if (!empty($this->_params['group_bys'][$fieldName])) { - switch (CRM_Utils_Array::value($fieldName, $this->_params['group_bys_freq'])) { + switch ($this->_params['group_bys_freq'][$fieldName] ?? NULL) { case 'YEARWEEK': $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL WEEKDAY({$field['dbAlias']}) DAY) AS {$tableName}_{$fieldName}_start"; $select[] = "YEARWEEK({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; diff --git a/CRM/Report/Form/Contribute/Summary.php b/CRM/Report/Form/Contribute/Summary.php index dbb03695b2..c1183d0c9d 100644 --- a/CRM/Report/Form/Contribute/Summary.php +++ b/CRM/Report/Form/Contribute/Summary.php @@ -365,7 +365,7 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { if (array_key_exists('group_bys', $table)) { foreach ($table['group_bys'] as $fieldName => $field) { if (!empty($this->_params['group_bys'][$fieldName])) { - switch (CRM_Utils_Array::value($fieldName, $this->_params['group_bys_freq'])) { + switch ($this->_params['group_bys_freq'][$fieldName] ?? NULL) { case 'YEARWEEK': $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL WEEKDAY({$field['dbAlias']}) DAY) AS {$tableName}_{$fieldName}_start"; $select[] = "YEARWEEK({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; @@ -621,7 +621,7 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { $statistics = parent::statistics($rows); $softCredit = $this->_params['fields']['soft_amount'] ?? NULL; - $onlySoftCredit = $softCredit && !CRM_Utils_Array::value('total_amount', $this->_params['fields']); + $onlySoftCredit = $softCredit && empty($this->_params['fields']['total_amount']); if (!isset($this->_groupByArray['civicrm_contribution_currency'])) { $this->_groupByArray['civicrm_contribution_currency'] = 'currency'; } diff --git a/CRM/Report/Form/Member/Summary.php b/CRM/Report/Form/Member/Summary.php index 2559f35356..acf00c3a88 100644 --- a/CRM/Report/Form/Member/Summary.php +++ b/CRM/Report/Form/Member/Summary.php @@ -182,7 +182,7 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form { foreach ($table['group_bys'] as $fieldName => $field) { if (!empty($this->_params['group_bys'][$fieldName])) { - switch (CRM_Utils_Array::value($fieldName, $this->_params['group_bys_freq'])) { + switch ($this->_params['group_bys_freq'][$fieldName] ?? NULL) { case 'YEARWEEK': $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL WEEKDAY({$field['dbAlias']}) DAY) AS {$tableName}_{$fieldName}_start"; diff --git a/CRM/Report/Utils/Get.php b/CRM/Report/Utils/Get.php index f952c842bf..ac64bf00d7 100644 --- a/CRM/Report/Utils/Get.php +++ b/CRM/Report/Utils/Get.php @@ -206,7 +206,7 @@ class CRM_Report_Utils_Get { // process only filters for now foreach ($fieldGrp as $tableName => $fields) { foreach ($fields as $fieldName => $field) { - switch (CRM_Utils_Array::value('type', $field)) { + switch ($field['type'] ?? NULL) { case CRM_Utils_Type::T_INT: case CRM_Utils_Type::T_FLOAT: case CRM_Utils_Type::T_MONEY: diff --git a/api/v3/Relationship.php b/api/v3/Relationship.php index 4e7cbc9bee..0c4251254f 100644 --- a/api/v3/Relationship.php +++ b/api/v3/Relationship.php @@ -102,7 +102,7 @@ function civicrm_api3_relationship_get($params) { return ['count' => $relationships]; } foreach ($relationships as $relationshipId => $values) { - _civicrm_api3_custom_data_get($relationships[$relationshipId], CRM_Utils_Array::value('check_permissions', $params), 'Relationship', $relationshipId, NULL, CRM_Utils_Array::value('relationship_type_id', $values)); + _civicrm_api3_custom_data_get($relationships[$relationshipId], $params['check_permissions'] ?? 0, 'Relationship', $relationshipId, NULL, $values['relationship_type_id'] ?? NULL); } return civicrm_api3_create_success($relationships, $params); } diff --git a/api/v3/utils.php b/api/v3/utils.php index 6548801c89..7dff36515b 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -1523,7 +1523,7 @@ function _civicrm_api3_validate($entity, $action, $params) { * @throws Exception */ function _civicrm_api3_validate_switch_cases($fieldName, $fieldInfo, $entity, $params, $action) { - switch (CRM_Utils_Array::value('type', $fieldInfo)) { + switch ($fieldInfo['type'] ?? NULL) { case CRM_Utils_Type::T_INT: _civicrm_api3_validate_integer($params, $fieldName, $fieldInfo, $entity); break; @@ -1585,7 +1585,7 @@ function _civicrm_api3_validate_fields($entity, $action, &$params, $fields) { $fields = array_merge($fields, $chainApiParams); } foreach ($fields as $fieldName => $fieldInfo) { - switch (CRM_Utils_Array::value('type', $fieldInfo)) { + switch ($fieldInfo['type'] ?? NULL) { case CRM_Utils_Type::T_INT: //field is of type integer _civicrm_api3_validate_integer($params, $fieldName, $fieldInfo, $entity); -- 2.25.1