Use ?? operator instead of CRM_Utils_Array::value() in array assignments with null...
authorColeman Watts <coleman@civicrm.org>
Sun, 8 Mar 2020 21:53:37 +0000 (17:53 -0400)
committerColeman Watts <coleman@civicrm.org>
Wed, 11 Mar 2020 23:47:02 +0000 (19:47 -0400)
13 files changed:
CRM/Activity/BAO/Activity.php
CRM/Admin/Form/ParticipantStatusType.php
CRM/Contact/Form/Contact.php
CRM/Core/BAO/File.php
CRM/Core/PseudoConstant.php
CRM/Event/Cart/Form/Cart.php
CRM/Event/Form/SelfSvcTransfer.php
CRM/Report/Form.php
CRM/Utils/Cache.php
CRM/Utils/Chart.php
CRM/Utils/Migrate/ExportJSON.php
CRM/Utils/Recent.php
tools/scripts/solr/createSyncJSON.php

index de4479355025b56bf3cb4e9fcc5731d213a51f60..06f0e91b62bd0c745d4319de584f59f796367ab2 100644 (file)
@@ -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,
       ];
index 168aa180c586a5650b937eac9454c2a6f92ed518..4f7516d8d11d14c43e1fc47f9cb7dacd06930c48 100644 (file)
@@ -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,
     ];
index a36de18d6752572c7752da35d1bb6160b9ad667b..fff3ef2c8c704c45739f555829717afd76fbfb39 100644 (file)
@@ -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);
     }
index 207f02ea6c5532e31909d066d65874368a501dc7..0d34aaaf00298648319c13501cbf889387580fad 100644 (file)
@@ -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);
index 3078e8f84cd116238c0fc041d0f7758475fb94ec..773194a1aea18b813263dde562589ad314870bc2 100644 (file)
@@ -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,
       ];
index 3b7bee6931efb6cd152af277953f8627a5834111..048c2ba5b9cccc231e0c3b0c78c204e9aa43bc2e 100644 (file)
@@ -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 = [];
index 487138ebe232b85859d72ac8367e85c98eb0b51a..6dc21ffd9924e616a962ed25c60a32f3cfa06a30 100644 (file)
@@ -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
index 9690867ff6d4bdcedfb4c63280c5d789310139ca..cf099a3debbe6a3adb9096e564e951312fa76019 100644 (file)
@@ -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,
       ];
     }
 
index 3ac1130ce9438601ef17441ce6f0069089c11db2..6243a72bf3d89e446c669a9d2aada9e6d9e47afa 100644 (file)
@@ -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;
index 88a075085e020922f4d72b5603e6afe8a1991fa4..c8745fa0a5f0b745c958bbacea851f0311e43480 100644 (file)
@@ -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'] ?? [],
       ];
     }
 
index 72550171c665752ed7b81e6662da0fc85d1130ec..a472aa44e65ab49ae1cf1c49b711f5ef380b639e 100644 (file)
@@ -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,
         ];
       }
     }
index 0b9f3de7abd10072df7fb191355907c04023d03a..59818c0b0161810545c107cf6937bfc61505a124 100644 (file)
@@ -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,
index e33ead5976f2cf6a66fc5c86ff1157470b671736..cb7c6172c98648a262f0f6b1d52c24dcb90d41fc 100644 (file)
@@ -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,
       ];
     }
   }