Use ?? operator instead of CRM_Utils_Array::value() in return statements
authorColeman Watts <coleman@civicrm.org>
Mon, 9 Mar 2020 15:50:45 +0000 (11:50 -0400)
committerColeman Watts <coleman@civicrm.org>
Mon, 9 Mar 2020 15:50:45 +0000 (11:50 -0400)
18 files changed:
CRM/Campaign/BAO/Survey.php
CRM/Contact/BAO/Contact.php
CRM/Contribute/BAO/Contribution.php
CRM/Core/Component.php
CRM/Core/Controller.php
CRM/Core/Payment/Form.php
CRM/Core/Payment/PayPalProIPN.php
CRM/Core/PseudoConstant.php
CRM/Core/Session.php
CRM/Event/Cart/BAO/Cart.php
CRM/Event/PseudoConstant.php
CRM/Financial/Form/SalesTaxTrait.php
CRM/Invoicing/Utils.php
CRM/Logging/ReportSummary.php
CRM/Report/Form/Contact/Relationship.php
CRM/Report/Utils/Report.php
CRM/Utils/System.php
tests/phpunit/api/v3/TaxContributionPageTest.php

index 810cec0d4a09b2e7c154ce9e8ce28d92453b750c..9277e4f04014043dc3ce96673032b1623062b272 100644 (file)
@@ -886,7 +886,7 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
       }
     }
 
-    return CRM_Utils_Array::value($surveyId, $ufIds);
+    return $ufIds[$surveyId] ?? NULL;
   }
 
   /**
index 4698884396019cf127f3a637b7559bf1e4404ab5..f068d0a0337caff9e5285ac2ba394c771aca6248 100644 (file)
@@ -3620,7 +3620,7 @@ LEFT JOIN civicrm_address ON ( civicrm_address.contact_id = civicrm_contact.id )
   public static function isFieldHasLocationType($fieldTitle) {
     foreach (CRM_Contact_BAO_Contact::importableFields() as $key => $field) {
       if ($field['title'] === $fieldTitle) {
-        return CRM_Utils_Array::value('hasLocationType', $field);
+        return $field['hasLocationType'] ?? NULL;
       }
     }
     return FALSE;
index 3f2ca58df0f72f292d1a583aa91011a75ec2f05c..9ec355bb6ecd1e103ad162b8c687decb8ee1d493 100644 (file)
@@ -5008,7 +5008,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac
    */
   public static function checkContributeSettings($name) {
     $contributeSettings = Civi::settings()->get('contribution_invoice_settings');
-    return CRM_Utils_Array::value($name, $contributeSettings);
+    return $contributeSettings[$name] ?? NULL;
   }
 
   /**
index 73cb707a5ad13b381ad30151f51b03cd0fd25ed4..10b302d5f5f8477f0970c045722eae72f0b57e62 100644 (file)
@@ -63,7 +63,7 @@ class CRM_Core_Component {
   public static function get($name, $attribute = NULL) {
     $comp = CRM_Utils_Array::value($name, self::_info());
     if ($attribute) {
-      return CRM_Utils_Array::value($attribute, $comp->info);
+      return $comp->info[$attribute] ?? NULL;
     }
     return $comp;
   }
index 6f2ea70368ae7bc4bf16648291522928c4ddfd4e..8cdb5a2d5226a3047a1c39c5f8f9c688e86afc98 100644 (file)
@@ -464,7 +464,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
    */
   public function getButtonName() {
     $data = &$this->container();
-    return CRM_Utils_Array::value('_qf_button_name', $data);
+    return $data['_qf_button_name'] ?? NULL;
   }
 
   /**
index 1881d38554e40a9cdc4f8bdde8d79ba23eaea6e5..496f46d22ee12da1afb430f5a3fa26ba1b135e8e 100644 (file)
@@ -375,7 +375,7 @@ class CRM_Core_Payment_Form {
       return $month;
     }
 
-    return CRM_Utils_Array::value('m', $src['credit_card_exp_date']);
+    return $src['credit_card_exp_date']['m'] ?? NULL;
   }
 
   /**
@@ -388,7 +388,7 @@ class CRM_Core_Payment_Form {
    * @return int
    */
   public static function getCreditCardExpirationYear($src) {
-    return CRM_Utils_Array::value('Y', $src['credit_card_exp_date']);
+    return $src['credit_card_exp_date']['Y'] ?? NULL;
   }
 
   /**
index 42c23e308799ef910f612eaae75f1dd3520857dc..359937e6cb2a3e1523a09e005a3f2d3afe97daed 100644 (file)
@@ -76,7 +76,7 @@ class CRM_Core_Payment_PayPalProIPN extends CRM_Core_Payment_BaseIPN {
       throw new CRM_Core_Exception("Failure: Missing Parameter $name");
     }
     else {
-      return CRM_Utils_Array::value($name, $this->_invoiceData);
+      return $this->_invoiceData[$name] ?? NULL;
     }
   }
 
index 2c9dee0a09e1bc5493a993e95f4f858eb94ed3af..1e3f80bd49590280c236e05fcb2c8ad387c57913 100644 (file)
@@ -397,7 +397,7 @@ class CRM_Core_PseudoConstant {
     if ($values === FALSE) {
       return FALSE;
     }
-    return CRM_Utils_Array::value($key, $values);
+    return $values[$key] ?? NULL;
   }
 
   /**
@@ -417,7 +417,7 @@ class CRM_Core_PseudoConstant {
     if ($values === FALSE) {
       return FALSE;
     }
-    return CRM_Utils_Array::value($key, $values);
+    return $values[$key] ?? NULL;
   }
 
   /**
@@ -1478,7 +1478,7 @@ WHERE  id = %1
       self::$accountOptionValues[$cacheKey] = CRM_Core_OptionGroup::values($optionGroupName, FALSE, FALSE, FALSE, $condition);
     }
     if ($id) {
-      return CRM_Utils_Array::value($id, self::$accountOptionValues[$cacheKey]);
+      return self::$accountOptionValues[$cacheKey][$id] ?? NULL;
     }
 
     return self::$accountOptionValues[$cacheKey];
index 8cbcfdfeada0d42acd5969301bd5eac19e54f1bf..037efb1115b57af76c192a859c779c2b0e189b89 100644 (file)
@@ -250,7 +250,7 @@ class CRM_Core_Session {
       $session =& $this->_session[$this->_key][$prefix];
     }
 
-    return CRM_Utils_Array::value($name, $session);
+    return $session[$name] ?? NULL;
   }
 
   /**
index ac4090363f61f4a19649ff1c7c7406a680cbe103..1acabfe0a3bd7f167ba2f94711b32eaa0b574f5d 100644 (file)
@@ -238,7 +238,7 @@ class CRM_Event_Cart_BAO_Cart extends CRM_Event_Cart_DAO_Cart {
    * @return mixed
    */
   public function get_event_in_cart_by_event_id($event_id) {
-    return CRM_Utils_Array::value($event_id, $this->events_in_carts);
+    return $this->events_in_carts[$event_id] ?? NULL;
   }
 
   /**
index 9fd6a842ff6a79d3a0ac2edbdc6954dbc4d223e9..780adc60b11512e9e7fa1ada510ca551516b9854 100644 (file)
@@ -298,7 +298,7 @@ class CRM_Event_PseudoConstant extends CRM_Core_PseudoConstant {
       );
     }
     if ($id) {
-      return CRM_Utils_Array::value($id, self::$pcPage);
+      return self::$pcPage[$id] ?? NULL;
     }
     return self::$pcPage;
   }
index 777895dbb091fd51a2e963cc288e4a7471cd5bcf..888ac75f97605a6fac00813e261ec59c881e8511 100644 (file)
@@ -41,7 +41,7 @@ trait CRM_Financial_Form_SalesTaxTrait {
     if (!$invoicing) {
       return '';
     }
-    return CRM_Utils_Array::value('tax_term', $invoiceSettings);
+    return $invoiceSettings['tax_term'] ?? NULL;
   }
 
   /**
index daf3088747e865fcd75b128529835af1037bcd7c..dbcc4befacd850f6a2731d5949d8baf853b09cf2 100644 (file)
@@ -59,7 +59,7 @@ class CRM_Invoicing_Utils {
       return TRUE;
     }
     $invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
-    return CRM_Utils_Array::value('invoicing', $invoiceSettings);
+    return $invoiceSettings['invoicing'] ?? NULL;
   }
 
   /**
@@ -70,7 +70,7 @@ class CRM_Invoicing_Utils {
    */
   public static function getTaxTerm() {
     $invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
-    return CRM_Utils_Array::value('tax_term', $invoiceSettings);
+    return $invoiceSettings['tax_term'] ?? NULL;
   }
 
 }
