Code Inspection: Ternary expression can be replaced with condition (#728)

This commit is contained in:
Roman Kelesidis 2023-05-29 00:32:36 +07:00 committed by GitHub
commit de076c80ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 29 additions and 29 deletions

View file

@ -302,7 +302,7 @@ if ($view === 'username') {
// Attachments
if ($view === 'attachments') {
$user_based = $uid ? true : false;
$user_based = (bool)$uid;
$search_based = (isset($_POST['search']) && $_POST['search']);
$hidden_fields = '';

View file

@ -33,10 +33,10 @@ $size = request_var('size', '');
$quota_size = request_var('quota_size', '');
$pm_size = request_var('pm_size', '');
$submit = isset($_POST['submit']) ? true : false;
$check_upload = isset($_POST['settings']) ? true : false;
$check_image_cat = isset($_POST['cat_settings']) ? true : false;
$search_imagick = isset($_POST['search_imagick']) ? true : false;
$submit = isset($_POST['submit']);
$check_upload = isset($_POST['settings']);
$check_image_cat = isset($_POST['cat_settings']);
$search_imagick = isset($_POST['search_imagick']);
// Re-evaluate the Attachment Configuration
$sql = 'SELECT * FROM ' . BB_ATTACH_CONFIG;
@ -423,7 +423,7 @@ if ($submit && $mode == 'quota') {
$quota_desc = get_var('quota_description', '');
$filesize = get_var('add_max_filesize', 0);
$size_select = get_var('add_size_select', '');
$add = isset($_POST['add_quota_check']) ? true : false;
$add = isset($_POST['add_quota_check']);
if ($quota_desc != '' && $add) {
// check Quota Description

View file

@ -124,8 +124,8 @@ switch ($mode) {
'SITENAME' => htmlCHR($new['sitename']),
'CONFIG_SITE_DESCRIPTION' => htmlCHR($new['site_desc']),
'DISABLE_BOARD' => $new['board_disable'] ? true : false,
'ALLOW_AUTOLOGIN' => $new['allow_autologin'] ? true : false,
'DISABLE_BOARD' => (bool)$new['board_disable'],
'ALLOW_AUTOLOGIN' => (bool)$new['allow_autologin'],
'AUTOLOGIN_TIME' => (int)$new['max_autologin_time'],
'MAX_POLL_OPTIONS' => $new['max_poll_options'],
'FLOOD_INTERVAL' => $new['flood_interval'],
@ -137,12 +137,12 @@ switch ($mode) {
'TIMEZONE_SELECT' => \TorrentPier\Legacy\Select::timezone($new['board_timezone'], 'board_timezone'),
'MAX_LOGIN_ATTEMPTS' => $new['max_login_attempts'],
'LOGIN_RESET_TIME' => $new['login_reset_time'],
'PRUNE_ENABLE' => $new['prune_enable'] ? true : false,
'ALLOW_BBCODE' => $new['allow_bbcode'] ? true : false,
'ALLOW_SMILIES' => $new['allow_smilies'] ? true : false,
'ALLOW_SIG' => $new['allow_sig'] ? true : false,
'PRUNE_ENABLE' => (bool)$new['prune_enable'],
'ALLOW_BBCODE' => (bool)$new['allow_bbcode'],
'ALLOW_SMILIES' => (bool)$new['allow_smilies'],
'ALLOW_SIG' => (bool)$new['allow_sig'],
'SIG_SIZE' => $new['max_sig_chars'],
'ALLOW_NAMECHANGE' => $new['allow_namechange'] ? true : false,
'ALLOW_NAMECHANGE' => (bool)$new['allow_namechange'],
'SMILIES_PATH' => $new['smilies_path'],
));
break;

View file

@ -43,9 +43,9 @@ $mode = get_var('mode', '');
$e_mode = get_var('e_mode', '');
$error = false;
$add_forum = isset($_POST['add_forum']) ? true : false;
$delete_forum = isset($_POST['del_forum']) ? true : false;
$submit = isset($_POST['submit']) ? true : false;
$add_forum = isset($_POST['add_forum']);
$delete_forum = isset($_POST['del_forum']);
$submit = isset($_POST['submit']);
// Get Attachment Config
$attach_config = array();
@ -120,7 +120,7 @@ if ($submit && $mode == 'extensions') {
$extension = get_var('add_extension', '');
$extension_explain = get_var('add_extension_explain', '');
$extension_group = get_var('add_group_select', 0);
$add = isset($_POST['add_extension_check']) ? true : false;
$add = isset($_POST['add_extension_check']);
if ($extension != '' && $add) {
$template->assign_vars(array(
@ -301,7 +301,7 @@ if ($submit && $mode == 'groups') {
$size_select = get_var('add_size_select', '');
$is_allowed = isset($_POST['add_allowed']) ? 1 : 0;
$add = isset($_POST['add_extension_group_check']) ? true : false;
$add = isset($_POST['add_extension_group_check']);
if ($extension_group != '' && $add) {
// check Extension Group

View file

@ -65,7 +65,7 @@ if (!empty($_POST['edit']) || !empty($_POST['new'])) {
'S_GROUP_OPEN_CHECKED' => ($group_info['group_type'] == GROUP_OPEN) ? HTML_CHECKED : '',
'S_GROUP_CLOSED_CHECKED' => ($group_info['group_type'] == GROUP_CLOSED) ? HTML_CHECKED : '',
'S_GROUP_HIDDEN_CHECKED' => ($group_info['group_type'] == GROUP_HIDDEN) ? HTML_CHECKED : '',
'RELEASE_GROUP' => $group_info['release_group'] ? true : false,
'RELEASE_GROUP' => (bool)$group_info['release_group'],
'S_GROUP_ACTION' => 'admin_groups.php',
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));

View file

@ -59,8 +59,8 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
} elseif (isset($_GET['pane']) && $_GET['pane'] == 'right') {
$template->assign_vars(array(
'TPL_ADMIN_MAIN' => true,
'ADMIN_LOCK' => $bb_cfg['board_disable'] ? true : false,
'ADMIN_LOCK_CRON' => file_exists(BB_DISABLED) ? true : false,
'ADMIN_LOCK' => (bool)$bb_cfg['board_disable'],
'ADMIN_LOCK_CRON' => file_exists(BB_DISABLED),
));
// Get forum statistics

View file

@ -380,7 +380,7 @@ if (!$group_id) {
'U_GROUP_RELEASES' => "group.php?view=releases&" . POST_GROUPS_URL . "=$group_id",
'U_GROUP_MEMBERS' => "group.php?view=members&" . POST_GROUPS_URL . "=$group_id",
'U_GROUP_CONFIG' => "group_edit.php?g=$group_id",
'RELEASE_GROUP' => ($group_info['release_group']) ? true : false,
'RELEASE_GROUP' => (bool)$group_info['release_group'],
'GROUP_TYPE' => $group_type,
'S_GROUP_OPEN_TYPE' => GROUP_OPEN,

View file

@ -66,7 +66,7 @@ if ($is_moderator) {
'GROUP_DESCRIPTION' => htmlCHR($group_info['group_description']),
'GROUP_SIGNATURE' => htmlCHR($group_info['group_signature']),
'U_GROUP_URL' => GROUP_URL . $group_id,
'RELEASE_GROUP' => $group_info['release_group'] ? true : false,
'RELEASE_GROUP' => (bool)$group_info['release_group'],
'GROUP_TYPE' => $group_type,
'S_GROUP_OPEN_TYPE' => GROUP_OPEN,
'S_GROUP_CLOSED_TYPE' => GROUP_CLOSED,

View file

@ -46,7 +46,7 @@ function attachment_quota_settings($admin_mode, $mode, $submit = false)
if ($admin_mode == 'user') {
// We overwrite submit here... to be sure
$submit = (isset($_POST['submit'])) ? true : false;
$submit = isset($_POST['submit']);
if (!$submit && $mode != 'save') {
$user_id = get_var(POST_USERS_URL, 0);

View file

@ -79,7 +79,7 @@ function get_supported_image_types($type)
}
return array(
'gd' => ($new_type) ? true : false,
'gd' => (bool)$new_type,
'format' => $new_type,
'version' => (function_exists('imagecreatetruecolor')) ? 2 : 1
);

View file

@ -555,7 +555,7 @@ switch ($mode) {
'POSTER_NAME' => wbr($poster),
'POST_DATE' => $post_date,
'MESSAGE' => $message,
'CHECKBOX' => (defined('BEGIN_CHECKBOX')) ? true : false,
'CHECKBOX' => defined('BEGIN_CHECKBOX'),
'POST_ID' => $post_id,
'ROW_ID' => $i,
'CB_ID' => 'cb_' . $i,

View file

@ -170,7 +170,7 @@ if ($post_info = DB()->fetch_row($sql)) {
$post_data['poster_id'] = $post_info['poster_id'];
$selected_rg = $post_info['poster_rg_id'];
$switch_rg_sig = ($post_info['attach_rg_sig']) ? true : false;
$switch_rg_sig = (bool)$post_info['attach_rg_sig'];
// Can this user edit/delete the post?
if ($post_info['poster_id'] != $userdata['user_id'] && !$is_auth['auth_mod']) {

View file

@ -71,8 +71,8 @@ class AttachPosting extends Attach
global $mode, $confirm, $is_auth, $post_id, $delete, $refresh;
if (!$refresh) {
$add_attachment_box = (!empty($_POST['add_attachment_box'])) ? true : false;
$posted_attachments_box = (!empty($_POST['posted_attachments_box'])) ? true : false;
$add_attachment_box = !empty($_POST['add_attachment_box']);
$posted_attachments_box = !empty($_POST['posted_attachments_box']);
$refresh = $add_attachment_box || $posted_attachments_box;
}