[REF] Replace CRM_Utils_Array::value with ?? in variable assignments
authoreileen <emcnaughton@wikimedia.org>
Tue, 17 Mar 2020 03:19:59 +0000 (16:19 +1300)
committereileen <emcnaughton@wikimedia.org>
Tue, 17 Mar 2020 03:20:31 +0000 (16:20 +1300)
This is a partial of https://github.com/civicrm/civicrm-core/pull/16768 & consists of the lines I have reviewed from it

20 files changed:
CRM/Contact/BAO/Contact.php
api/api.php
api/v3/Activity.php
api/v3/Attachment.php
api/v3/Contact.php
api/v3/Contribution.php
api/v3/ContributionPage.php
api/v3/CustomValue.php
api/v3/Domain.php
api/v3/Generic.php
api/v3/GroupContact.php
api/v3/Job.php
api/v3/Mailing.php
api/v3/MailingEventSubscribe.php
api/v3/Membership.php
api/v3/MembershipStatus.php
api/v3/Order.php
api/v3/Payment.php
api/v3/Setting.php
api/v3/utils.php

index 82eb740b62ea2b69ef0e555d34863ee53796f99c..54270410c2127797c0066d599f8795f295dc5431 100644 (file)
@@ -105,7 +105,7 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact {
    */
   public static function add(&$params) {
     $contact = new CRM_Contact_DAO_Contact();
-    $contactID = CRM_Utils_Array::value('contact_id', $params);
+    $contactID = $params['contact_id'] ?? NULL;
     if (empty($params)) {
       return NULL;
     }
@@ -164,7 +164,7 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact {
       $contact->sort_name = substr($contact->sort_name, 0, 128);
     }
 
-    $privacy = CRM_Utils_Array::value('privacy', $params);
+    $privacy = $params['privacy'] ?? NULL;
     if ($privacy &&
       is_array($privacy) &&
       !empty($privacy)
@@ -1610,7 +1610,7 @@ WHERE     civicrm_contact.id = " . CRM_Utils_Type::escape($id, 'Integer');
 
         //Sorting fields in alphabetical order(CRM-1507)
         foreach ($fields as $k => $v) {
-          $sortArray[$k] = CRM_Utils_Array::value('title', $v);
+          $sortArray[$k] = $v['title'] ?? NULL;
         }
 
         $fields = array_merge($sortArray, $fields);
@@ -1748,7 +1748,7 @@ WHERE     civicrm_contact.id = " . CRM_Utils_Type::escape($id, 'Integer');
             $locationTypeName = 1;
           }
           else {
-            $locationTypeName = CRM_Utils_Array::value($id, $locationTypes);
+            $locationTypeName = $locationTypes[$id] ?? NULL;
             if (!$locationTypeName) {
               continue;
             }
@@ -1814,7 +1814,7 @@ WHERE     civicrm_contact.id = " . CRM_Utils_Type::escape($id, 'Integer');
       $blocks = CRM_Core_BAO_Location::getValues($entityBlock);
       foreach ($blocks[$block] as $key => $value) {
         if (!empty($value['is_primary'])) {
-          $locationType = CRM_Utils_Array::value('location_type_id', $value);
+          $locationType = $value['location_type_id'] ?? NULL;
         }
       }
     }
@@ -2056,8 +2056,8 @@ ORDER BY civicrm_email.is_primary DESC";
       $details = self::getHierContactDetails($contactID, $fields);
 
       $contactDetails = $details[$contactID];
-      $data['contact_type'] = CRM_Utils_Array::value('contact_type', $contactDetails);
-      $data['contact_sub_type'] = CRM_Utils_Array::value('contact_sub_type', $contactDetails);
+      $data['contact_type'] = $contactDetails['contact_type'] ?? NULL;
+      $data['contact_sub_type'] = $contactDetails['contact_sub_type'] ?? NULL;
     }
     else {
       //we should get contact type only if contact
@@ -2106,10 +2106,10 @@ ORDER BY civicrm_email.is_primary DESC";
     }
 
     if ($ctype == 'Organization') {
-      $data['organization_name'] = CRM_Utils_Array::value('organization_name', $contactDetails);
+      $data['organization_name'] = $contactDetails['organization_name'] ?? NULL;
     }
     elseif ($ctype == 'Household') {
-      $data['household_name'] = CRM_Utils_Array::value('household_name', $contactDetails);
+      $data['household_name'] = $contactDetails['household_name'] ?? NULL;
     }
 
     $locationType = [];
@@ -2606,7 +2606,7 @@ AND       civicrm_openid.is_primary = 1";
       CRM_Core_OptionGroup::lookupValues($temp, $names, FALSE);
 
       $values['preferred_communication_method'] = $preffComm;
-      $values['preferred_communication_method_display'] = CRM_Utils_Array::value('preferred_communication_method_display', $temp);
+      $values['preferred_communication_method_display'] = $temp['preferred_communication_method_display'] ?? NULL;
 
       if ($contact->preferred_mail_format) {
         $preferredMailingFormat = CRM_Core_SelectValues::pmf();
@@ -2623,8 +2623,8 @@ AND       civicrm_openid.is_primary = 1";
         $birthDate = CRM_Utils_Date::customFormat($contact->birth_date, '%Y%m%d');
         if ($birthDate < date('Ymd')) {
           $age = CRM_Utils_Date::calculateAge($birthDate);
-          $values['age']['y'] = CRM_Utils_Array::value('years', $age);
-          $values['age']['m'] = CRM_Utils_Array::value('months', $age);
+          $values['age']['y'] = $age['years'] ?? NULL;
+          $values['age']['m'] = $age['months'] ?? NULL;
         }
       }
 
@@ -3254,7 +3254,7 @@ AND       civicrm_openid.is_primary = 1";
    *   TRUE if user has all permissions, FALSE if otherwise.
    */
   public static function checkUserMenuPermissions($aclPermissionedTasks, $corePermission, $menuOptions) {
-    $componentName = CRM_Utils_Array::value('component', $menuOptions);
+    $componentName = $menuOptions['component'] ?? NULL;
 
     // if component action - make sure component is enable.
     if ($componentName && !in_array($componentName, CRM_Core_Config::singleton()->enableComponents)) {
@@ -3264,7 +3264,7 @@ AND       civicrm_openid.is_primary = 1";
     // make sure user has all required permissions.
     $hasAllPermissions = FALSE;
 
-    $permissions = CRM_Utils_Array::value('permissions', $menuOptions);
+    $permissions = $menuOptions['permissions'] ?? NULL;
     if (!is_array($permissions) || empty($permissions)) {
       $hasAllPermissions = TRUE;
     }
index 7cbc5d180dcb56f88b29b805d538a6e4bcaaf1fc..85edf1a326700c4e0febec33a85ad14872392975 100644 (file)
@@ -267,7 +267,7 @@ function _civicrm_api_replace_variable($value, $parentResult, $separator) {
       if (array_key_exists($fieldname, $parentResult) && is_array($parentResult[$fieldname])) {
         $arrayLocation = $parentResult[$fieldname];
         foreach ($stringParts as $key => $innerValue) {
-          $arrayLocation = CRM_Utils_Array::value($innerValue, $arrayLocation);
+          $arrayLocation = $arrayLocation[$innerValue] ?? NULL;
         }
         $value = $arrayLocation;
       }
index 73f43f05a424a22a35d57535f03fb8e0ed541502..f6734a371c262f6d46fd99347b0e49663ad20fe2 100644 (file)
@@ -556,7 +556,7 @@ function _civicrm_api3_activity_get_formatResult($params, $activities, $options)
     ]);
     foreach ($activities as &$activity) {
       if (!empty($activity['case_id'])) {
-        $case = CRM_Utils_Array::value($activity['case_id'][0], $cases['values']);
+        $case = $cases['values'][$activity['case_id'][0]] ?? NULL;
         if ($case) {
           foreach ($case as $key => $value) {
             if ($key != 'id') {
@@ -705,14 +705,14 @@ function _civicrm_api3_activity_check_params(&$params) {
   //correctly by doing pseudoconstant validation
   // needs testing
   $activityTypes = CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'validate');
-  $activityName = CRM_Utils_Array::value('activity_name', $params);
+  $activityName = $params['activity_name'] ?? NULL;
   $activityName = ucfirst($activityName);
-  $activityLabel = CRM_Utils_Array::value('activity_label', $params);
+  $activityLabel = $params['activity_label'] ?? NULL;
   if ($activityLabel) {
     $activityTypes = CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'create');
   }
 
-  $activityTypeId = CRM_Utils_Array::value('activity_type_id', $params);
+  $activityTypeId = $params['activity_type_id'] ?? NULL;
 
   if ($activityName || $activityLabel) {
     $activityTypeIdInList = array_search(($activityName ? $activityName : $activityLabel), $activityTypes);
index b2834091f8d3ccc164183b8e254efc1da3f15a76..c29d63bd34fc1889890a42254691cb7a86884db0 100644 (file)
@@ -338,7 +338,7 @@ function __civicrm_api3_attachment_find($params, $id, $file, $entityFile, $isTru
  * @throws API_Exception validation errors
  */
 function _civicrm_api3_attachment_parse_params($params) {
-  $id = CRM_Utils_Array::value('id', $params, NULL);
+  $id = $params['id'] ?? NULL;
   if ($id && !is_numeric($id)) {
     throw new API_Exception("Malformed id");
   }
index d79910a4c73282781d66fb23f9973fed9aa7c80f..d84f039113093a10f96976539f7772c14571665d 100644 (file)
@@ -607,9 +607,9 @@ function _civicrm_api3_greeting_format_params($params) {
     ];
 
     $greetings = CRM_Core_PseudoConstant::greeting($filter);
-    $greetingId = CRM_Utils_Array::value("{$key}{$greeting}_id", $params);
-    $greetingVal = CRM_Utils_Array::value("{$key}{$greeting}", $params);
-    $customGreeting = CRM_Utils_Array::value("{$key}{$greeting}_custom", $params);
+    $greetingId = $params["{$key}{$greeting}_id"] ?? NULL;
+    $greetingVal = $params["{$key}{$greeting}"] ?? NULL;
+    $customGreeting = $params["{$key}{$greeting}_custom"] ?? NULL;
 
     if (!$greetingId && $greetingVal) {
       $params["{$key}{$greeting}_id"] = CRM_Utils_Array::key($params["{$key}{$greeting}"], $greetings);
@@ -1419,11 +1419,11 @@ function _civicrm_api3_contact_proximity_spec(&$params) {
  * @throws Exception
  */
 function civicrm_api3_contact_proximity($params) {
-  $latitude = CRM_Utils_Array::value('latitude', $params);
-  $longitude = CRM_Utils_Array::value('longitude', $params);
-  $distance = CRM_Utils_Array::value('distance', $params);
+  $latitude = $params['latitude'] ?? NULL;
+  $longitude = $params['longitude'] ?? NULL;
+  $distance = $params['distance'] ?? NULL;
 
-  $unit = CRM_Utils_Array::value('unit', $params);
+  $unit = $params['unit'] ?? NULL;
 
   // check and ensure that lat/long and distance are floats
   if (
index 66dc25a66f06a8c8b05dcc27eccc7074958b6fde..b9e633a03a6d29d52099ea350e9d5b791534d4ea 100644 (file)
@@ -356,7 +356,7 @@ function _civicrm_api3_contribution_get_spec(&$params) {
 
   $params['financial_type_id']['api.aliases'] = ['contribution_type_id'];
   $params['payment_instrument_id']['api.aliases'] = ['contribution_payment_instrument', 'payment_instrument'];
-  $params['contact_id'] = CRM_Utils_Array::value('contribution_contact_id', $params);
+  $params['contact_id'] = $params['contribution_contact_id'] ?? NULL;
   $params['contact_id']['api.aliases'] = ['contribution_contact_id'];
   $params['is_template']['api.default'] = 0;
   unset($params['contribution_contact_id']);
@@ -672,8 +672,8 @@ function _ipn_process_transaction(&$params, $contribution, $input, $ids, $firstC
     $input['receipt_from_name'] = CRM_Utils_Array::value('receipt_from_name', $params, $domainFromName);
     $input['receipt_from_email'] = CRM_Utils_Array::value('receipt_from_email', $params, $domainFromEmail);
   }
-  $input['card_type_id'] = CRM_Utils_Array::value('card_type_id', $params);
-  $input['pan_truncation'] = CRM_Utils_Array::value('pan_truncation', $params);
+  $input['card_type_id'] = $params['card_type_id'] ?? NULL;
+  $input['pan_truncation'] = $params['pan_truncation'] ?? NULL;
   $transaction = new CRM_Core_Transaction();
   return CRM_Contribute_BAO_Contribution::completeOrder($input, $ids, $objects, $transaction,
      $contribution, CRM_Utils_Array::value('is_post_payment_create', $params));
index 4202987d176f989f79aae6f48f4c658c746c2944..d744043f712240ef6cdf4e1c23f4c95a2b9e0767 100644 (file)
@@ -102,7 +102,7 @@ function civicrm_api3_contribution_page_validate($params) {
   // authorization from a payment processor like Paypal checkout) the lack of a qfKey will not result in a valid
   // one being generated so we generate one first.
   $originalRequest = $_REQUEST;
-  $qfKey = CRM_Utils_Array::value('qfKey', $_REQUEST);
+  $qfKey = $_REQUEST['qfKey'] ?? NULL;
   if (!$qfKey) {
     $_REQUEST['qfKey'] = CRM_Core_Key::get('CRM_Core_Controller', TRUE);
   }
index a524d615715938c963f17330f8e55300e9872196..0711224f0021e52fa9fa0d979a068caf86a01472 100644 (file)
@@ -347,14 +347,14 @@ function civicrm_api3_custom_value_gettree($params) {
     $result[$group['name']] = [];
     $groupToReturn = $toReturn['custom_group'] ? $toReturn['custom_group'] : array_keys($group);
     foreach ($groupToReturn as $item) {
-      $result[$group['name']][$item] = CRM_Utils_Array::value($item, $group);
+      $result[$group['name']][$item] = $group[$item] ?? NULL;
     }
     $result[$group['name']]['fields'] = [];
     foreach ($group['fields'] as $fieldInfo) {
       $field = ['value' => NULL];
       $fieldToReturn = $toReturn['custom_field'] ? $toReturn['custom_field'] : array_keys($fieldInfo);
       foreach ($fieldToReturn as $item) {
-        $field[$item] = CRM_Utils_Array::value($item, $fieldInfo);
+        $field[$item] = $fieldInfo[$item] ?? NULL;
       }
       unset($field['customValue']);
       if (!empty($fieldInfo['customValue'])) {
index de3f425b76f588777161f46fde1bd5fdb691f968..166179f88fa1591cb5eef75e7de61f1145d09fc5 100644 (file)
@@ -25,7 +25,7 @@
  */
 function civicrm_api3_domain_get($params) {
 
-  $params['version'] = CRM_Utils_Array::value('domain_version', $params);
+  $params['version'] = $params['domain_version'] ?? NULL;
   unset($params['version']);
 
   $bao = new CRM_Core_BAO_Domain();
@@ -54,7 +54,7 @@ function civicrm_api3_domain_get($params) {
       ];
 
       if (!empty($values['location']['email'])) {
-        $domain['domain_email'] = CRM_Utils_Array::value('email', $values['location']['email'][1]);
+        $domain['domain_email'] = $values['location']['email'][1]['email'] ?? NULL;
       }
 
       if (!empty($values['location']['phone'])) {
index 549ed2a420706b42f90cc5b9052b3288eb0eaa87..fe355becf2f93594c0689c10d4bf4bca6977e9d8 100644 (file)
@@ -60,8 +60,8 @@ function civicrm_api3_generic_getfields($apiRequest, $unique = TRUE) {
   }
   $entity = $apiRequest['entity'];
   $lowercase_entity = _civicrm_api_get_entity_name_from_camel($entity);
-  $subentity    = CRM_Utils_Array::value('contact_type', $apiRequest['params']);
-  $action = CRM_Utils_Array::value('action', $apiRequest['params']);
+  $subentity    = $apiRequest['params']['contact_type'] ?? NULL;
+  $action = $apiRequest['params']['action'] ?? NULL;
   $sequential = empty($apiRequest['params']['sequential']) ? 0 : 1;
   $apiRequest['params']['options'] = CRM_Utils_Array::value('options', $apiRequest['params'], []);
   $optionsToResolve = (array) CRM_Utils_Array::value('get_options', $apiRequest['params']['options'], []);
@@ -414,7 +414,7 @@ function civicrm_api3_generic_getoptions($apiRequest) {
     return civicrm_api3_create_error("The field '{$apiRequest['params']['field']}' doesn't exist.");
   }
   // Validate 'context' from params
-  $context = CRM_Utils_Array::value('context', $apiRequest['params']);
+  $context = $apiRequest['params']['context'] ?? NULL;
   CRM_Core_DAO::buildOptionsContext($context);
   unset($apiRequest['params']['context'], $apiRequest['params']['field'], $apiRequest['params']['condition']);
 
@@ -502,10 +502,10 @@ function _civicrm_api3_generic_get_metadata_options(&$metadata, $apiRequest, $fi
   }
 
   // Allow caller to specify context
-  $context = CRM_Utils_Array::value('get_options_context', $apiRequest['params']['options']);
+  $context = $apiRequest['params']['options']['get_options_context'] ?? NULL;
   // Default to api action if it is a supported context.
   if (!$context) {
-    $action = CRM_Utils_Array::value('action', $apiRequest['params']);
+    $action = $apiRequest['params']['action'] ?? NULL;
     $contexts = CRM_Core_DAO::buildOptionsContext();
     if (isset($contexts[$action])) {
       $context = $action;
index 116ec298a6b32b7d7b233e7d8d6296eaec21ce9c..250438378f774e038337164192bc3a8e3c9cc9ae 100644 (file)
@@ -52,7 +52,7 @@ function civicrm_api3_group_contact_get($params) {
   }
   $status = CRM_Utils_Array::value('status', $params, 'Added');
 
-  $groupId = CRM_Utils_Array::value('group_id', $params);
+  $groupId = $params['group_id'] ?? NULL;
   $values = CRM_Contact_BAO_GroupContact::getContactGroup($params['contact_id'], $status, NULL, FALSE, TRUE, FALSE, TRUE, $groupId);
   return civicrm_api3_create_success($values, $params, 'GroupContact');
 }
@@ -219,7 +219,7 @@ function _civicrm_api3_group_contact_common($params, $op = 'Added') {
 
   $method = CRM_Utils_Array::value('method', $params, 'API');
   $status = CRM_Utils_Array::value('status', $params, $op);
-  $tracking = CRM_Utils_Array::value('tracking', $params);
+  $tracking = $params['tracking'] ?? NULL;
 
   if ($op == 'Added' || $op == 'Pending') {
     $extraReturnValues = [
index c3dd38b069a4db2c1d9a0f957ab40d778f90ff60..252726d7878e8b0892a219237a57d24c1726324d 100644 (file)
@@ -512,7 +512,7 @@ function civicrm_api3_job_process_respondent($params) {
  * @throws \CiviCRM_API3_Exception
  */
 function civicrm_api3_job_process_batch_merge($params) {
-  $rule_group_id = CRM_Utils_Array::value('rule_group_id', $params);
+  $rule_group_id = $params['rule_group_id'] ?? NULL;
   if (!$rule_group_id) {
     $rule_group_id = civicrm_api3('RuleGroup', 'getvalue', [
       'contact_type' => 'Individual',
@@ -521,8 +521,8 @@ function civicrm_api3_job_process_batch_merge($params) {
       'options' => ['limit' => 1],
     ]);
   }
-  $rgid = CRM_Utils_Array::value('rgid', $params);
-  $gid = CRM_Utils_Array::value('gid', $params);
+  $rgid = $params['rgid'] ?? NULL;
+  $gid = $params['gid'] ?? NULL;
   $mode = CRM_Utils_Array::value('mode', $params, 'safe');
 
   $result = CRM_Dedupe_Merger::batchMerge($rule_group_id, $gid, $mode, 1, 2, CRM_Utils_Array::value('criteria', $params, []), CRM_Utils_Array::value('check_permissions', $params), NULL, $params['search_limit']);
index fc7645a049c8c78e66cf5bbc3c89b9097807f6a1..185b3cd374ad063926d3d56efa66f56d2e1ad448 100644 (file)
@@ -192,7 +192,7 @@ function civicrm_api3_mailing_clone($params) {
   $get = civicrm_api3('Mailing', 'getsingle', ['id' => $params['id']]);
 
   $newParams = [];
-  $newParams['debug'] = CRM_Utils_Array::value('debug', $params);
+  $newParams['debug'] = $params['debug'] ?? NULL;
   $newParams['groups']['include'] = [];
   $newParams['groups']['exclude'] = [];
   $newParams['mailings']['include'] = [];
@@ -393,9 +393,9 @@ function civicrm_api3_mailing_event_reply($params) {
   $queue     = $params['event_queue_id'];
   $hash      = $params['hash'];
   $replyto   = $params['replyTo'];
-  $bodyTxt   = CRM_Utils_Array::value('bodyTxt', $params);
-  $bodyHTML  = CRM_Utils_Array::value('bodyHTML', $params);
-  $fullEmail = CRM_Utils_Array::value('fullEmail', $params);
+  $bodyTxt   = $params['bodyTxt'] ?? NULL;
+  $bodyHTML  = $params['bodyHTML'] ?? NULL;
+  $fullEmail = $params['fullEmail'] ?? NULL;
 
   $mailing = CRM_Mailing_Event_BAO_Reply::reply($job, $queue, $hash, $replyto);
 
@@ -440,8 +440,8 @@ function civicrm_api3_mailing_event_forward($params) {
   $queue     = $params['event_queue_id'];
   $hash      = $params['hash'];
   $email     = $params['email'];
-  $fromEmail = CRM_Utils_Array::value('fromEmail', $params);
-  $params    = CRM_Utils_Array::value('params', $params);
+  $fromEmail = $params['fromEmail'] ?? NULL;
+  $params    = $params['params'] ?? NULL;
 
   $forward = CRM_Mailing_Event_BAO_Forward::forward($job, $queue, $hash, $email, $fromEmail, $params);
 
@@ -538,7 +538,7 @@ function civicrm_api3_mailing_preview($params) {
   }
 
   $mailing = new CRM_Mailing_BAO_Mailing();
-  $mailingID = CRM_Utils_Array::value('id', $params);
+  $mailingID = $params['id'] ?? NULL;
   if ($mailingID) {
     $mailing->id = $mailingID;
     $mailing->find(TRUE);
@@ -555,7 +555,7 @@ function civicrm_api3_mailing_preview($params) {
   $attachments = CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $mailing->id);
 
   $returnProperties = $mailing->getReturnProperties();
-  $contactID = CRM_Utils_Array::value('contact_id', $params);
+  $contactID = $params['contact_id'] ?? NULL;
   if (!$contactID) {
     // If we still don't have a userID in a session because we are annon then set contactID to be 0
     $contactID = empty($session->get('userID')) ? 0 : $session->get('userID');
@@ -564,7 +564,7 @@ function civicrm_api3_mailing_preview($params) {
 
   if (!$contactID) {
     $details = CRM_Utils_Token::getAnonymousTokenDetails($mailingParams, $returnProperties, TRUE, TRUE, NULL, $mailing->getFlattenedTokens());
-    $details = CRM_Utils_Array::value(0, $details[0]);
+    $details = $details[0][0] ?? NULL;
   }
   else {
     $details = CRM_Utils_Token::getTokenDetails($mailingParams, $returnProperties, TRUE, TRUE, NULL, $mailing->getFlattenedTokens());
index b594d772ac60c10d4ac7afe8d1bc0c362bf04758..92a8795bdb20f3fd0ef60257ce411faa3466d17b 100644 (file)
@@ -29,7 +29,7 @@
 function civicrm_api3_mailing_event_subscribe_create($params) {
   $email      = $params['email'];
   $group_id   = $params['group_id'];
-  $contact_id = CRM_Utils_Array::value('contact_id', $params);
+  $contact_id = $params['contact_id'] ?? NULL;
 
   $group            = new CRM_Contact_DAO_Group();
   $group->is_active = 1;
index 879aeb80ad1f45d905f47e7682c0282c74f265ba..8e935373d1a13a9dd319f6b9d37c41709a065404 100644 (file)
@@ -208,7 +208,7 @@ function _civicrm_api3_membership_get_spec(&$params) {
 function civicrm_api3_membership_get($params) {
   $activeOnly = $membershipTypeId = $membershipType = NULL;
 
-  $contactID = CRM_Utils_Array::value('contact_id', $params);
+  $contactID = $params['contact_id'] ?? NULL;
   if (!empty($params['filters']) && is_array($params['filters']) && isset($params['filters']['is_current'])) {
     $activeOnly = $params['filters']['is_current'];
     unset($params['filters']['is_current']);
@@ -291,7 +291,7 @@ function _civicrm_api3_membership_relationsship_get_customv2behaviour(&$params,
 
     // populating relationship type name.
     $relationshipType = new CRM_Contact_BAO_RelationshipType();
-    $relationshipType->id = CRM_Utils_Array::value('relationship_type_id', $membershipType);
+    $relationshipType->id = $membershipType['relationship_type_id'] ?? NULL;
     if ($relationshipType->find(TRUE)) {
       $membershipValues[$membershipId]['relationship_name'] = $relationshipType->name_a_b;
     }
index 97421d09d9bf06259f6e3c32d640d7d7e43e5b5a..f49c269435f894e729b2aad37a95f5b9cab172d6 100644 (file)
@@ -72,7 +72,7 @@ function civicrm_api3_membership_status_update($params) {
 
   civicrm_api3_verify_mandatory($params, NULL, ['id']);
   //don't allow duplicate names.
-  $name = CRM_Utils_Array::value('name', $params);
+  $name = $params['name'] ?? NULL;
   if ($name) {
     $status = new CRM_Member_DAO_MembershipStatus();
     $status->name = $params['name'];
index 464dcd427058828abf546d574b188c23390afaf0..99b270ec29755882805bc62f9a2a9e4439f659b0 100644 (file)
@@ -74,7 +74,7 @@ function civicrm_api3_order_create($params) {
   civicrm_api3_verify_one_mandatory($params, NULL, ['line_items', 'total_amount']);
   $entity = NULL;
   $entityIds = [];
-  $contributionStatus = CRM_Utils_Array::value('contribution_status_id', $params);
+  $contributionStatus = $params['contribution_status_id'] ?? NULL;
   if ($contributionStatus !== 'Pending' && 'Pending' !== CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $contributionStatus)) {
     CRM_Core_Error::deprecatedFunctionWarning("Creating a Order with a status other than pending is deprecated. Currently empty defaults to 'Completed' so as a transition not passing in 'Pending' is deprecated. You can chain payment creation e.g civicrm_api3('Order', 'create', ['blah' => 'blah', 'contribution_status_id' => 'Pending', 'api.Payment.create => ['total_amount' => 5]]");
   }
index cab15b3f3cd709a55bd4efda82455ef5ca1a53c5..32cff589fd9b804a8cde01dd4b52c5560ee03537 100644 (file)
@@ -30,7 +30,7 @@ function civicrm_api3_payment_get($params) {
   $financialTrxn = [];
   $limit = '';
   if (isset($params['options']) && !empty($params['options']['limit'])) {
-    $limit = CRM_Utils_Array::value('limit', $params['options']);
+    $limit = $params['options']['limit'] ?? NULL;
   }
   $params['options']['limit'] = 0;
   if (isset($params['trxn_id'])) {
index dc5fc1d6e969becd7684f348592502ee5b633789..9d8fce5e6c30918b3d83a42424e3ea902024eb0d 100644 (file)
@@ -132,7 +132,7 @@ function _civicrm_api3_setting_getdefaults_spec(&$params) {
  * @throws \API_Exception
  */
 function civicrm_api3_setting_getoptions($params) {
-  $domainId = CRM_Utils_Array::value('domain_id', $params);
+  $domainId = $params['domain_id'] ?? NULL;
   $specs = \Civi\Core\SettingsMetadata::getMetadata(['name' => $params['field']], $domainId, TRUE);
 
   if (empty($specs[$params['field']]) || !is_array(CRM_Utils_Array::value('options', $specs[$params['field']]))) {
index d7f6598d2f3098ce839f2c4f659283cf0d4ced8c..a6f5665e3adae23aa5f1f343f9e5a7ca4afa208c 100644 (file)
@@ -539,10 +539,10 @@ function _civicrm_api3_get_using_query_object($entity, $params, $additional_opti
     }
   }
   $options = array_merge($options, $additional_options);
-  $sort             = CRM_Utils_Array::value('sort', $options, NULL);
-  $offset             = CRM_Utils_Array::value('offset', $options, NULL);
-  $limit             = CRM_Utils_Array::value('limit', $options, NULL);
-  $smartGroupCache  = CRM_Utils_Array::value('smartGroupCache', $params);
+  $sort             = $options['sort'] ?? NULL;
+  $offset             = $options['offset'] ?? NULL;
+  $limit             = $options['limit'] ?? NULL;
+  $smartGroupCache  = $params['smartGroupCache'] ?? NULL;
 
   if ($getCount) {
     $limit = NULL;