summaryrefslogtreecommitdiffstats
path: root/inc/request.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2021-06-24 14:45:05 +0200
committerSimon Rettberg2021-06-24 14:45:05 +0200
commit51de7b7aac7ed626bee3bce1c3068159e54ab95b (patch)
treea21aae11caceaec3e2c5807ea5073e1cbdd874a4 /inc/request.inc.php
parent[dnbd3] Update translations (diff)
downloadslx-admin-51de7b7aac7ed626bee3bce1c3068159e54ab95b.tar.gz
slx-admin-51de7b7aac7ed626bee3bce1c3068159e54ab95b.tar.xz
slx-admin-51de7b7aac7ed626bee3bce1c3068159e54ab95b.zip
[locations/minilinux] Minor cleanups and fixes
Diffstat (limited to 'inc/request.inc.php')
-rw-r--r--inc/request.inc.php10
1 files changed, 5 insertions, 5 deletions
diff --git a/inc/request.inc.php b/inc/request.inc.php
index 7e9ed97e..bdbd32d5 100644
--- a/inc/request.inc.php
+++ b/inc/request.inc.php
@@ -23,7 +23,7 @@ class Request
* @param string $type if the parameter exists, cast it to given type
* @return mixed Field from $_GET, or $default if not set
*/
- public static function get($key, $default = false, $type = false)
+ public static function get(string $key, $default = false, $type = false)
{
return self::handle($_GET, $key, $default, $type);
}
@@ -34,7 +34,7 @@ class Request
* @param string $default Value to return if $_POST does not contain $key
* @return mixed Field from $_POST, or $default if not set
*/
- public static function post($key, $default = false, $type = false)
+ public static function post(string $key, $default = false, $type = false)
{
return self::handle($_POST, $key, $default, $type);
}
@@ -45,7 +45,7 @@ class Request
* @param string $default Value to return if $_REQUEST does not contain $key
* @return mixed Field from $_REQUEST, or $default if not set
*/
- public static function any($key, $default = false, $type = false)
+ public static function any(string $key, $default = false, $type = false)
{
return self::handle($_REQUEST, $key, $default, $type);
}
@@ -68,14 +68,14 @@ class Request
private static function handle(&$array, $key, $default, $type)
{
- if (!isset($array[$key])) {
+ if (!array_key_exists($key, $array)) {
if ($default === self::REQUIRED || $default === self::REQUIRED_EMPTY) {
Message::addError('main.parameter-missing', $key);
Util::redirect('?do=' . $_REQUEST['do']);
}
return $default;
}
- if ($default === self::REQUIRED && (string)$array[$key] === '') {
+ if ($default === self::REQUIRED && is_string($array[$key]) && $array[$key] === '') {
Message::addError('main.parameter-empty', $key);
Util::redirect('?do=' . $_REQUEST['do']);
}