php7.4 / psalm fixes

pull/325/head
David Goodwin 4 years ago
parent 882b6835ed
commit 1ad184641d

@ -27,7 +27,7 @@
"jakub-onderka/php-parallel-lint": "^1.0", "jakub-onderka/php-parallel-lint": "^1.0",
"php": ">7.2.0", "php": ">7.2.0",
"php-coveralls/php-coveralls" : "*", "php-coveralls/php-coveralls" : "*",
"phpunit/phpunit": "^6.0", "phpunit/phpunit": "^6|^7",
"vimeo/psalm":"^3.0", "vimeo/psalm":"^3.0",
"zendframework/zendframework1": "^1.12.0" "zendframework/zendframework1": "^1.12.0"
}, },

@ -1721,6 +1721,7 @@ function db_query($sql, array $values = array(), $ignore_errors = false) {
$link = db_connect(); $link = db_connect();
$error_text = ''; $error_text = '';
$stmt = null;
try { try {
$stmt = $link->prepare($sql); $stmt = $link->prepare($sql);
$stmt->execute($values); $stmt->execute($values);

@ -12,6 +12,6 @@ if(function_exists('random_int')) {
return; return;
} }
function random_int() { // someone might not be using php_crypt or ask for password generation, in which case random_int() won't be called function random_int($a, $b) { // someone might not be using php_crypt or ask for password generation, in which case random_int() won't be called
die(__FILE__ . " Postfixadmin security: Please install https://github.com/paragonie/random_compat OR enable the 'Phar' extension."); die(__FILE__ . " Postfixadmin security: Please install https://github.com/paragonie/random_compat OR enable the 'Phar' extension.");
} }

@ -139,7 +139,7 @@ class AliasHandler extends PFAHandler {
public function init($id) { public function init($id) {
@list($local_part, $domain) = explode('@', $id); # supress error message if $id doesn't contain '@' @list($local_part, $domain) = explode('@', $id); # supress error message if $id doesn't contain '@'
if ($local_part == '*') { # catchall - postfix expects '@domain', not '*@domain' if ($local_part == '*' && !is_null($domain)) { # catchall - postfix expects '@domain', not '*@domain'
$id = '@' . $domain; $id = '@' . $domain;
} }

@ -46,7 +46,7 @@ class CliEdit extends Shell {
if (strtolower($val) == 'y') { if (strtolower($val) == 'y') {
$val = 1; $val = 1;
} # convert y to 1 } # convert y to 1
if (strtolower($val) == 'n') { elseif (strtolower($val) == 'n') {
$val = 0; $val = 0;
} # convert n to 0 } # convert n to 0
$values[$key] = $val; # don't modify any other value - *Handler will complain if it's invalid ;-) $values[$key] = $val; # don't modify any other value - *Handler will complain if it's invalid ;-)

@ -586,7 +586,7 @@ class MailboxHandler extends PFAHandler {
if ($quota <= 0) { if ($quota <= 0) {
$quota = 0; $quota = 0;
} # TODO: check if this is correct behaviour } # TODO: check if this is correct behaviour
$cmdarg4=escapeshellarg($quota); $cmdarg4 = escapeshellarg("" . $quota);
$command= "$cmd $cmdarg1 $cmdarg2 $cmdarg3 $cmdarg4"; $command= "$cmd $cmdarg1 $cmdarg2 $cmdarg3 $cmdarg4";
$retval=0; $retval=0;
$output=array(); $output=array();

@ -168,10 +168,10 @@ abstract class PFAHandler {
*/ */
public function __construct($new = 0, $username = "", $is_admin = 1) { public function __construct($new = 0, $username = "", $is_admin = 1) {
# set label_field if not explicitely set # set label_field if not explicitely set
if (!isset($this->id_field)) { if (empty($this->id_field)) {
throw new \InvalidArgumentException("id_field must be defined"); throw new \InvalidArgumentException("id_field must be defined");
} }
if (!isset($this->db_table)) { if (empty($this->db_table)) {
throw new \InvalidArgumentException("db_table must be defined"); throw new \InvalidArgumentException("db_table must be defined");
} }
if (empty($this->label_field)) { if (empty($this->label_field)) {
@ -237,9 +237,6 @@ abstract class PFAHandler {
); );
} }
if (empty($this->db_table)) {
throw new Exception("db_table not defined");
}
$struct_hook = Config::read_string($this->db_table . '_struct_hook'); $struct_hook = Config::read_string($this->db_table . '_struct_hook');
if (!empty($struct_hook) && is_string($struct_hook) && $struct_hook != 'NO' && function_exists($struct_hook)) { if (!empty($struct_hook) && is_string($struct_hook) && $struct_hook != 'NO' && function_exists($struct_hook)) {
$this->struct = $struct_hook($this->struct); $this->struct = $struct_hook($this->struct);

@ -97,6 +97,7 @@ class Shell {
*/ */
public $handler_to_use; public $handler_to_use;
public $new;
/** /**
* Constructs this Shell instance. * Constructs this Shell instance.
* *

@ -28,6 +28,9 @@ if (file_exists(dirname(__FILE__) . '/../config.inc.php')) {
require_once(dirname(__FILE__) . '/../config.inc.php'); require_once(dirname(__FILE__) . '/../config.inc.php');
} }
/**
* @psalm-suppress TypeDoesNotContainType
*/
if ($CONF['configured']) { if ($CONF['configured']) {
header("Location: login.php"); header("Location: login.php");
exit; exit;

Loading…
Cancel
Save