From 7965a83aff384586087f88e704c415ec3c5dd420 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Tue, 17 Sep 2019 21:05:08 +0100 Subject: [PATCH] tighten psalm checks even more --- functions.inc.php | 6 +++--- model/Config.php | 2 +- model/Shell.php | 5 ++--- psalm.xml | 14 -------------- public/list.php | 3 +++ 5 files changed, 9 insertions(+), 21 deletions(-) diff --git a/functions.inc.php b/functions.inc.php index 8a40d6a0..35b4dbe3 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -352,8 +352,8 @@ function escape_string($string_or_int) { * $param = safeget('param', 'default') * * @param string $param parameter name. - * @param string $default (optional) - default value if key is not set. - * @return string + * @param string|array $default (optional) - default value if key is not set. + * @return string|array */ function safeget($param, $default = "") { $retval = $default; @@ -1574,7 +1574,7 @@ function db_connect() { /** * Returns the appropriate boolean value for the database. * - * @param bool $bool + * @param bool|string $bool * @return string|int as appropriate for underlying db platform */ function db_get_boolean($bool) { diff --git a/model/Config.php b/model/Config.php index 067370be..7b949901 100644 --- a/model/Config.php +++ b/model/Config.php @@ -109,7 +109,7 @@ final class Config { * Configure::read('Name.key'); will return only the value of Configure::Name[key] * * @param string $var Variable to obtain - * @return array|string|null string value of Configure::$var + * @return array|string|null|bool some value * @access public */ public static function read($var) { diff --git a/model/Shell.php b/model/Shell.php index 3d2bece6..09fbaaa4 100644 --- a/model/Shell.php +++ b/model/Shell.php @@ -180,9 +180,8 @@ class Shell { /** * Outputs to the stdout filehandle. * - * @param string $string String to output. + * @param string|array $string String to output. * @param boolean $newline If true, the outputs gets an added newline. - * @access public */ public function out($string, $newline = true) { if (is_array($string)) { @@ -197,7 +196,7 @@ class Shell { /** * Outputs to the stderr filehandle. * - * @param string $string Error text to output. + * @param string|array $string Error text to output. * @access public */ public function err($string) { diff --git a/psalm.xml b/psalm.xml index a1a05f1d..df696107 100644 --- a/psalm.xml +++ b/psalm.xml @@ -35,17 +35,6 @@ - - - - - - - - - - - @@ -55,13 +44,10 @@ - - - diff --git a/public/list.php b/public/list.php index 7f25e4f6..7e2d0900 100644 --- a/public/list.php +++ b/public/list.php @@ -23,6 +23,9 @@ $username = authentication_get_username(); # enforce login $table = safeget('table'); +if(!is_string($table)) { + die("table parameter must be a string"); +} $handlerclass = ucfirst($table) . 'Handler'; if (!preg_match('/^[a-z]+$/', $table) || !file_exists(dirname(__FILE__) . "/../model/$handlerclass.php")) { # validate $table