Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NFC] Use strict comparison where possible #16896

Merged
merged 1 commit into from
Mar 26, 2020

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

Minor code standards cleanup

Before

Non-strict comparison used when comparing against strings

After

Strict comparison used

Technical Details

Also fixes a couple of comments & uses of Array::value

Comments

Strict comparison should always be used where possible

@civibot
Copy link

civibot bot commented Mar 25, 2020

(Standard links)

@civibot civibot bot added the master label Mar 25, 2020
@eileenmcnaughton
Copy link
Contributor Author

test this please

@@ -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') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a little ambiguous about which operator goes first (?? or ===)

Suggested change
if ($fields['_qf_Activity_next_'] ?? NULL === 'Delete') {
if (($fields['_qf_Activity_next_'] ?? NULL) === 'Delete') {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol - I was going the brackets but thought you have been removing them from lots of places where I wanted them

@@ -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';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$params['is_multi_activity'] = $params['separation'] ?? NULL === 'separate';
$params['is_multi_activity'] = ($params['separation'] ?? NULL) === 'separate';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@colemanw fixed

Also fixes a couple of comments & uses of Array::value
@colemanw
Copy link
Member

Unrelated fail.

@colemanw colemanw merged commit b86da8a into civicrm:master Mar 26, 2020
@colemanw colemanw deleted the act branch March 26, 2020 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants