From 950207c60dd1f3d142fb787891205ff1398bbdc9 Mon Sep 17 00:00:00 2001
From: colemanw <coleman@civicrm.org>
Date: Fri, 7 Feb 2025 11:29:11 -0500
Subject: [PATCH] UtilsArray - Refactor out uses of deprecated
 CRM_Utils_Array::value.

---
 CRM/Activity/BAO/Query.php               | 2 +-
 CRM/Contact/BAO/Query.php                | 3 ++-
 CRM/Contact/Form/Merge.php               | 4 ++--
 CRM/Contact/Page/AJAX.php                | 2 +-
 CRM/Core/Permission.php                  | 2 +-
 CRM/Event/Form/Registration/Register.php | 2 +-
 CRM/Export/BAO/ExportProcessor.php       | 4 ++--
 CRM/Utils/REST.php                       | 2 +-
 CRM/Utils/VersionCheck.php               | 2 +-
 9 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/CRM/Activity/BAO/Query.php b/CRM/Activity/BAO/Query.php
index c40672f8530..92702de7829 100644
--- a/CRM/Activity/BAO/Query.php
+++ b/CRM/Activity/BAO/Query.php
@@ -617,7 +617,7 @@ class CRM_Activity_BAO_Query {
   public static function whereClauseSingleActivityText(&$values, &$query) {
     [$name, $op, $value, $grouping, $wildcard] = $values;
     $activityOptionValues = $query->getWhereValues('activity_option', $grouping);
-    $activityOption = CRM_Utils_Array::value(2, $activityOptionValues, 6);
+    $activityOption = $activityOptionValues[2] ?? 6;
 
     $query->_useDistinct = TRUE;
 
diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php
index c2da15bf7ac..998cd52bade 100644
--- a/CRM/Contact/BAO/Query.php
+++ b/CRM/Contact/BAO/Query.php
@@ -4812,7 +4812,8 @@ civicrm_relationship.start_date > {$today}
     if (!is_array($values)) {
       return FALSE;
     }
-    if (($operator = CRM_Utils_Array::value(1, $values)) == FALSE) {
+    $operator = $values[1] ?? FALSE;
+    if (!$operator) {
       return FALSE;
     }
     return in_array($operator, CRM_Core_DAO::acceptedSQLOperators());
diff --git a/CRM/Contact/Form/Merge.php b/CRM/Contact/Form/Merge.php
index 9dee169d5f6..1a63c7a6a2c 100644
--- a/CRM/Contact/Form/Merge.php
+++ b/CRM/Contact/Form/Merge.php
@@ -261,7 +261,7 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form {
         // on the form.
         if (substr($element[1], 0, 13) === 'move_location') {
           $element[4] = array_merge(
-            (array) CRM_Utils_Array::value(4, $element, []),
+            (array) ($element[4] ?? []),
             [
               'data-location' => substr($element[1], 14),
               'data-is_location' => TRUE,
@@ -270,7 +270,7 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form {
         if (substr($element[1], 0, 15) === 'location_blocks') {
           // @todo We could add some data elements here to make jquery manipulation more straight-forward
           // @todo consider enabling if it is an add & defaulting to true.
-          $element[4] = array_merge((array) CRM_Utils_Array::value(4, $element, []), ['disabled' => TRUE]);
+          $element[4] = array_merge((array) ($element[4] ?? []), ['disabled' => TRUE]);
         }
         $newCheckBox = $this->addElement($element[0],
           $element[1],
diff --git a/CRM/Contact/Page/AJAX.php b/CRM/Contact/Page/AJAX.php
index 0cb54004a2e..acaa0d3f123 100644
--- a/CRM/Contact/Page/AJAX.php
+++ b/CRM/Contact/Page/AJAX.php
@@ -245,7 +245,7 @@ class CRM_Contact_Page_AJAX {
         // first check if there is any existing relationship present with same parameters.
         // If yes then update the relationship by setting active and start date to current time
         $relationship = civicrm_api3('Relationship', 'get', $params)['values'];
-        $params = array_merge(CRM_Utils_Array::value(0, $relationship, $params), [
+        $params = array_merge($relationship[0] ?? $params, [
           'start_date' => 'now',
           'is_active' => TRUE,
           'end_date' => '',
diff --git a/CRM/Core/Permission.php b/CRM/Core/Permission.php
index 737931f3e1c..24d875af939 100644
--- a/CRM/Core/Permission.php
+++ b/CRM/Core/Permission.php
@@ -572,7 +572,7 @@ class CRM_Core_Permission {
       $item['access_callback'][0] == 'CRM_Core_Permission' &&
       $item['access_callback'][1] == 'checkMenu'
     ) {
-      $op = CRM_Utils_Array::value(1, $item['access_arguments'], 'and');
+      $op = $item['access_arguments'][1] ?? 'and';
       return self::checkMenu($item['access_arguments'][0], $op);
     }
     else {
diff --git a/CRM/Event/Form/Registration/Register.php b/CRM/Event/Form/Registration/Register.php
index b3602fdecac..abcc728ccb8 100644
--- a/CRM/Event/Form/Registration/Register.php
+++ b/CRM/Event/Form/Registration/Register.php
@@ -617,7 +617,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
       $primaryParticipantCount = $form->getParticipantCount($ppParams);
 
       //get price set fields errors in.
-      $errors = array_merge($errors, CRM_Utils_Array::value(0, $priceSetErrors, []));
+      $errors = array_merge($errors, $priceSetErrors[0] ?? []);
 
       $totalParticipants = $primaryParticipantCount;
       if ($numberAdditionalParticipants) {
diff --git a/CRM/Export/BAO/ExportProcessor.php b/CRM/Export/BAO/ExportProcessor.php
index 80ec7221fab..718a6495a62 100644
--- a/CRM/Export/BAO/ExportProcessor.php
+++ b/CRM/Export/BAO/ExportProcessor.php
@@ -1683,7 +1683,7 @@ class CRM_Export_BAO_ExportProcessor {
             foreach ($relationValue as $ltype => $val) {
               foreach (array_keys($val) as $fld) {
                 $type = explode('-', $fld);
-                $this->addOutputSpecification($type[0], $key, $ltype, CRM_Utils_Array::value(1, $type));
+                $this->addOutputSpecification($type[0], $key, $ltype, $type[1] ?? NULL);
               }
             }
           }
@@ -1700,7 +1700,7 @@ class CRM_Export_BAO_ExportProcessor {
             if (!empty($type[1])) {
               $daoFieldName .= "-" . $type[1];
             }
-            $this->addOutputSpecification($actualDBFieldName, NULL, $locationType, CRM_Utils_Array::value(1, $type));
+            $this->addOutputSpecification($actualDBFieldName, NULL, $locationType, $type[1] ?? NULL);
             $outputColumns[$daoFieldName] = TRUE;
           }
         }
diff --git a/CRM/Utils/REST.php b/CRM/Utils/REST.php
index 9e334bab42e..b1bc3e7757c 100644
--- a/CRM/Utils/REST.php
+++ b/CRM/Utils/REST.php
@@ -550,7 +550,7 @@ class CRM_Utils_REST {
         $call[0],
         $call[1],
       ];
-      $output[$key] = self::process($args, CRM_Utils_Array::value(2, $call, []));
+      $output[$key] = self::process($args, $call[2] ?? []);
     }
     return $output;
   }
diff --git a/CRM/Utils/VersionCheck.php b/CRM/Utils/VersionCheck.php
index 80491b7c28c..f122a28494c 100644
--- a/CRM/Utils/VersionCheck.php
+++ b/CRM/Utils/VersionCheck.php
@@ -346,7 +346,7 @@ class CRM_Utils_VersionCheck {
       'api_action' => "version_check",
       'api_entity' => "job",
     ]);
-    $this->cronJob = CRM_Utils_Array::value(0, $jobs['values'], []);
+    $this->cronJob = $jobs['values'][0] ?? [];
   }
 
 }
-- 
GitLab