summaryrefslogtreecommitdiffstats
path: root/modules-available/dnbd3/inc/dnbd3util.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2023-11-14 14:47:55 +0100
committerSimon Rettberg2023-11-14 14:47:55 +0100
commit06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0 (patch)
tree7e5493b102074672d8cfd8fe1a61e49f080edbe8 /modules-available/dnbd3/inc/dnbd3util.inc.php
parentUpdate phpstorm config (diff)
downloadslx-admin-06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0.tar.gz
slx-admin-06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0.tar.xz
slx-admin-06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0.zip
Add function param/return types, fix a lot more phpstorm complaints
Diffstat (limited to 'modules-available/dnbd3/inc/dnbd3util.inc.php')
-rw-r--r--modules-available/dnbd3/inc/dnbd3util.inc.php19
1 files changed, 10 insertions, 9 deletions
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)