Merge pull request #16138 from eileenmcnaughton/static
authorMatthew Wire <mjw@mjwconsult.co.uk>
Sun, 22 Dec 2019 11:48:18 +0000 (11:48 +0000)
committerGitHub <noreply@github.com>
Sun, 22 Dec 2019 11:48:18 +0000 (11:48 +0000)
Switch static var to using Civi::statics

CRM/Contact/BAO/Relationship.php
CRM/Member/BAO/Membership.php
tests/phpunit/api/v3/ContributionTest.php

index 12b23f5242e6be3762de138f55e9a7dd364df934..325ce00de6180eda7e9e47e253461f09e77f703a 100644 (file)
@@ -1124,14 +1124,16 @@ WHERE  relationship_type_id = " . CRM_Utils_Type::escape($type, 'Integer');
    *
    * @return array
    *   [select, from, where]
-   * @throws \Exception
+   *
+   * @throws \CRM_Core_Exception
+   * @throws \CiviCRM_API3_Exception
    */
   public static function makeURLClause($contactId, $status, $numRelationship, $count, $relationshipId, $direction, $params = []) {
     $select = $from = $where = '';
 
     $select = '( ';
     if ($count) {
-      if ($direction == 'a_b') {
+      if ($direction === 'a_b') {
         $select .= ' SELECT count(DISTINCT civicrm_relationship.id) as cnt1, 0 as cnt2 ';
       }
       else {
@@ -1166,7 +1168,7 @@ WHERE  relationship_type_id = " . CRM_Utils_Type::escape($type, 'Integer');
                               civicrm_relationship.is_permission_b_a as is_permission_b_a,
                               civicrm_relationship.case_id as case_id';
 
-      if ($direction == 'a_b') {
+      if ($direction === 'a_b') {
         $select .= ', civicrm_relationship_type.label_a_b as label_a_b,
                               civicrm_relationship_type.label_b_a as relation ';
       }
@@ -1176,11 +1178,11 @@ WHERE  relationship_type_id = " . CRM_Utils_Type::escape($type, 'Integer');
       }
     }
 
-    $from = "
+    $from = '
       FROM  civicrm_relationship
 INNER JOIN  civicrm_relationship_type ON ( civicrm_relationship.relationship_type_id = civicrm_relationship_type.id )
-INNER JOIN  civicrm_contact ";
-    if ($direction == 'a_b') {
+INNER JOIN  civicrm_contact ';
+    if ($direction === 'a_b') {
       $from .= 'ON ( civicrm_contact.id = civicrm_relationship.contact_id_a ) ';
     }
     else {
@@ -1188,18 +1190,18 @@ INNER JOIN  civicrm_contact ";
     }
 
     if (!$count) {
-      $from .= "
+      $from .= '
 LEFT JOIN  civicrm_address ON (civicrm_address.contact_id = civicrm_contact.id AND civicrm_address.is_primary = 1)
 LEFT JOIN  civicrm_phone   ON (civicrm_phone.contact_id = civicrm_contact.id AND civicrm_phone.is_primary = 1)
 LEFT JOIN  civicrm_email   ON (civicrm_email.contact_id = civicrm_contact.id AND civicrm_email.is_primary = 1)
 LEFT JOIN  civicrm_state_province ON (civicrm_address.state_province_id = civicrm_state_province.id)
 LEFT JOIN  civicrm_country ON (civicrm_address.country_id = civicrm_country.id)
-";
+';
     }
 
     $where = 'WHERE ( 1 )';
     if ($contactId) {
-      if ($direction == 'a_b') {
+      if ($direction === 'a_b') {
         $where .= ' AND civicrm_relationship.contact_id_b = ' . CRM_Utils_Type::escape($contactId, 'Positive');
       }
       else {
@@ -1245,7 +1247,7 @@ LEFT JOIN  civicrm_country ON (civicrm_address.country_id = civicrm_country.id)
         $where .= ' AND relationship_type_id = ' . CRM_Utils_Type::escape($params['relationship_type_id'], 'Positive');
       }
     }
-    if ($direction == 'a_b') {
+    if ($direction === 'a_b') {
       $where .= ' ) UNION ';
     }
     else {
@@ -1279,7 +1281,9 @@ LEFT JOIN  civicrm_country ON (civicrm_address.country_id = civicrm_country.id)
    *
    * @return array|int
    *   relationship records
-   * @throws \Exception
+   *
+   * @throws \CRM_Core_Exception
+   * @throws \CiviCRM_API3_Exception
    */
   public static function getRelationship(
     $contactId = NULL,
index 4d51b83ef204a1348acb0213bcf502e8cb5afe10..9cfd7a67e12c8f27272c164de15dcfc3b0695939 100644 (file)
@@ -447,6 +447,9 @@ class CRM_Member_BAO_Membership extends CRM_Member_DAO_Membership {
    *
    * @return array
    *   array of contact_id of all related contacts.
+   *
+   * @throws \CRM_Core_Exception
+   * @throws \CiviCRM_API3_Exception
    */
   public static function checkMembershipRelationship($membershipTypeID, $contactId, $action = CRM_Core_Action::ADD) {
     $contacts = [];
index 0f58088aa3c8b660b4d1e00da66aefe762ed0b88..1e71806386870e158e6ee0b7c4aa0c82102d073c 100644 (file)
@@ -58,6 +58,8 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
 
   /**
    * Setup function.
+   *
+   * @throws \CRM_Core_Exception
    */
   public function setUp() {
     parent::setUp();
@@ -126,6 +128,8 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
 
   /**
    * Test Get.
+   *
+   * @throws \CRM_Core_Exception
    */
   public function testGetContribution() {
     $contributionSettings = $this->enableTaxAndInvoicing();
@@ -211,6 +215,8 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
 
   /**
    * Test that test contributions can be retrieved.
+   *
+   * @throws \CRM_Core_Exception
    */
   public function testGetTestContribution() {
     $this->callAPISuccess('Contribution', 'create', array_merge($this->_params, ['is_test' => 1]));