(REF) Replace CRM_Utils_Array with equivalent `?? NULL`
authorcolemanw <coleman@civicrm.org>
Sat, 22 Jul 2023 02:57:06 +0000 (19:57 -0700)
committerTim Otten <totten@civicrm.org>
Sat, 22 Jul 2023 03:33:29 +0000 (20:33 -0700)
19 files changed:
CRM/Admin/Form/ScheduleReminders.php
CRM/Badge/BAO/Badge.php
CRM/Case/Form/Activity.php
CRM/Contribute/BAO/ContributionRecur.php
CRM/Contribute/Form/Contribution.php
CRM/Contribute/Form/Task/Batch.php
CRM/Core/BAO/Block.php
CRM/Core/BAO/File.php
CRM/Core/Form.php
CRM/Event/Form/ManageEvent/Fee.php
CRM/Event/Form/Participant.php
CRM/Event/Form/ParticipantFeeSelection.php
CRM/Report/Form.php
CRM/Report/Form/Contribute/RecurSummary.php
CRM/Report/Form/Contribute/Summary.php
CRM/Report/Form/Member/Summary.php
CRM/Report/Utils/Get.php
api/v3/Relationship.php
api/v3/utils.php

index d2c4dd580e4a24af50e7fb48c285094705747470..1f1237790ddcbfedeabe1ab79481e560b27bc927 100644 (file)
@@ -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');
     }
 
index b83929b180e50091cfd213a42b00547d52d92c28..d3486b13ff254aade14bd521d047702a94f24bb9 100644 (file)
@@ -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;
index c0dfe15a80c5397dc33d869a173b5a8e3fce0a8c..affa4e4458cb4e10dc7857332fbc80fa6768479d 100644 (file)
@@ -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;
     }
 
index 6d74fa4f07b9ca6ae9a60b7c70b4dfc8fcc1e505..23d39173edb75cfe24982fa60f8113cb560b4a9e 100644 (file)
@@ -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;
index 5e73cd098303961a7ae4b29fb6b6191256525527..2577e1289c969d03d13088cde0605cc56cfc4d26 100644 (file)
@@ -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');
         }
       }
index 4d50e0b5a089e7f3c131f5d7815d31a85f9eba15..c06896771d8925aaed5d5dccad82857c672e6cf6 100644 (file)
@@ -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);
           }
index a5abbe73c827d5667d5195414c27979ca29fb239..bd80441e142d5aac1db1d697c615272d12225917 100644 (file)
@@ -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;
index 1786f71c8a39bfe6f939b963dff379f4f711c776..b1672b4aa090d88a867b616ccebceb67a3d130ea 100644 (file)
@@ -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);
 
index a57ebe8dbfcf047d8bd2f775a5039d122f96688c..bc34cb2ed88f609bbde1b644c6b038302587c763 100644 (file)
@@ -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']]);
       }
     }
index caf14a29d8a7e501d70ca7bc816754746f033ebc..52eb1eb987a7a87db753fc1e017d7ac968099d7d 100644 (file)
@@ -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]),
index cf7e54c1e96a2db9f54474a9c747c7ed74955855..2331084417a144bfc04e8e41ed10bbd4fdecd41b 100644 (file)
@@ -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;
index 865e791c535866ceb15d6655eb0b42a9743a5f72..c42cdc721ffe592aec1b0c232fabf2fb409345b8 100644 (file)
@@ -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);
index cbb5d165312a10e85d70f991fd500695711a6a7a..95b08b81de28af905e3081131fd7ab6d2255a6a8 100644 (file)
@@ -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";
index 21d6883cd4ddf09c554dcb2e717f097c2c313cff..758d7bac7d45d128509c2b382e7670be4432fad8 100644 (file)
@@ -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";
index dbb03695b2f5ede1d60c17694c97c76e361c082b..c1183d0c9d591bbf797e1a2875e0f6e4ae5cd3ee 100644 (file)
@@ -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';
     }
index 2559f35356e9f14399ee5f6aed487e4356a5c3fa..acf00c3a88d321ffd42cf41ec4784c6a72774bbf 100644 (file)
@@ -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";
 
index f952c842bf853d9832d72c2205f7e2da4644b5c1..ac64bf00d7d9c6459cd3ebede4a6e44896c3ae57 100644 (file)
@@ -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:
index 4e7cbc9beef1e75ad622429b5823ffca2ba24e80..0c4251254faccca2f730dffafc0af387e6016df9 100644 (file)
@@ -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);
 }
index 6548801c898b44f21cda8df263d625645a729057..7dff36515b28ecd0e17253febd8715135ab99f67 100644 (file)
@@ -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);