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

Cleanup reverse boolean expressions #16850

Merged
merged 1 commit into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CRM/Admin/Page/AJAX.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public static function getTagTree() {
}
}
else {
$hasChildTags = empty($childTagIDs[$dao->id]) ? FALSE : TRUE;
$hasChildTags = !empty($childTagIDs[$dao->id]);
$usedFor = (array) explode(',', $dao->used_for);
$tag = [
'id' => $dao->id,
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contact/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -5847,7 +5847,7 @@ public function filterRelatedContacts(&$from, &$where, &$having) {
* @return bool
*/
public static function caseImportant($op) {
return in_array($op, ['LIKE', 'IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY']) ? FALSE : TRUE;
return !in_array($op, ['LIKE', 'IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY']);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contact/Form/Edit/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public static function setDefaultValues(&$defaults, &$form) {
}
}
$form->assign('showHideAddressFields', $parsedAddress);
$form->assign('loadShowHideAddressFields', empty($parsedAddress) ? FALSE : TRUE);
$form->assign('loadShowHideAddressFields', !empty($parsedAddress));
}
// end of parse address functionality
}
Expand Down
4 changes: 2 additions & 2 deletions CRM/Contribute/Form/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ public function buildQuickForm() {
$paymentInstrument = FALSE;
if (!$this->_mode) {
// payment_instrument isn't required in edit and will not be present when payment block is enabled.
$required = $this->_id ? FALSE : TRUE;
$required = !$this->_id;
$checkPaymentID = array_search('Check', CRM_Contribute_PseudoConstant::paymentInstrument('name'));
$paymentInstrument = $this->add('select', 'payment_instrument_id',
ts('Payment Method'),
Expand Down Expand Up @@ -776,7 +776,7 @@ public function buildQuickForm() {

$totalAmount = $this->addMoney('total_amount',
ts('Total Amount'),
($hasPriceSets) ? FALSE : TRUE,
!$hasPriceSets,
$attributes['total_amount'],
TRUE, 'currency', NULL, $currencyFreeze
);
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contribute/Form/Contribution/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ public static function processFormContribution(
$contactID = $contributionParams['contact_id'];

$isEmailReceipt = !empty($form->_values['is_email_receipt']);
$isSeparateMembershipPayment = empty($params['separate_membership_payment']) ? FALSE : TRUE;
$isSeparateMembershipPayment = !empty($params['separate_membership_payment']);
$pledgeID = !empty($params['pledge_id']) ? $params['pledge_id'] : CRM_Utils_Array::value('pledge_id', $form->_values);
if (!$isSeparateMembershipPayment && !empty($form->_values['pledge_block_id']) &&
(!empty($params['is_pledge']) || $pledgeID)) {
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contribute/Form/ContributionCharts.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public function postProcess() {
// finally assign this chart data to template.
$this->assign('hasYearlyChart', $yearlyChart);
$this->assign('hasByMonthChart', $monthlyChart);
$this->assign('hasChart', empty($chartData) ? FALSE : TRUE);
$this->assign('hasChart', !empty($chartData));
$this->assign('chartData', json_encode($chartData ?? []));
}

Expand Down
4 changes: 2 additions & 2 deletions CRM/Core/BAO/UFGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ public static function getEditHTML(
$controller->setEmbedded(TRUE);

//CRM-5839 - though we want to process form, get the control back.
$controller->setSkipRedirection(($doNotProcess) ? FALSE : TRUE);
$controller->setSkipRedirection(!$doNotProcess);

$controller->run();

Expand Down Expand Up @@ -907,7 +907,7 @@ public static function getEditHTML(
$controller->setEmbedded(TRUE);

//CRM-5846 - give the control back to drupal.
$controller->setSkipRedirection(($doNotProcess) ? FALSE : TRUE);
$controller->setSkipRedirection(!$doNotProcess);
$controller->run();

$template = CRM_Core_Smarty::singleton();
Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/PseudoConstant.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public static function get($daoName, $fieldName, $params = [], $context = NULL)
$params += [
'grouping' => FALSE,
'localize' => $localizeDefault,
'onlyActive' => ($context == 'validate' || $context == 'get') ? FALSE : TRUE,
'onlyActive' => !($context == 'validate' || $context == 'get'),
'fresh' => FALSE,
'context' => $context,
];
Expand Down
5 changes: 2 additions & 3 deletions CRM/Core/Selector/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ public function run() {
// Merge headers not containing weight to ordered headers
$finalColumnHeaders = array_merge($reorderedHeaders, $noWeightHeaders);

$rowsEmpty = count($rows) ? FALSE : TRUE;
$qill = $this->getQill();
$summary = $this->getSummary();
// if we need to store in session, lets update session
Expand All @@ -353,7 +352,7 @@ public function run() {
}
$this->_store->set("{$this->_prefix}rows", $rows);
$this->_store->set("{$this->_prefix}rowCount", $this->_total);
$this->_store->set("{$this->_prefix}rowsEmpty", $rowsEmpty);
$this->_store->set("{$this->_prefix}rowsEmpty", !$rows);
$this->_store->set("{$this->_prefix}qill", $qill);
$this->_store->set("{$this->_prefix}summary", $summary);
}
Expand All @@ -363,7 +362,7 @@ public function run() {

self::$_template->assign_by_ref("{$this->_prefix}columnHeaders", $finalColumnHeaders);
self::$_template->assign_by_ref("{$this->_prefix}rows", $rows);
self::$_template->assign("{$this->_prefix}rowsEmpty", $rowsEmpty);
self::$_template->assign("{$this->_prefix}rowsEmpty", !$rows);
self::$_template->assign("{$this->_prefix}qill", $qill);
self::$_template->assign("{$this->_prefix}summary", $summary);
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Dedupe/BAO/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public static function validateContacts($cid, $oid) {
$exception->contact_id2 = $cid;
}

return $exception->find(TRUE) ? FALSE : TRUE;
return !$exception->find(TRUE);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion CRM/Group/Form/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public function buildQuickForm() {

$doParentCheck = FALSE;
if (CRM_Core_Permission::isMultisiteEnabled()) {
$doParentCheck = ($this->_id && CRM_Core_BAO_Domain::isDomainGroup($this->_id)) ? FALSE : TRUE;
$doParentCheck = !($this->_id && CRM_Core_BAO_Domain::isDomainGroup($this->_id));
}

$options = array(
Expand Down
3 changes: 1 addition & 2 deletions CRM/Report/Form/Grant/Statistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,8 @@ public function alterDisplay(&$rows) {
$customGroupTitle = $this->_columns[$customGroupTitle[0]]['group_title'];
$grantStatistics[$customGroupTitle]['title'] = ts('By %1', [1 => $customGroupTitle]);

$customData = ($customValue) ? FALSE : TRUE;
self::getStatistics($grantStatistics[$customGroupTitle], $customFieldTitle, $values,
$awardedGrants, $awardedGrantsAmount, $customData
$awardedGrants, $awardedGrantsAmount, !$customValue
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/UF/Page/ProfileEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public static function convertCiviModelToBackboneModel($extends, $title, $availa
$sectionName = 'cg_' . $customGroup->id;
$section = [
'title' => ts('%1: %2', [1 => $title, 2 => $customGroup->title]),
'is_addable' => $customGroup->is_reserved ? FALSE : TRUE,
'is_addable' => !$customGroup->is_reserved,
'custom_group_id' => $customGroup->id,
'extends_entity_column_id' => $customGroup->extends_entity_column_id,
'extends_entity_column_value' => CRM_Utils_Array::explodePadded($customGroup->extends_entity_column_value),
Expand Down
2 changes: 1 addition & 1 deletion CRM/Utils/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ public static function overdue($date, $now = NULL) {
$now = self::isoToMysql($now);
}

return (strtotime($mysqlDate) >= strtotime($now)) ? FALSE : TRUE;
return !(strtotime($mysqlDate) >= strtotime($now));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion CRM/Utils/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ public static function getIconFromMimeType($mimeType) {
*/
public static function isValidFileName($fileName = NULL) {
if ($fileName) {
$check = $fileName !== basename($fileName) ? FALSE : TRUE;
$check = ($fileName === basename($fileName));
if ($check) {
if (substr($fileName, 0, 1) == '/' || substr($fileName, 0, 1) == '.' || substr($fileName, 0, 1) == DIRECTORY_SEPARATOR) {
$check = FALSE;
Expand Down
8 changes: 2 additions & 6 deletions CRM/Utils/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ public static function integer($value) {
*/
public static function positiveInteger($value) {
if (is_int($value)) {
return ($value < 0) ? FALSE : TRUE;
return !($value < 0);
}

// CRM-13460
Expand All @@ -458,11 +458,7 @@ public static function positiveInteger($value) {
return FALSE;
}

if (preg_match('/^\d+$/', $value)) {
return TRUE;
}

return FALSE;
return (bool) preg_match('/^\d+$/', $value);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion CRM/Utils/System/Joomla.php
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ public function loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE
*/
public function isUserLoggedIn() {
$user = JFactory::getUser();
return ($user->guest) ? FALSE : TRUE;
return !$user->guest;
}

/**
Expand Down