From: eileen Date: Fri, 17 Jan 2020 00:45:34 +0000 (+1300) Subject: [NFC] Minor code tidy up X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7473db7f2af84b59984011107c222b5991127288;p=civicrm-core.git [NFC] Minor code tidy up Declare Exceptions, use strict comparison --- diff --git a/CRM/Contribute/Form/Search.php b/CRM/Contribute/Form/Search.php index 6ad2e48cd7..abe1b63316 100644 --- a/CRM/Contribute/Form/Search.php +++ b/CRM/Contribute/Form/Search.php @@ -45,7 +45,7 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search { * Prefix for the controller. * @var string */ - protected $_prefix = "contribute_"; + protected $_prefix = 'contribute_'; /** * Explicitly declare the entity api name. @@ -78,7 +78,7 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search { $this->_context ); $prefix = NULL; - if ($this->_context == 'user') { + if ($this->_context === 'user') { $prefix = $this->_prefix; } @@ -231,6 +231,8 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search { * done. * The processing consists of using a Selector / Controller framework for getting the * search results. + * + * @throws \CRM_Core_Exception */ public function postProcess() { if ($this->_done) { @@ -244,9 +246,9 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search { $this->fixFormValues(); // We don't show test records in summaries or dashboards - if (empty($this->_formValues['contribution_test']) && $this->_force && !empty($this->_context) && $this->_context == 'dashboard') { + if (empty($this->_formValues['contribution_test']) && $this->_force && !empty($this->_context) && $this->_context === 'dashboard') { // @todo - stop changing formValues - respect submitted form values, change a working array. - $this->_formValues["contribution_test"] = 0; + $this->_formValues['contribution_test'] = 0; } foreach ([ @@ -335,7 +337,7 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search { $selector->setKey($this->controller->_key); $prefix = NULL; - if ($this->_context == 'basic' || $this->_context == 'user') { + if ($this->_context === 'basic' || $this->_context === 'user') { $prefix = $this->_prefix; } @@ -350,7 +352,7 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search { $controller->setEmbedded(TRUE); $query = &$selector->getQuery(); - if ($this->_context == 'user') { + if ($this->_context === 'user') { $query->setSkipPermission(TRUE); } @@ -361,6 +363,8 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search { * Use values from $_GET if force is set to TRUE. * * Note that this means that GET over-rides POST. This was a historical decision & the reasoning is not explained. + * + * @throws \CRM_Core_Exception */ public function fixFormValues() { if (!$this->_force) { diff --git a/CRM/Contribute/Selector/Search.php b/CRM/Contribute/Selector/Search.php index b219918535..91e65fbfa1 100644 --- a/CRM/Contribute/Selector/Search.php +++ b/CRM/Contribute/Selector/Search.php @@ -608,7 +608,7 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C } /** - * @return string + * @return \CRM_Contact_BAO_Query */ public function &getQuery() { return $this->_query; diff --git a/CRM/Event/BAO/Query.php b/CRM/Event/BAO/Query.php index abf74dc022..ba9a353df8 100644 --- a/CRM/Event/BAO/Query.php +++ b/CRM/Event/BAO/Query.php @@ -49,25 +49,25 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_Query { if (($query->_mode & CRM_Contact_BAO_Query::MODE_EVENT) || CRM_Contact_BAO_Query::componentPresent($query->_returnProperties, 'participant_') ) { - $query->_select['participant_id'] = "civicrm_participant.id as participant_id"; + $query->_select['participant_id'] = 'civicrm_participant.id as participant_id'; $query->_element['participant_id'] = 1; $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1; //add fee level if (!empty($query->_returnProperties['participant_fee_level'])) { - $query->_select['participant_fee_level'] = "civicrm_participant.fee_level as participant_fee_level"; + $query->_select['participant_fee_level'] = 'civicrm_participant.fee_level as participant_fee_level'; $query->_element['participant_fee_level'] = 1; } //add participant contact ID if (!empty($query->_returnProperties['participant_contact_id'])) { - $query->_select['participant_contact_id'] = "civicrm_participant.contact_id as participant_contact_id"; + $query->_select['participant_contact_id'] = 'civicrm_participant.contact_id as participant_contact_id'; $query->_element['participant_contact_id'] = 1; } //add fee amount if (!empty($query->_returnProperties['participant_fee_amount'])) { - $query->_select['participant_fee_amount'] = "civicrm_participant.fee_amount as participant_fee_amount"; + $query->_select['participant_fee_amount'] = 'civicrm_participant.fee_amount as participant_fee_amount'; $query->_element['participant_fee_amount'] = 1; } @@ -471,12 +471,12 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_Query { $from = NULL; switch ($name) { case 'civicrm_participant': - $from = " LEFT JOIN civicrm_participant ON civicrm_participant.contact_id = contact_a.id "; + $from = ' LEFT JOIN civicrm_participant ON civicrm_participant.contact_id = contact_a.id '; break; case 'civicrm_event': //CRM-17121 - $from = " LEFT JOIN civicrm_event ON civicrm_participant.event_id = civicrm_event.id "; + $from = ' LEFT JOIN civicrm_event ON civicrm_participant.event_id = civicrm_event.id '; break; case 'event_type': diff --git a/CRM/Member/Form/Search.php b/CRM/Member/Form/Search.php index 1d9234f543..0ae19be96a 100644 --- a/CRM/Member/Form/Search.php +++ b/CRM/Member/Form/Search.php @@ -80,7 +80,7 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search { $this->_context ); $prefix = NULL; - if ($this->_context == 'basic') { + if ($this->_context === 'basic') { $prefix = $this->_prefix; } @@ -188,6 +188,8 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search { * done. * The processing consists of using a Selector / Controller framework for getting the * search results. + * + * @throws \CRM_Core_Exception */ public function postProcess() { if ($this->_done) { @@ -233,7 +235,7 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search { $selector->setKey($this->controller->_key); $prefix = NULL; - if ($this->_context == 'basic') { + if ($this->_context === 'basic') { $prefix = $this->_prefix; } @@ -255,6 +257,8 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search { * If this search has been forced then see if there are any get values, and if so over-ride the post values. * * Note that this means that GET over-rides POST :) & that force with no parameters can be very destructive. + * + * @throws \CRM_Core_Exception */ public function fixFormValues() { if (!$this->_force) {