diff options
author | Simon Rettberg | 2023-11-14 14:47:55 +0100 |
---|---|---|
committer | Simon Rettberg | 2023-11-14 14:47:55 +0100 |
commit | 06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0 (patch) | |
tree | 7e5493b102074672d8cfd8fe1a61e49f080edbe8 /inc/trigger.inc.php | |
parent | Update phpstorm config (diff) | |
download | slx-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 'inc/trigger.inc.php')
-rw-r--r-- | inc/trigger.inc.php | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/inc/trigger.inc.php b/inc/trigger.inc.php index df06229b..4776855c 100644 --- a/inc/trigger.inc.php +++ b/inc/trigger.inc.php @@ -15,9 +15,9 @@ class Trigger * Compile iPXE pxelinux menu. Needs to be done whenever the server's IP * address changes. * - * @return ?string false if launching task failed, task-id otherwise + * @return ?string null if launching task failed, task-id otherwise */ - public static function ipxe(string $taskId = null) + public static function ipxe(string $taskId = null): ?string { static $lastResult = null; if ($lastResult !== null) @@ -101,18 +101,14 @@ class Trigger * @param bool $ifLocalOnly Only execute task if the storage type is local (used for DNBD3) * @return ?string task id of mount procedure, or false on error */ - public static function mount($vmstore = false, bool $ifLocalOnly = false) + public static function mount($vmstore = false, bool $ifLocalOnly = false): ?string { if ($vmstore === false) { $vmstore = Property::getVmStoreConfig(); } if (!is_array($vmstore)) return null; - if (isset($vmstore['storetype'])) { - $storetype = $vmstore['storetype']; - } else { - $storetype = 'unknown'; - } + $storetype = $vmstore['storetype'] ?? 'unknown'; if ($storetype === 'nfs') { $addr = $vmstore['nfsaddr']; $opts = 'nfsopts'; @@ -126,11 +122,7 @@ class Trigger // Bail out if storage is not local, and we only want to run it in that case if ($ifLocalOnly && $addr !== 'null') return null; - if (isset($vmstore[$opts])) { - $opts = $vmstore[$opts]; - }else { - $opts = null; - } + $opts = $vmstore[$opts] ?? null; $status = Taskmanager::submit('MountVmStore', array( 'address' => $addr, 'type' => 'images', @@ -172,7 +164,7 @@ class Trigger return $tasksLeft; } - private static function triggerDaemons(string $action, $parent, &$taskids) + private static function triggerDaemons(string $action, ?string $parent, array &$taskids): ?string { $task = Taskmanager::submit('Systemctl', array( 'operation' => $action, @@ -200,7 +192,7 @@ class Trigger /** * Stop any daemons that might be sitting on the VMstore, or database. */ - public static function stopDaemons($parent, &$taskids) + public static function stopDaemons(?string $parent, array &$taskids): ?string { $parent = self::triggerDaemons('stop', $parent, $taskids); $task = Taskmanager::submit('LdadpLauncher', array( |