index 2a882e842d8ee100ef9623d12dd5daef350dd763..364474b199daff1eefe8b4de344d6dce4dcac2d6 100644 (file)
@@ -280,7 +280,7 @@ WHERE  log_date <= %1 AND id = %2 ORDER BY log_date DESC LIMIT 1";
         if (array_key_exists('options', $this->_logTables[$entity]['bracket_info']) &&
           $entityID
         ) {
-          return CRM_Utils_Array::value($entityID, $this->_logTables[$entity]['bracket_info']['options']);
+          return $this->_logTables[$entity]['bracket_info']['options'][$entityID] ?? NULL;
         }
       }
     }
index f2756c3e65a34e17eac7cb21a96a0c10868148f4..4807844732a6194e382c7df31d978af8a901e31f 100644 (file)
@@ -792,7 +792,7 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form {
     if (!$lookup) {
       $lookup = CRM_Contact_BAO_Relationship::buildOptions("is_permission_a_b");
     };
-    return CRM_Utils_Array::value($key, $lookup);
+    return $lookup[$key] ?? NULL;
   }
 
   /**
index 276ef7fe6bca7781bc3a0eb3ec1daedfcfd14859..329bf0f83575839696effa228a7d25970cfdb0f8 100644 (file)
@@ -99,7 +99,7 @@ WHERE  TRIM(BOTH '/' FROM CONCAT(report_id, '/', name)) = %1";
       $params = [1 => [$path, 'String']];
       $valId[$path] = CRM_Core_DAO::singleValueQuery($sql, $params);
     }
-    return CRM_Utils_Array::value($path, $valId);
+    return $valId[$path] ?? NULL;
   }
 
   /**
index 29b043f1568eff6d62002f278ac4c0fdba52e5f6..9f71dab6d6388e127465edcbde867e636534eb12 100644 (file)
@@ -1278,7 +1278,7 @@ class CRM_Utils_System {
    *   The previous page URL
    */
   public static function refererPath() {
-    return CRM_Utils_Array::value('HTTP_REFERER', $_SERVER);
+    return $_SERVER['HTTP_REFERER'] ?? NULL;
   }
 
   /**
index 0bbc33074928de4ab57f259969cb63e77c40603a..3c2b82e73f7cc7839458504a7e4c79df3be1d389 100644 (file)
@@ -501,7 +501,7 @@ class api_v3_TaxContributionPageTest extends CiviUnitTestCase {
 
     $result = [];
     CRM_Financial_BAO_FinancialTypeAccount::retrieve($searchParams, $result);
-    return CRM_Utils_Array::value('financial_account_id', $result);
+    return $result['financial_account_id'] ?? NULL;
   }
 
   /**