From f3062ddeb17078501830eaacdada1a666319302b Mon Sep 17 00:00:00 2001
From: Thibault Dockx <thibault.dockx@fusiondirectory.org>
Date: Mon, 24 Feb 2025 15:10:37 +0000
Subject: [PATCH] :sparkles: Feat(Login) - login adapt php8.2

Adapt include/login to php82
---
 include/login/class_LoginMethod.inc | 6 +++---
 include/login/class_LoginPost.inc   | 8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/login/class_LoginMethod.inc b/include/login/class_LoginMethod.inc
index a4e1b3b0f..9ea359ef1 100755
--- a/include/login/class_LoginMethod.inc
+++ b/include/login/class_LoginMethod.inc
@@ -85,11 +85,11 @@ class LoginMethod
   static function validateUserInput (): bool
   {
     global $message, $smarty;
-    static::$username = trim(static::$username);
+    static::$username = trim((string) static::$username);
     if (!preg_match('/^[@A-Za-z0-9_.-]+$/', static::$username)) {
       $message = _('Please specify a valid username!');
       return FALSE;
-    } elseif (mb_strlen(static::$password, 'UTF-8') == 0) {
+    } elseif (mb_strlen((string) static::$password, 'UTF-8') == 0) {
       $message = _('Please specify your password!');
       $smarty->assign('focusfield', 'password');
       return FALSE;
@@ -170,7 +170,7 @@ class LoginMethod
   }
 
   /*! \brief Final step of successful login: redirect to main.php */
-  static function redirect ()
+  static function redirect (): never
   {
     static::connect();
     header('Location: main.php');
diff --git a/include/login/class_LoginPost.inc b/include/login/class_LoginPost.inc
index bc18fe38d..bb4f50d0c 100755
--- a/include/login/class_LoginPost.inc
+++ b/include/login/class_LoginPost.inc
@@ -107,7 +107,7 @@ class LoginPost extends LoginMethod
     /* Fill template with required values */
     $username = '';
     if (isset($_POST['username'])) {
-      $username = trim($_POST['username']);
+      $username = trim((string) $_POST['username']);
     }
     $smarty->assign('date',       gmdate('D, d M Y H:i:s'));
     $smarty->assign('username',   $username);
@@ -150,7 +150,7 @@ class LoginPost extends LoginMethod
     /* show login screen */
     $smarty->assign('PHPSESSID', session_id());
     if ($error_collector != '') {
-      $smarty->assign('php_errors', preg_replace('/%BUGBODY%/', $error_collector_mailto, $error_collector).'</div>');
+      $smarty->assign('php_errors', preg_replace('/%BUGBODY%/', (string) $error_collector_mailto, (string) $error_collector).'</div>');
     } else {
       $smarty->assign('php_errors', '');
     }
@@ -179,7 +179,7 @@ class LoginPost extends LoginMethod
     /* Fill template with required values */
     $username = '';
     if (isset($_POST['username'])) {
-      $username = trim($_POST['username']);
+      $username = trim((string) $_POST['username']);
     }
     $smarty->assign('date',       gmdate('D, d M Y H:i:s'));
     $smarty->assign('username',   $username);
@@ -196,7 +196,7 @@ class LoginPost extends LoginMethod
     /* show login screen */
     $smarty->assign('PHPSESSID', session_id());
     if ($error_collector != '') {
-      $smarty->assign('php_errors', preg_replace('/%BUGBODY%/', $error_collector_mailto, $error_collector).'</div>');
+      $smarty->assign('php_errors', preg_replace('/%BUGBODY%/', (string) $error_collector_mailto, (string) $error_collector).'</div>');
     } else {
       $smarty->assign('php_errors', '');
     }
-- 
GitLab