CRM/Contact - Cleanup boolean expressions
authorColeman Watts <coleman@civicrm.org>
Tue, 17 Mar 2020 23:34:12 +0000 (19:34 -0400)
committereileen <emcnaughton@wikimedia.org>
Thu, 19 Mar 2020 04:07:56 +0000 (17:07 +1300)
CRM/Contact/BAO/Contact.php
CRM/Contact/BAO/Contact/Utils.php
CRM/Contact/BAO/ContactType.php
CRM/Contact/Form/Merge.php
CRM/Contact/Form/Search.php
CRM/Contact/Form/Task/ProximityCommon.php

index bbcd516d8402a042d92d22262839d7874386f311..93e9b556d1ef3581c4a70159c330f21e2e6fe795 100644 (file)
@@ -1935,9 +1935,9 @@ ORDER BY civicrm_email.is_primary DESC";
         $name = $dao->display_name;
       }
       $email = $dao->email;
-      $doNotEmail = $dao->do_not_email ? TRUE : FALSE;
-      $onHold = $dao->on_hold ? TRUE : FALSE;
-      $isDeceased = $dao->is_deceased ? TRUE : FALSE;
+      $doNotEmail = (bool) $dao->do_not_email;
+      $onHold = (bool) $dao->on_hold;
+      $isDeceased = (bool) $dao->is_deceased;
       return [$name, $email, $doNotEmail, $onHold, $isDeceased];
     }
     return [NULL, NULL, NULL, NULL, NULL];
index 3a408b24b4330cb484954eb6969f5eb996e09ca9..fa355a42bc4c80b429b69df8f0224c2ee4584602 100644 (file)
@@ -55,11 +55,7 @@ class CRM_Contact_BAO_Contact_Utils {
         $imageInfo[$contactType]['url'] = $imageUrl;
       }
       else {
-        $isSubtype = (array_key_exists('parent_id', $typeInfo) &&
-          $typeInfo['parent_id']
-        ) ? TRUE : FALSE;
-
-        if ($isSubtype) {
+        if (!empty($typeInfo['parent_id'])) {
           $type = CRM_Contact_BAO_ContactType::getBasicType($typeInfo['name']) . '-subtype';
         }
         else {
@@ -118,7 +114,7 @@ FROM   civicrm_contact
 WHERE  id IN ( $idString )
 ";
     $count = CRM_Core_DAO::singleValueQuery($query);
-    return $count > 1 ? TRUE : FALSE;
+    return $count > 1;
   }
 
   /**
index c79a77c148216b6287be3ed9077186004bcb5812..947f8dc4305e432b292d8320eb04b8e448cc2092 100644 (file)
@@ -46,7 +46,7 @@ class CRM_Contact_BAO_ContactType extends CRM_Contact_DAO_ContactType {
    */
   public static function isActive($contactType) {
     $contact = self::contactTypeInfo(FALSE);
-    $active = array_key_exists($contactType, $contact) ? TRUE : FALSE;
+    $active = array_key_exists($contactType, $contact);
     return $active;
   }
 
index 2c3d2cb35cd02cfbae63678787d6b7ad2def141c..ddea89ac896a2477f668634d4084e8af09cb7e92 100644 (file)
@@ -161,7 +161,7 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form {
         $this->assign('otherUfName', $otherUser ? $otherUser['name'] : NULL);
       }
 
-      $cmsUser = ($mainUfId && $otherUfId) ? TRUE : FALSE;
+      $cmsUser = $mainUfId && $otherUfId;
       $this->assign('user', $cmsUser);
 
       $rowsElementsAndInfo = CRM_Dedupe_Merger::getRowsElementsAndInfo($this->_cid, $this->_oid);
index 6273816711c9f990e5a7373ebe3a1c5e1db6acae..322dc47e317bb42c42bd06f7eca146b49ce6b204 100644 (file)
@@ -183,7 +183,7 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search {
    */
   public static function isSearchContext($context) {
     $searchContext = CRM_Utils_Array::value($context, self::validContext());
-    return $searchContext ? TRUE : FALSE;
+    return (bool) $searchContext;
   }
 
   public static function setModeValues() {
index b4aed3a98cf99fdee02d0a7bb74d60a23c6cf9cd..58c6abe8fcfbbadbcc842190c6ecca88fb1adc18 100644 (file)
@@ -49,7 +49,7 @@ class CRM_Contact_Form_Task_ProximityCommon {
    */
   public static function buildQuickForm($form, $proxSearch) {
     // is proximity search required (2) or optional (1)?
-    $proxRequired = ($proxSearch == 2 ? TRUE : FALSE);
+    $proxRequired = ($proxSearch == 2);
     $form->assign('proximity_search', TRUE);
 
     $form->add('text', 'prox_street_address', ts('Street Address'), NULL, FALSE);