diff --git a/include/accept-to-gettext.inc b/include/accept-to-gettext.inc
index a0fffc4fe785dff119a16dd97410f950285db48f..31407a8372651da87c536b94ce4952c8d43bdd69 100755
--- a/include/accept-to-gettext.inc
+++ b/include/accept-to-gettext.inc
@@ -75,7 +75,7 @@
 function parse_scores ($str)
 {
   $scores = [];
-  $parts = preg_split('/,/', $str);
+  $parts = preg_split('/,/', (string) $str);
   foreach ($parts as $part) {
     $part = trim(strtolower($part));
     if (preg_match("/(.*);q=(.*)/", $part, $matches)) {
@@ -108,7 +108,7 @@ function max_scores ($scores, $testvals)
  */
 function parse_gettext_lang ($str)
 {
-  if (preg_match("/^([^_]*)(_([^_]*))?\.(.*)$/", $str, $m)) {
+  if (preg_match("/^([^_]*)(_([^_]*))?\.(.*)$/", (string) $str, $m)) {
     return [strtolower($m[1]), strtolower($m[3]), strtolower($m[4])];
   } else {
     return FALSE;
diff --git a/include/class_ACLPermissions.inc b/include/class_ACLPermissions.inc
index 253c50312c8ede8368bd88409dd0c761b402a6e7..063e9a21412bc1cf3b4d08367bc212b02644cc3b 100755
--- a/include/class_ACLPermissions.inc
+++ b/include/class_ACLPermissions.inc
@@ -18,7 +18,7 @@
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 */
 
-class ACLPermissions
+class ACLPermissions implements \Stringable
 {
   static protected $letters = [
     'r' => 'read',
@@ -40,9 +40,9 @@ class ACLPermissions
   public function __construct (string $rights = '')
   {
     foreach (static::$letters as $letter => $var) {
-      $this->$var = (strpos($rights, $letter) !== FALSE);
+      $this->$var = (str_contains($rights, (string) $letter));
     }
-    $this->self = (strpos($rights, 's') !== FALSE);
+    $this->self = (str_contains($rights, 's'));
   }
 
   public function toString (bool $readOnly = FALSE): string
@@ -60,7 +60,7 @@ class ACLPermissions
     }
   }
 
-  public function __toString ()
+  public function __toString (): string
   {
     return $this->toString(FALSE);
   }
diff --git a/include/class_CSRFProtection.inc b/include/class_CSRFProtection.inc
index a726c4592370c8a4f1cfe70a150781b754c8e4a8..20f9a9ca0b8a5e3ef53001fe0ceba5e013cde0db 100755
--- a/include/class_CSRFProtection.inc
+++ b/include/class_CSRFProtection.inc
@@ -57,11 +57,11 @@ class CSRFProtection
       $origin = $_SERVER['HTTP_REFERER'];
     }
     if ($origin) {
-      $origin = preg_replace('|^[^/]+://([^/]+)(/.*)?$|', '\1', $origin);
+      $origin = preg_replace('|^[^/]+://([^/]+)(/.*)?$|', '\1', (string) $origin);
       $target = FALSE;
       if (!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) {
         /* Only take the first value, there may be several separated by commas */
-        list($target) = explode(',', $_SERVER['HTTP_X_FORWARDED_HOST'], 2);
+        list($target) = explode(',', (string) $_SERVER['HTTP_X_FORWARDED_HOST'], 2);
       } elseif (!empty($_SERVER['HTTP_HOST'])) {
         $target = $_SERVER['HTTP_HOST'];
       }
diff --git a/include/class_IconTheme.inc b/include/class_IconTheme.inc
index 8fce8ab7e9846890293776a75ecb2382a07eff21..780355e9329d6b81baa32d17c452e8b4df4b2169 100755
--- a/include/class_IconTheme.inc
+++ b/include/class_IconTheme.inc
@@ -69,14 +69,10 @@ class IconThemeDir
 
   function MatchesSize ($size)
   {
-    switch ($this->Type) {
-      case 'Fixed':
-        return ($this->Size == $size);
-      case 'Threshold':
-      case 'Scalable':
-      default:
-        return (($this->MinSize <= $size) && ($size <= $this->MaxSize));
-    }
+    return match ($this->Type) {
+        'Fixed' => $this->Size == $size,
+        default => ($this->MinSize <= $size) && ($size <= $this->MaxSize),
+    };
   }
 
   function SizeDistance ($size)
@@ -116,10 +112,10 @@ class IconTheme
       throw new ThemeFileParsingException('Error while parsing theme file');
     }
     if (isset($datas['Icon Theme']['Directories']) && !empty($datas['Icon Theme']['Directories'])) {
-      $dirs = preg_split('/,/', $datas['Icon Theme']['Directories']);
+      $dirs = preg_split('/,/', (string) $datas['Icon Theme']['Directories']);
       foreach ($dirs as $name) {
         if (isset($datas[$name])) {
-          $this->subdirs[strtolower($datas[$name]['Context'])][$name] = new IconThemeDir($datas[$name]);
+          $this->subdirs[strtolower((string) $datas[$name]['Context'])][$name] = new IconThemeDir($datas[$name]);
         }
       }
     }
@@ -133,7 +129,7 @@ class IconTheme
 
   function FindIcon ($context, $icon, $size)
   {
-    $context = strtolower($context);
+    $context = strtolower((string) $context);
     return $this->FindIconHelper($context, $icon, $size);
   }
 
@@ -219,7 +215,7 @@ class IconTheme
             } else {
               $themes[$file] = new IconTheme("$path/$file", static::$default_theme);
             }
-          } catch (ThemeFileParsingException $e) {
+          } catch (ThemeFileParsingException) {
             continue;
           }
         }
@@ -231,7 +227,7 @@ class IconTheme
   static public function findThemeIcon ($theme, $context, $icon, $size)
   {
     // We have to sanitize the $icon received from $_GET['icon']. Fixing vulnerability : CWE-35
-    if (!preg_match('/^[a-zA-Z0-9_\-]+$/', $icon)) {
+    if (!preg_match('/^[a-zA-Z0-9_\-]+$/', (string) $icon)) {
       trigger_error('Error: Wrong icon name received');
       die('Error: wrong icon name received');
     }
diff --git a/include/class_Language.inc b/include/class_Language.inc
index aeddcb541956141aea66c8b48433405eca5a279b..a474af31c45a5ad426309f433a40fe3637926c51 100755
--- a/include/class_Language.inc
+++ b/include/class_Language.inc
@@ -108,7 +108,7 @@ class Language
     /* Check for global language settings in configuration */
     if (isset($config) && ($config->get_cfg_value('language') != '')) {
       $lang = $config->get_cfg_value('language');
-      if (!preg_match('/utf/i', $lang)) {
+      if (!preg_match('/utf/i', (string) $lang)) {
         $lang .= '.UTF-8';
       }
       return $lang;
@@ -134,8 +134,8 @@ class Language
    */
   public static function isAvailable (string $lang): bool
   {
-    if (strpos($lang, '.') === FALSE) {
-      $lang = $lang.'.UTF-8';
+    if (!str_contains($lang, '.')) {
+      $lang .= '.UTF-8';
     }
 
     /* Store current locale */
@@ -245,7 +245,7 @@ class Language
    */
   public static function isRTL ($lang)
   {
-    return preg_match('/^(fa_|ar_)/', $lang);
+    return preg_match('/^(fa_|ar_)/', (string) $lang);
   }
 
   public static function setHeaders ($language, $mime)
@@ -254,7 +254,7 @@ class Language
 
     if (!headers_sent()) {
       header("Content-Language: $lang".(empty($country) ? '' : "-$country"));
-      if (!empty($char) && preg_match('|^text/|', $mime)) {
+      if (!empty($char) && preg_match('|^text/|', (string) $mime)) {
         header("Content-Type: $mime; charset=$char");
       } else {
         header("Content-Type: $mime");
diff --git a/include/class_Lock.inc b/include/class_Lock.inc
index 4e3c06f1d945099e3d1b9c76021ce46bdfbc882f..655bedf57c8ea4d85e37cd9d96bbe2ac241f84fc 100755
--- a/include/class_Lock.inc
+++ b/include/class_Lock.inc
@@ -81,7 +81,7 @@ class Lock
     /* Check for existing entries in lock area */
     $ldap = $config->get_ldap_link();
     $ldap->cd(get_ou('lockRDN').get_ou('fusiondirectoryRDN').$config->current['BASE']);
-    $ldap->search('(&(objectClass=fdLockEntry)(fdUserDn='.ldap_escape_f($user).')(fdObjectDn='.base64_encode($object).'))',
+    $ldap->search('(&(objectClass=fdLockEntry)(fdUserDn='.ldap_escape_f($user).')(fdObjectDn='.base64_encode((string) $object).'))',
         ['fdUserDn']);
     if ($ldap->get_errno() == 32) {
       /* No such object, means the locking branch is missing, create it */
@@ -92,7 +92,7 @@ class Lock
         $error->display();
       }
       $ldap->cd(get_ou('lockRDN').get_ou('fusiondirectoryRDN').$config->current['BASE']);
-      $ldap->search('(&(objectClass=fdLockEntry)(fdUserDn='.ldap_escape_f($user).')(fdObjectDn='.base64_encode($object).'))',
+      $ldap->search('(&(objectClass=fdLockEntry)(fdUserDn='.ldap_escape_f($user).')(fdObjectDn='.base64_encode((string) $object).'))',
         ['fdUserDn']);
     }
     if (!$ldap->success()) {
@@ -108,14 +108,14 @@ class Lock
     /* Add lock if none present */
     if ($ldap->count() == 0) {
       $attrs  = [];
-      $name   = md5($object);
+      $name   = md5((string) $object);
       $dn     = 'cn='.$name.','.get_ou('lockRDN').get_ou('fusiondirectoryRDN').$config->current['BASE'];
       $ldap->cd($dn);
       $attrs = [
         'objectClass'     => 'fdLockEntry',
         'cn'              => $name,
         'fdUserDn'        => $user,
-        'fdObjectDn'      => base64_encode($object),
+        'fdObjectDn'      => base64_encode((string) $object),
         'fdLockTimestamp' => LdapGeneralizedTime::toString(new DateTime('now')),
       ];
       $ldap->add($attrs);
@@ -163,7 +163,7 @@ class Lock
     $ldap = $config->get_ldap_link();
     $dn   = get_ou('lockRDN').get_ou('fusiondirectoryRDN').$config->current['BASE'];
     $ldap->cd($dn);
-    $ldap->search('(&(objectClass=fdLockEntry)(fdObjectDn='.base64_encode($object).'))', ['fdObjectDn']);
+    $ldap->search('(&(objectClass=fdLockEntry)(fdObjectDn='.base64_encode((string) $object).'))', ['fdObjectDn']);
     if (!$ldap->success()) {
       throw new FusionDirectoryLdapError($dn, LDAP_SEARCH, $ldap->get_error(), $ldap->get_errno());
     } elseif ($attrs = $ldap->fetch()) {
@@ -221,7 +221,7 @@ class Lock
       }
       $filter = '(&(objectClass=fdLockEntry)(|';
       foreach ($objects as $obj) {
-        $filter .= '(fdObjectDn='.base64_encode($obj).')';
+        $filter .= '(fdObjectDn='.base64_encode((string) $obj).')';
       }
       $filter .= '))';
     } else {
@@ -229,7 +229,7 @@ class Lock
         /* If readonly is allowed and asked and there is only one object, bypass lock detection */
         return [];
       }
-      $filter = '(&(objectClass=fdLockEntry)(fdObjectDn='.base64_encode($objects).'))';
+      $filter = '(&(objectClass=fdLockEntry)(fdObjectDn='.base64_encode((string) $objects).'))';
     }
 
     /* Get LDAP link, check for presence of the lock entry */
@@ -254,7 +254,7 @@ class Lock
       } else {
         $locks[] = new Lock(
           $attrs['dn'],
-          base64_decode($attrs['fdObjectDn'][0]),
+          base64_decode((string) $attrs['fdObjectDn'][0]),
           $attrs['fdUserDn'][0],
           $date
         );
diff --git a/include/class_URL.inc b/include/class_URL.inc
index 0ad8c72be864bb1b0be1291078d119a6213f4c99..bd6553d042dce99c1798646a17d91ba24ffbce92 100755
--- a/include/class_URL.inc
+++ b/include/class_URL.inc
@@ -31,10 +31,10 @@ class URL
   public static function sslOn (): bool
   {
     if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
-      return (strcasecmp($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') == 0);
+      return (strcasecmp((string) $_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') == 0);
     }
     if (isset($_SERVER['HTTPS'])) {
-      return (strcasecmp($_SERVER['HTTPS'], 'on') == 0);
+      return (strcasecmp((string) $_SERVER['HTTPS'], 'on') == 0);
     }
     return FALSE;
   }
diff --git a/include/class_acl.inc b/include/class_acl.inc
index 470a2c5227a6aa8a6f3440ceae7ec17a2018c126..acf497dd1bad000e98ae31ecaf0c3411f20ca3ad 100755
--- a/include/class_acl.inc
+++ b/include/class_acl.inc
@@ -59,7 +59,7 @@ class acl
     unset($role['count']);
     $result = [];
     foreach ($role as $aclTemplate) {
-      $list = explode(':', $aclTemplate, 2);
+      $list = explode(':', (string) $aclTemplate, 2);
       $result[$list[0]] = static::extractACL($list[1]);
     }
     ksort($result);
@@ -73,7 +73,7 @@ class acl
    */
   static function explodeACL ($acl)
   {
-    $list = explode(':', $acl);
+    $list = explode(':', (string) $acl);
     if (count($list) == 6) {
       list($index, $type, $role, $members, $userfilter, $targetfilter) = $list;
       $userfilter   = base64_decode($userfilter);
@@ -177,7 +177,7 @@ class acl
   {
     /* Rip acl off the string, seperate by ',' and place it in an array */
     $as = preg_replace('/^[^:]+:[^:]+:[^:]*:([^:]*).*$/', '\1', $acl);
-    $aa = explode(',', $as);
+    $aa = explode(',', (string) $as);
     $a  = [];
 
     /* Dis-assemble single ACLs */
diff --git a/include/class_baseSelector.inc b/include/class_baseSelector.inc
index 88e9363959c4310cece41ab46a43560c48186610..5f94c24394d9c8ea38bd3d567fe2c8a360cf0441 100755
--- a/include/class_baseSelector.inc
+++ b/include/class_baseSelector.inc
@@ -124,7 +124,7 @@ class baseSelector
 
     foreach ($bases as $base => $dummy) {
       // Build path style display
-      $elements = explode(',', substr($base, 0, strlen($base) - strlen($config->current['BASE'])));
+      $elements = explode(',', substr($base, 0, strlen($base) - strlen((string) $config->current['BASE'])));
       $elements = array_reverse($elements, TRUE);
 
       $this->pathMapping[$base] = (($base == $config->current['BASE']) ? '/' : preg_replace('/(^|,)[a-z0-9]+=/i', '/', implode(',', $elements)));
@@ -151,7 +151,7 @@ class baseSelector
     $last_base    = $this->base;
     if (isset($_REQUEST['BPID']) && $_REQUEST['BPID'] == $this->pid) {
       if (!empty($_POST['bs_rebase_'.$this->pid])) {
-        $new_base = base64_decode($_POST['bs_rebase_'.$this->pid]);
+        $new_base = base64_decode((string) $_POST['bs_rebase_'.$this->pid]);
         if (isset($this->pathMapping[$new_base])) {
           $this->base   = $new_base;
           $this->action = 'rebase';
@@ -166,7 +166,7 @@ class baseSelector
           // Check if base is available
           $this->lastState = FALSE;
           foreach ($this->pathMapping as $key => $path) {
-            if (mb_strtolower($path) == mb_strtolower($_POST[$this->getInputHtmlId()])) {
+            if (mb_strtolower((string) $path) == mb_strtolower((string) $_POST[$this->getInputHtmlId()])) {
               $this->base       = $key;
               $this->lastState  = TRUE;
               break;
@@ -202,7 +202,7 @@ class baseSelector
         continue;
       }
 
-      $elements     = explode(',', substr($base, 0, strlen($base) - strlen($config->current['BASE'])));
+      $elements     = explode(',', substr($base, 0, strlen($base) - strlen((string) $config->current['BASE'])));
       /* Remove last one */
       array_pop($elements);
       /* Remove first one */
diff --git a/include/class_config.inc b/include/class_config.inc
index 52c6c4f1ebecdcb576b77f4f7685056f2ac43924..2ec72a7be8e1c50b5c05ed252b3e22f88513a3b2 100755
--- a/include/class_config.inc
+++ b/include/class_config.inc
@@ -178,7 +178,7 @@ class config
     xml_set_object($this->parser, $this);
     xml_set_element_handler($this->parser, "tag_open", "tag_close");
 
-    if (!xml_parse($this->parser, chop($xmldata))) {
+    if (!xml_parse($this->parser, rtrim((string) $xmldata))) {
       $msg = sprintf(_('XML error in fusiondirectory.conf: %s at line %d'),
             xml_error_string(xml_get_error_code($this->parser)),
             xml_get_current_line_number($this->parser));
@@ -214,9 +214,9 @@ class config
 
     /* yes/no to true/false and upper case TRUE to true and so on*/
     foreach ($attrs as $name => $value) {
-      if (preg_match("/^(true|yes)$/i", $value)) {
+      if (preg_match("/^(true|yes)$/i", (string) $value)) {
         $attrs[$name] = "TRUE";
-      } elseif (preg_match("/^(false|no)$/i", $value)) {
+      } elseif (preg_match("/^(false|no)$/i", (string) $value)) {
         $attrs[$name] = "FALSE";
       }
     }
@@ -226,7 +226,7 @@ class config
       /* Handle location */
       case 'LOCATION':
         if ($this->tags[$this->level - 2] == 'MAIN') {
-          $attrs['NAME'] = preg_replace('/[<>"\']/', '', $attrs['NAME']);
+          $attrs['NAME'] = preg_replace('/[<>"\']/', '', (string) $attrs['NAME']);
 
           $this->currentLocation = $attrs['NAME'];
 
@@ -246,8 +246,8 @@ class config
             $attrs['BASE']  = $this->data['LOCATIONS'][$this->currentLocation]['BASE'];
           } else {
             /* Format from FD<1.3 */
-            $server         = preg_replace('!^([^:]+://[^/]+)/.*$!', '\\1', $attrs['URI']);
-            $attrs['BASE']  = preg_replace('!^[^:]+://[^/]+/(.*)$!', '\\1', $attrs['URI']);
+            $server         = preg_replace('!^([^:]+://[^/]+)/.*$!', '\\1', (string) $attrs['URI']);
+            $attrs['BASE']  = preg_replace('!^[^:]+://[^/]+/(.*)$!', '\\1', (string) $attrs['URI']);
             $attrs['URI']   = $server;
           }
 
@@ -393,7 +393,7 @@ class config
     if (isset($this->current['REFERRAL'])) {
       $servers  = [];
       foreach ($this->current['REFERRAL'] as $server => $ref) {
-        $servers[$server] = strlen($ref['BASE']);
+        $servers[$server] = strlen((string) $ref['BASE']);
       }
       asort($servers);
       reset($servers);
@@ -464,9 +464,9 @@ class config
     if ($attrs = $ldap->fetch()) {
       for ($i = 0; $i < $attrs['count']; $i++) {
         $key = $attrs[$i];
-        if (preg_match('/^fdTabHook$/i', $key)) {
+        if (preg_match('/^fdTabHook$/i', (string) $key)) {
           for ($j = 0; $j < $attrs[$key]['count']; ++$j) {
-            $parts  = explode('|', $attrs[$key][$j], 3);
+            $parts  = explode('|', (string) $attrs[$key][$j], 3);
             $class  = strtoupper($parts[0]);
             $mode   = strtoupper($parts[1]);
             $cmd    = $parts[2];
@@ -482,14 +482,14 @@ class config
             }
             $this->data['HOOKS'][$class][$mode][] = $cmd;
           }
-        } elseif (preg_match('/^fd/', $key)) {
+        } elseif (preg_match('/^fd/', (string) $key)) {
           if (isset($attrs[$key]['count']) && ($attrs[$key]['count'] > 1)) {
             $value = $attrs[$key];
             unset($value['count']);
           } else {
             $value = $attrs[$key][0];
           }
-          $key = strtoupper(preg_replace('/^fd/', '', $key));
+          $key = strtoupper(preg_replace('/^fd/', '', (string) $key));
           $this->current[$key] = $value;
         }
       }
@@ -507,7 +507,7 @@ class config
       }
       $value = [];
       foreach ($this->current['MANAGEMENTCONFIG'] as $config) {
-        list($class, $json) = explode(':', $config, 2);
+        list($class, $json) = explode(':', (string) $config, 2);
         $value[$class] = $json;
       }
       $this->current['MANAGEMENTCONFIG'] = $value;
@@ -518,7 +518,7 @@ class config
       }
       $value = [];
       foreach ($this->current['MANAGEMENTUSERCONFIG'] as $config) {
-        list($user, $class, $json) = explode(':', $config, 3);
+        list($user, $class, $json) = explode(':', (string) $config, 3);
         $value[$user][$class] = $json;
       }
       $this->current['MANAGEMENTUSERCONFIG'] = $value;
@@ -726,7 +726,7 @@ class config
     }
 
     $base   = $this->current['BASE'];
-    $qbase  = preg_quote($base, '/');
+    $qbase  = preg_quote((string) $base, '/');
 
     $arr  = [];
 
@@ -734,7 +734,7 @@ class config
     foreach ($this->departmentList as $val) {
 
       /* Split dn into single department pieces */
-      $elements = array_reverse(explode(',', preg_replace("/$qbase$/", '', $val)));
+      $elements = array_reverse(explode(',', preg_replace("/$qbase$/", '', (string) $val)));
 
       /* Add last ou element of current dn to our array */
       $last = &$arr;
@@ -745,8 +745,8 @@ class config
         }
 
         /* Extract department name */
-        $elestr = trim(preg_replace('/^[^=]*+=/', '', $ele), ',');
-        $nameA  = trim(preg_replace('/=.*$/', '', $ele), ',');
+        $elestr = trim((string) preg_replace('/^[^=]*+=/', '', $ele), ',');
+        $nameA  = trim((string) preg_replace('/=.*$/', '', $ele), ',');
         if ($nameA != 'ou') {
           $nameA = " ($nameA)";
         } else {
@@ -794,8 +794,8 @@ class config
       $name = preg_replace('/\\\\,/', ',', $name);
 
       /* Check if current name is too long, then cut it */
-      if (mb_strlen($name, 'UTF-8') > $max_size) {
-        $name = mb_substr($name, 0, ($max_size - 3), 'UTF-8')." ...";
+      if (mb_strlen((string) $name, 'UTF-8') > $max_size) {
+        $name = mb_substr((string) $name, 0, ($max_size - 3), 'UTF-8')." ...";
       }
 
       /* Append the name to the list */
@@ -832,8 +832,8 @@ class config
    */
   function searchHooks ($class, $value)
   {
-    $class = strtoupper($class);
-    $value = strtoupper($value);
+    $class = strtoupper((string) $class);
+    $value = strtoupper((string) $value);
     return (isset($this->data['HOOKS'][$class][$value]) ? $this->data['HOOKS'][$class][$value] : []);
   }
 
@@ -856,7 +856,7 @@ class config
    */
   function get_cfg_value ($name, $default = '')
   {
-    $name = strtoupper($name);
+    $name = strtoupper((string) $name);
     $res  = $default;
 
     /* Check if we have a current value for $name */
@@ -960,7 +960,7 @@ class config
         foreach ($plInfo['plObjectType'] as $key => $value) {
           if (is_numeric($key)) {
             /* This is not the main tab */
-            $tabclass = strtoupper($value).'TABS';
+            $tabclass = strtoupper((string) $value).'TABS';
             if (($tabclass == 'GROUPTABS') && class_available('mixedGroup')) {
               $tabclass = 'OGROUP-USERTABS';
             }
@@ -971,10 +971,10 @@ class config
             $this->data['TABS'][$tabclass][] = $entry;
           } else {
             /* This is the main tab */
-            if (isset($this->data['OBJECTS'][strtoupper($key)])) {
-              die("duplicated object type ".strtoupper($key)." in ".$this->data['OBJECTS'][strtoupper($key)]['mainTab']." and $class");
+            if (isset($this->data['OBJECTS'][strtoupper((string) $key)])) {
+              die("duplicated object type ".strtoupper((string) $key)." in ".$this->data['OBJECTS'][strtoupper((string) $key)]['mainTab']." and $class");
             }
-            $tabclass = strtoupper($key)."TABS";
+            $tabclass = strtoupper((string) $key)."TABS";
             $value['tabGroup']        = $tabclass;
             $value['mainTab']         = $class;
             $value['templateActive']  = FALSE;
@@ -1005,7 +1005,7 @@ class config
             if (!isset($value['tabClass'])) {
               $value['tabClass'] = 'simpleTabs';
             }
-            $this->data['OBJECTS'][strtoupper($key)] = $value;
+            $this->data['OBJECTS'][strtoupper((string) $key)] = $value;
             logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $tabclass, "Adding $class as main tab of");
             if (!isset($this->data['TABS'][$tabclass])) {
               $this->data['TABS'][$tabclass] = [];
@@ -1033,7 +1033,7 @@ class config
     /* Extract categories definitions from object types */
     foreach ($this->data['OBJECTS'] as $key => $infos) {
       logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $infos['aclCategory'], "ObjectType $key category");
-      if (strtoupper($infos['aclCategory']) == $key) {
+      if (strtoupper((string) $infos['aclCategory']) == $key) {
         $cat = $infos['aclCategory'];
         if (!isset($this->data['CATEGORIES'][$cat])) {
           $this->data['CATEGORIES'][$cat] = ['classes' => ['0']];
@@ -1076,12 +1076,12 @@ class config
         foreach ($plInfo['plObjectType'] as $key => $value) {
           if (is_numeric($key)) {
             /* This is not the main tab */
-            $obj = strtoupper($value);
+            $obj = strtoupper((string) $value);
           } else {
             /* This is the main tab */
-            $obj = strtoupper($key);
+            $obj = strtoupper((string) $key);
           }
-          if (strpos($obj, 'OGROUP-') === 0) {
+          if (str_starts_with($obj, 'OGROUP-')) {
             $obj = 'OGROUP';
           }
           /* if this is an existing objectType, not just a tab group */
@@ -1101,7 +1101,7 @@ class config
       /* Read management info */
       if (isset($plInfo['plManages'])) {
         foreach ($plInfo['plManages'] as $type) {
-          $obj = strtoupper($type);
+          $obj = strtoupper((string) $type);
           if (!isset($this->data['OBJECTS'][$obj])) {
             continue;
           }
@@ -1132,7 +1132,7 @@ class config
           }
         }
       }
-      logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, join(',', array_unique($acl)), "Class $class categories");
+      logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, implode(',', array_unique($acl)), "Class $class categories");
       /* Feed menu */
       if (isset($plInfo['plSection'])) {
         $section = $plInfo['plSection'];
@@ -1145,7 +1145,7 @@ class config
         if (isset($plInfo['plSelfModify']) && $plInfo['plSelfModify']) {
           $acl[] = $acl[0].'/'.$class.':self';
         }
-        $acl = join(',', array_unique($acl));
+        $acl = implode(',', array_unique($acl));
 
         if (is_array($section)) {
           $section  = key($section);
diff --git a/include/class_exceptions.inc b/include/class_exceptions.inc
index 3ea0cea1161e28e91561237fd0e5d96ebf86be09..e6b37fcdd6ff3858d8684e478946a17636a686b0 100755
--- a/include/class_exceptions.inc
+++ b/include/class_exceptions.inc
@@ -31,7 +31,7 @@ class FusionDirectoryException extends Exception
   public function toArray (): array
   {
     return [
-      'class'   => get_class($this),
+      'class'   => static::class,
       'message' => $this->getMessage(),
       'line'    => $this->getLine(),
       'file'    => $this->getFile(),
diff --git a/include/class_ldap.inc b/include/class_ldap.inc
index 53b05aa7c38c526aee6a9c100c06b090a2fe4c18..aa55fed119674ff2cf3d3b49be18766a47176159 100755
--- a/include/class_ldap.inc
+++ b/include/class_ldap.inc
@@ -204,35 +204,15 @@ class LDAP
       if (@ldap_parse_result($this->cid, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls)) {
         if (isset($ctrls[LDAP_CONTROL_PASSWORDPOLICYRESPONSE]['value']['error'])) {
           $this->hascon = FALSE;
-          switch ($ctrls[LDAP_CONTROL_PASSWORDPOLICYRESPONSE]['value']['error']) {
-            case 0:
+          $this->error = match ($ctrls[LDAP_CONTROL_PASSWORDPOLICYRESPONSE]['value']['error']) {
               /* passwordExpired - password has expired and must be reset */
-              $this->error = _('It seems your user password has expired. Please use <a href="recovery.php">password recovery</a> to change it.');
-              break;
-            case 1:
+              0 => _('It seems your user password has expired. Please use <a href="recovery.php">password recovery</a> to change it.'),
               /* accountLocked */
-              $this->error = _('Account locked. Please contact your system administrator!');
-              break;
-            case 2:
+              1 => _('Account locked. Please contact your system administrator!'),
               /* changeAfterReset - password must be changed before the user will be allowed to perform any other operation */
-              $this->error = 'changeAfterReset';
-              break;
-            case 3:
-              /* passwordModNotAllowed */
-            case 4:
-              /* mustSupplyOldPassword */
-            case 5:
-              /* insufficientPasswordQuality */
-            case 6:
-              /* passwordTooShort */
-            case 7:
-              /* passwordTooYoung */
-            case 8:
-              /* passwordInHistory */
-            default:
-              $this->error = sprintf(_('Unexpected ppolicy error "%s", please contact the administrator'), $ctrls[LDAP_CONTROL_PASSWORDPOLICYRESPONSE]['value']['error']);
-              break;
-          }
+              2 => 'changeAfterReset',
+              default => sprintf(_('Unexpected ppolicy error "%s", please contact the administrator'), $ctrls[LDAP_CONTROL_PASSWORDPOLICYRESPONSE]['value']['error']),
+          };
           // Note: Also available: expire, grace
         } else {
           $this->hascon = ($errcode == 0);
@@ -333,7 +313,7 @@ class LDAP
     if ($basedn == '') {
       $basedn = $this->basedn;
     }
-    return preg_replace("/[^,]*[,]*[ ]*(.*)/", "$1", $basedn);
+    return preg_replace("/[^,]*[,]*[ ]*(.*)/", "$1", (string) $basedn);
   }
 
   /*!
@@ -356,7 +336,7 @@ class LDAP
 
       $startTime = microtime(TRUE);
       $this->clearResult($srp);
-      switch (strtolower($scope)) {
+      switch (strtolower((string) $scope)) {
         case 'base':
           if (isset($controls)) {
             $this->sr[$srp] = @ldap_read($this->cid, $this->basedn, $filter, $attrs, 0, 0, 0, LDAP_DEREF_NEVER, $controls);
@@ -718,7 +698,7 @@ class LDAP
   function rename_dn ($source, $dest)
   {
     /* Check if source and destination are the same entry */
-    if (strtolower($source) == strtolower($dest)) {
+    if (strtolower((string) $source) == strtolower((string) $dest)) {
       trigger_error("Source and destination can't be the same entry.");
       $this->error = "Source and destination can't be the same entry.";
       return FALSE;
@@ -736,8 +716,8 @@ class LDAP
          parent   =>  ou=department,dc=...
          dest_rdn =>  cn=herbert
      */
-    $parent   = preg_replace("/^[^,]+,/", "", $dest);
-    $dest_rdn = preg_replace("/,.*$/", "", $dest);
+    $parent   = preg_replace("/^[^,]+,/", "", (string) $dest);
+    $dest_rdn = preg_replace("/,.*$/", "", (string) $dest);
 
     if ($this->hascon) {
       if ($this->reconnect) {
@@ -782,7 +762,7 @@ class LDAP
       $this->cd($deletedn);
       $this->search($srp, '(objectClass=*)', ['dn']);
       while ($attrs = $this->fetch($srp)) {
-        $delarray[$attrs['dn']] = strlen($attrs['dn']);
+        $delarray[$attrs['dn']] = strlen((string) $attrs['dn']);
       }
       arsort($delarray);
       reset($delarray);
@@ -813,7 +793,7 @@ class LDAP
 
     $str = "";
     if (isset($attrs['objectClass'])
-      && preg_match("/^objectClass: value #([0-9]*) invalid per syntax$/", $this->get_additional_error(), $m)) {
+      && preg_match("/^objectClass: value #([0-9]*) invalid per syntax$/", (string) $this->get_additional_error(), $m)) {
       $ocs = $attrs['objectClass'];
       if (!is_array($ocs)) {
         $ocs = [$ocs];
@@ -823,7 +803,7 @@ class LDAP
       }
     }
     if ($error == "Undefined attribute type") {
-      $str = " - <b>attribute: ".preg_replace("/:.*$/", "", $this->get_additional_error())."</b>";
+      $str = " - <b>attribute: ".preg_replace("/:.*$/", "", (string) $this->get_additional_error())."</b>";
     }
 
     logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $attrs, "Erroneous data");
@@ -916,7 +896,7 @@ class LDAP
    * */
   function create_missing_trees ($srp, $target, $ignoreReferralBases = TRUE)
   {
-    $real_path = substr($target, 0, strlen($target) - strlen($this->basedn) - 1);
+    $real_path = substr((string) $target, 0, strlen((string) $target) - strlen((string) $this->basedn) - 1);
 
     if ($target == $this->basedn) {
       $l = ["dummy"];
@@ -950,8 +930,8 @@ class LDAP
 
       /* Create missing entry? */
       if (!$this->dn_exists($cdn)) {
-        $type   = preg_replace('/^([^=]+)=.*$/', '\\1', $cdn);
-        $param  = preg_replace('/^[^=]+=([^,]+).*$/', '\\1', $cdn);
+        $type   = preg_replace('/^([^=]+)=.*$/', '\\1', (string) $cdn);
+        $param  = preg_replace('/^[^=]+=([^,]+).*$/', '\\1', (string) $cdn);
         $param  = preg_replace(['/\\\\,/','/\\\\"/'], [',','"'], $param);
 
         $na = [];
@@ -1060,7 +1040,7 @@ class LDAP
    */
   function success (): bool
   {
-    return (trim($this->error) === 'Success');
+    return (trim((string) $this->error) === 'Success');
   }
 
   /*!
@@ -1114,7 +1094,7 @@ class LDAP
   function get_credentials ($url, $referrals = NULL)
   {
     $ret    = [];
-    $url    = preg_replace('!\?\?.*$!', '', $url);
+    $url    = preg_replace('!\?\?.*$!', '', (string) $url);
     $server = preg_replace('!^([^:]+://[^/]+)/.*$!', '\\1', $url);
 
     if ($referrals === NULL) {
@@ -1163,9 +1143,9 @@ class LDAP
 
     // Prepare parameters to be valid for shell execution
     $dn     = escapeshellarg($dn);
-    $pwd    = escapeshellarg($this->bindpw);
-    $host   = escapeshellarg($this->hostname);
-    $admin  = escapeshellarg($this->binddn);
+    $pwd    = escapeshellarg((string) $this->bindpw);
+    $host   = escapeshellarg((string) $this->hostname);
+    $admin  = escapeshellarg((string) $this->binddn);
     $filter = escapeshellarg($filter);
 
     $cmd = 'ldapsearch'.($this->tls ? ' -ZZ' : '')." -x -LLLL -D {$admin} {$filter} {$limit} {$wrap} {$scope} -H {$host} -b {$dn} -w {$pwd} ";
@@ -1368,7 +1348,7 @@ class LDAP
       /* Create missing trees */
       $this->cd($config->current['BASE']);
       try {
-        $this->create_missing_trees($srp, preg_replace('/^[^,]+,/', '', $dn));
+        $this->create_missing_trees($srp, preg_replace('/^[^,]+,/', '', (string) $dn));
       } catch (FusionDirectoryError $error) {
         $error->display();
       }
@@ -1439,12 +1419,12 @@ class LDAP
       return [];
     }
     foreach ($attrs[0]['objectclasses'] as $val) {
-      if (preg_match('/^[0-9]+$/', $val)) {
+      if (preg_match('/^[0-9]+$/', (string) $val)) {
         continue;
       }
       $name     = 'OID';
-      $pattern  = explode(' ', $val);
-      $ocname   = preg_replace("/^.* NAME\s+\(*\s*'([^']+)'\s*\)*.*$/", '\\1', $val);
+      $pattern  = explode(' ', (string) $val);
+      $ocname   = preg_replace("/^.* NAME\s+\(*\s*'([^']+)'\s*\)*.*$/", '\\1', (string) $val);
       $objectclasses[$ocname] = [];
 
       $value = '';
@@ -1501,19 +1481,19 @@ class LDAP
   function value2container ($value)
   {
     /* Set emtpy values to "TRUE" only */
-    if (preg_match('/^\s*$/', $value)) {
+    if (preg_match('/^\s*$/', (string) $value)) {
       return TRUE;
     }
 
     /* Remove ' and " if needed */
-    $value = preg_replace('/^[\'"]/', '', $value);
+    $value = preg_replace('/^[\'"]/', '', (string) $value);
     $value = preg_replace('/[\'"] *$/', '', $value);
 
     /* Convert to array if $ is inside... */
     if (preg_match('/\$/', $value)) {
       $container = preg_split('/\s*\$\s*/', $value);
     } else {
-      $container = chop($value);
+      $container = rtrim($value);
     }
 
     return $container;
@@ -1543,7 +1523,7 @@ class LDAP
    */
   function getCn ($dn)
   {
-    $simple = explode(",", $dn);
+    $simple = explode(",", (string) $dn);
 
     foreach ($simple as $piece) {
       $partial = explode("=", $piece);
diff --git a/include/class_ldapFilter.inc b/include/class_ldapFilter.inc
index 245195353f68abac2079316639da79d01fe79511..2bdfedc56647d53d6e35331f4fecf9f52c6c9e75 100755
--- a/include/class_ldapFilter.inc
+++ b/include/class_ldapFilter.inc
@@ -33,7 +33,7 @@
   *   // do something
   * }
   */
-class ldapFilter
+class ldapFilter implements \Stringable
 {
   static $operators = ['!', '&', '|'];
 
@@ -46,9 +46,9 @@ class ldapFilter
     $this->subparts = $subparts;
   }
 
-  function __toString ()
+  function __toString (): string
   {
-    return '('.$this->operator.join($this->subparts).')';
+    return '('.$this->operator.implode('', $this->subparts).')';
   }
 
   function __invoke ($array)
@@ -92,7 +92,7 @@ class ldapFilter
   static function parse ($filter)
   {
     // Remove starting and ending parenthesis
-    $filter = preg_replace(['/^\\s*\\(/', '/\\)\\s*$/'], '', $filter);
+    $filter = preg_replace(['/^\\s*\\(/', '/\\)\\s*$/'], '', (string) $filter);
 
     if (in_array($filter[0], ldapFilter::$operators)) {
       $subfilters = [];
@@ -121,7 +121,7 @@ class ldapFilter
       } else {
         return new ldapFilter($filter[0], $subfilters);
       }
-    } elseif (preg_match('/^([^\\(\\)\\=\\>\\<]+)('.join('|', ldapFilterLeaf::$operators).')([^\\(\\)]*)$/', $filter, $m)) {
+    } elseif (preg_match('/^([^\\(\\)\\=\\>\\<]+)('.implode('|', ldapFilterLeaf::$operators).')([^\\(\\)]*)$/', $filter, $m)) {
       return new ldapFilterLeaf($m[1], $m[2], $m[3]);
     } else {
       throw new FusionDirectoryException('Failed to parse '.$filter);
@@ -132,7 +132,7 @@ class ldapFilter
 /*!
  * \brief Leaf of an LDAP filter, for instance (objectClass=*)
  */
-class ldapFilterLeaf extends ldapFilter
+class ldapFilterLeaf extends ldapFilter implements \Stringable
 {
   static $operators = ['=','~=','>=','<='];
 
@@ -141,21 +141,21 @@ class ldapFilterLeaf extends ldapFilter
 
   function __construct ($left, $operator, $right)
   {
-    if (@strrpos($left, ':dn:', -4) !== FALSE) {
+    if (@strrpos((string) $left, ':dn:', -4) !== FALSE) {
       $this->dnFilter = TRUE;
-      $left = substr($left, 0, -4);
+      $left = substr((string) $left, 0, -4);
     }
     parent::__construct($operator, [$left, $right]);
     if (($this->operator == '=') || ($this->operator == '~=')) {
       $prefix = '';
       $suffix = '';
-      if (preg_match('/^\\*/', $this->subparts[1])) {
+      if (preg_match('/^\\*/', (string) $this->subparts[1])) {
         $prefix = '.*';
       }
-      if (preg_match('/\\*$/', $this->subparts[1])) {
+      if (preg_match('/\\*$/', (string) $this->subparts[1])) {
         $suffix = '.*';
       }
-      $search = preg_replace(['/^\\*/','/\\*$/'], '', $this->subparts[1]);
+      $search = preg_replace(['/^\\*/','/\\*$/'], '', (string) $this->subparts[1]);
       if ($this->dnFilter) {
         $this->pattern = '/'.$left.'='.$prefix.preg_quote($search, '/').$suffix.',/';
       } elseif ($this->subparts[1] == '*') {
@@ -171,7 +171,7 @@ class ldapFilterLeaf extends ldapFilter
     return $this->dnFilter;
   }
 
-  function __toString ()
+  function __toString (): string
   {
     return '('.$this->subparts[0].($this->dnFilter ? ':dn:' : '').$this->operator.$this->subparts[1].')';
   }
@@ -198,7 +198,7 @@ class ldapFilterLeaf extends ldapFilter
           case '~=':
             trigger_error('Filter apply might not work as expected');
           case '=':
-            if (preg_match($this->pattern, $value)) {
+            if (preg_match($this->pattern, (string) $value)) {
               return TRUE;
             }
             break;
diff --git a/include/class_ldapSizeLimit.inc b/include/class_ldapSizeLimit.inc
index 20c8e1922a379f34f7b1d5459a0e61592f826a01..614c3034b5c795d19934976561c98d53dfe83a30 100755
--- a/include/class_ldapSizeLimit.inc
+++ b/include/class_ldapSizeLimit.inc
@@ -44,7 +44,7 @@ class ldapSizeLimit
     global $config;
 
     $this->sizeLimit  = $config->get_cfg_value('LDAPSIZELIMIT', 200);
-    $this->ignore     = preg_match('/true/i', $config->get_cfg_value('LDAPSIZEIGNORE', 'TRUE'));
+    $this->ignore     = preg_match('/true/i', (string) $config->get_cfg_value('LDAPSIZEIGNORE', 'TRUE'));
   }
 
   function getSizeLimit ()
diff --git a/include/class_logging.inc b/include/class_logging.inc
index 8cc6b4638ff993e6f71164a238d34b2564efe017..c14ba408b0d237b8633f9fb5a9218c81f61ad2ee 100755
--- a/include/class_logging.inc
+++ b/include/class_logging.inc
@@ -144,7 +144,7 @@ class logging
         fusiondirectory_log($logline);
       }
 
-      if (($_SERVER['REQUEST_METHOD'] == 'POST') && preg_match('/index.php$/', $_SERVER['REQUEST_URI'])) {
+      if (($_SERVER['REQUEST_METHOD'] == 'POST') && preg_match('/index.php$/', (string) $_SERVER['REQUEST_URI'])) {
         return;
       }
 
diff --git a/include/class_objects.inc b/include/class_objects.inc
index 42358dce9fac0b47d7c57a8e92ac02dc8efd0e0d..3843768c8512ded252a7d252414a6219e8c099c5 100755
--- a/include/class_objects.inc
+++ b/include/class_objects.inc
@@ -91,7 +91,7 @@ class objects
       }
       foreach ($search_attrs as $search_attr) {
         //Below str_replace allows us to remove the options, resulting in proper ACL inspection. (ACLs do not take options).
-        $search_attr = preg_replace('/;x-.*/', '', $search_attr);
+        $search_attr = preg_replace('/;x-.*/', '', (string) $search_attr);
         $category = $ui->getAttributeCategory($types[0], $search_attr);
         if ($category === FALSE) {
           throw new FusionDirectoryException('Could not find ACL for attribute "'.$search_attr.'" for type "'.$types[0].'"');
@@ -99,7 +99,7 @@ class objects
         if ($category === TRUE) {
           continue;
         }
-        if (strpos($ui->get_permissions($ou, $category, $search_attr), 'r') === FALSE) {
+        if (!str_contains((string) $ui->get_permissions($ou, $category, $search_attr), 'r')) {
           $attrsAcls[$search_attr] = [$category, $search_attr];
         }
       }
@@ -117,18 +117,18 @@ class objects
 
     try {
       $ldap = static::search($types, $search_attrs, $ou, $filter, $checkAcl, $scope, $templateSearch, $partialFilterAcls, $sizeLimit);
-    } catch (NonExistingBranchException $e) {
+    } catch (NonExistingBranchException) {
       return [];
     }
     $result = [];
     while ($fetched_attrs = $ldap->fetch()) {
       $key = $fetched_attrs['dn'];
       if ($checkAcl) {
-        if (strpos($ui->get_permissions($key, $acl), 'r') === FALSE) {
+        if (!str_contains((string) $ui->get_permissions($key, $acl), 'r')) {
           continue;
         }
         foreach ($partialFilterAcls as $partialFilterAcl) {
-          if (strpos($ui->get_permissions($key, $partialFilterAcl[0], $partialFilterAcl[1]), 'r') === FALSE) {
+          if (!str_contains((string) $ui->get_permissions($key, $partialFilterAcl[0], $partialFilterAcl[1]), 'r')) {
             continue 2;
           }
         }
@@ -138,7 +138,7 @@ class objects
         foreach ($attrs as $attr => $mode) {
           if (isset($fetched_attrs[$attr])) {
             if (isset($attrsAcls[$attr]) &&
-                (strpos($ui->get_permissions($key, $attrsAcls[$attr][0], $attrsAcls[$attr][1]), 'r') === FALSE)) {
+                (!str_contains((string) $ui->get_permissions($key, $attrsAcls[$attr][0], $attrsAcls[$attr][1]), 'r'))) {
               continue;
             }
             switch ($mode) {
@@ -160,16 +160,16 @@ class objects
         if ($templateSearch) {
           if (
               isset($fetched_attrs['cn']) &&
-              (!$checkAcl || (strpos($ui->get_permissions($key, $tplAcl, 'template_cn'), 'r') !== FALSE))
+              (!$checkAcl || (str_contains((string) $ui->get_permissions($key, $tplAcl, 'template_cn'), 'r')))
             ) {
             $result[$key]['cn'] = $fetched_attrs['cn'][0];
           }
           $result[$key]['fdTemplateField'] = [];
           foreach ($fetched_attrs['fdTemplateField'] as $templateField) {
-            $attr = explode(':', $templateField, 2)[0];
+            $attr = explode(':', (string) $templateField, 2)[0];
             if (isset($attrs[$attr])) {
               if (isset($attrsAcls[$attr]) &&
-                  (strpos($ui->get_permissions($key, $attrsAcls[$attr][0], $attrsAcls[$attr][1]), 'r') === FALSE)) {
+                  (!str_contains((string) $ui->get_permissions($key, $attrsAcls[$attr][0], $attrsAcls[$attr][1]), 'r'))) {
                 continue;
               }
               $result[$key]['fdTemplateField'][] = $templateField;
@@ -186,17 +186,17 @@ class objects
         if ($attrs == 'cn') {
           if (
               isset($fetched_attrs['cn']) &&
-              (!$checkAcl || (strpos($ui->get_permissions($key, $tplAcl, 'template_cn'), 'r') !== FALSE))
+              (!$checkAcl || (str_contains((string) $ui->get_permissions($key, $tplAcl, 'template_cn'), 'r')))
             ) {
             $result[$key] = $fetched_attrs['cn'][0];
           }
         } else {
           if (isset($attrsAcls[$attrs]) &&
-              (strpos($ui->get_permissions($key, $attrsAcls[$attrs][0], $attrsAcls[$attrs][1]), 'r') === FALSE)) {
+              (!str_contains((string) $ui->get_permissions($key, $attrsAcls[$attrs][0], $attrsAcls[$attrs][1]), 'r'))) {
             continue;
           }
           foreach ($fetched_attrs['fdTemplateField'] as $templateField) {
-            list($attr, $value) = explode(':', $templateField, 2);
+            list($attr, $value) = explode(':', (string) $templateField, 2);
             if ($attrs == $attr) {
               $result[$key] = $value;
               break;
@@ -205,7 +205,7 @@ class objects
         }
       } elseif (isset($fetched_attrs[$attrs])) {
         if (isset($attrsAcls[$attrs]) &&
-            (strpos($ui->get_permissions($key, $attrsAcls[$attrs][0], $attrsAcls[$attrs][1]), 'r') === FALSE)) {
+            (!str_contains((string) $ui->get_permissions($key, $attrsAcls[$attrs][0], $attrsAcls[$attrs][1]), 'r'))) {
           continue;
         }
         $result[$key] = $fetched_attrs[$attrs][0];
@@ -231,9 +231,9 @@ class objects
       if (!empty($partialFilterAcls)) {
         throw new FusionDirectoryException('Not enough rights to use "'.$partialFilterAcls[0][1].'" in filter');
       }
-    } catch (EmptyFilterException $e) {
+    } catch (EmptyFilterException) {
       return 0;
-    } catch (NonExistingBranchException $e) {
+    } catch (NonExistingBranchException) {
       return 0;
     }
     return $ldap->count();
@@ -278,7 +278,7 @@ class objects
       throw new NonExistingBranchException($ou);
     }
     if (empty($filter)) {
-      $filter = '(|'.implode($typeFilters).')';
+      $filter = '(|'.implode('', $typeFilters).')';
     } else {
       if ($checkAcl) {
         if (count($types) > 1) {
@@ -295,7 +295,7 @@ class objects
           if ($category === TRUE) {
             continue;
           }
-          if (strpos($ui->get_permissions($ou, $category, $acl), 'r') === FALSE) {
+          if (!str_contains((string) $ui->get_permissions($ou, $category, $acl), 'r')) {
             $partialFilterAcls[] = [$category, $acl];
           }
         }
@@ -303,7 +303,7 @@ class objects
       if (!preg_match('/^\(.*\)$/', $filter)) {
         $filter = '('.$filter.')';
       }
-      $filter = '(&'.$filter.'(|'.implode($typeFilters).'))';
+      $filter = '(&'.$filter.'(|'.implode('', $typeFilters).'))';
     }
     if ($templateSearch) {
       $templateFilterObject = new ldapFilter(
@@ -441,12 +441,12 @@ class objects
       if (empty($infos['ou'])) {
         $infos['filterRDN'] = '';
       } else {
-        $parts = ldap_explode_dn(preg_replace('/,$/', '', $infos['ou']), 0);
+        $parts = ldap_explode_dn(preg_replace('/,$/', '', (string) $infos['ou']), 0);
         if ($parts !== FALSE) {
           unset($parts['count']);
           $dnFilter = [];
           foreach ($parts as $part) {
-            preg_match('/([^=]+)=(.*)$/', $part, $m);
+            preg_match('/([^=]+)=(.*)$/', (string) $part, $m);
             $dnFilter[] = '('.$m[1].':dn:='.$m[2].')';
           }
           if (count($dnFilter) > 1) {
@@ -532,14 +532,14 @@ class objects
       // Search all templates from the current dn.
       try {
         $ldap = static::search($type, ['cn'], $infos['ou'].$value, $filter, FALSE, 'subtree', TRUE);
-      } catch (NonExistingBranchException $e) {
+      } catch (NonExistingBranchException) {
         continue;
       }
       if ($ldap->count() != 0) {
         while ($attrs = $ldap->fetch()) {
           $dn = $attrs['dn'];
           if (($requiredPermissions != '')
-            && !preg_match('/'.$requiredPermissions.'/', $ui->get_permissions($dn, $infos['aclCategory'].'/'.'template'))) {
+            && !preg_match('/'.$requiredPermissions.'/', (string) $ui->get_permissions($dn, $infos['aclCategory'].'/'.'template'))) {
             continue;
           }
           $templates[$dn] = $attrs['cn'][0].' - '.$key;
diff --git a/include/class_passwordRecovery.inc b/include/class_passwordRecovery.inc
index 47b3d01520f5db9f87636a0aff1b40c89334487e..62d98c91c75b57eccdf1ea7c630f5b8595031802 100755
--- a/include/class_passwordRecovery.inc
+++ b/include/class_passwordRecovery.inc
@@ -245,7 +245,7 @@ class passwordRecovery extends standAlonePage
     if (class_available('supannAccount') && ($config->get_cfg_value('supannPasswordRecovery', 'TRUE') == 'TRUE')) {
       $objectClasses[] = 'supannPerson';
     }
-    $filter = '(&(|(objectClass=' . join(')(objectClass=', $objectClasses) . '))(' . $this->loginAttribute . '=' . ldap_escape_f($this->login) . '))';
+    $filter = '(&(|(objectClass=' . implode(')(objectClass=', $objectClasses) . '))(' . $this->loginAttribute . '=' . ldap_escape_f($this->login) . '))';
     $ldap->cd($config->current['BASE']);
     $ldap->search($filter, ['dn']);
 
@@ -345,9 +345,9 @@ class passwordRecovery extends standAlonePage
     }
 
     $reinit_link = URL::getPageURL();
-    $reinit_link .= '?uniq=' . urlencode($token);
-    $reinit_link .= '&login=' . urlencode($this->login);
-    $reinit_link .= '&email_address=' . urlencode($this->email_address);
+    $reinit_link .= '?uniq=' . urlencode((string) $token);
+    $reinit_link .= '&login=' . urlencode((string) $this->login);
+    $reinit_link .= '&email_address=' . urlencode((string) $this->email_address);
 
     logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $reinit_link, 'Setting link to');
 
diff --git a/include/class_pluglist.inc b/include/class_pluglist.inc
index 78d652011fa213284b7255f06e3d6480f3273fb2..e27708ec5083ecedd5283b379d70ec53c42fb953 100755
--- a/include/class_pluglist.inc
+++ b/include/class_pluglist.inc
@@ -275,7 +275,7 @@ class pluglist
                  <plugin acl="user/user:self" class="user"...  */
       if (preg_match("/:self$/", $acl_to_check)) {
         $acl_to_check = preg_replace("/:self$/", "", $acl_to_check);
-        if (strpos($acl_to_check, '/')) {
+        if (strpos((string) $acl_to_check, '/')) {
           if ($ui->get_permissions($ui->dn, $acl_to_check, "") != "") {
             $this->silly_cache[$aclname] = TRUE;
             return TRUE;
@@ -394,7 +394,7 @@ class pluglist
     } else {
       $plug = "NOTHING";
     }
-    $lines  = preg_split("/\n/", $this->menu);
+    $lines  = preg_split("/\n/", (string) $this->menu);
     foreach ($lines as &$line) {
       if (preg_match('/'.preg_quote("main.php?plug=$plug&amp;reset=1", '/').'/', $line)) {
         $line = preg_replace('/class="menuitem"/', 'class="menuitem menucurrent"', $line);
@@ -405,7 +405,7 @@ class pluglist
     unset($line);
 
     /* Write menu output */
-    $this->menu = join("\n", $lines);
+    $this->menu = implode("\n", $lines);
   }
 
   /*!
@@ -441,8 +441,8 @@ class pluglist
           }
 
           /* Load icon */
-          if (isset($info['CLASS']) && !preg_match("/\//", $plIcon) && !preg_match("/^geticon/", $plIcon)) {
-            $image = get_template_path('plugins/'.preg_replace('%^.*/([^/]+)/[^/]+$%', '\1', $class_mapping[$info['CLASS']]).'/images/'.$plIcon);
+          if (isset($info['CLASS']) && !preg_match("/\//", (string) $plIcon) && !preg_match("/^geticon/", (string) $plIcon)) {
+            $image = get_template_path('plugins/'.preg_replace('%^.*/([^/]+)/[^/]+$%', '\1', (string) $class_mapping[$info['CLASS']]).'/images/'.$plIcon);
           } else {
             $image = $plIcon;
           }
diff --git a/include/class_session.inc b/include/class_session.inc
index 5db5e9aabdd094e73c779735f3ea0ace681455b4..b7b48276a2e7dd3658da2fdb8d0a022d91375138 100755
--- a/include/class_session.inc
+++ b/include/class_session.inc
@@ -165,13 +165,13 @@ class session
 
     /* Check for changed browsers and bail out */
     if (isset($_SESSION['HTTP_USER_AGENT'])) {
-      if ($_SESSION['HTTP_USER_AGENT'] != md5($_SERVER['HTTP_USER_AGENT'])) {
+      if ($_SESSION['HTTP_USER_AGENT'] != md5((string) $_SERVER['HTTP_USER_AGENT'])) {
         session_destroy();
         session_name("FusionDirectory");
         session_start();
       }
     } else {
-      $_SESSION['HTTP_USER_AGENT'] = md5($_SERVER['HTTP_USER_AGENT']);
+      $_SESSION['HTTP_USER_AGENT'] = md5((string) $_SERVER['HTTP_USER_AGENT']);
     }
 
     /* Regenerate ID to increase security */
@@ -210,7 +210,7 @@ class session
           sprintf('Session destroyed (%s)', $reason)
         );
       }
-    } catch (Exception $e) {
+    } catch (Exception) {
       /* Ignore exceptions here */
     }
     @session_destroy();
diff --git a/include/class_standAlonePage.inc b/include/class_standAlonePage.inc
index 91ac1aab6429f6821d6a55014713e0982ad538b3..fca1e66bb2f3cb2c665ad20d5c9c91d104f4adf2 100755
--- a/include/class_standAlonePage.inc
+++ b/include/class_standAlonePage.inc
@@ -49,7 +49,7 @@ abstract class standAlonePage
         $this->directories[$key] = $key;
       }
 
-      $ui = new userinfoNoAuth(get_class($this));
+      $ui = new userinfoNoAuth(static::class);
       session::set('ui', $ui);
     }
 
@@ -188,7 +188,7 @@ abstract class standAlonePage
 
     $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', '');
     }
@@ -224,7 +224,7 @@ abstract class standAlonePage
   {
     $params = '';
     foreach ($keys as $key) {
-      $params .= "&amp;$key=".urlencode($this->$key);
+      $params .= "&amp;$key=".urlencode((string) $this->$key);
     }
     return preg_replace('/^&amp;/', '?', $params);
   }
diff --git a/include/class_template.inc b/include/class_template.inc
index f971eb40ea9105be31b350ca16cd7e0c50f20e22..2bd2f0a7559a700adfe3b69a1c7c70a36e073b56 100755
--- a/include/class_template.inc
+++ b/include/class_template.inc
@@ -314,7 +314,7 @@ class template implements FusionDirectoryDialog
     if ($targetdn !== NULL) {
       $this->tabObject = objects::open($targetdn, $this->type);
       unset($this->attrs['objectClass']['count']);
-      foreach ($this->tabObject->by_object as $class => $plugin) {
+      foreach ($this->tabObject->by_object as $plugin) {
         if ($plugin->isActive()) {
           $this->attrs['objectClass'] = $plugin->mergeObjectClasses($this->attrs['objectClass']);
         }
@@ -352,7 +352,7 @@ class template implements FusionDirectoryDialog
     $ui           = get_userinfo();
     $specialAttrs = [];
     foreach (static::$uiSpecialAttributes as $attr) {
-      $specialAttrs['caller'.strtoupper($attr)] = $ui->$attr;
+      $specialAttrs['caller'.strtoupper((string) $attr)] = $ui->$attr;
     }
     $this->attrs = templateHandling::parseArray($this->attrs, $specialAttrs, $targetdn);
     $this->tabObject->adapt_from_template($this->attrs, array_merge([], ...array_values($this->attributes)));
diff --git a/include/class_templateHandling.inc b/include/class_templateHandling.inc
index 3e30a4251dc2d3664a8118f79823863e8d6b3d5f..96f7f82cf3cff3f5e75228022313f9c7a185799c 100755
--- a/include/class_templateHandling.inc
+++ b/include/class_templateHandling.inc
@@ -50,7 +50,7 @@ class templateHandling
       unset($template_attrs['fdTemplateField']['count']);
       sort($template_attrs['fdTemplateField']);
       foreach ($template_attrs['fdTemplateField'] as $field) {
-        if (!preg_match('/^([^:]+):(.*)$/s', $field, $m)) {
+        if (!preg_match('/^([^:]+):(.*)$/s', (string) $field, $m)) {
           throw new FusionDirectoryException('Template field does not match format');
         }
         if (isset($attrs[$m[1]])) {
@@ -83,7 +83,7 @@ class templateHandling
 
     /* Remove all concerned values */
     foreach ($template_attrs['fdTemplateField'] as $key => $value) {
-      preg_match('/^([^:]+):(.*)$/s', $value, $m);
+      preg_match('/^([^:]+):(.*)$/s', (string) $value, $m);
       if (isset($attrs[$m[1]])) {
         unset($template_attrs['fdTemplateField'][$key]);
       }
@@ -307,7 +307,7 @@ class templateHandling
   {
     $fields = [];
     $offset = 0;
-    while (preg_match('/%([^%]+)%/', $string, $m, PREG_OFFSET_CAPTURE, $offset)) {
+    while (preg_match('/%([^%]+)%/', (string) $string, $m, PREG_OFFSET_CAPTURE, $offset)) {
       $mask   = $m[1][0];
       $offset = $m[0][1] + strlen($m[0][0]);
       if ($mask == '|') {
@@ -328,21 +328,21 @@ class templateHandling
       $mode = $args[0];
     }
 
-    $str = htmlentities($str, ENT_NOQUOTES, 'UTF-8');
+    $str = htmlentities((string) $str, ENT_NOQUOTES, 'UTF-8');
 
     $str = preg_replace('#&([A-za-z])(?:acute|cedil|circ|grave|orn|ring|slash|th|tilde|uml);#', '\1', $str);
     // handle ligatures
-    $str = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $str);
+    $str = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', (string) $str);
     // delete unhandled characters
-    $str = preg_replace('#&[^;]+;#', '', $str);
+    $str = preg_replace('#&[^;]+;#', '', (string) $str);
 
     if ($mode === 'ascii') {
       return [$str];
     } elseif ($mode === 'uid') {
       if (strict_uid_mode()) {
-        $str = preg_replace('/[^a-z0-9_-]/', '', mb_strtolower($str, 'UTF-8'));
+        $str = preg_replace('/[^a-z0-9_-]/', '', mb_strtolower((string) $str, 'UTF-8'));
       } else {
-        $str = preg_replace('/[^a-zA-Z0-9 _.-]/', '', $str);
+        $str = preg_replace('/[^a-zA-Z0-9 _.-]/', '', (string) $str);
       }
       return [$str];
     } else {
@@ -356,7 +356,7 @@ class templateHandling
     $ret = [];
     foreach ($args as $arg) {
       setlocale(LC_CTYPE, [$arg,"$arg.UTF8"]);
-      $ret[] = iconv('UTF8', 'ASCII//TRANSLIT', $str);
+      $ret[] = iconv('UTF8', 'ASCII//TRANSLIT', (string) $str);
     }
     setlocale(LC_CTYPE, $localesaved);
     return array_unique($ret);
@@ -373,7 +373,7 @@ class templateHandling
       }
     }
 
-    return [preg_replace($pattern.'u', $replace, $str)];
+    return [preg_replace($pattern.'u', (string) $replace, (string) $str)];
   }
 
   private static function modifierSubString (array $args, $str)
@@ -384,14 +384,14 @@ class templateHandling
     if (count($args) < 2) {
       array_unshift($args, 0);
     }
-    if (preg_match('/^(\d+)-(\d+)$/', $args[1], $m)) {
+    if (preg_match('/^(\d+)-(\d+)$/', (string) $args[1], $m)) {
       $res = [];
       for ($i = $m[1];$i <= $m[2]; ++$i) {
-        $res[] = mb_substr($str, $args[0], $i);
+        $res[] = mb_substr((string) $str, $args[0], $i);
       }
       return array_unique($res);
     } else {
-      return [mb_substr($str, $args[0], $args[1])];
+      return [mb_substr((string) $str, $args[0], $args[1])];
     }
   }
 
@@ -518,7 +518,7 @@ class templateHandling
     if (empty($json)) {
       $modifierStates = [];
     } else {
-      $modifierStates = json_decode($json, TRUE);
+      $modifierStates = json_decode((string) $json, TRUE);
     }
     if (isset($modifierStates[$args[0]])) {
       $value = $modifierStates[$args[0]]['value'] + $args[2];
@@ -541,7 +541,7 @@ class templateHandling
 
   private static function modifierTitleCase ($str)
   {
-    return [mb_convert_case($str, MB_CASE_TITLE, 'UTF-8')];
+    return [mb_convert_case((string) $str, MB_CASE_TITLE, 'UTF-8')];
   }
 
   /*! \brief Apply a modifier
@@ -576,9 +576,9 @@ class templateHandling
       case 'J':
         // Join
         if (isset($args[0])) {
-          $result = [join($args[0], $str)];
+          $result = [implode($args[0], $str)];
         } else {
-          $result = [join($str)];
+          $result = [implode('', $str)];
         }
         break;
       case 'C':
@@ -614,17 +614,17 @@ class templateHandling
       case 'b':
         // base64
         if (isset($args[0]) && ($args[0] == 'd')) {
-          $result = [base64_decode($str)];
+          $result = [base64_decode((string) $str)];
         }
-        $result = [base64_encode($str)];
+        $result = [base64_encode((string) $str)];
         break;
       case 'u':
         // uppercase
-        $result = [mb_strtoupper($str, 'UTF-8')];
+        $result = [mb_strtoupper((string) $str, 'UTF-8')];
         break;
       case 'l':
         // lowercase
-        $result = [mb_strtolower($str, 'UTF-8')];
+        $result = [mb_strtolower((string) $str, 'UTF-8')];
         break;
       case 'a':
         // remove accent
@@ -718,7 +718,7 @@ class templateHandling
       unset($values['count']);
       foreach ($values as $value) {
         $offset = 0;
-        while (preg_match('/%([^%\|]+\|)?([^%]+)%/', $value, $m, PREG_OFFSET_CAPTURE, $offset)) {
+        while (preg_match('/%([^%\|]+\|)?([^%]+)%/', (string) $value, $m, PREG_OFFSET_CAPTURE, $offset)) {
           $offset = $m[0][1] + strlen($m[0][0]);
           $depends[$key][] = $m[2][0];
           if (!isset($attrs[$m[2][0]])) {
diff --git a/include/class_tests.inc b/include/class_tests.inc
index aefb4c58ed92740da93b857568ef975bc11c1114..62f471e5e35e1a5ed81d7cce1766c4db996132db 100755
--- a/include/class_tests.inc
+++ b/include/class_tests.inc
@@ -51,7 +51,7 @@ class tests
       return TRUE;
     }
 
-    return preg_match("/^[\/0-9 ()+*-]+$/", $nr);
+    return preg_match("/^[\/0-9 ()+*-]+$/", (string) $nr);
   }
 
 
@@ -62,7 +62,7 @@ class tests
    */
   public static function is_dns_name ($str)
   {
-    return preg_match("/^[a-z0-9\.\-_]*$/i", $str);
+    return preg_match("/^[a-z0-9\.\-_]*$/i", (string) $str);
   }
 
 
@@ -73,7 +73,7 @@ class tests
    */
   public static function is_valid_hostname ($str)
   {
-    return preg_match("/^[a-z0-9\.\-]*$/i", $str);
+    return preg_match("/^[a-z0-9\.\-]*$/i", (string) $str);
   }
 
 
@@ -89,7 +89,7 @@ class tests
     }
 
     /* Using @stephenhay regexp from http://mathiasbynens.be/demo/url-regex (removed ftp through) */
-    return preg_match("@^(https?)://[^\s/$.?#].[^\s]*$@i", $url);
+    return preg_match("@^(https?)://[^\s/$.?#].[^\s]*$@i", (string) $url);
   }
 
 
@@ -104,7 +104,7 @@ class tests
       return TRUE;
     }
 
-    return preg_match("/^[a-z0-9 _-]+$/i", $dn);
+    return preg_match("/^[a-z0-9 _-]+$/i", (string) $dn);
   }
 
 
@@ -122,9 +122,9 @@ class tests
     /* STRICT adds spaces and case insenstivity to the uid check.
        This is dangerous and should not be used. */
     if (strict_uid_mode()) {
-      return preg_match("/^[a-z0-9_-]+$/", $uid);
+      return preg_match("/^[a-z0-9_-]+$/", (string) $uid);
     } else {
-      return preg_match("/^[a-z0-9 _.-]+$/i", $uid);
+      return preg_match("/^[a-z0-9 _.-]+$/i", (string) $uid);
     }
   }
 
@@ -166,7 +166,7 @@ class tests
    */
   public static function is_mac ($mac)
   {
-    return preg_match('/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/', $mac);
+    return preg_match('/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/', (string) $mac);
   }
 
 
@@ -200,11 +200,11 @@ class tests
     if (preg_match("/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.".
                     "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.".
                     "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.".
-                    "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/", $ip)) {
+                    "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/", (string) $ip)) {
       $mask = preg_replace("/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.".
               "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.".
               "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.".
-              "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/", "", $ip);
+              "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/", "", (string) $ip);
 
       $mask = preg_replace("/^\//", "", $mask);
       if ((in_array("$mask", $res)) && preg_match("/^[0-9\.]/", $mask)) {
@@ -224,7 +224,7 @@ class tests
    */
   public static function is_domain ($str)
   {
-    return preg_match("/^(([a-z0-9\-]{2,63})\.)*[a-z]{2,63}$/i", $str);
+    return preg_match("/^(([a-z0-9\-]{2,63})\.)*[a-z]{2,63}$/i", (string) $str);
   }
 
 
@@ -239,7 +239,7 @@ class tests
       return FALSE;
     }
 
-    return preg_match("/^[0-9]+$/", $id);
+    return preg_match("/^[0-9]+$/", (string) $id);
   }
 
 
@@ -253,11 +253,11 @@ class tests
     if ($path == "") {
       return TRUE;
     }
-    if (!preg_match('/^[a-z0-9%\/_.+-]+$/i', $path)) {
+    if (!preg_match('/^[a-z0-9%\/_.+-]+$/i', (string) $path)) {
       return FALSE;
     }
 
-    return preg_match("/\/.+$/", $path);
+    return preg_match("/\/.+$/", (string) $path);
   }
 
 
@@ -310,10 +310,10 @@ class tests
     if (!tests::is_ipv4($ip1) || !tests::is_ipv4($ip2)) {
       return FALSE;
     } else {
-      $ar1  = array_map('intval', explode('.', $ip1));
+      $ar1  = array_map('intval', explode('.', (string) $ip1));
       $var1 = $ar1[0] * (16777216) + $ar1[1] * (65536) + $ar1[2] * (256) + $ar1[3];
 
-      $ar2  = array_map('intval', explode('.', $ip2));
+      $ar2  = array_map('intval', explode('.', (string) $ip2));
       $var2 = $ar2[0] * (16777216) + $ar2[1] * (65536) + $ar2[2] * (256) + $ar2[3];
       return ($var1 < $var2);
     }
@@ -331,9 +331,9 @@ class tests
    */
   public static function is_in_network ($network, $netmask, $address)
   {
-    $nw = array_map('intval', explode('.', $network));
-    $nm = array_map('intval', explode('.', $netmask));
-    $ad = array_map('intval', explode('.', $address));
+    $nw = array_map('intval', explode('.', (string) $network));
+    $nm = array_map('intval', explode('.', (string) $netmask));
+    $ad = array_map('intval', explode('.', (string) $address));
 
     /* Generate inverted netmask */
     $ni = [];
@@ -354,9 +354,9 @@ class tests
   /* \brief Check if the specified IPv4 address $address is inside the given network */
   public static function is_in_ip_range ($from, $to, $address)
   {
-    $from = array_map('intval', explode('.', $from));
-    $to   = array_map('intval', explode('.', $to));
-    $ad   = array_map('intval', explode('.', $address));
+    $from = array_map('intval', explode('.', (string) $from));
+    $to   = array_map('intval', explode('.', (string) $to));
+    $ad   = array_map('intval', explode('.', (string) $address));
 
     /* Transform to integer */
     $from = $from[0] * (16777216) + $from[1] * (65536) + $from[2] * (256) + $from[3];
@@ -370,7 +370,7 @@ class tests
   public static function is_orcid ($orcid)
   {
     /* Remove hyphens, remove last digit, convert to array */
-    $baseDigits = str_split(str_replace('-', '', substr($orcid, 0, -1)));
+    $baseDigits = str_split(str_replace('-', '', substr((string) $orcid, 0, -1)));
     $sum = 0;
     foreach ($baseDigits as $baseDigit) {
       $sum = ($sum + (int)$baseDigit) * 2;
@@ -379,6 +379,6 @@ class tests
     $result     = (12 - $remainder) % 11;
     $orcidCheckSum = (($result == 10) ? "X" : (string)$result);
 
-    return ($orcidCheckSum != substr($orcid, -1));
+    return ($orcidCheckSum != substr((string) $orcid, -1));
   }
 }
diff --git a/include/class_timezone.inc b/include/class_timezone.inc
index 8ca62f9ed73ea0e54ba4e54d178af56dec42e698..80c6a111f068fc5ec98572ee798d6bee4044eb59 100755
--- a/include/class_timezone.inc
+++ b/include/class_timezone.inc
@@ -78,7 +78,7 @@ class timezone
     if (static::setDefaultTimezoneFromConfig()) {
       $tz       = $config->get_cfg_value('timezone');
       $tz_delta = date('Z', $stamp);
-      $tz_delta = $tz_delta / 3600;
+      $tz_delta /= 3600;
       return ['name' => $tz, 'value' => $tz_delta];
     } else {
       return ['name' => 'unconfigured', 'value' => 0];
diff --git a/include/class_userinfo.inc b/include/class_userinfo.inc
index 305ecae99ccd32f0be9f6b067ef5685317f747a6..d6d4b8941dca8d8e496e5900ef0fb746654ddc81 100755
--- a/include/class_userinfo.inc
+++ b/include/class_userinfo.inc
@@ -215,7 +215,7 @@ class userinfo
               }
               break;
             case 'U':
-              if (mb_strtolower($memberDn) === mb_strtolower($this->dn)) {
+              if (mb_strtolower($memberDn) === mb_strtolower((string) $this->dn)) {
                 $interesting = TRUE;
                 break 2;
               }
@@ -307,7 +307,7 @@ class userinfo
     foreach ($this->ACL as $dn => $acl) {
       $all_acl[$dn][$dn] = $acl;
       $sdn = $dn;
-      while (strpos($dn, ',') !== FALSE) {
+      while (str_contains($dn, ',')) {
         $dn = preg_replace('/^[^,]*+,/', '', $dn);
         if (isset($this->ACL[$dn])) {
           $all_acl[$sdn][$dn] = array_filter(
@@ -324,8 +324,8 @@ class userinfo
 
     /* Append Self entry */
     $dn = $this->dn;
-    while (strpos($dn, ',') && !isset($all_acl[$dn])) {
-      $dn = preg_replace('/^[^,]*+,/', '', $dn);
+    while (strpos((string) $dn, ',') && !isset($all_acl[$dn])) {
+      $dn = preg_replace('/^[^,]*+,/', '', (string) $dn);
     }
     if (isset($all_acl[$dn])) {
       $this->ACLperPath[$this->dn] = $all_acl[$dn];
@@ -382,7 +382,7 @@ class userinfo
   */
   function is_copyable ($dn, $object): bool
   {
-    return (strpos($this->get_complete_category_acls($dn, $object), 'r') !== FALSE);
+    return (str_contains((string) $this->get_complete_category_acls($dn, $object), 'r'));
   }
 
 
@@ -399,8 +399,8 @@ class userinfo
    */
   function is_cutable ($dn, $object, $class): bool
   {
-    $remove = (strpos($this->get_permissions($dn, $object.'/'.$class), 'd') !== FALSE);
-    $read   = (strpos($this->get_complete_category_acls($dn, $object), 'r') !== FALSE);
+    $remove = (str_contains((string) $this->get_permissions($dn, $object.'/'.$class), 'd'));
+    $read   = (str_contains((string) $this->get_complete_category_acls($dn, $object), 'r'));
     return ($remove && $read);
   }
 
@@ -416,7 +416,7 @@ class userinfo
    */
   function is_pasteable ($dn, $object): bool
   {
-    return (strpos($this->get_complete_category_acls($dn, $object), 'w') !== FALSE);
+    return (str_contains((string) $this->get_complete_category_acls($dn, $object), 'w'));
   }
 
 
@@ -480,13 +480,13 @@ class userinfo
     foreach ($categories as $category) {
       $acl = $this->get_permissions($dn, $category.'/SnapshotHandler');
       foreach ($objectPermissions as $i => $perm) {
-        if (strpos($acl, $perm) === FALSE) {
+        if (!str_contains((string) $acl, $perm)) {
           unset($objectPermissions[$i]);
         }
       }
       foreach ($attributePermissions as $i => $attribute) {
         $acl = $this->get_permissions($dn, $category.'/SnapshotHandler', $attribute);
-        if (strpos($acl, 'w') === FALSE) {
+        if (!str_contains((string) $acl, 'w')) {
           unset($attributePermissions[$i]);
         }
       }
@@ -533,8 +533,8 @@ class userinfo
 
     /* Detect the set of ACLs we have to check for this object */
     $parentACLdn = $dn;
-    while (!isset($this->ACLperPath[$parentACLdn]) && (strpos($parentACLdn, ',') !== FALSE)) {
-      $parentACLdn = preg_replace('/^[^,]*+,/', '', $parentACLdn);
+    while (!isset($this->ACLperPath[$parentACLdn]) && (str_contains((string) $parentACLdn, ','))) {
+      $parentACLdn = preg_replace('/^[^,]*+,/', '', (string) $parentACLdn);
     }
     if (!isset($this->ACLperPath[$parentACLdn])) {
       $ACL_CACHE["$dn+$object+$attribute"] = '';
@@ -572,8 +572,8 @@ class userinfo
           }
 
           /* Category ACLs (e.g. $object = "user/0") */
-          if (strstr($object, '/0')) {
-            $ocs = preg_replace("/\/0$/", '', $object);
+          if (strstr((string) $object, '/0')) {
+            $ocs = preg_replace("/\/0$/", '', (string) $object);
             if (isset($config->data['CATEGORIES'][$ocs]) && ($attribute == '')) {
               foreach ($config->data['CATEGORIES'][$ocs]['classes'] as $oc) {
                 if (isset($subacl['acl'][$ocs.'/'.$oc])) {
@@ -674,7 +674,7 @@ class userinfo
             if ($skip_self_acls && isset($data[0]) && $data[0]->isSelf()) {
               continue;
             }
-            if (preg_match('/^'.preg_quote($mod, '/').'/', $cat) || ($cat === 'all')) {
+            if (preg_match('/^'.preg_quote((string) $mod, '/').'/', (string) $cat) || ($cat === 'all')) {
               /* $cat starts with $mod (example: cat=user/user and mod=user) or cat is 'all' */
               $found = TRUE;
               break;
@@ -682,8 +682,8 @@ class userinfo
           }
 
           if ($found && !isset($departmentInfo[$dn])) {
-            while (!isset($departmentInfo[$dn]) && strpos($dn, ',')) {
-              $dn = preg_replace("/^[^,]+,/", "", $dn);
+            while (!isset($departmentInfo[$dn]) && strpos((string) $dn, ',')) {
+              $dn = preg_replace("/^[^,]+,/", "", (string) $dn);
             }
             if (isset($departmentInfo[$dn])) {
               $deps[$dn] = $dn;
@@ -699,7 +699,7 @@ class userinfo
           continue;
         }
         $acl = '';
-        if (strpos($mod, '/')) {
+        if (strpos((string) $mod, '/')) {
           $acl .= $this->get_permissions($dn, $mod);
         } else {
           $acl .= $this->get_category_permissions($dn, $mod);
@@ -753,7 +753,7 @@ class userinfo
           $tmp = $this->get_permissions($dn, $category.'/'.$oc);
           $types = $acl;
           for ($i = 0, $l = strlen($types); $i < $l; $i++) {
-            if (strpos($tmp, $types[$i]) === FALSE) {
+            if (!str_contains((string) $tmp, $types[$i])) {
               $acl = str_replace($types[$i], '', $acl);
             }
           }
@@ -833,7 +833,7 @@ class userinfo
             return POSIX_WARN_ABOUT_EXPIRATION;
           }
         }
-      } catch (NonExistingLdapNodeException $e) {
+      } catch (NonExistingLdapNodeException) {
         /* ppolicy not found in LDAP */
       }
     }
@@ -940,7 +940,7 @@ class userinfo
     global $config;
     $blacklist = $config->get_cfg_value('PluginsMenuBlacklist', []);
     foreach ($blacklist as $item) {
-      list ($group, $p) = explode('|', $item, 2);
+      list ($group, $p) = explode('|', (string) $item, 2);
       if (($plugin == $p) && (in_array($group, $this->groups) || in_array($group, $this->roles))) {
         return TRUE;
       }
@@ -1022,7 +1022,7 @@ class userinfo
    */
   public static function sanitizeAttributeName ($name)
   {
-    return preg_replace('/[\/\-,.#:;]/', '_', $name);
+    return preg_replace('/[\/\-,.#:;]/', '_', (string) $name);
   }
 
   /*!
@@ -1046,7 +1046,7 @@ class userinfo
 
     $allowed_attributes = ['uid','mail'];
     $verify_attr = [];
-    $tmp = explode(',', $config->get_cfg_value('loginAttribute'));
+    $tmp = explode(',', (string) $config->get_cfg_value('loginAttribute'));
     foreach ($tmp as $attr) {
       if (in_array($attr, $allowed_attributes)) {
         $verify_attr[] = $attr;
diff --git a/include/class_xml.inc b/include/class_xml.inc
index 19020b23dd7b78562da745d3b2cce13c491d4a7e..5e21d16176264c4d96b1bc4c2e699d4c7bbd83cb 100755
--- a/include/class_xml.inc
+++ b/include/class_xml.inc
@@ -56,7 +56,7 @@ class xml
     xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8"); // http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
     xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
     xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
-    xml_parse_into_struct($parser, trim($contents), $xml_values);
+    xml_parse_into_struct($parser, trim((string) $contents), $xml_values);
     xml_parser_free($parser);
 
     if (!$xml_values) {
diff --git a/include/functions.inc b/include/functions.inc
index 0517b1b326e2a89b643dec1f1e14b010eb890c0c..bbae1843a5f0a86234f2358d3c756c4b5425cbcb 100755
--- a/include/functions.inc
+++ b/include/functions.inc
@@ -41,7 +41,7 @@ require_once('accept-to-gettext.inc');
  *  \param array $class_name list of class name
  */
 
-function fusiondirectory_autoload ($class_name)
+function fusiondirectory_autoload ($class_name): void
 {
   global $class_mapping, $BASE_DIR, $config;
 
@@ -57,11 +57,11 @@ function fusiondirectory_autoload ($class_name)
   }
 
   /* Do not try to autoload smarty classes */
-  if (strpos($class_name, 'Smarty_') === 0) {
+  if (str_starts_with((string) $class_name, 'Smarty_')) {
     return;
   }
 
-  if (strpos($class_name, 'FusionDirectory\\') === 0) {
+  if (str_starts_with((string) $class_name, 'FusionDirectory\\')) {
     $class_name = preg_replace('/^.+\\\\([^\\\\]+)$/', '\\1', "$class_name");
   }
 
@@ -138,7 +138,7 @@ function plugin_available ($plugin)
  *
  * \param string $info Optional: Additional information
  */
-function DEBUG ($level, $line, $function, $file, $data, $info = '')
+function DEBUG ($level, $line, $function, $file, $data, $info = ''): void
 {
   logging::debug($level, $line, $function, $file, $data, $info);
 }
@@ -194,7 +194,7 @@ function get_template_path ($filename = '', $plugin = FALSE, $path = '')
       $path = session::get('plugin_dir');
       $nf   = preg_replace('!^'.$BASE_DIR.'/!', '', preg_replace('/^\.\.\//', '', $path));
     } else {
-      $nf = preg_replace('!^'.$BASE_DIR.'/!', '', $path);
+      $nf = preg_replace('!^'.$BASE_DIR.'/!', '', (string) $path);
     }
     $paths = [
       "$BASE_DIR/ihtml/themes/$theme/$nf/$filename",
@@ -285,7 +285,7 @@ function array_merge_unique (array $ar1, array $ar2): array
  *
  * \param string $message the message to log
  */
-function fusiondirectory_log ($message)
+function fusiondirectory_log ($message): void
 {
   global $ui;
 
@@ -356,7 +356,7 @@ function convert_department_dn ($dn, $base = NULL)
 
   /* Build a sub-directory style list of the tree level
      specified in $dn */
-  $dn = preg_replace('/'.preg_quote($base, '/')."$/i", '', $dn);
+  $dn = preg_replace('/'.preg_quote((string) $base, '/')."$/i", '', (string) $dn);
   if (empty($dn)) {
     return '/';
   }
@@ -454,13 +454,13 @@ function get_ou ($name)
   }
 
   if ($ou != '') {
-    if (!preg_match('/^[^=]+=[^=]+/', $ou)) {
+    if (!preg_match('/^[^=]+=[^=]+/', (string) $ou)) {
       $ou = "ou=$ou";
     } else {
       $ou = "$ou";
     }
 
-    if (preg_match('/'.preg_quote($config->current['BASE'], '/').'$/', $ou)) {
+    if (preg_match('/'.preg_quote((string) $config->current['BASE'], '/').'$/', $ou)) {
       return $ou;
     } else {
       if (preg_match('/,$/', $ou)) {
@@ -502,7 +502,7 @@ function get_base_from_people ($dn)
   global $config;
 
   $pattern  = "/^[^,]+,".preg_quote(get_people_ou(), '/')."/i";
-  $base     = preg_replace($pattern, '', $dn);
+  $base     = preg_replace($pattern, '', (string) $dn);
 
   /* Set to base, if we're not on a correct subtree */
   $departmentInfo = $config->getDepartmentInfo();
@@ -615,16 +615,16 @@ function dn2base ($dn, $ou = NULL)
 {
   if ($ou === NULL) {
     if (get_people_ou() != '') {
-      $dn = preg_replace('/,'.get_people_ou().'/i', ',', $dn);
+      $dn = preg_replace('/,'.get_people_ou().'/i', ',', (string) $dn);
     }
     if (get_ou('groupRDN') != '') {
-      $dn = preg_replace('/,'.get_ou('groupRDN').'/i', ',', $dn);
+      $dn = preg_replace('/,'.get_ou('groupRDN').'/i', ',', (string) $dn);
     }
   } else {
-    $dn = preg_replace("/,$ou/i", ',', $dn);
+    $dn = preg_replace("/,$ou/i", ',', (string) $dn);
   }
 
-  return preg_replace('/^[^,]+,/i', '', $dn);
+  return preg_replace('/^[^,]+,/i', '', (string) $dn);
 }
 
 /*!
@@ -639,7 +639,7 @@ function dn2base ($dn, $ou = NULL)
  */
 function check_command ($cmdline)
 {
-  $cmd = preg_replace("/ .*$/", '', $cmdline);
+  $cmd = preg_replace("/ .*$/", '', (string) $cmdline);
 
   /* Check if command exists in filesystem */
   if (!file_exists($cmd)) {
@@ -664,7 +664,7 @@ function check_command ($cmdline)
 function normalize_netmask ($netmask)
 {
   /* Check for notation of netmask */
-  if (!preg_match('/^([0-9]+\.){3}[0-9]+$/', $netmask)) {
+  if (!preg_match('/^([0-9]+\.){3}[0-9]+$/', (string) $netmask)) {
     $num      = (int)($netmask);
     $netmask  = "";
 
@@ -713,7 +713,7 @@ function normalize_netmask ($netmask)
  */
 function netmask_to_bits ($netmask)
 {
-  $nm = explode('.', $netmask, 4);
+  $nm = explode('.', (string) $netmask, 4);
 
   $res = 0;
   for ($n = 0; $n < 4; $n++) {
@@ -745,7 +745,7 @@ function netmask_to_bits ($netmask)
  */
 function to_byte ($value)
 {
-  $value = strtolower(trim($value));
+  $value = strtolower(trim((string) $value));
 
   if (!is_numeric(substr($value, -1))) {
     switch (substr($value, -1)) {
@@ -813,7 +813,7 @@ function humanReadableSize ($bytes, $precision = 2)
  */
 function in_array_ics ($value, array $items)
 {
-  return preg_grep('/^'.preg_quote($value, '/').'$/i', $items);
+  return preg_grep('/^'.preg_quote((string) $value, '/').'$/i', $items);
 }
 
 /*!
@@ -902,7 +902,7 @@ function scan_directory ($path, $sort_desc = FALSE)
  *
  * \param string $directory smarty compile dir
  */
-function clean_smarty_compile_dir ($directory)
+function clean_smarty_compile_dir ($directory): void
 {
   if (is_dir($directory) && is_readable($directory)) {
     // Set revision filename to REVISION
@@ -955,7 +955,7 @@ function create_revision ($revision_file, $revision)
 {
   $result = FALSE;
 
-  if (is_dir(dirname($revision_file)) && is_writable(dirname($revision_file))) {
+  if (is_dir(dirname((string) $revision_file)) && is_writable(dirname((string) $revision_file))) {
     $fh = fopenWithErrorHandling($revision_file, 'w');
     if (is_array($fh)) {
       $error = new FusionDirectoryError(
@@ -968,7 +968,7 @@ function create_revision ($revision_file, $revision)
       $error->display();
       return $result;
     } else {
-      if (fwrite($fh, $revision)) {
+      if (fwrite($fh, (string) $revision)) {
         $result = TRUE;
       }
       fclose($fh);
@@ -1045,7 +1045,7 @@ function compare_revision ($revision_file, $revision)
 function array_key_ics ($ikey, array $items)
 {
   $tmp  = array_change_key_case($items, CASE_LOWER);
-  $ikey = strtolower($ikey);
+  $ikey = strtolower((string) $ikey);
   if (isset($tmp[$ikey])) {
     return $tmp[$ikey];
   }
@@ -1115,7 +1115,7 @@ function array_cmp_recursive ($src, $dst): int
     }
     return 0;
   }
-  return strcmp($src, $dst);
+  return strcmp((string) $src, (string) $dst);
 }
 
 /*!
@@ -1127,7 +1127,7 @@ function array_cmp_recursive ($src, $dst): int
 function normalizeLdap ($input)
 {
   trigger_error('deprecated, use ldap_escape_f');
-  return addcslashes($input, '*()\\/');
+  return addcslashes((string) $input, '*()\\/');
 }
 
 /*!
@@ -1360,7 +1360,7 @@ function getEntryCSN (string $dn): string
  *
  * \param  string $type The content identifier, default value is "application/octet-stream";
  */
-function send_binary_content ($data, $name, $type = "application/octet-stream")
+function send_binary_content ($data, $name, $type = "application/octet-stream"): void
 {
   header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
   header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
@@ -1370,8 +1370,8 @@ function send_binary_content ($data, $name, $type = "application/octet-stream")
   header("Content-type: ".$type);
 
   /* Strip name if it is a complete path */
-  if (preg_match("/\//", $name)) {
-    $name = basename($name);
+  if (preg_match("/\//", (string) $name)) {
+    $name = basename((string) $name);
   }
 
   /* force download dialog */
@@ -1432,7 +1432,7 @@ function cred_decrypt ($input, $password)
 {
   /************************* Inspired by Crypt/CBC.pm *******************************/
   $input = pack('H*', $input);
-  if (substr($input, 0, 8) != 'Salted__') {
+  if (!str_starts_with($input, 'Salted__')) {
     throw new FusionDirectoryException("Invalid hash header: expected 'Salted__', found '".substr($input, 0, 8)."'");
   }
   $salt   = substr($input, 8, 8);
@@ -1479,7 +1479,7 @@ function isIpInNet ($ip, $net, $mask)
 function expandIPv6 ($ip)
 {
   $hex  = unpack('H*hex', inet_pton($ip));
-  return substr(preg_replace('/([A-f0-9]{4})/', "$1:", $hex['hex']), 0, -1);
+  return substr(preg_replace('/([A-f0-9]{4})/', "$1:", (string) $hex['hex']), 0, -1);
 }
 
 /* Mark the occurance of a string with a span */
@@ -1487,7 +1487,7 @@ function mark ($needle, $haystack)
 {
   $result = '';
 
-  while (preg_match('/^(.*)('.preg_quote($needle).')(.*)$/i', $haystack, $matches)) {
+  while (preg_match('/^(.*)('.preg_quote((string) $needle).')(.*)$/i', (string) $haystack, $matches)) {
     $result   .= $matches[1].'<span class="mark">'.$matches[2].'</span>';
     $haystack = $matches[3];
   }
@@ -1495,12 +1495,12 @@ function mark ($needle, $haystack)
   return $result.$haystack;
 }
 
-function reset_errors ()
+function reset_errors (): void
 {
   session::set('errorsAlreadyPosted', []);
 }
 
-function load_all_classes ()
+function load_all_classes (): void
 {
   global $BASE_DIR, $class_list, $class_mapping;
   /* Initially load all classes */
@@ -1534,7 +1534,7 @@ function ldap_escape_dn ($str, $ignore = '')
 
 function mail_utf8 ($to, $from_user, $from_email, $subject, $message, $replyto_user = NULL, $replyto_email = NULL, $type = 'plain')
 {
-  $subject = "=?UTF-8?B?".base64_encode($subject)."?=";
+  $subject = "=?UTF-8?B?".base64_encode((string) $subject)."?=";
 
   if ($replyto_user === NULL) {
     $replyto_user = $from_user;
@@ -1545,7 +1545,7 @@ function mail_utf8 ($to, $from_user, $from_email, $subject, $message, $replyto_u
   }
 
   if ($from_user) {
-    $from_user = "=?UTF-8?B?".base64_encode($from_user)."?=";
+    $from_user = "=?UTF-8?B?".base64_encode((string) $from_user)."?=";
     $headers = "From: $from_user <$from_email>\r\n";
   } else {
     $headers = "From: <$from_email>\r\n";
@@ -1553,7 +1553,7 @@ function mail_utf8 ($to, $from_user, $from_email, $subject, $message, $replyto_u
 
   if ($replyto_email) {
     if ($replyto_user) {
-      $replyto_user = "=?UTF-8?B?".base64_encode($replyto_user)."?=";
+      $replyto_user = "=?UTF-8?B?".base64_encode((string) $replyto_user)."?=";
       $headers .= "Reply-To: $replyto_user <$replyto_email>\r\n";
     } else {
       $headers .= "Reply-To: <$replyto_email>\r\n";
@@ -1565,7 +1565,7 @@ function mail_utf8 ($to, $from_user, $from_email, $subject, $message, $replyto_u
 
   $additional_parameters = "-f".$from_email;
 
-  return mail($to, $subject, $message, $headers, $additional_parameters);
+  return mail((string) $to, $subject, (string) $message, $headers, $additional_parameters);
 }
 
 /* Calls fopen, gives errors as an array if any, file handle if successful */
diff --git a/include/functions_debug.inc b/include/functions_debug.inc
index b6e335479e43df8832f965a4786a4c9c8d6f78d4..7a4e299456e30db84fb4fc0f7444e82ac9f85be0 100755
--- a/include/functions_debug.inc
+++ b/include/functions_debug.inc
@@ -106,7 +106,7 @@ class printAClass
     if ($iteration) {
       $tmp_key_bg_color = '';
       for ($i = 0; $i < 6; $i += 2) {
-        $c = substr($key_bg_color, $i, 2);
+        $c = substr((string) $key_bg_color, $i, 2);
         $c = hexdec($c);
         $c += 15;
         if ($c > 255) {
@@ -147,14 +147,14 @@ class printAClass
           break;
 
         case 'string':
-          if ($this->look_for_leading_tabs && preg_match('/^\t/m', $value)) {
+          if ($this->look_for_leading_tabs && preg_match('/^\t/m', (string) $value)) {
             $search       = ['/\t/', "/\n/"];
             $replace      = ['&nbsp;&nbsp;&nbsp;','<br />'];
-            $value        = preg_replace($search, $replace, htmlspecialchars($value));
+            $value        = preg_replace($search, $replace, htmlspecialchars((string) $value));
             $value_style  = 'color:black;border:1px gray dotted;';
           } else {
             $value_style  = 'color:black;';
-            $value        = nl2br(htmlspecialchars($value));
+            $value        = nl2br(htmlspecialchars((string) $value));
           }
           break;
 
@@ -181,7 +181,7 @@ class printAClass
         if ($this->show_object_vars) {
           $this->print_a(get_object_vars($value), TRUE, $key_bg_color);
         } else {
-          $this->output .= '<div style="'.$value_style.'">OBJECT - '.get_class($value).'</div>';
+          $this->output .= '<div style="'.$value_style.'">OBJECT - '.$value::class.'</div>';
         }
       } else {
         $this->output .= '<div style="'.$value_style.'" title="'.$type.'">'.$value.'</div>';
diff --git a/include/password-methods/class_passwordMethodCrypt.inc b/include/password-methods/class_passwordMethodCrypt.inc
index 77a1995c95f059502ef18347f62454f5e0336dc6..38a790c1fff2f65449ff49e33a21fcca1ff96022 100755
--- a/include/password-methods/class_passwordMethodCrypt.inc
+++ b/include/password-methods/class_passwordMethodCrypt.inc
@@ -154,27 +154,27 @@ class passwordMethodCrypt extends passwordMethod
 
     $password_hash = preg_replace('/^{[^}]+}!?/', '', (string) $password_hash);
 
-    if (preg_match("/^[a-zA-Z0-9.\/][a-zA-Z0-9.\/]/", $password_hash)) {
+    if (preg_match("/^[a-zA-Z0-9.\/][a-zA-Z0-9.\/]/", (string) $password_hash)) {
       return "crypt/standard-des";
     }
 
-    if (preg_match("/^_[a-zA-Z0-9.\/]/", $password_hash)) {
+    if (preg_match("/^_[a-zA-Z0-9.\/]/", (string) $password_hash)) {
       return "crypt/enhanced-des";
     }
 
-    if (preg_match('/^\$1\$/', $password_hash)) {
+    if (preg_match('/^\$1\$/', (string) $password_hash)) {
       return "crypt/md5";
     }
 
-    if (preg_match('/^(\$2\$|\$2a\$)/', $password_hash)) {
+    if (preg_match('/^(\$2\$|\$2a\$)/', (string) $password_hash)) {
       return "crypt/blowfish";
     }
 
-    if (preg_match('/^\$5\$/', $password_hash)) {
+    if (preg_match('/^\$5\$/', (string) $password_hash)) {
       return "crypt/sha-256";
     }
 
-    if (preg_match('/^\$6\$/', $password_hash)) {
+    if (preg_match('/^\$6\$/', (string) $password_hash)) {
       return "crypt/sha-512";
     }
 
diff --git a/include/php_setup.inc b/include/php_setup.inc
index dfe4c432c5c2c19c51572f08b9af64059a5514c6..42d0503255135ac603637dbba8b6575780616e85 100755
--- a/include/php_setup.inc
+++ b/include/php_setup.inc
@@ -87,19 +87,11 @@ function html_trace ($errstr = "")
       $func .= $ct['function'];
     }
     if (isset($ct['type'])) {
-      switch ($ct['type']) {
-        case '::':
-          $type = _('static');
-          break;
-
-        case '->':
-          $type = _('method');
-          break;
-
-        default:
-          $type = 'unknown';
-          break;
-      }
+      $type = match ($ct['type']) {
+          '::' => _('static'),
+          '->' => _('method'),
+          default => 'unknown',
+      };
     } else {
       $type = '-';
     }
@@ -119,7 +111,7 @@ function html_trace ($errstr = "")
           return '…';
         }
         if (is_object($arg)) {
-          return 'CLASS:&nbsp;' . get_class($arg);
+          return 'CLASS:&nbsp;' . $arg::class;
         } elseif (is_array($arg)) { /* Avoid converting array to string errors */
           $i++;
           $ret = 'array(' . implode(',', array_map($f, array_keys($arg), $arg)) . ')';
@@ -193,19 +185,19 @@ function gosaRaiseError ($errno, $errstr, $errfile, $errline)
   }
 
   /* Workaround for buggy imap_open error outputs */
-  if (preg_match('/imap_open/', $errstr)) {
+  if (preg_match('/imap_open/', (string) $errstr)) {
     set_error_handler('gosaRaiseError', E_WARNING | E_NOTICE | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE | E_STRICT);
     return;
   }
 
   /* Hide ldap size limit messages */
-  if (preg_match('/ldap_error/', $errstr) && preg_match('/sizelimit/', $errstr)) {
+  if (preg_match('/ldap_error/', (string) $errstr) && preg_match('/sizelimit/', (string) $errstr)) {
     set_error_handler('gosaRaiseError', E_WARNING | E_NOTICE | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE | E_STRICT);
     return;
   }
 
   /* Send all errors to logging class, except "Ldap : No such object" messages*/
-  if (class_exists('logging') && !preg_match('/No such object/', $errstr)) {
+  if (class_exists('logging') && !preg_match('/No such object/', (string) $errstr)) {
     logging::log('error', 'php', $errfile, [], 'Type:' . $errno . ', Message:' . $errstr . ', File:' . $errfile . ', Line: ' . $errline);
   }
 
@@ -243,7 +235,7 @@ function gosaRaiseError ($errno, $errstr, $errfile, $errline)
   $error_collector .= $html_trace;
 
   /* Flush in case of fatal errors */
-  if (preg_match('/^fatal/i', $errstr) || (PHP_ERROR_FATAL == 'TRUE')) {
+  if (preg_match('/^fatal/i', (string) $errstr) || (PHP_ERROR_FATAL == 'TRUE')) {
     trigger_error("Source error: " . $errstr . " in " . $errfile . " on line " . $errline);
     session::destroy('Fatal error');
     if (PHP_ERROR_FATAL == 'TRUE') {
@@ -262,11 +254,11 @@ function gosaRaiseError ($errno, $errstr, $errfile, $errline)
  *
  * \param Throwable $throwable
  */
-function fusiondirectoryExceptionHandler (Throwable $throwable)
+function fusiondirectoryExceptionHandler (Throwable $throwable): void
 {
   try {
-    logging::log('error', 'fatal', '', [], 'Uncaught ' . get_class($throwable) . ': ' . $throwable->getMessage());
-  } catch (Throwable $t) {
+    logging::log('error', 'fatal', '', [], 'Uncaught ' . $throwable::class . ': ' . $throwable->getMessage());
+  } catch (Throwable) {
     /* Ignore exceptions/errors here */
   }
 
@@ -274,12 +266,12 @@ function fusiondirectoryExceptionHandler (Throwable $throwable)
     if ($throwable instanceof FatalError) {
       $throwable->display();
     } else {
-      $error = new FatalError(htmlescape(sprintf(_('Uncaught %s: %s'), get_class($throwable), $throwable->getMessage())), 0, $throwable);
+      $error = new FatalError(htmlescape(sprintf(_('Uncaught %s: %s'), $throwable::class, $throwable->getMessage())), 0, $throwable);
       $error->display();
     }
-  } catch (Throwable $t) {
+  } catch (Throwable) {
     /* Minimal display if exceptions happens when building the pretty one */
-    echo 'Uncaught ' . get_class($throwable) . ': ' . $throwable->getMessage();
+    echo 'Uncaught ' . $throwable::class . ': ' . $throwable->getMessage();
   }
 
   exit(255);
@@ -288,7 +280,7 @@ function fusiondirectoryExceptionHandler (Throwable $throwable)
 /*!
  * \brief Dummy error handler
  */
-function dummy_error_handler ()
+function dummy_error_handler (): void
 {
 }
 
diff --git a/include/simpleplugin/attributes/class_SetAttribute.inc b/include/simpleplugin/attributes/class_SetAttribute.inc
index 197177b4f0078dbb5aaf1dc3064ef4537a3ba787..4af72827db5f22f68f5bc60d54c6951a64ad434a 100755
--- a/include/simpleplugin/attributes/class_SetAttribute.inc
+++ b/include/simpleplugin/attributes/class_SetAttribute.inc
@@ -634,7 +634,7 @@ class OrderedArrayAttribute extends SetAttribute
     if ($this->order) {
       if (preg_match('/^'.$id.'_up_/', (string) $postValue)) {
         $key = preg_replace('/^'.$id.'_up_/', '', (string) $postValue);
-        $key = (int)preg_replace('/_[xy]$/', '', $key);
+        $key = (int)preg_replace('/_[xy]$/', '', (string) $key);
 
         $tmp                        = $this->postValue[$key];
         $this->postValue[$key]      = $this->postValue[$key - 1];
@@ -643,7 +643,7 @@ class OrderedArrayAttribute extends SetAttribute
       }
       if (preg_match('/^'.$id.'_down_/', (string) $postValue)) {
         $key = preg_replace('/^'.$id.'_down_/', '', (string) $postValue);
-        $key = (int)preg_replace('/_[xy]$/', '', $key);
+        $key = (int)preg_replace('/_[xy]$/', '', (string) $key);
 
         $tmp                        = $this->postValue[$key];
         $this->postValue[$key]      = $this->postValue[$key + 1];
@@ -653,13 +653,13 @@ class OrderedArrayAttribute extends SetAttribute
     }
     if ($this->edit_enabled && preg_match('/^'.$id.'_edit_/', (string) $postValue)) {
       $key = preg_replace('/^'.$id.'_edit_/', '', (string) $postValue);
-      $key = preg_replace('/_[xy]$/', '', $key);
+      $key = preg_replace('/_[xy]$/', '', (string) $key);
       $this->handleEdit($key);
       return TRUE;
     }
     if (preg_match('/^'.$id.'_del_/', (string) $postValue)) {
       $key = preg_replace('/^'.$id.'_del_/', '', (string) $postValue);
-      $key = preg_replace('/_[xy]$/', '', $key);
+      $key = preg_replace('/_[xy]$/', '', (string) $key);
       $this->delPostValue($key);
       return TRUE;
     }