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

[REF] Simplify obtuse boolean expressions #16819

Merged
merged 1 commit into from
Mar 17, 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/ACL/BAO/ACL.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ public static function check($str, $contactID) {
$params = [1 => [$str, 'String']];

$count = CRM_Core_DAO::singleValueQuery($query, $params);
return ($count) ? TRUE : FALSE;
return (bool) $count;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Civi/Test/GenericAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function assertAttributesEquals($expectedValues, $actualValues, $message
* @param array $list
*/
public function assertArrayKeyExists($key, &$list) {
$result = isset($list[$key]) ? TRUE : FALSE;
$result = isset($list[$key]);
$this->assertTrue($result, sprintf("%s element exists?", $key));
}

Expand Down
7 changes: 1 addition & 6 deletions api/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,7 @@ function _civicrm_api3_api_getfields(&$apiRequest) {
* true if error, false otherwise
*/
function civicrm_error($result) {
if (is_array($result)) {
return (array_key_exists('is_error', $result) &&
$result['is_error']
) ? TRUE : FALSE;
}
return FALSE;
return is_array($result) && !empty($result['is_error']);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions api/v3/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,8 @@ function civicrm_api3_contact_delete($params) {
if ($contactID == $session->get('userID')) {
return civicrm_api3_create_error('This contact record is linked to the currently logged in user account - and cannot be deleted.');
}
$restore = !empty($params['restore']) ? $params['restore'] : FALSE;
$skipUndelete = !empty($params['skip_undelete']) ? $params['skip_undelete'] : FALSE;
$restore = !empty($params['restore']);
$skipUndelete = !empty($params['skip_undelete']);

// CRM-12929
// restrict permanent delete if a contact has financial trxn associated with it
Expand Down
4 changes: 2 additions & 2 deletions api/v3/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* @throws API_Exception
*/
function civicrm_api3_profile_get($params) {
$nonStandardLegacyBehaviour = is_numeric($params['profile_id']) ? TRUE : FALSE;
$nonStandardLegacyBehaviour = is_numeric($params['profile_id']);
if (!empty($params['check_permissions']) && !empty($params['contact_id']) && !1 === civicrm_api3('contact', 'getcount', ['contact_id' => $params['contact_id'], 'check_permissions' => 1])) {
throw new API_Exception('permission denied');
}
Expand Down Expand Up @@ -296,7 +296,7 @@ function _civicrm_api3_profile_submit_spec(&$params, $apirequest) {
//@todo get_options should take an array - @ the moment it is only takes 'all' - which is supported
// by other getfields fn
// we don't resolve state, country & county for performance reasons
$resolveOptions = CRM_Utils_Array::value('get_options', $apirequest['params']) == 'all' ? TRUE : FALSE;
$resolveOptions = ($apirequest['params']['get_options'] ?? NULL) == 'all';
$profileID = _civicrm_api3_profile_getProfileID($apirequest['params']['profile_id']);
$params = _civicrm_api3_buildprofile_submitfields($profileID, $resolveOptions, CRM_Utils_Array::value('cache_clear', $params));
}
Expand Down
2 changes: 1 addition & 1 deletion install/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ public function checkdatabase($databaseConfig, $dbName) {
)
);
}
$onlyRequire = ($dbName == 'Drupal' || $dbName == 'Backdrop') ? TRUE : FALSE;
$onlyRequire = $dbName == 'Drupal' || $dbName == 'Backdrop';
$this->requireDatabaseOrCreatePermissions(
$databaseConfig['server'],
$databaseConfig['username'],
Expand Down