From 82c2964bb8893973bbeab037afd67aff9fefd51d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Tue, 26 May 2020 22:27:45 -0300 Subject: [PATCH] Remove useless elses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- examples/openid.php | 56 ++++++------- libraries/classes/CheckUserPrivileges.php | 82 +++++++++---------- .../classes/Command/CacheWarmupCommand.php | 34 ++++---- libraries/classes/Config.php | 4 +- libraries/classes/Config/PageSettings.php | 4 +- .../classes/Controllers/ImportController.php | 1 + .../Preferences/ExportController.php | 4 +- .../Preferences/FeaturesController.php | 4 +- .../Preferences/ImportController.php | 4 +- .../Preferences/MainPanelController.php | 4 +- .../Preferences/NavigationController.php | 4 +- .../Controllers/Preferences/SqlController.php | 4 +- .../Preferences/TwoFactorController.php | 10 +-- .../Server/PrivilegesController.php | 4 +- libraries/classes/Database/Events.php | 4 +- libraries/classes/Database/Routines.php | 30 +++---- libraries/classes/Database/Triggers.php | 28 +++---- libraries/classes/Encoding.php | 4 +- libraries/classes/File.php | 4 +- libraries/classes/Git.php | 70 ++++++++-------- libraries/classes/Import.php | 18 ++-- .../Plugins/Auth/AuthenticationConfig.php | 4 +- .../Plugins/Auth/AuthenticationCookie.php | 20 ++--- .../Plugins/Auth/AuthenticationHttp.php | 8 +- .../Plugins/Auth/AuthenticationSignon.php | 4 +- .../classes/Plugins/AuthenticationPlugin.php | 4 +- .../Abs/HexTransformationsPlugin.php | 4 +- .../Abs/InlineTransformationsPlugin.php | 8 +- libraries/classes/Plugins/TwoFactorPlugin.php | 4 +- libraries/classes/Replication.php | 4 +- libraries/classes/Server/Privileges.php | 4 +- libraries/classes/Server/Status/Monitor.php | 6 +- libraries/classes/Table.php | 10 +-- libraries/classes/Types.php | 42 +++++----- phpstan-baseline.neon | 5 -- setup/config.php | 8 +- .../Table/SearchControllerTest.php | 4 +- .../Table/StructureControllerTest.php | 4 +- test/classes/Stubs/DbiDummy.php | 4 +- test/selenium/TestBase.php | 4 +- 40 files changed, 262 insertions(+), 266 deletions(-) diff --git a/examples/openid.php b/examples/openid.php index bab1db309c..24f4cfed8b 100644 --- a/examples/openid.php +++ b/examples/openid.php @@ -142,32 +142,32 @@ if (isset($_POST['start'])) { header('Location: ' . $url); exit; -} else { - /* Grab query string */ - if (! count($_POST)) { - [, $queryString] = explode('?', $_SERVER['REQUEST_URI']); - } else { - // I hate php sometimes - $queryString = file_get_contents('php://input'); - } - - /* Check reply */ - try { - $message = new OpenID_Message($queryString, OpenID_Message::FORMAT_HTTP); - } catch (Throwable $e) { - Die_error($e); - } - - $id = $message->get('openid.claimed_id'); - - if (! empty($id) && isset($AUTH_MAP[$id])) { - $_SESSION['PMA_single_signon_user'] = $AUTH_MAP[$id]['user']; - $_SESSION['PMA_single_signon_password'] = $AUTH_MAP[$id]['password']; - session_write_close(); - /* Redirect to phpMyAdmin (should use absolute URL here!) */ - header('Location: ../index.php'); - } else { - Show_page('

User not allowed!

'); - exit; - } +} + +/* Grab query string */ +if (! count($_POST)) { + [, $queryString] = explode('?', $_SERVER['REQUEST_URI']); +} else { + // I hate php sometimes + $queryString = file_get_contents('php://input'); +} + +/* Check reply */ +try { + $message = new OpenID_Message($queryString, OpenID_Message::FORMAT_HTTP); +} catch (Throwable $e) { + Die_error($e); +} + +$id = $message->get('openid.claimed_id'); + +if (! empty($id) && isset($AUTH_MAP[$id])) { + $_SESSION['PMA_single_signon_user'] = $AUTH_MAP[$id]['user']; + $_SESSION['PMA_single_signon_password'] = $AUTH_MAP[$id]['password']; + session_write_close(); + /* Redirect to phpMyAdmin (should use absolute URL here!) */ + header('Location: ../index.php'); +} else { + Show_page('

User not allowed!

'); + exit; } diff --git a/libraries/classes/CheckUserPrivileges.php b/libraries/classes/CheckUserPrivileges.php index 100603410f..e67ffc2870 100644 --- a/libraries/classes/CheckUserPrivileges.php +++ b/libraries/classes/CheckUserPrivileges.php @@ -261,53 +261,53 @@ class CheckUserPrivileges // @todo we should not break here, cause GRANT ALL *.* // could be revoked by a later rule like GRANT SELECT ON db.* break; - } else { - // this array may contain wildcards - $GLOBALS['dbs_where_create_table_allowed'][] = $show_grants_dbname; + } - $dbname_to_test = Util::backquote($show_grants_dbname); + // this array may contain wildcards + $GLOBALS['dbs_where_create_table_allowed'][] = $show_grants_dbname; - if ($GLOBALS['is_create_db_priv']) { - // no need for any more tests if we already know this - continue; - } + $dbname_to_test = Util::backquote($show_grants_dbname); - // does this db exist? - if ((preg_match('/' . $re0 . '%|_/', $show_grants_dbname) - && ! preg_match('/\\\\%|\\\\_/', $show_grants_dbname)) - || (! $this->dbi->tryQuery( - 'USE ' . preg_replace( - '/' . $re1 . '(%|_)/', - '\\1\\3', - $dbname_to_test - ) - ) - && mb_substr($this->dbi->getError(), 1, 4) != 1044) - ) { - /** - * Do not handle the underscore wildcard - * (this case must be rare anyway) - */ - $GLOBALS['db_to_create'] = preg_replace( - '/' . $re0 . '%/', - '\\1', - $show_grants_dbname - ); - $GLOBALS['db_to_create'] = preg_replace( + if ($GLOBALS['is_create_db_priv']) { + // no need for any more tests if we already know this + continue; + } + + // does this db exist? + if ((preg_match('/' . $re0 . '%|_/', $show_grants_dbname) + && ! preg_match('/\\\\%|\\\\_/', $show_grants_dbname)) + || (! $this->dbi->tryQuery( + 'USE ' . preg_replace( '/' . $re1 . '(%|_)/', '\\1\\3', - $GLOBALS['db_to_create'] - ); - $GLOBALS['is_create_db_priv'] = true; + $dbname_to_test + ) + ) + && mb_substr($this->dbi->getError(), 1, 4) != 1044) + ) { + /** + * Do not handle the underscore wildcard + * (this case must be rare anyway) + */ + $GLOBALS['db_to_create'] = preg_replace( + '/' . $re0 . '%/', + '\\1', + $show_grants_dbname + ); + $GLOBALS['db_to_create'] = preg_replace( + '/' . $re1 . '(%|_)/', + '\\1\\3', + $GLOBALS['db_to_create'] + ); + $GLOBALS['is_create_db_priv'] = true; - /** - * @todo collect $GLOBALS['db_to_create'] into an array, - * to display a drop-down in the "Create database" dialog - */ - // we don't break, we want all possible databases - //break; - } // end if - } // end elseif + /** + * @todo collect $GLOBALS['db_to_create'] into an array, + * to display a drop-down in the "Create database" dialog + */ + // we don't break, we want all possible databases + //break; + } // end if // end elseif } // end if } // end while diff --git a/libraries/classes/Command/CacheWarmupCommand.php b/libraries/classes/Command/CacheWarmupCommand.php index c39773e864..b326a9399f 100644 --- a/libraries/classes/Command/CacheWarmupCommand.php +++ b/libraries/classes/Command/CacheWarmupCommand.php @@ -57,24 +57,24 @@ final class CacheWarmupCommand extends Command return $this->warmUpTwigCache($output); } elseif ($input->getOption('routing') === true) { return $this->warmUpRoutingCache($output); - } else { - $output->writeln('Warming up all caches.', OutputInterface::VERBOSITY_VERBOSE); - $twigCode = $this->warmUptwigCache($output); - if ($twigCode !== 0) { - $output->writeln('Twig cache generation had an error.'); - - return $twigCode; - } - $routingCode = $this->warmUpTwigCache($output); - if ($routingCode !== 0) { - $output->writeln('Routing cache generation had an error.'); - - return $twigCode; - } - $output->writeln('Warm up of all caches done.', OutputInterface::VERBOSITY_VERBOSE); - - return 0; } + + $output->writeln('Warming up all caches.', OutputInterface::VERBOSITY_VERBOSE); + $twigCode = $this->warmUptwigCache($output); + if ($twigCode !== 0) { + $output->writeln('Twig cache generation had an error.'); + + return $twigCode; + } + $routingCode = $this->warmUpTwigCache($output); + if ($routingCode !== 0) { + $output->writeln('Routing cache generation had an error.'); + + return $twigCode; + } + $output->writeln('Warm up of all caches done.', OutputInterface::VERBOSITY_VERBOSE); + + return 0; } private function warmUpRoutingCache(OutputInterface $output): int diff --git a/libraries/classes/Config.php b/libraries/classes/Config.php index f2ae7f1923..0ec5babe35 100644 --- a/libraries/classes/Config.php +++ b/libraries/classes/Config.php @@ -1125,9 +1125,9 @@ class Config { if (isset($_COOKIE[$this->getCookieName($cookieName)])) { return $_COOKIE[$this->getCookieName($cookieName)]; - } else { - return null; } + + return null; } /** diff --git a/libraries/classes/Config/PageSettings.php b/libraries/classes/Config/PageSettings.php index 2a94eb02a2..9812b5d7c1 100644 --- a/libraries/classes/Config/PageSettings.php +++ b/libraries/classes/Config/PageSettings.php @@ -109,9 +109,9 @@ class PageSettings $response->getFooter()->getSelfUrl() ); exit; - } else { - $error = $result; } + + $error = $result; } } diff --git a/libraries/classes/Controllers/ImportController.php b/libraries/classes/Controllers/ImportController.php index 3f6f1c730f..e66719e1b3 100644 --- a/libraries/classes/Controllers/ImportController.php +++ b/libraries/classes/Controllers/ImportController.php @@ -598,6 +598,7 @@ final class ImportController extends AbstractController Util::handleDisableFKCheckCleanup($default_fk_check); } catch (Throwable $e) { Util::handleDisableFKCheckCleanup($default_fk_check); + throw $e; } } diff --git a/libraries/classes/Controllers/Preferences/ExportController.php b/libraries/classes/Controllers/Preferences/ExportController.php index adb59b6e9e..d5001c9034 100644 --- a/libraries/classes/Controllers/Preferences/ExportController.php +++ b/libraries/classes/Controllers/Preferences/ExportController.php @@ -83,9 +83,9 @@ class ExportController extends AbstractController ); return; - } else { - $error = $result; } + + $error = $result; } // display forms diff --git a/libraries/classes/Controllers/Preferences/FeaturesController.php b/libraries/classes/Controllers/Preferences/FeaturesController.php index 4b2af3cc23..7441925cdc 100644 --- a/libraries/classes/Controllers/Preferences/FeaturesController.php +++ b/libraries/classes/Controllers/Preferences/FeaturesController.php @@ -83,9 +83,9 @@ class FeaturesController extends AbstractController ); return; - } else { - $error = $result; } + + $error = $result; } // display forms diff --git a/libraries/classes/Controllers/Preferences/ImportController.php b/libraries/classes/Controllers/Preferences/ImportController.php index 24e7b0f07c..d068bfec0b 100644 --- a/libraries/classes/Controllers/Preferences/ImportController.php +++ b/libraries/classes/Controllers/Preferences/ImportController.php @@ -83,9 +83,9 @@ class ImportController extends AbstractController ); return; - } else { - $error = $result; } + + $error = $result; } // display forms diff --git a/libraries/classes/Controllers/Preferences/MainPanelController.php b/libraries/classes/Controllers/Preferences/MainPanelController.php index c4567e00ac..50298819e8 100644 --- a/libraries/classes/Controllers/Preferences/MainPanelController.php +++ b/libraries/classes/Controllers/Preferences/MainPanelController.php @@ -83,9 +83,9 @@ class MainPanelController extends AbstractController ); return; - } else { - $error = $result; } + + $error = $result; } // display forms diff --git a/libraries/classes/Controllers/Preferences/NavigationController.php b/libraries/classes/Controllers/Preferences/NavigationController.php index 24ec2b62b5..c8e92abedb 100644 --- a/libraries/classes/Controllers/Preferences/NavigationController.php +++ b/libraries/classes/Controllers/Preferences/NavigationController.php @@ -83,9 +83,9 @@ class NavigationController extends AbstractController ); return; - } else { - $error = $result; } + + $error = $result; } // display forms diff --git a/libraries/classes/Controllers/Preferences/SqlController.php b/libraries/classes/Controllers/Preferences/SqlController.php index 789072b814..71688d0964 100644 --- a/libraries/classes/Controllers/Preferences/SqlController.php +++ b/libraries/classes/Controllers/Preferences/SqlController.php @@ -83,9 +83,9 @@ class SqlController extends AbstractController ); return; - } else { - $error = $result; } + + $error = $result; } // display forms diff --git a/libraries/classes/Controllers/Preferences/TwoFactorController.php b/libraries/classes/Controllers/Preferences/TwoFactorController.php index 6ca0b8ba66..05a1727a8a 100644 --- a/libraries/classes/Controllers/Preferences/TwoFactorController.php +++ b/libraries/classes/Controllers/Preferences/TwoFactorController.php @@ -51,10 +51,10 @@ class TwoFactorController extends AbstractController ]); return; - } else { - $twoFactor->configure(''); - Message::rawNotice(__('Two-factor authentication has been removed.'))->display(); } + + $twoFactor->configure(''); + Message::rawNotice(__('Two-factor authentication has been removed.'))->display(); } elseif (isset($_POST['2fa_configure'])) { if (! $twoFactor->configure($_POST['2fa_configure'])) { echo $this->template->render('preferences/two_factor/configure', [ @@ -63,9 +63,9 @@ class TwoFactorController extends AbstractController ]); return; - } else { - Message::rawNotice(__('Two-factor authentication has been configured.'))->display(); } + + Message::rawNotice(__('Two-factor authentication has been configured.'))->display(); } $backend = $twoFactor->getBackend(); diff --git a/libraries/classes/Controllers/Server/PrivilegesController.php b/libraries/classes/Controllers/Server/PrivilegesController.php index ee2cec162c..550e6fa04d 100644 --- a/libraries/classes/Controllers/Server/PrivilegesController.php +++ b/libraries/classes/Controllers/Server/PrivilegesController.php @@ -471,9 +471,9 @@ class PrivilegesController extends AbstractController $this->response->addJSON('title', $title); return; - } else { - $this->response->addHTML('

' . $title . '

' . $export); } + + $this->response->addHTML('

' . $title . '

' . $export); } if (isset($_GET['adduser'])) { diff --git a/libraries/classes/Database/Events.php b/libraries/classes/Database/Events.php index 1fffb4922d..a705d85cbe 100644 --- a/libraries/classes/Database/Events.php +++ b/libraries/classes/Database/Events.php @@ -571,9 +571,9 @@ class Events $this->response->setRequestStatus(false); $this->response->addJSON('message', $message); exit; - } else { - $message->display(); } + + $message->display(); } } diff --git a/libraries/classes/Database/Routines.php b/libraries/classes/Database/Routines.php index a6981c96f9..a68e54f330 100644 --- a/libraries/classes/Database/Routines.php +++ b/libraries/classes/Database/Routines.php @@ -214,9 +214,9 @@ class Routines $this->response->setRequestStatus(false); $this->response->addJSON('message', $message); exit; - } else { - $message->display(); } + + $message->display(); } } } @@ -1447,11 +1447,11 @@ class Routines $this->response->setRequestStatus(false); $this->response->addJSON('message', $message); exit; - } else { - echo $message->getDisplay(); - unset($_POST); - //NOTE: Missing exit ? } + + echo $message->getDisplay(); + unset($_POST); + //NOTE: Missing exit ? } $queries = is_array($routine) ? $this->getQueriesFromRoutineForm($routine) : []; @@ -1562,16 +1562,16 @@ class Routines $this->response->addJSON('message', $message->getDisplay() . $output); $this->response->addJSON('dialog', false); exit; - } else { - echo $message->getDisplay() , $output; - if ($message->isError()) { - // At least one query has failed, so shouldn't - // execute any more queries, so we quit. - exit; - } - unset($_POST); - // Now deliberately fall through to displaying the routines list } + + echo $message->getDisplay() , $output; + if ($message->isError()) { + // At least one query has failed, so shouldn't + // execute any more queries, so we quit. + exit; + } + unset($_POST); + // Now deliberately fall through to displaying the routines list } /** diff --git a/libraries/classes/Database/Triggers.php b/libraries/classes/Database/Triggers.php index c94113e7a8..ff574123cf 100644 --- a/libraries/classes/Database/Triggers.php +++ b/libraries/classes/Database/Triggers.php @@ -320,19 +320,19 @@ class Triggers } if (empty($temp)) { return null; - } else { - $retval = []; - $retval['create'] = $temp['create']; - $retval['drop'] = $temp['drop']; - $retval['item_name'] = $temp['name']; - $retval['item_table'] = $temp['table']; - $retval['item_action_timing'] = $temp['action_timing']; - $retval['item_event_manipulation'] = $temp['event_manipulation']; - $retval['item_definition'] = $temp['definition']; - $retval['item_definer'] = $temp['definer']; - - return $retval; } + + $retval = []; + $retval['create'] = $temp['create']; + $retval['drop'] = $temp['drop']; + $retval['item_name'] = $temp['name']; + $retval['item_table'] = $temp['table']; + $retval['item_action_timing'] = $temp['action_timing']; + $retval['item_event_manipulation'] = $temp['event_manipulation']; + $retval['item_definition'] = $temp['definition']; + $retval['item_definer'] = $temp['definer']; + + return $retval; } /** @@ -580,9 +580,9 @@ class Triggers $this->response->setRequestStatus(false); $this->response->addJSON('message', $message); exit; - } else { - $message->display(); } + + $message->display(); } } diff --git a/libraries/classes/Encoding.php b/libraries/classes/Encoding.php index c1ea1044ee..e3a0066015 100644 --- a/libraries/classes/Encoding.php +++ b/libraries/classes/Encoding.php @@ -124,9 +124,9 @@ class Encoding self::$_engine = self::$_enginemap[$engine][1]; return; - } else { - Core::warnMissingExtension(self::$_enginemap[$engine][2]); } + + Core::warnMissingExtension(self::$_enginemap[$engine][2]); } /* Autodetection */ diff --git a/libraries/classes/File.php b/libraries/classes/File.php index 89a8626294..d42b695ebc 100644 --- a/libraries/classes/File.php +++ b/libraries/classes/File.php @@ -248,9 +248,9 @@ class File { if ($this->getName() === null) { return false; - } else { - return is_uploaded_file($this->getName()); } + + return is_uploaded_file($this->getName()); } /** diff --git a/libraries/classes/Git.php b/libraries/classes/Git.php index db38a85d9d..ca11148b2c 100644 --- a/libraries/classes/Git.php +++ b/libraries/classes/Git.php @@ -449,42 +449,42 @@ class Git } return [trim($hash), $branch]; - } else { - // deal with packed refs - $packedRefs = @file_get_contents($gitFolder . '/packed-refs'); - if ($packedRefs === false) { - $this->config->set('PMA_VERSION_GIT', 0); - - return [null, null]; - } - // split file to lines - $refLines = explode(PHP_EOL, $packedRefs); - foreach ($refLines as $line) { - // skip comments - if ($line[0] == '#') { - continue; - } - // parse line - $parts = explode(' ', $line); - // care only about named refs - if (count($parts) != 2) { - continue; - } - // have found our ref? - if ($parts[1] == $refHead) { - $hash = $parts[0]; - break; - } - } - if (! isset($hash)) { - $this->config->set('PMA_VERSION_GIT', 0); - - // Could not find ref - return [null, null]; - } - - return [$hash, $branch]; } + + // deal with packed refs + $packedRefs = @file_get_contents($gitFolder . '/packed-refs'); + if ($packedRefs === false) { + $this->config->set('PMA_VERSION_GIT', 0); + + return [null, null]; + } + // split file to lines + $refLines = explode(PHP_EOL, $packedRefs); + foreach ($refLines as $line) { + // skip comments + if ($line[0] == '#') { + continue; + } + // parse line + $parts = explode(' ', $line); + // care only about named refs + if (count($parts) != 2) { + continue; + } + // have found our ref? + if ($parts[1] == $refHead) { + $hash = $parts[0]; + break; + } + } + if (! isset($hash)) { + $this->config->set('PMA_VERSION_GIT', 0); + + // Could not find ref + return [null, null]; + } + + return [$hash, $branch]; } else { return [trim($refHead), $branch]; } diff --git a/libraries/classes/Import.php b/libraries/classes/Import.php index 36e81b5537..10f7230ce6 100644 --- a/libraries/classes/Import.php +++ b/libraries/classes/Import.php @@ -416,13 +416,13 @@ class Import $GLOBALS['finished'] = true; return $GLOBALS['import_text']; - } else { - $r = mb_substr($GLOBALS['import_text'], 0, $size); - $GLOBALS['offset'] += $size; - $GLOBALS['import_text'] = mb_substr($GLOBALS['import_text'], $size); - - return $r; } + + $r = mb_substr($GLOBALS['import_text'], 0, $size); + $GLOBALS['offset'] += $size; + $GLOBALS['import_text'] = mb_substr($GLOBALS['import_text'], $size); + + return $r; } $result = $import_handle->read($size); @@ -1675,10 +1675,10 @@ class Import $message = Message::rawError($error); $response->addJSON('message', $message); exit; - } else { - // If everything fine, START a transaction. - $GLOBALS['dbi']->query('START TRANSACTION'); } + + // If everything fine, START a transaction. + $GLOBALS['dbi']->query('START TRANSACTION'); } /** diff --git a/libraries/classes/Plugins/Auth/AuthenticationConfig.php b/libraries/classes/Plugins/Auth/AuthenticationConfig.php index b1e5b595da..3126f2e10e 100644 --- a/libraries/classes/Plugins/Auth/AuthenticationConfig.php +++ b/libraries/classes/Plugins/Auth/AuthenticationConfig.php @@ -38,9 +38,9 @@ class AuthenticationConfig extends AuthenticationPlugin $response->addJSON('reload_flag', '1'); if (defined('TESTSUITE')) { return true; - } else { - exit; } + + exit; } return true; diff --git a/libraries/classes/Plugins/Auth/AuthenticationCookie.php b/libraries/classes/Plugins/Auth/AuthenticationCookie.php index 8f0ada3f68..9cf678005c 100644 --- a/libraries/classes/Plugins/Auth/AuthenticationCookie.php +++ b/libraries/classes/Plugins/Auth/AuthenticationCookie.php @@ -105,9 +105,9 @@ class AuthenticationCookie extends AuthenticationPlugin if (! $session_expired && $response->loginPage()) { if (defined('TESTSUITE')) { return true; - } else { - exit; } + + exit; } /** @@ -240,9 +240,9 @@ class AuthenticationCookie extends AuthenticationPlugin if (! defined('TESTSUITE')) { exit; - } else { - return true; } + + return true; } /** @@ -405,9 +405,9 @@ class AuthenticationCookie extends AuthenticationPlugin $this->showFailure('no-activity'); if (! defined('TESTSUITE')) { exit; - } else { - return false; } + + return false; } // check password cookie @@ -522,9 +522,9 @@ class AuthenticationCookie extends AuthenticationPlugin if (! defined('TESTSUITE')) { exit; - } else { - return false; } + + return false; } // Set server cookies if required (once per session) and, in this case, // force reload to ensure the client accepts cookies @@ -544,9 +544,9 @@ class AuthenticationCookie extends AuthenticationPlugin ); if (! defined('TESTSUITE')) { exit; - } else { - return false; } + + return false; } // end if return true; diff --git a/libraries/classes/Plugins/Auth/AuthenticationHttp.php b/libraries/classes/Plugins/Auth/AuthenticationHttp.php index 9f06677bda..ea4805c8dd 100644 --- a/libraries/classes/Plugins/Auth/AuthenticationHttp.php +++ b/libraries/classes/Plugins/Auth/AuthenticationHttp.php @@ -41,9 +41,9 @@ class AuthenticationHttp extends AuthenticationPlugin $response->addJSON('reload_flag', '1'); if (defined('TESTSUITE')) { return true; - } else { - exit; } + + exit; } return $this->authForm(); @@ -97,9 +97,9 @@ class AuthenticationHttp extends AuthenticationPlugin if (! defined('TESTSUITE')) { exit; - } else { - return false; } + + return false; } /** diff --git a/libraries/classes/Plugins/Auth/AuthenticationSignon.php b/libraries/classes/Plugins/Auth/AuthenticationSignon.php index a45ba575c5..df07897745 100644 --- a/libraries/classes/Plugins/Auth/AuthenticationSignon.php +++ b/libraries/classes/Plugins/Auth/AuthenticationSignon.php @@ -44,9 +44,9 @@ class AuthenticationSignon extends AuthenticationPlugin if (! defined('TESTSUITE')) { exit; - } else { - return false; } + + return false; } /** diff --git a/libraries/classes/Plugins/AuthenticationPlugin.php b/libraries/classes/Plugins/AuthenticationPlugin.php index e8e3a586ee..7a42766354 100644 --- a/libraries/classes/Plugins/AuthenticationPlugin.php +++ b/libraries/classes/Plugins/AuthenticationPlugin.php @@ -345,9 +345,9 @@ abstract class AuthenticationPlugin if ($response->loginPage()) { if (defined('TESTSUITE')) { return; - } else { - exit; } + + exit; } echo $this->template->render('login/header', ['theme' => $GLOBALS['PMA_Theme']]); Message::rawNotice( diff --git a/libraries/classes/Plugins/Transformations/Abs/HexTransformationsPlugin.php b/libraries/classes/Plugins/Transformations/Abs/HexTransformationsPlugin.php index 7773fd499f..bc1421b30a 100644 --- a/libraries/classes/Plugins/Transformations/Abs/HexTransformationsPlugin.php +++ b/libraries/classes/Plugins/Transformations/Abs/HexTransformationsPlugin.php @@ -50,9 +50,9 @@ abstract class HexTransformationsPlugin extends TransformationsPlugin if ($options[0] < 1) { return bin2hex($buffer); - } else { - return chunk_split(bin2hex($buffer), $options[0], ' '); } + + return chunk_split(bin2hex($buffer), $options[0], ' '); } /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */ diff --git a/libraries/classes/Plugins/Transformations/Abs/InlineTransformationsPlugin.php b/libraries/classes/Plugins/Transformations/Abs/InlineTransformationsPlugin.php index 2b72e48916..dd605fa081 100644 --- a/libraries/classes/Plugins/Transformations/Abs/InlineTransformationsPlugin.php +++ b/libraries/classes/Plugins/Transformations/Abs/InlineTransformationsPlugin.php @@ -45,7 +45,7 @@ abstract class InlineTransformationsPlugin extends TransformationsPlugin $cfg = $GLOBALS['cfg']; $options = $this->getOptions($options, $cfg['DefaultTransformations']['Inline']); - if (PMA_IS_GD2) { + if (defined('PMA_IS_GD2') && PMA_IS_GD2 === 1) { return '[' . htmlspecialchars($buffer) . ']'; - } else { - return '[' . htmlspecialchars($buffer) . ']'; } + + return '[' . htmlspecialchars($buffer) . ']'; } /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */ diff --git a/libraries/classes/Plugins/TwoFactorPlugin.php b/libraries/classes/Plugins/TwoFactorPlugin.php index b6f9a29228..a4867a43d1 100644 --- a/libraries/classes/Plugins/TwoFactorPlugin.php +++ b/libraries/classes/Plugins/TwoFactorPlugin.php @@ -165,8 +165,8 @@ class TwoFactorPlugin if ($return_url) { return $parsed['scheme'] . '://' . $parsed['host'] . (! empty($parsed['port']) ? ':' . $parsed['port'] : ''); - } else { - return $parsed['host']; } + + return $parsed['host']; } } diff --git a/libraries/classes/Replication.php b/libraries/classes/Replication.php index 94c3808de0..03162b7df3 100644 --- a/libraries/classes/Replication.php +++ b/libraries/classes/Replication.php @@ -28,9 +28,9 @@ class Replication $list = explode('.', $string); if ($what == 'db') { return $list[0]; - } else { - return $list[1]; } + + return $list[1]; } /** diff --git a/libraries/classes/Server/Privileges.php b/libraries/classes/Server/Privileges.php index 8072471513..5cc440ef34 100644 --- a/libraries/classes/Server/Privileges.php +++ b/libraries/classes/Server/Privileges.php @@ -97,9 +97,9 @@ class Privileges if ($response->isAjax()) { $response->addJSON('message', $dialog); exit; - } else { - $html .= $dialog; } + + $html .= $dialog; } return $html; diff --git a/libraries/classes/Server/Status/Monitor.php b/libraries/classes/Server/Status/Monitor.php index 415d76b419..76f7ff41ae 100644 --- a/libraries/classes/Server/Status/Monitor.php +++ b/libraries/classes/Server/Status/Monitor.php @@ -405,10 +405,10 @@ class Monitor // Group this value, thus do not add to the result list continue 2; - } else { - $insertTablesFirst = $i; - $insertTables[$matches[2]] += $row['#'] - 1; } + + $insertTablesFirst = $i; + $insertTables[$matches[2]] += $row['#'] - 1; } // No break here diff --git a/libraries/classes/Table.php b/libraries/classes/Table.php index 64c17efc25..fea9c9d76c 100644 --- a/libraries/classes/Table.php +++ b/libraries/classes/Table.php @@ -217,9 +217,9 @@ class Table } return false; - } else { - return $tbl_storage_engine == $engine; } + + return $tbl_storage_engine == $engine; } /** @@ -1803,10 +1803,10 @@ class Table $move_columns_sql_result = $this->_dbi->tryQuery($move_columns_sql_query); if ($move_columns_sql_result !== false) { return $this->_dbi->getFieldsMeta($move_columns_sql_result); - } else { - // unsure how to reproduce but it was seen on the reporting server - return []; } + + // unsure how to reproduce but it was seen on the reporting server + return []; } /** diff --git a/libraries/classes/Types.php b/libraries/classes/Types.php index 514869ef40..be7ff4cc63 100644 --- a/libraries/classes/Types.php +++ b/libraries/classes/Types.php @@ -618,28 +618,28 @@ class Types 'ST_PolyFromWKB', 'ST_MPolyFromWKB', ]; - } else { - return [ - 'GeomFromText', - 'GeomFromWKB', - - 'GeomCollFromText', - 'LineFromText', - 'MLineFromText', - 'PointFromText', - 'MPointFromText', - 'PolyFromText', - 'MPolyFromText', - - 'GeomCollFromWKB', - 'LineFromWKB', - 'MLineFromWKB', - 'PointFromWKB', - 'MPointFromWKB', - 'PolyFromWKB', - 'MPolyFromWKB', - ]; } + + return [ + 'GeomFromText', + 'GeomFromWKB', + + 'GeomCollFromText', + 'LineFromText', + 'MLineFromText', + 'PointFromText', + 'MPointFromText', + 'PolyFromText', + 'MPolyFromText', + + 'GeomCollFromWKB', + 'LineFromWKB', + 'MLineFromWKB', + 'PointFromWKB', + 'MPointFromWKB', + 'PolyFromWKB', + 'MPolyFromWKB', + ]; } return []; diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e909cccf78..466434e25b 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -3185,11 +3185,6 @@ parameters: count: 1 path: libraries/classes/Plugins/Transformations/Abs/ExternalTransformationsPlugin.php - - - message: "#^If condition is always true\\.$#" - count: 1 - path: libraries/classes/Plugins/Transformations/Abs/InlineTransformationsPlugin.php - - message: "#^Method PhpMyAdmin\\\\Plugins\\\\Transformations\\\\Output\\\\Text_Plain_Binarytoip\\:\\:applyTransformation\\(\\) should return string but returns string\\|false\\.$#" count: 1 diff --git a/setup/config.php b/setup/config.php index 8d56a9bded..550ad641ed 100644 --- a/setup/config.php +++ b/setup/config.php @@ -44,8 +44,8 @@ if (Core::ifSetOr($_POST['submit_clear'], '')) { $response->disable(); echo ConfigGenerator::getConfigFile($GLOBALS['ConfigFile']); exit; -} else { - // Show generated config file in a