From 6a415b825eac9745b19f77f75b6071ff0049225e Mon Sep 17 00:00:00 2001 From: provokateurin Date: Tue, 17 Dec 2024 09:49:49 +0100 Subject: [PATCH] refactor(settings): Use parameters explicitly when setting mail settings Signed-off-by: provokateurin --- .../lib/Controller/MailSettingsController.php | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/apps/settings/lib/Controller/MailSettingsController.php b/apps/settings/lib/Controller/MailSettingsController.php index ca037f409b3c1..037024dd1f3b8 100644 --- a/apps/settings/lib/Controller/MailSettingsController.php +++ b/apps/settings/lib/Controller/MailSettingsController.php @@ -56,22 +56,32 @@ public function __construct( */ #[AuthorizedAdminSetting(settings: Overview::class)] #[PasswordConfirmationRequired] - public function setMailSettings($mail_domain, - $mail_from_address, - $mail_smtpmode, - $mail_smtpsecure, - $mail_smtphost, - $mail_smtpauth, - $mail_smtpport, - $mail_sendmailmode) { - $params = get_defined_vars(); - $configs = []; - foreach ($params as $key => $value) { + public function setMailSettings( + string $mail_domain, + string $mail_from_address, + string $mail_smtpmode, + string $mail_smtpsecure, + string $mail_smtphost, + int $mail_smtpauth, + string $mail_smtpport, + string $mail_sendmailmode, + ) { + $configs = [ + 'mail_domain' => $mail_domain, + 'mail_from_address' => $mail_from_address, + 'mail_smtpmode' => $mail_smtpmode, + 'mail_smtpsecure' => $mail_smtpsecure, + 'mail_smtphost' => $mail_smtphost, + 'mail_smtpauth' => $mail_smtpauth, + 'mail_smtpport' => $mail_smtpport, + 'mail_sendmailmode' => $mail_sendmailmode, + ]; + foreach ($configs as $key => $value) { $configs[$key] = empty($value) ? null : $value; } // Delete passwords from config in case no auth is specified - if ($params['mail_smtpauth'] !== 1) { + if ($configs['mail_smtpauth'] !== 1) { $configs['mail_smtpname'] = null; $configs['mail_smtppassword'] = null; }