1
0
mirror of https://github.com/postfixadmin/postfixadmin.git synced 2025-08-10 16:02:58 +03:00

psalm improvements

This commit is contained in:
David Goodwin
2021-02-17 21:29:18 +00:00
parent c87d8a8319
commit b2831d1241
8 changed files with 10 additions and 12 deletions

View File

@@ -88,7 +88,7 @@ if (!empty($CONF['language_hook']) && function_exists($CONF['language_hook'])) {
Config::write('__LANG', $PALANG);
if (!defined('POSTFIXADMIN_CLI')) {
if (!isset($CONF) || !isset($PALANG)) {
if (!isset($PALANG)) {
die("environment not setup correctly");
}
require_once(__DIR__ . '/lib/smarty/libs/Autoloader.php');

View File

@@ -16,7 +16,7 @@
"lint": "@php ./vendor/bin/parallel-lint --exclude vendor/ --exclude lib/block_random_int.php --exclude lib/array_column.php .",
"test": "@php ./vendor/bin/phpunit --coverage-clover ./clover.xml tests/",
"test-fixup": "mkdir -p templates_c ; test -f config.local.php || touch config.local.php",
"psalm": "@php ./vendor/bin/psalm --show-info=false "
"psalm": "@php ./vendor/bin/psalm --no-cache --show-info=false "
},
"require": {
"php": ">=7.0"

View File

@@ -36,7 +36,7 @@ class Login {
$crypt_password = pacrypt($password, $row['password']);
} catch (\Exception $e) {
error_log("Error while trying to call pacrypt()");
error_log($e);
error_log("" . $e);
hash_equals("not", "comparable");
return false; // just refuse to login?
}
@@ -49,7 +49,7 @@ class Login {
$x = pacrypt('abc', 'def');
} catch (\Exception $e) {
error_log("Error trying to call pacrypt()");
error_log($e);
error_log("" . $e);
}
return hash_equals('not', 'comparable');

View File

@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<psalm
errorLevel="5"
phpVersion="7.4"
errorLevel="4"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
@@ -35,4 +36,5 @@
<LessSpecificReturnType errorLevel="info"/>
</issueHandlers>
</psalm>

View File

@@ -49,10 +49,6 @@ if (isset($_POST['search']) && is_array($_POST['search'])) {
$search = $_GET['search'];
}
if (!is_array($search)) {
die(Config::Lang('invalid_parameter'));
}
if (count($list_domains) == 0) {
if (authentication_has_role('global-admin')) {
flash_error($PALANG['no_domains_exist']);

View File

@@ -545,7 +545,7 @@ function create_admin($values) {
}
/**
* @return array['info' => string[], 'warn' => string[], 'error' => string[] ]
* @return array like: ['info' => string[], 'warn' => string[], 'error' => string[] ]
*/
function do_software_environment_check() {
$CONF = Config::getInstance()->getAll();

View File

@@ -108,7 +108,7 @@ if ($_SERVER['REQUEST_METHOD'] === "POST") {
// throttle password reset requests to prevent brute force attack
$elapsed_time = microtime(true) - $start_time;
if ($elapsed_time < 2 * pow(10, 6)) {
usleep(2 * pow(10, 6) - $elapsed_time);
usleep( (int) ( 2 * pow(10, 6) - $elapsed_time ) );
}
flash_info(Config::Lang('pPassword_recovery_processed'));

View File

@@ -142,7 +142,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
}
if (isset($choice_of_reply[$tInterval_Time])) {
$fInterval_Time = $tInterval_Time;
$fInterval_Time = (int) $tInterval_Time;
} else {
$fInterval_Time = 0;
}