[NFC] Code cleanup around comments, strict comparison, formatting
authoreileen <emcnaughton@wikimedia.org>
Sat, 11 Apr 2020 03:15:34 +0000 (15:15 +1200)
committereileen <emcnaughton@wikimedia.org>
Sat, 11 Apr 2020 03:33:23 +0000 (15:33 +1200)
CRM/Member/Form/Membership.php
CRM/Member/Form/MembershipRenewal.php

index 7a13df8b716222c3f669b276ec9ea6a68cffb32e..412b6d27ee871198fdef4f0062143e53b49503d2 100644 (file)
@@ -194,6 +194,7 @@ class CRM_Member_Form_Membership extends CRM_Member_Form {
    * Form preProcess function.
    *
    * @throws \CRM_Core_Exception
+   * @throws \CiviCRM_API3_Exception
    */
   public function preProcess() {
     // This string makes up part of the class names, differentiating them (not sure why) from the membership fields.
@@ -665,9 +666,11 @@ class CRM_Member_Form_Membership extends CRM_Member_Form {
    * @param array $files
    * @param CRM_Member_Form_Membership $self
    *
-   * @throws CiviCRM_API3_Exception
    * @return bool|array
    *   mixed true or array of errors
+   *
+   * @throws \CRM_Core_Exception
+   * @throws CiviCRM_API3_Exception
    */
   public static function formRule($params, $files, $self) {
     $errors = [];
@@ -880,6 +883,9 @@ class CRM_Member_Form_Membership extends CRM_Member_Form {
 
   /**
    * Process the form submission.
+   *
+   * @throws \CRM_Core_Exception
+   * @throws \CiviCRM_API3_Exception
    */
   public function postProcess() {
     if ($this->_action & CRM_Core_Action::DELETE) {
@@ -925,10 +931,6 @@ class CRM_Member_Form_Membership extends CRM_Member_Form {
   /**
    * Send email receipt.
    *
-   * @deprecated
-   *   This function is shared with Batch_Entry which has limited overlap
-   *   & needs rationalising.
-   *
    * @param CRM_Core_Form $form
    *   Form object.
    * @param array $formValues
@@ -938,6 +940,12 @@ class CRM_Member_Form_Membership extends CRM_Member_Form {
    *
    * @return bool
    *   true if mail was sent successfully
+   * @throws \CRM_Core_Exception
+   *
+   * @deprecated
+   *   This function is shared with Batch_Entry which has limited overlap
+   *   & needs rationalising.
+   *
    */
   public static function emailReceipt(&$form, &$formValues, &$membership, $customValues = NULL) {
     // retrieve 'from email id' for acknowledgement
@@ -1661,7 +1669,7 @@ class CRM_Member_Form_Membership extends CRM_Member_Form {
     if ($contributionId && !empty($membershipIds)) {
       $contributionDetails = CRM_Contribute_BAO_Contribution::getContributionDetails(
         CRM_Export_Form_Select::MEMBER_EXPORT, $this->_membershipIDs);
-      if ($contributionDetails[$membership->id]['contribution_status'] == 'Completed') {
+      if ($contributionDetails[$membership->id]['contribution_status'] === 'Completed') {
         $receiptSend = TRUE;
       }
     }
@@ -1703,6 +1711,8 @@ class CRM_Member_Form_Membership extends CRM_Member_Form {
    * @param CRM_Member_DAO_Membership $membership
    *     Updated membership object
    *
+   * @throws \CRM_Core_Exception
+   * @throws \CiviCRM_API3_Exception
    */
   protected function updateContributionOnMembershipTypeChange($inputParams, $membership) {
     if (Civi::settings()->get('update_contribution_on_membership_type_change') &&
@@ -1784,7 +1794,7 @@ class CRM_Member_Form_Membership extends CRM_Member_Form {
     $buttonName = $this->controller->getButtonName();
     $session = CRM_Core_Session::singleton();
 
-    if ($this->_context == 'standalone') {
+    if ($this->_context === 'standalone') {
       if ($buttonName == $this->getButtonName('upload', 'new')) {
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/member/add',
           'reset=1&action=add&context=standalone'
@@ -1890,6 +1900,7 @@ class CRM_Member_Form_Membership extends CRM_Member_Form {
 
   /**
    * @return bool
+   * @throws \CRM_Core_Exception
    */
   protected function isUpdateToExistingRecurringMembership() {
     $isRecur = FALSE;
@@ -1910,6 +1921,7 @@ class CRM_Member_Form_Membership extends CRM_Member_Form {
    * @param \CRM_Member_BAO_Membership $membership
    *
    * @return bool
+   * @throws \CRM_Core_Exception
    */
   protected function emailMembershipReceipt($formValues, $membership) {
     $customValues = $this->getCustomValuesForReceipt($formValues, $membership);
@@ -1932,7 +1944,7 @@ class CRM_Member_Form_Membership extends CRM_Member_Form {
       && !empty($this->_groupTree)
     ) {
       foreach ($this->_groupTree as $groupID => $group) {
-        if ($groupID == 'info') {
+        if ($groupID === 'info') {
           continue;
         }
         foreach ($group['fields'] as $k => $field) {
@@ -1944,7 +1956,7 @@ class CRM_Member_Form_Membership extends CRM_Member_Form {
 
     $members = [['member_id', '=', $membership->id, 0, 0]];
     // check whether its a test drive
-    if ($this->_mode == 'test') {
+    if ($this->_mode === 'test') {
       $members[] = ['member_test', '=', 1, 0, 0];
     }
 
index 78b733e71b826eda4343e3b022796b38bd27141e..04287f6bfe5691e53be33e0f10af35a8dfff54ae 100644 (file)
@@ -29,6 +29,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
 
   /**
    * email of the person paying for the membership (used for receipts)
+   *
    * @var string
    */
   protected $_memberEmail = NULL;
@@ -50,6 +51,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
 
   /**
    * email of the person paying for the membership (used for receipts)
+   *
    * @var string
    */
   protected $_contributorEmail = NULL;
@@ -71,6 +73,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
   /**
    * context would be set to standalone if the contact is use is being selected from
    * the form rather than in the URL
+   *
    * @var string
    */
   public $_context;
@@ -99,25 +102,25 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
   /**
    * Set entity fields to be assigned to the form.
    */
-  protected function setEntityFields() {}
+  protected function setEntityFields() {
+  }
 
   /**
    * Set the delete message.
    *
    * We do this from the constructor in order to do a translation.
    */
-  public function setDeleteMessage() {}
+  public function setDeleteMessage() {
+  }
 
   /**
    * Set the renewal notification status message.
    */
   public function setRenewalMessage() {
-    $statusMsg = ts('%1 membership for %2 has been renewed.', array(1 => $this->membershipTypeName, 2 => $this->_memberDisplayName));
+    $statusMsg = ts('%1 membership for %2 has been renewed.', [1 => $this->membershipTypeName, 2 => $this->_memberDisplayName]);
 
     if ($this->isMailSent) {
-      $statusMsg .= ' ' . ts('A renewal confirmation and receipt has been sent to %1.', array(
-        1 => $this->_contributorEmail,
-      ));
+      $statusMsg .= ' ' . ts('A renewal confirmation and receipt has been sent to %1.', [1 => $this->_contributorEmail]);
     }
     CRM_Core_Session::setStatus($statusMsg, ts('Complete'), 'success');
   }
@@ -135,8 +138,8 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
     parent::preProcess();
 
     $this->assign('endDate', CRM_Utils_Date::customFormat(CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership',
-        $this->_id, 'end_date'
-      )
+      $this->_id, 'end_date'
+    )
     ));
     $this->assign('membershipStatus',
       CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus',
@@ -176,6 +179,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
    *
    * @return array
    *   Default values.
+   * @throws \CRM_Core_Exception
    */
   public function setDefaultValues() {
 
@@ -211,7 +215,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
     $defaults['send_receipt'] = 0;
 
     //set Soft Credit Type to Gift by default
-    $scTypes = CRM_Core_OptionGroup::values("soft_credit_type");
+    $scTypes = CRM_Core_OptionGroup::values('soft_credit_type');
     $defaults['soft_credit_type_id'] = CRM_Utils_Array::value(ts('Gift'), array_flip($scTypes));
 
     $renewalDate = $defaults['renewal_date'] ?? NULL;
@@ -226,6 +230,8 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
 
   /**
    * Build the form object.
+   *
+   * @throws \CRM_Core_Exception
    */
   public function buildQuickForm() {
 
@@ -412,6 +418,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
    *
    * @return bool|array
    *   mixed true or array of errors
+   * @throws \CRM_Core_Exception
    */
   public static function formRule($params, $files, $self) {
     $errors = [];
@@ -453,6 +460,9 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
 
   /**
    * Process the renewal form.
+   *
+   * @throws \CRM_Core_Exception
+   * @throws \CiviCRM_API3_Exception
    */
   public function postProcess() {
     // get the submitted form values.
@@ -546,7 +556,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
 
       $this->_params['contribution_status_id'] = $result['payment_status_id'];
       $this->_params['trxn_id'] = $result['trxn_id'];
-      $this->_params['is_test'] = ($this->_mode == 'live') ? 0 : 1;
+      $this->_params['is_test'] = ($this->_mode === 'live') ? 0 : 1;
       $this->set('params', $this->_params);
       $this->assign('trxn_id', $result['trxn_id']);
     }
@@ -661,7 +671,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
     // retrieve custom data
     $customFields = $customValues = $fo = [];
     foreach ($this->_groupTree as $groupID => $group) {
-      if ($groupID == 'info') {
+      if ($groupID === 'info') {
         continue;
       }
       foreach ($group['fields'] as $k => $field) {
@@ -671,7 +681,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
     }
     $members = [['member_id', '=', $this->_membershipId, 0, 0]];
     // check whether its a test drive
-    if ($this->_mode == 'test') {
+    if ($this->_mode === 'test') {
       $members[] = ['member_test', '=', 1, 0, 0];
     }
     CRM_Core_BAO_UFGroup::getValues($this->_contactID, $customFields, $customValues, FALSE, $members);
@@ -697,7 +707,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
       $this->assign('is_pay_later', 0);
       $this->assign('isPrimary', 1);
       $this->assign('receipt_text_renewal', $this->_params['receipt_text']);
-      if ($this->_mode == 'test') {
+      if ($this->_mode === 'test') {
         $this->assign('action', '1024');
       }
     }
@@ -710,7 +720,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
         'from' => $receiptFrom,
         'toName' => $this->_contributorDisplayName,
         'toEmail' => $this->_contributorEmail,
-        'isTest' => $this->_mode == 'test',
+        'isTest' => $this->_mode === 'test',
       ]
     );
   }