diff options
Diffstat (limited to 'modules-available/serversetup-bwlp-ipxe/inc/scriptbuilderipxe.inc.php')
-rw-r--r-- | modules-available/serversetup-bwlp-ipxe/inc/scriptbuilderipxe.inc.php | 45 |
1 files changed, 15 insertions, 30 deletions
diff --git a/modules-available/serversetup-bwlp-ipxe/inc/scriptbuilderipxe.inc.php b/modules-available/serversetup-bwlp-ipxe/inc/scriptbuilderipxe.inc.php index 3ca312aa..4896f598 100644 --- a/modules-available/serversetup-bwlp-ipxe/inc/scriptbuilderipxe.inc.php +++ b/modules-available/serversetup-bwlp-ipxe/inc/scriptbuilderipxe.inc.php @@ -3,7 +3,7 @@ class ScriptBuilderIpxe extends ScriptBuilderBase { - private function getUrlBase() + private function getUrlBase(): string { if (isset($_SERVER['REQUEST_URI'])) { $url = parse_url($_SERVER['REQUEST_URI']); @@ -23,7 +23,7 @@ class ScriptBuilderIpxe extends ScriptBuilderBase } - private function getUrlFull(&$hasExt, $key = null, $value = null) + private function getUrlFull(?bool &$hasExt = null, string $key = null, string $value = null): string { $url = parse_url($_SERVER['REQUEST_URI']); $urlbase = $this->getUrlBase(); @@ -58,7 +58,7 @@ class ScriptBuilderIpxe extends ScriptBuilderBase /** * Redirect to same URL, but add our extended params */ - private function redirect($key = null, $value = null) + private function redirect(string $key = null, string $value = null): string { // Redirect to self with added parameters $urlfull = $this->getUrlFull($hasExt, $key, $value); @@ -102,27 +102,24 @@ HERE; return false; } - public function getBootEntry($entry) + public function getBootEntry(?BootEntry $entry): string { - if (!$entry) { + if ($entry === null) { return "#!ipxe\nprompt --timeout 5000 Invalid boot entry id\n"; } return $entry->toScript($this); } - public function getMenu(IPxeMenu $menu, bool $bootstrap) + public function getMenu(IPxeMenu $menu, bool $bootstrap): string { if ($bootstrap) { return "#!ipxe\nimgfree ||\n" . $this->menuToScript($menu); } - $base = $this->getUrlFull($he); + $base = $this->getUrlFull(); return "#!ipxe\nset self {$base} ||\n" . $this->menuToScript($menu); } - /** - * @param IPxeMenu $menu - */ - public function menuToScript($menu) + public function menuToScript(IPxeMenu $menu): string { if ($this->hasExtension) { $slxConsoleUpdate = '--update'; @@ -186,12 +183,7 @@ HERE; return $output; } - /** - * @param $requestedDefaultId - * @param MenuEntry $entry - * @return string - */ - private function getMenuItemScript($requestedDefaultId, $entry) + private function getMenuItemScript(int $requestedDefaultId, MenuEntry $entry): string { $str = 'item '; if ($entry->gap) { @@ -220,7 +212,7 @@ HERE; return $str . " || prompt Could not create menu item for {$entry->menuentryid}\n"; } - public function getSpecial($special) + public function getSpecial(string $special): string { if ($special === 'localboot') { // Get preferred localboot method, depending on system model @@ -269,11 +261,7 @@ HERE; } } // Convert to actual ipxe code - if (isset($BOOT_METHODS[$localboot])) { - $localboot = $BOOT_METHODS[$localboot]; - } else { - $localboot = 'prompt Localboot not possible'; - } + $localboot = $BOOT_METHODS[$localboot] ?? 'prompt Localboot not possible'; $output = <<<BLA imgfree || console || @@ -287,7 +275,7 @@ BLA; return $output; } - public function output($string) + public function output(string $string): void { // iPXE introduced UTF-8 support at some point in 2022, and now expects all text/script files to be // encoded as such. Since we still offer to use older versions, we need to detect that here and handle @@ -319,10 +307,7 @@ BLA; const PROP_PW_SALT = 'ipxe.salt.'; - /** - * @param MenuEntry $menuEntryId - */ - private function passwordDialog($entry) + private function passwordDialog(MenuEntry $entry): string { if ($this->hasExtension) { $salt = dechex(mt_rand(0x100000, 0xFFFFFF)); @@ -348,7 +333,7 @@ chain -a \${self}&entryid={$entry->menuentryid}##params || goto fail || HERE; } - public function getMenuEntry($entry, $honorPassword = true) + public function getMenuEntry(?MenuEntry $entry, bool $honorPassword = true): string { if ($entry === null) return "#!ipxe\nprompt --timeout 10000 Invalid menu entry id\n"; @@ -402,7 +387,7 @@ HERE; return $output; } - public function execDataToScript($agnostic, $bios, $efi) : string + public function execDataToScript(?ExecData $agnostic, ?ExecData $bios, ?ExecData $efi) : string { if ($agnostic !== null) return $this->execDataToScriptInternal($agnostic) . "\ngoto fail\n"; |