From 6187cca44e0958167a823ce4a3e27596c8b713a6 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 8 Mar 2020 17:53:37 -0400 Subject: [PATCH] Use ?? operator instead of CRM_Utils_Array::value() in array assignments with null-ish defaults --- CRM/Activity/BAO/Activity.php | 2 +- CRM/Admin/Form/ParticipantStatusType.php | 4 ++-- CRM/Contact/Form/Contact.php | 4 ++-- CRM/Core/BAO/File.php | 2 +- CRM/Core/PseudoConstant.php | 2 +- CRM/Event/Cart/Form/Cart.php | 6 +++--- CRM/Event/Form/SelfSvcTransfer.php | 8 ++++---- CRM/Report/Form.php | 4 ++-- CRM/Utils/Cache.php | 2 +- CRM/Utils/Chart.php | 2 +- CRM/Utils/Migrate/ExportJSON.php | 2 +- CRM/Utils/Recent.php | 2 +- tools/scripts/solr/createSyncJSON.php | 2 +- 13 files changed, 21 insertions(+), 21 deletions(-) diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index de44793550..06f0e91b62 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -751,7 +751,7 @@ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity { 'activity_id' => $activity['id'], 'activity_date_time' => $activity['activity_date_time'] ?? NULL, 'subject' => $activity['subject'] ?? NULL, - 'assignee_contact_name' => CRM_Utils_Array::value('assignee_contact_sort_name', $activity, []), + 'assignee_contact_name' => $activity['assignee_contact_sort_name'] ?? [], 'source_contact_id' => $activity['source_contact_id'] ?? NULL, 'source_contact_name' => $activity['source_contact_sort_name'] ?? NULL, ]; diff --git a/CRM/Admin/Form/ParticipantStatusType.php b/CRM/Admin/Form/ParticipantStatusType.php index 168aa180c5..4f7516d8d1 100644 --- a/CRM/Admin/Form/ParticipantStatusType.php +++ b/CRM/Admin/Form/ParticipantStatusType.php @@ -89,8 +89,8 @@ class CRM_Admin_Form_ParticipantStatusType extends CRM_Admin_Form { 'name' => $formValues['name'] ?? NULL, 'label' => $formValues['label'] ?? NULL, 'class' => $formValues['class'] ?? NULL, - 'is_active' => CRM_Utils_Array::value('is_active', $formValues, FALSE), - 'is_counted' => CRM_Utils_Array::value('is_counted', $formValues, FALSE), + 'is_active' => $formValues['is_active'] ?? FALSE, + 'is_counted' => $formValues['is_counted'] ?? FALSE, 'weight' => $formValues['weight'] ?? NULL, 'visibility_id' => $formValues['visibility_id'] ?? NULL, ]; diff --git a/CRM/Contact/Form/Contact.php b/CRM/Contact/Form/Contact.php index a36de18d67..fff3ef2c8c 100644 --- a/CRM/Contact/Form/Contact.php +++ b/CRM/Contact/Form/Contact.php @@ -911,8 +911,8 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { // process membership status for deceased contact $deceasedParams = [ 'contact_id' => $params['contact_id'] ?? NULL, - 'is_deceased' => CRM_Utils_Array::value('is_deceased', $params, FALSE), - 'deceased_date' => CRM_Utils_Array::value('deceased_date', $params, NULL), + 'is_deceased' => $params['is_deceased'] ?? FALSE, + 'deceased_date' => $params['deceased_date'] ?? NULL, ]; $updateMembershipMsg = CRM_Member_BAO_Membership::updateMembershipStatus($deceasedParams, $this->_contactType); } diff --git a/CRM/Core/BAO/File.php b/CRM/Core/BAO/File.php index 207f02ea6c..0d34aaaf00 100644 --- a/CRM/Core/BAO/File.php +++ b/CRM/Core/BAO/File.php @@ -565,7 +565,7 @@ AND CEF.entity_id = %2"; $extraParams = [ 'description' => $formValues[$attachDesc], 'tag' => $tagParams, - 'attachment_taglist' => CRM_Utils_Array::value($attachFreeTags, $formValues, []), + 'attachment_taglist' => $formValues[$attachFreeTags] ?? [], ]; CRM_Utils_File::formatFile($formValues, $attachName, $extraParams); diff --git a/CRM/Core/PseudoConstant.php b/CRM/Core/PseudoConstant.php index 3078e8f84c..773194a1ae 100644 --- a/CRM/Core/PseudoConstant.php +++ b/CRM/Core/PseudoConstant.php @@ -232,7 +232,7 @@ class CRM_Core_PseudoConstant { // Merge params with schema defaults $params += [ - 'condition' => CRM_Utils_Array::value('condition', $pseudoconstant, []), + 'condition' => $pseudoconstant['condition'] ?? [], 'keyColumn' => $pseudoconstant['keyColumn'] ?? NULL, 'labelColumn' => $pseudoconstant['labelColumn'] ?? NULL, ]; diff --git a/CRM/Event/Cart/Form/Cart.php b/CRM/Event/Cart/Form/Cart.php index 3b7bee6931..048c2ba5b9 100644 --- a/CRM/Event/Cart/Form/Cart.php +++ b/CRM/Event/Cart/Form/Cart.php @@ -139,9 +139,9 @@ class CRM_Event_Cart_Form_Cart extends CRM_Core_Form { return $contact_id; } $contact_params = [ - 'email-Primary' => CRM_Utils_Array::value('email', $fields, NULL), - 'first_name' => CRM_Utils_Array::value('first_name', $fields, NULL), - 'last_name' => CRM_Utils_Array::value('last_name', $fields, NULL), + 'email-Primary' => $fields['email'] ?? NULL, + 'first_name' => $fields['first_name'] ?? NULL, + 'last_name' => $fields['last_name'] ?? NULL, 'is_deleted' => CRM_Utils_Array::value('is_deleted', $fields, TRUE), ]; $no_fields = []; diff --git a/CRM/Event/Form/SelfSvcTransfer.php b/CRM/Event/Form/SelfSvcTransfer.php index 487138ebe2..6dc21ffd99 100644 --- a/CRM/Event/Form/SelfSvcTransfer.php +++ b/CRM/Event/Form/SelfSvcTransfer.php @@ -259,10 +259,10 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { } if (empty($errors) && empty($contact_id)) { $params = [ - 'email-Primary' => CRM_Utils_Array::value('email', $fields, NULL), - 'first_name' => CRM_Utils_Array::value('first_name', $fields, NULL), - 'last_name' => CRM_Utils_Array::value('last_name', $fields, NULL), - 'is_deleted' => CRM_Utils_Array::value('is_deleted', $fields, FALSE), + 'email-Primary' => $fields['email'] ?? NULL, + 'first_name' => $fields['first_name'] ?? NULL, + 'last_name' => $fields['last_name'] ?? NULL, + 'is_deleted' => $fields['is_deleted'] ?? FALSE, ]; //create new contact for this name/email pair //if new contact, no need to check for contact already registered diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 9690867ff6..cf099a3deb 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -4411,7 +4411,7 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a 'fields' => [ 'address_name' => [ 'title' => ts('Address Name'), - 'default' => CRM_Utils_Array::value('name', $defaults, FALSE), + 'default' => $defaults['name'] ?? FALSE, 'name' => 'name', ], ], @@ -4421,7 +4421,7 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a foreach ($defaultAddressFields as $fieldName => $fieldLabel) { $addressFields['civicrm_address']['fields'][$fieldName] = [ 'title' => $fieldLabel, - 'default' => CRM_Utils_Array::value($fieldName, $defaults, FALSE), + 'default' => $defaults[$fieldName] ?? FALSE, ]; } diff --git a/CRM/Utils/Cache.php b/CRM/Utils/Cache.php index 3ac1130ce9..6243a72bf3 100644 --- a/CRM/Utils/Cache.php +++ b/CRM/Utils/Cache.php @@ -190,7 +190,7 @@ class CRM_Utils_Cache { if (defined('CIVICRM_DSN') && CIVICRM_DSN) { return new CRM_Utils_Cache_SqlGroup([ 'group' => $params['name'], - 'prefetch' => CRM_Utils_Array::value('prefetch', $params, FALSE), + 'prefetch' => $params['prefetch'] ?? FALSE, ]); } break; diff --git a/CRM/Utils/Chart.php b/CRM/Utils/Chart.php index 88a075085e..c8745fa0a5 100644 --- a/CRM/Utils/Chart.php +++ b/CRM/Utils/Chart.php @@ -200,7 +200,7 @@ class CRM_Utils_Chart { 'legend' => "$legend " . CRM_Utils_Array::value('legend', $rows, ts('Contribution')) . ' ' . ts('Summary'), 'values' => $graph[0], 'multiValues' => $graph, - 'barKeys' => CRM_Utils_Array::value('barKeys', $rows, []), + 'barKeys' => $rows['barKeys'] ?? [], ]; } diff --git a/CRM/Utils/Migrate/ExportJSON.php b/CRM/Utils/Migrate/ExportJSON.php index 72550171c6..a472aa44e6 100644 --- a/CRM/Utils/Migrate/ExportJSON.php +++ b/CRM/Utils/Migrate/ExportJSON.php @@ -523,7 +523,7 @@ WHERE ac.contact_id IN ( $ids ) $_fieldsRetrieved[$daoName][$value['name']] = [ 'uniqueName' => $key, 'type' => $value['type'], - 'title' => CRM_Utils_Array::value('title', $value, NULL), + 'title' => $value['title'] ?? NULL, ]; } } diff --git a/CRM/Utils/Recent.php b/CRM/Utils/Recent.php index 0b9f3de7ab..59818c0b01 100644 --- a/CRM/Utils/Recent.php +++ b/CRM/Utils/Recent.php @@ -120,7 +120,7 @@ class CRM_Utils_Recent { 'contact_id' => $contactId, 'contactName' => $contactName, 'subtype' => $others['subtype'] ?? NULL, - 'isDeleted' => CRM_Utils_Array::value('isDeleted', $others, FALSE), + 'isDeleted' => $others['isDeleted'] ?? FALSE, 'image_url' => $others['imageUrl'] ?? NULL, 'edit_url' => $others['editUrl'] ?? NULL, 'delete_url' => $others['deleteUrl'] ?? NULL, diff --git a/tools/scripts/solr/createSyncJSON.php b/tools/scripts/solr/createSyncJSON.php index e33ead5976..cb7c6172c9 100644 --- a/tools/scripts/solr/createSyncJSON.php +++ b/tools/scripts/solr/createSyncJSON.php @@ -475,7 +475,7 @@ function getDBFields($daoName) { $_fieldsRetrieved[$daoName][$value['name']] = [ 'uniqueName' => $key, 'type' => $value['type'], - 'title' => CRM_Utils_Array::value('title', $value, NULL), + 'title' => $value['title'] ?? NULL, ]; } } -- 2.25.1