diff options
author | Simon Rettberg | 2023-11-02 19:08:58 +0100 |
---|---|---|
committer | Simon Rettberg | 2023-11-02 19:08:58 +0100 |
commit | c2d95ffaeaa289752b4c7b6664b6ca112a02e350 (patch) | |
tree | 2c29b0157d14198aadbdbc9f8c18ded0bd4dadcd /modules-available/runmode/inc | |
parent | [rebootcontrol] Remove API prototype (diff) | |
download | slx-admin-c2d95ffaeaa289752b4c7b6664b6ca112a02e350.tar.gz slx-admin-c2d95ffaeaa289752b4c7b6664b6ca112a02e350.tar.xz slx-admin-c2d95ffaeaa289752b4c7b6664b6ca112a02e350.zip |
Roundup of issues reported by PHPStorm
Mostly redundant checks, logic errors, dead code, etc.
Diffstat (limited to 'modules-available/runmode/inc')
-rw-r--r-- | modules-available/runmode/inc/runmode.inc.php | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/modules-available/runmode/inc/runmode.inc.php b/modules-available/runmode/inc/runmode.inc.php index ccc432d2..65b444e7 100644 --- a/modules-available/runmode/inc/runmode.inc.php +++ b/modules-available/runmode/inc/runmode.inc.php @@ -297,7 +297,7 @@ class RunModeModuleConfig */ public $permission = false; - public function __construct($file) + public function __construct(string $file) { $data = json_decode(file_get_contents($file), true); if (!is_array($data)) @@ -313,19 +313,16 @@ class RunModeModuleConfig $this->loadType($data, 'permission', 'string'); } - private function loadType($data, $key, $type) + private function loadType(array $data, string $key, string $type): void { if (!isset($data[$key])) - return false; + return; if (is_string($type) && gettype($data[$key]) !== $type) - return false; - if (is_array($type) && !in_array(gettype($data[$key]), $type)) - return false; + return; $this->{$key} = $data[$key]; - return true; } - public function userHasPermission($locationId) + public function userHasPermission(?int $locationId): bool { return $this->permission === false || User::hasPermission($this->permission, $locationId); } |