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 --- .../sysconfig/addmodule_branding.inc.php | 31 ++++++++++------------ 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'modules-available/sysconfig/addmodule_branding.inc.php') diff --git a/modules-available/sysconfig/addmodule_branding.inc.php b/modules-available/sysconfig/addmodule_branding.inc.php index f3a90e58..5d94a489 100644 --- a/modules-available/sysconfig/addmodule_branding.inc.php +++ b/modules-available/sysconfig/addmodule_branding.inc.php @@ -11,7 +11,7 @@ class Branding_Start extends AddModule_Base { Render::addDialog(Dictionary::translateFile('config-module', 'branding_title'), false, 'branding-start', array( 'step' => 'Branding_ProcessFile', - 'edit' => $this->edit ? $this->edit->id() : false + 'edit' => $this->edit == null ? null : $this->edit->id(), )); } @@ -47,7 +47,7 @@ class Branding_ProcessFile extends AddModule_Base if (strpos($url, '://') === false) $url = "http://$url"; $title = false; - if (!$this->downloadSvg($this->svgFile, $url, $title)) + if (!Branding_ProcessFile::downloadSvg($this->svgFile, $url, $title)) Util::redirect('?do=SysConfig&action=addmodule&step=Branding_Start'); Session::set('logo_name', $title); } @@ -73,13 +73,13 @@ class Branding_ProcessFile extends AddModule_Base $png = base64_encode(file_get_contents($this->task['data']['pngFile'])); if (filesize($this->svgFile) < 1000000) $svg = base64_encode(file_get_contents($this->svgFile)); - Render::addDialog(Dictionary::translate('config-module', 'branding_title'), false, 'branding-check', array( + Render::addDialog(Dictionary::translateFile('config-module', 'branding_title'), false, 'branding-check', array( 'png' => $png, 'svg' => $svg, 'error' => $this->task['data']['error'], 'step' => 'Branding_Finish', - 'edit' => $this->edit ? $this->edit->id() : false, - 'title' => $this->edit ? $this->edit->title() : false + 'edit' => $this->edit === null ? null : $this->edit->id(), + 'title' => $this->edit === null ? null : $this->edit->title(), ) ); @unlink($this->svgFile); @@ -94,7 +94,7 @@ class Branding_ProcessFile extends AddModule_Base * @return boolean true of download succeeded, false on download error (also returns true if downloaded file doesn't * seem to be svg!) */ - private function downloadSvg($svgName, $url, &$title) + private static function downloadSvg(string $svgName, string $url, &$title): bool { $title = false; // [wikipedia] Did someone paste a link to a thumbnail of the svg? Let's fix that... @@ -121,7 +121,7 @@ class Branding_ProcessFile extends AddModule_Base foreach ($out[1] as $res) { if (strpos($res, 'action=edit') !== false) continue; - $new = $this->internetCombineUrl($url, html_entity_decode($res, ENT_COMPAT, 'UTF-8')); + $new = Branding_ProcessFile::internetCombineUrl($url, html_entity_decode($res, ENT_COMPAT, 'UTF-8')); if ($new !== $url) break; } @@ -143,7 +143,7 @@ class Branding_ProcessFile extends AddModule_Base * @param string $relative relative url that will be converted to an absolute url * @return string combined absolute url */ - private function internetCombineUrl($absolute, $relative) + private static function internetCombineUrl(string $absolute, string $relative): string { $p = parse_url($relative); if (!empty($p["scheme"])) @@ -206,29 +206,26 @@ class Branding_Finish extends AddModule_Base Message::addError('main.error-read', $tgz); Util::redirect('?do=SysConfig&action=addmodule&step=Branding_Start'); } - if ($this->edit === false) + if ($this->edit === null) { $module = ConfigModule::getInstance('Branding'); - else + } else { $module = $this->edit; - if ($module === false) { - Message::addError('main.error-read', 'branding.inc.php'); - Util::redirect('?do=SysConfig&action=addmodule&step=Branding_Start'); } $module->setData('tmpFile', $tgz); - if ($this->edit !== false) + if ($this->edit !== null) $ret = $module->update($title); else $ret = $module->insert($title); if (!$ret) Util::redirect('?do=SysConfig&action=addmodule&step=Branding_Start'); - elseif ($module->generate($this->edit === false, NULL, 200) === false) + elseif ($module->generate($this->edit === null, NULL, 200) === false) Util::redirect('?do=SysConfig&action=addmodule&step=Branding_Start'); Session::set('logo_tgz', false); Session::set('logo_name', false); // Yay - if ($this->edit !== false) + if ($this->edit !== null) { Message::addSuccess('module-edited'); - else { + } else { Message::addSuccess('module-added'); AddModule_Base::setStep('AddModule_Assign', $module->id()); return; -- cgit v1.2.3-55-g7522