Skip to content

Commit

Permalink
[NFC] Use strict comparison where possible
Browse files Browse the repository at this point in the history
Also fixes a couple of comments & uses of Array::value
  • Loading branch information
eileenmcnaughton committed Mar 25, 2020
1 parent afbf782 commit 6c96ff0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 22 deletions.
49 changes: 28 additions & 21 deletions CRM/Activity/Form/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public function preProcess() {
// if we're not adding new one, there must be an id to
// an activity we're trying to work on.
if ($this->_action != CRM_Core_Action::ADD &&
get_class($this->controller) != 'CRM_Contact_Controller_Search'
get_class($this->controller) !== 'CRM_Contact_Controller_Search'
) {
$this->_activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
}
Expand Down Expand Up @@ -315,7 +315,7 @@ public function preProcess() {
// Check the mode when this form is called either single or as
// search task action.
if ($this->_activityTypeId ||
$this->_context == 'standalone' ||
$this->_context === 'standalone' ||
$this->_currentlyViewedContactId
) {
$this->_single = TRUE;
Expand Down Expand Up @@ -386,7 +386,7 @@ public function preProcess() {
$qfKey = NULL;
}

if ($this->_context == 'fulltext') {
if ($this->_context === 'fulltext') {
$keyName = '&qfKey';
$urlParams = 'force=1';
$urlString = 'civicrm/contact/search/custom';
Expand All @@ -410,21 +410,21 @@ public function preProcess() {
$urlParams = 'reset=1';
$urlString = 'civicrm/dashboard';
}
elseif ($this->_context == 'search') {
elseif ($this->_context === 'search') {
$urlParams = 'force=1';
if ($qfKey) {
$urlParams .= "&qfKey=$qfKey";
}
$path = CRM_Utils_System::currentPath();
if ($this->_compContext == 'advanced') {
if ($this->_compContext === 'advanced') {
$urlString = 'civicrm/contact/search/advanced';
}
elseif ($path == 'civicrm/group/search'
|| $path == 'civicrm/contact/search'
|| $path == 'civicrm/contact/search/advanced'
|| $path == 'civicrm/contact/search/custom'
|| $path == 'civicrm/group/search'
|| $path == 'civicrm/contact/search/builder'
elseif ($path === 'civicrm/group/search'
|| $path === 'civicrm/contact/search'
|| $path === 'civicrm/contact/search/advanced'
|| $path === 'civicrm/contact/search/custom'
|| $path === 'civicrm/group/search'
|| $path === 'civicrm/contact/search/builder'
) {
$urlString = $path;
}
Expand All @@ -433,7 +433,7 @@ public function preProcess() {
}
$this->assign('searchKey', $qfKey);
}
elseif ($this->_context != 'caseActivity') {
elseif ($this->_context !== 'caseActivity') {
$urlParams = "action=browse&reset=1&cid={$this->_currentlyViewedContactId}&selectedChild=activity";
$urlString = 'civicrm/contact/view';
}
Expand Down Expand Up @@ -530,7 +530,7 @@ public function setDefaultValues() {
// if we're editing...
if (isset($this->_activityId)) {

if ($this->_context != 'standalone') {
if ($this->_context !== 'standalone') {
$this->assign('target_contact_value',
CRM_Utils_Array::value('target_contact_value', $defaults)
);
Expand Down Expand Up @@ -652,10 +652,10 @@ public function buildQuickForm() {
$attribute = $values['attributes'] ?? NULL;
$required = !empty($values['required']);

if ($values['type'] == 'select' && empty($attribute)) {
if ($values['type'] === 'select' && empty($attribute)) {
$this->addSelect($field, ['entity' => 'activity'], $required);
}
elseif ($values['type'] == 'entityRef') {
elseif ($values['type'] === 'entityRef') {
$this->addEntityRef($field, $values['label'], $attribute, $required);
}
else {
Expand Down Expand Up @@ -731,7 +731,7 @@ public function buildQuickForm() {
$this->add('datepicker', 'followup_date', ts('in'));

// Only admins and case-workers can change the activity source
if (!CRM_Core_Permission::check('administer CiviCRM') && $this->_context != 'caseActivity') {
if (!CRM_Core_Permission::check('administer CiviCRM') && $this->_context !== 'caseActivity') {
$this->getElement('source_contact_id')->freeze();
}

Expand Down Expand Up @@ -823,7 +823,7 @@ public function buildQuickForm() {
*/
public static function formRule($fields, $files, $self) {
// skip form rule if deleting
if (CRM_Utils_Array::value('_qf_Activity_next_', $fields) == 'Delete') {
if ($fields['_qf_Activity_next_'] ?? NULL === 'Delete') {
return TRUE;
}
$errors = [];
Expand Down Expand Up @@ -958,7 +958,7 @@ public function postProcess($params = NULL) {
$this->_activityId
);

$params['is_multi_activity'] = CRM_Utils_Array::value('separation', $params) == 'separate';
$params['is_multi_activity'] = $params['separation'] ?? NULL === 'separate';

$activity = [];
if (!empty($params['is_multi_activity']) &&
Expand All @@ -977,7 +977,7 @@ public function postProcess($params = NULL) {
}

// Redirect to contact page or activity view in standalone mode
if ($this->_context == 'standalone') {
if ($this->_context === 'standalone') {
if (count($params['target_contact_id']) == 1) {
$url = CRM_Utils_System::url('civicrm/contact/view', ['cid' => CRM_Utils_Array::first($params['target_contact_id']), 'selectedChild' => 'activity']);
}
Expand Down Expand Up @@ -1038,6 +1038,7 @@ public function postProcess($params = NULL) {
* Associated array of submitted values.
*
* @return self|null|object
* @throws \CRM_Core_Exception
*/
protected function processActivity(&$params) {
$activityAssigned = [];
Expand Down Expand Up @@ -1161,8 +1162,11 @@ protected function processActivity(&$params) {

/**
* Shorthand for getting id by display name (makes code more readable)
* @param $displayName
*
* @param string $displayName
*
* @return null|string
* @throws \CRM_Core_Exception
*/
protected function _getIdByDisplayName($displayName) {
return CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact',
Expand All @@ -1174,8 +1178,11 @@ protected function _getIdByDisplayName($displayName) {

/**
* Shorthand for getting display name by id (makes code more readable)
* @param $id
*
* @param int $id
*
* @return null|string
* @throws \CRM_Core_Exception
*/
protected function _getDisplayNameById($id) {
return CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact',
Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/BAO/CustomGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -1894,7 +1894,7 @@ public static function formatGroupTree(&$groupTree, $groupCount = 1, &$form = NU
* @param int $entityId
*
* @return array|int
* @throws \Exception
* @throws \CRM_Core_Exception
*/
public static function buildCustomDataView(&$form, &$groupTree, $returnCount = FALSE, $gID = NULL, $prefix = NULL, $customValueId = NULL, $entityId = NULL) {
$details = [];
Expand Down

0 comments on commit 6c96ff0

Please sign in to comment.