Remove useless elseif with if

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
Maurício Meneghini Fauth 2020-05-26 22:53:44 -03:00
parent 82c2964bb8
commit bd979dd1ff
27 changed files with 194 additions and 69 deletions

View File

@ -53,9 +53,13 @@ final class CacheWarmupCommand extends Command
$output->writeln('Please specify --twig or --routing');
return 1;
} elseif ($input->getOption('twig') === true) {
}
if ($input->getOption('twig') === true) {
return $this->warmUpTwigCache($output);
} elseif ($input->getOption('routing') === true) {
}
if ($input->getOption('routing') === true) {
return $this->warmUpRoutingCache($output);
}

View File

@ -54,7 +54,9 @@ class CentralColumnsController extends AbstractController
]);
return;
} elseif (isset($_POST['add_new_column'])) {
}
if (isset($_POST['add_new_column'])) {
$tmp_msg = $this->addNewColumn([
'col_name' => $_POST['col_name'] ?? null,
'col_default' => $_POST['col_default'] ?? null,

View File

@ -82,7 +82,9 @@ class ManageController extends AbstractController
echo json_encode($settings['config_data'], JSON_PRETTY_PRINT);
return;
} elseif (isset($_POST['submit_export'], $_POST['export_type']) && $_POST['export_type'] == 'php_file') {
}
if (isset($_POST['submit_export'], $_POST['export_type']) && $_POST['export_type'] == 'php_file') {
// export to JSON file
$this->response->disable();
$filename = 'phpMyAdmin-config-' . urlencode(Core::getenv('HTTP_HOST')) . '.php';
@ -96,13 +98,17 @@ class ManageController extends AbstractController
}
return;
} elseif (isset($_POST['submit_get_json'])) {
}
if (isset($_POST['submit_get_json'])) {
$settings = $this->userPreferences->load();
$this->response->addJSON('prefs', json_encode($settings['config_data']));
$this->response->addJSON('mtime', $settings['mtime']);
return;
} elseif (isset($_POST['submit_import'])) {
}
if (isset($_POST['submit_import'])) {
// load from JSON file
$json = '';
if (isset($_POST['import_type'], $_FILES['import_file'])

View File

@ -381,7 +381,9 @@ class OperationsController extends AbstractController
if ($name == 'PRIMARY') {
$hideOrderTable = true;
break;
} elseif (! $idx->getNonUnique()) {
}
if (! $idx->getNonUnique()) {
$notNull = true;
foreach ($idx->getColumns() as $column) {
if ($column->getNull()) {

View File

@ -401,19 +401,25 @@ final class ReplaceController extends AbstractController
$controller->index();
return;
} elseif ($goto_include === '/database/sql') {
}
if ($goto_include === '/database/sql') {
/** @var DatabaseSqlController $controller */
$controller = $containerBuilder->get(DatabaseSqlController::class);
$controller->index();
return;
} elseif ($goto_include === '/table/change') {
}
if ($goto_include === '/table/change') {
/** @var ChangeController $controller */
$controller = $containerBuilder->get(ChangeController::class);
$controller->index();
return;
} elseif ($goto_include === '/table/sql') {
}
if ($goto_include === '/table/sql') {
/** @var TableSqlController $controller */
$controller = $containerBuilder->get(TableSqlController::class);
$controller->index();
@ -604,19 +610,25 @@ final class ReplaceController extends AbstractController
$controller->index();
return;
} elseif ($goto_include === '/database/sql') {
}
if ($goto_include === '/database/sql') {
/** @var DatabaseSqlController $controller */
$controller = $containerBuilder->get(DatabaseSqlController::class);
$controller->index();
return;
} elseif ($goto_include === '/table/change') {
}
if ($goto_include === '/table/change') {
/** @var ChangeController $controller */
$controller = $containerBuilder->get(ChangeController::class);
$controller->index();
return;
} elseif ($goto_include === '/table/sql') {
}
if ($goto_include === '/table/sql') {
/** @var TableSqlController $controller */
$controller = $containerBuilder->get(TableSqlController::class);
$controller->index();

View File

@ -1800,7 +1800,9 @@ class Qbe
$candidate_columns,
$needsort,
];
} elseif (isset($index_columns) && count($index_columns) > 0) {
}
if (isset($index_columns) && count($index_columns) > 0) {
$candidate_columns = $index_columns;
$needsort = 1;
@ -1808,7 +1810,9 @@ class Qbe
$candidate_columns,
$needsort,
];
} elseif (isset($where_clause_columns) && count($where_clause_columns) > 0) {
}
if (isset($where_clause_columns) && count($where_clause_columns) > 0) {
$candidate_columns = $where_clause_columns;
$needsort = 0;

View File

@ -1202,7 +1202,9 @@ class DatabaseInterface implements DbalInterface
}
return $columns;
} elseif ($table === null) {
}
if ($table === null) {
$tables = $this->getTables($database);
foreach ($tables as $table) {
$columns[$table] = $this->getColumnsFull(
@ -2662,7 +2664,9 @@ class DatabaseInterface implements DbalInterface
);
return false;
} elseif ($mode == self::CONNECT_AUXILIARY) {
}
if ($mode == self::CONNECT_AUXILIARY) {
// Do not go back to main login if connection failed
// (currently used only in unit testing)
return false;

View File

@ -100,7 +100,9 @@ class ErrorHandler
);
$_SESSION['errors'][$error->getHash()] = $error;
break;
} elseif (($error instanceof Error)
}
if (($error instanceof Error)
&& ! $error->isDisplayed()
) {
$_SESSION['errors'][$key] = $error;

View File

@ -461,7 +461,9 @@ class File
$this->_error_message = null;
return true;
} elseif ($this->setSelectedFromTblChangeRequest($key, $rownumber)) {
}
if ($this->setSelectedFromTblChangeRequest($key, $rownumber)) {
// well done ...
$this->_error_message = null;

View File

@ -542,9 +542,13 @@ class GisVisualization
{
if ($format == 'svg') {
return $this->asSVG();
} elseif ($format == 'png') {
}
if ($format == 'png') {
return $this->asPng();
} elseif ($format == 'ol') {
}
if ($format == 'ol') {
return $this->asOl();
}

View File

@ -107,7 +107,9 @@ class Git
$_SESSION['is_git_revision'] = false;
return false;
} elseif (@is_dir($gitmatch[1])) {
}
if (@is_dir($gitmatch[1])) {
//Detected git external folder location
$git_location = $gitmatch[1];
} else {

View File

@ -88,11 +88,15 @@ class Import
global $timestamp, $maximum_time, $timeout_passed;
if ($maximum_time == 0) {
return false;
} elseif ($timeout_passed) {
}
if ($timeout_passed) {
return true;
/* 5 in next row might be too much */
} elseif (time() - $timestamp > $maximum_time - 5) {
}
if (time() - $timestamp > $maximum_time - 5) {
$timeout_passed = true;
return true;
@ -465,7 +469,9 @@ class Import
return substr($contents, 3);
// UTF-16 BE, LE
} elseif (strncmp($contents, "\xFE\xFF", 2) === 0
}
if (strncmp($contents, "\xFE\xFF", 2) === 0
|| strncmp($contents, "\xFF\xFE", 2) === 0
) {
return substr($contents, 2);
@ -667,7 +673,9 @@ class Import
*/
if (! strcmp('NULL', $cell)) {
return $last_cumulative_size;
} elseif ($curr_type == self::VARCHAR) {
}
if ($curr_type == self::VARCHAR) {
/**
* What to do if the current cell is of type VARCHAR
*/
@ -680,7 +688,9 @@ class Import
}
return $last_cumulative_size;
} elseif ($last_cumulative_type == self::DECIMAL) {
}
if ($last_cumulative_type == self::DECIMAL) {
/**
* The last cumulative type was DECIMAL
*/
@ -691,7 +701,9 @@ class Import
}
return $oldM;
} elseif ($last_cumulative_type == self::BIGINT || $last_cumulative_type == self::INT) {
}
if ($last_cumulative_type == self::BIGINT || $last_cumulative_type == self::INT) {
/**
* The last cumulative type was BIGINT or INT
*/
@ -700,7 +712,9 @@ class Import
}
return $last_cumulative_size;
} elseif (! isset($last_cumulative_type) || $last_cumulative_type == self::NONE) {
}
if (! isset($last_cumulative_type) || $last_cumulative_type == self::NONE) {
/**
* This is the first row to be analyzed
*/
@ -715,7 +729,9 @@ class Import
*/
return -1;
} elseif ($curr_type == self::DECIMAL) {
}
if ($curr_type == self::DECIMAL) {
/**
* What to do if the current cell is of type DECIMAL
*/
@ -731,7 +747,9 @@ class Import
}
return $last_cumulative_size;
} elseif ($last_cumulative_type == self::DECIMAL) {
}
if ($last_cumulative_type == self::DECIMAL) {
/**
* The last cumulative type was DECIMAL
*/
@ -748,7 +766,9 @@ class Import
}
return $last_cumulative_size;
} elseif ($last_cumulative_type == self::BIGINT || $last_cumulative_type == self::INT) {
}
if ($last_cumulative_type == self::BIGINT || $last_cumulative_type == self::INT) {
/**
* The last cumulative type was BIGINT or INT
*/
@ -760,7 +780,9 @@ class Import
}
return $last_cumulative_size . ',' . $size[self::D];
} elseif (! isset($last_cumulative_type) || $last_cumulative_type == self::NONE) {
}
if (! isset($last_cumulative_type) || $last_cumulative_type == self::NONE) {
/**
* This is the first row to be analyzed
*/
@ -778,7 +800,9 @@ class Import
*/
return -1;
} elseif ($curr_type == self::BIGINT || $curr_type == self::INT) {
}
if ($curr_type == self::BIGINT || $curr_type == self::INT) {
/**
* What to do if the current cell is of type BIGINT or INT
*/
@ -791,7 +815,9 @@ class Import
}
return $last_cumulative_size;
} elseif ($last_cumulative_type == self::DECIMAL) {
}
if ($last_cumulative_type == self::DECIMAL) {
/**
* The last cumulative type was DECIMAL
*/
@ -808,7 +834,9 @@ class Import
/* Use $newInt + $oldD as new M */
return ($newInt + $oldD) . ',' . $oldD;
} elseif ($last_cumulative_type == self::BIGINT || $last_cumulative_type == self::INT) {
}
if ($last_cumulative_type == self::BIGINT || $last_cumulative_type == self::INT) {
/**
* The last cumulative type was BIGINT or INT
*/
@ -817,7 +845,9 @@ class Import
}
return $last_cumulative_size;
} elseif (! isset($last_cumulative_type) || $last_cumulative_type == self::NONE) {
}
if (! isset($last_cumulative_type) || $last_cumulative_type == self::NONE) {
/**
* This is the first row to be analyzed
*/

View File

@ -1581,7 +1581,9 @@ class InsertEdit
if ($files === false) {
return '<span style="color:red">' . __('Error') . '</span><br>' . "\n"
. __('The directory you set for upload work cannot be reached.') . "\n";
} elseif (! empty($files)) {
}
if (! empty($files)) {
return "<br>\n"
. '<i>' . __('Or') . '</i> '
. __('web server upload directory:') . '<br>' . "\n"
@ -2653,16 +2655,22 @@ class InsertEdit
) {
if (empty($multi_edit_funcs[$key])) {
return $current_value;
} elseif ($multi_edit_funcs[$key] === 'PHP_PASSWORD_HASH') {
}
if ($multi_edit_funcs[$key] === 'PHP_PASSWORD_HASH') {
$hash = password_hash($current_value, PASSWORD_DEFAULT);
return "'" . $hash . "'";
} elseif ($multi_edit_funcs[$key] === 'UUID') {
}
if ($multi_edit_funcs[$key] === 'UUID') {
/* This way user will know what UUID new row has */
$uuid = $this->dbi->fetchValue('SELECT UUID()');
return "'" . $uuid . "'";
} elseif ((in_array($multi_edit_funcs[$key], $gis_from_text_functions)
}
if ((in_array($multi_edit_funcs[$key], $gis_from_text_functions)
&& substr($current_value, 0, 3) == "'''")
|| in_array($multi_edit_funcs[$key], $gis_from_wkb_functions)
) {
@ -2672,7 +2680,9 @@ class InsertEdit
$current_value = str_replace("''", "'", $current_value);
return $multi_edit_funcs[$key] . '(' . $current_value . ')';
} elseif (! in_array($multi_edit_funcs[$key], $func_no_param)
}
if (! in_array($multi_edit_funcs[$key], $func_no_param)
|| ($current_value != "''"
&& in_array($multi_edit_funcs[$key], $func_optional_param))
) {

View File

@ -270,7 +270,9 @@ class Navigation
if (isset($pmaThemeImage) && @file_exists($pmaThemeImage . 'logo_left.png')) {
return $pmaThemeImage . 'logo_left.png';
} elseif (isset($pmaThemeImage) && @file_exists($pmaThemeImage . 'pma_logo2.png')) {
}
if (isset($pmaThemeImage) && @file_exists($pmaThemeImage . 'pma_logo2.png')) {
return $pmaThemeImage . 'pma_logo2.png';
}

View File

@ -789,7 +789,9 @@ class Node
if (! $GLOBALS['cfg']['NavigationTreeEnableExpansion']
) {
return '';
} elseif ($match) {
}
if ($match) {
$this->visible = true;
return Generator::getImage('b_minus');

View File

@ -187,9 +187,13 @@ abstract class AuthenticationPlugin
'Login without a password is forbidden by configuration'
. ' (see AllowNoPassword)'
);
} elseif ($failure == 'root-denied' || $failure == 'allow-denied') {
}
if ($failure == 'root-denied' || $failure == 'allow-denied') {
return __('Access denied!');
} elseif ($failure == 'no-activity') {
}
if ($failure == 'no-activity') {
return sprintf(
__('You have been automatically logged out due to inactivity of %s seconds.'
. ' Once you log in again, you should be able to resume the work where you left off.'),
@ -200,7 +204,9 @@ abstract class AuthenticationPlugin
$dbi_error = $GLOBALS['dbi']->getError();
if (! empty($dbi_error)) {
return htmlspecialchars($dbi_error);
} elseif (isset($GLOBALS['errno'])) {
}
if (isset($GLOBALS['errno'])) {
return '#' . $GLOBALS['errno'] . ' '
. __('Cannot log in to the MySQL server');
}

View File

@ -314,7 +314,9 @@ class ImportCsv extends AbstractImportCsv
// subtract data we didn't handle yet and stop processing
$GLOBALS['offset'] -= strlen($buffer);
break;
} elseif ($data !== true) {
}
if ($data !== true) {
// Append new data to buffer
$buffer .= $data;
unset($data);

View File

@ -107,7 +107,9 @@ class ImportMediawiki extends ImportPlugin
// Subtract data we didn't handle yet and stop processing
$GLOBALS['offset'] -= mb_strlen($buffer);
break;
} elseif ($data !== true) {
}
if ($data !== true) {
// Append new data to buffer
$buffer = $data;
unset($data);
@ -149,7 +151,9 @@ class ImportMediawiki extends ImportPlugin
if (! strcmp(mb_substr($cur_buffer_line, 0, 4), '<!--')) {
$inside_comment = true;
continue;
} elseif ($inside_comment) {
}
if ($inside_comment) {
// Check end of comment
if (! strcmp(mb_substr($cur_buffer_line, 0, 4), '-->')
) {

View File

@ -121,7 +121,9 @@ class ImportOds extends ImportPlugin
/* subtract data we didn't handle yet and stop processing */
$GLOBALS['offset'] -= strlen($buffer);
break;
} elseif ($data !== true) {
}
if ($data !== true) {
/* Append new data to buffer */
$buffer .= $data;
unset($data);
@ -247,7 +249,9 @@ class ImportOds extends ImportPlugin
)
) {
return (float) $cell_attrs['value'];
} elseif ($_REQUEST['ods_recognize_currency']
}
if ($_REQUEST['ods_recognize_currency']
&& ! strcmp('currency', (string) $cell_attrs['value-type'])
) {
return (float) $cell_attrs['value'];

View File

@ -78,7 +78,9 @@ class ImportXml extends ImportPlugin
/* subtract data we didn't handle yet and stop processing */
$GLOBALS['offset'] -= strlen($buffer);
break;
} elseif ($data !== true) {
}
if ($data !== true) {
/* Append new data to buffer */
$buffer .= $data;
unset($data);

View File

@ -528,7 +528,9 @@ class Privileges
return 'SELECT * FROM `mysql`.`user`'
. " WHERE `User` = '" . $this->dbi->escapeString($username) . "'"
. " AND `Host` = '" . $this->dbi->escapeString($hostname) . "';";
} elseif ($table == '*') {
}
if ($table == '*') {
return 'SELECT * FROM `mysql`.`db`'
. " WHERE `User` = '" . $this->dbi->escapeString($username) . "'"
. " AND `Host` = '" . $this->dbi->escapeString($hostname) . "'"

View File

@ -1553,13 +1553,10 @@ class Table
// only allow the above regex in unquoted identifiers
// see : https://dev.mysql.com/doc/refman/5.7/en/identifiers.html
return true;
} elseif ($is_backquoted) {
// If backquoted, all characters should be allowed (except w/ trailing spaces)
return true;
}
// If not backquoted and doesn't follow the above regex
return false;
// If backquoted, all characters should be allowed (except w/ trailing spaces).
return $is_backquoted;
}
/**

View File

@ -271,7 +271,9 @@ final class Search
// If the function takes multiple parameters
if (strpos($func_type, 'IS NULL') !== false || strpos($func_type, 'IS NOT NULL') !== false) {
return Util::backquote($names) . ' ' . $func_type;
} elseif ($geom_funcs[$geom_func]['params'] > 1) {
}
if ($geom_funcs[$geom_func]['params'] > 1) {
// create gis data from the criteria input
$gis_data = Util::createGISData($criteriaValues, $this->dbi->getVersion());

View File

@ -1602,7 +1602,9 @@ class Util
$engine = strtoupper((string) $engine);
if (($engine === 'INNODB') || ($engine === 'PBXT')) {
return true;
} elseif ($engine === 'NDBCLUSTER' || $engine === 'NDB') {
}
if ($engine === 'NDBCLUSTER' || $engine === 'NDB') {
$ndbver = strtolower(
$GLOBALS['dbi']->fetchValue('SELECT @@ndb_version_string')
);
@ -1623,7 +1625,9 @@ class Util
{
if ($GLOBALS['cfg']['DefaultForeignKeyChecks'] === 'enable') {
return true;
} elseif ($GLOBALS['cfg']['DefaultForeignKeyChecks'] === 'disable') {
}
if ($GLOBALS['cfg']['DefaultForeignKeyChecks'] === 'disable') {
return false;
}
@ -2002,7 +2006,9 @@ class Util
. 'POLYGON|MULTIPOLYGON|GEOMETRYCOLLECTION)';
if (preg_match("/^'" . $geom_types . "\(.*\)',[0-9]*$/i", $gis_string)) {
return $geomFromText . '(' . $gis_string . ')';
} elseif (preg_match('/^' . $geom_types . '\(.*\)$/i', $gis_string)) {
}
if (preg_match('/^' . $geom_types . '\(.*\)$/i', $gis_string)) {
return $geomFromText . "('" . $gis_string . "')";
}
@ -2482,7 +2488,9 @@ class Util
if ($level == null) {
return $tabList;
} elseif (array_key_exists($level, $tabList)) {
}
if (array_key_exists($level, $tabList)) {
return $tabList[$level];
}
@ -2555,7 +2563,9 @@ class Util
$names = $GLOBALS['dbi']->getLowerCaseNames();
if ($names === '0') {
return 'COLLATE utf8_bin';
} elseif ($names === '2') {
}
if ($names === '2') {
return 'COLLATE utf8_general_ci';
}

View File

@ -201,7 +201,9 @@ class HttpRequest
if (curl_getinfo($curlHandle, CURLINFO_SSL_VERIFYRESULT) != 0) {
if ($ssl == 0) {
return $this->curl($url, $method, $returnOnlyStatus, $content, $header, CURLOPT_CAINFO);
} elseif ($ssl == CURLOPT_CAINFO) {
}
if ($ssl == CURLOPT_CAINFO) {
return $this->curl($url, $method, $returnOnlyStatus, $content, $header, CURLOPT_CAPATH);
}
}
@ -282,7 +284,9 @@ class HttpRequest
) {
if (function_exists('curl_init')) {
return $this->curl($url, $method, $returnOnlyStatus, $content, $header);
} elseif (ini_get('allow_url_fopen')) {
}
if (ini_get('allow_url_fopen')) {
return $this->fopen($url, $method, $returnOnlyStatus, $content, $header);
}

View File

@ -38,7 +38,9 @@ if (Core::ifSetOr($_POST['submit_clear'], '')) {
// drop post data
$response->generateHeader303('index.php' . Url::getCommonRaw());
exit;
} elseif (Core::ifSetOr($_POST['submit_download'], '')) {
}
if (Core::ifSetOr($_POST['submit_download'], '')) {
// Output generated config file
Core::downloadHeader('config.inc.php', 'text/plain');
$response->disable();

View File

@ -217,7 +217,9 @@ abstract class TestBase extends TestCase
return 'https://'
. $this->getBrowserStackCredentials() .
'@hub-cloud.browserstack.com/wd/hub';
} elseif ($this->hasSeleniumConfig()) {
}
if ($this->hasSeleniumConfig()) {
return 'http://'
. getenv('TESTSUITE_SELENIUM_HOST') . ':'
. getenv('TESTSUITE_SELENIUM_PORT') . '/wd/hub';