From 06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 14 Nov 2023 14:47:55 +0100 Subject: Add function param/return types, fix a lot more phpstorm complaints --- modules-available/dnbd3/inc/dnbd3util.inc.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'modules-available/dnbd3/inc/dnbd3util.inc.php') diff --git a/modules-available/dnbd3/inc/dnbd3util.inc.php b/modules-available/dnbd3/inc/dnbd3util.inc.php index 90940e8a..47d7a4ea 100644 --- a/modules-available/dnbd3/inc/dnbd3util.inc.php +++ b/modules-available/dnbd3/inc/dnbd3util.inc.php @@ -108,11 +108,9 @@ class Dnbd3Util { /** * A client is booting that has runmode dnbd3 proxy - set config vars accordingly. * - * @param string $machineUuid * @param string $mode always 'proxy' - * @param string $modeData */ - public static function runmodeConfigHook($machineUuid, $mode, $modeData) + public static function runmodeConfigHook(string $machineUuid, string $mode, string $modeData) { $self = Property::getServerIp(); // Get all directly assigned locations @@ -125,7 +123,7 @@ class Dnbd3Util { $assignedLocs[] = $row['locationid']; } $modeData = (array)json_decode($modeData, true) + self::defaultRunmodeConfig(); - if (!empty($assignedLocs) && isset($modeData['firewall']) && $modeData['firewall']) { + if (!empty($assignedLocs) && ($modeData['firewall'] ?? false)) { // Get all sub-locations too $recursiveLocs = $assignedLocs; $locations = Location::getLocationsAssoc(); @@ -215,10 +213,10 @@ class Dnbd3Util { * @param int $end end address * @return string CIDR notation */ - private static function range2Cidr($start, $end) + private static function range2Cidr(int $start, int $end): string { if (PHP_INT_SIZE > 4) { - $bin = decbin((int)$start ^ (int)$end); + $bin = decbin($start ^ $end); } else { $bin = decbin((int)(float)$start ^ (int)(float)$end); } @@ -258,12 +256,15 @@ class Dnbd3Util { $ranges[] = $row; } - public static function defaultRunmodeConfig() + /** + * @return array{bgr: bool, firewall: bool} + */ + public static function defaultRunmodeConfig(): array { - return array( + return [ 'bgr' => true, 'firewall' => false - ); + ]; } public static function matchAddress($server) -- cgit v1.2.3-55-g7522