From 693f96ce09a14bae666854bc32464f99b1e1d301 Mon Sep 17 00:00:00 2001
From: Thibault Dockx <thibault.dockx@fusiondirectory.org>
Date: Mon, 20 Jan 2025 18:38:19 +0000
Subject: [PATCH] :sparkles: (User) - locking mechanism

Fixing phpstan for 7.4
---
 include/simpleplugin/class_simplePlugin.inc |  4 +-
 plugins/personal/generic/class_user.inc     | 54 ++++++++++-----------
 2 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/include/simpleplugin/class_simplePlugin.inc b/include/simpleplugin/class_simplePlugin.inc
index 6fc9c1f03..e93ed9aa4 100644
--- a/include/simpleplugin/class_simplePlugin.inc
+++ b/include/simpleplugin/class_simplePlugin.inc
@@ -162,7 +162,7 @@ class simplePlugin implements SimpleTab
 
     // This class-level state allows children to get readOnly automatically.
     if (self::$user_locked) {
-      $this->read_only = true;
+      $this->read_only = TRUE;
     }
 
     try {
@@ -307,7 +307,7 @@ class simplePlugin implements SimpleTab
   }
 
 
-  public static function setUserLocked(bool $locked): void
+  public static function setUserLocked (bool $locked): void
   {
     self::$user_locked = $locked;
   }
diff --git a/plugins/personal/generic/class_user.inc b/plugins/personal/generic/class_user.inc
index 9ad6f87ff..b920c5e29 100644
--- a/plugins/personal/generic/class_user.inc
+++ b/plugins/personal/generic/class_user.inc
@@ -51,20 +51,20 @@ class user extends simplePlugin
   static function plInfo (): array
   {
     return [
-      'plShortName'   => _('User'),
+      'plShortName' => _('User'),
       'plDescription' => _('User account information'),
-      'plIcon'        => 'geticon.php?context=applications&icon=user-info&size=48',
-      'plSmallIcon'   => 'geticon.php?context=applications&icon=user-info&size=16',
-      'plSelfModify'  => TRUE,
+      'plIcon' => 'geticon.php?context=applications&icon=user-info&size=48',
+      'plSmallIcon' => 'geticon.php?context=applications&icon=user-info&size=16',
+      'plSelfModify' => TRUE,
       'plObjectClass' => ['inetOrgPerson', 'organizationalPerson', 'person'],
-      'plFilter'      => '(objectClass=inetOrgPerson)',
-      'plObjectType'  => ['user' => [
-        'name'        => _('User'),
+      'plFilter' => '(objectClass=inetOrgPerson)',
+      'plObjectType' => ['user' => [
+        'name' => _('User'),
         'description' => _('User account'),
-        'mainAttr'    => 'uid',
-        'nameAttr'    => 'cn',
-        'icon'        => 'geticon.php?context=types&icon=user&size=16',
-        'ou'          => get_ou('userRDN'),
+        'mainAttr' => 'uid',
+        'nameAttr' => 'cn',
+        'icon' => 'geticon.php?context=types&icon=user&size=16',
+        'ou' => get_ou('userRDN'),
       ]],
       'plForeignKeys' => [
         'manager' => ['user', 'dn', 'manager=%oldvalue%', '*']
@@ -85,9 +85,9 @@ class user extends simplePlugin
     asort($languages);
     $languages      = array_merge(['' => ''], $languages);
     $attributesInfo = [
-      'perso'        => [
-        'name'  => _('Personal information'),
-        'icon'  => 'geticon.php?context=types&icon=user&size=16',
+      'perso' => [
+        'name' => _('Personal information'),
+        'icon' => 'geticon.php?context=types&icon=user&size=16',
         'attrs' => [
           new HiddenAttribute('cn'),
           new StringAttribute(
@@ -116,9 +116,9 @@ class user extends simplePlugin
           ),
         ]
       ],
-      'contact'      => [
-        'name'  => _('Organizational contact information'),
-        'icon'  => 'geticon.php?context=types&icon=user&size=16',
+      'contact' => [
+        'name' => _('Organizational contact information'),
+        'icon' => 'geticon.php?context=types&icon=user&size=16',
         'attrs' => [
           new StringAttribute(
             _('Location'), _('Location'),
@@ -162,9 +162,9 @@ class user extends simplePlugin
           ),
         ]
       ],
-      'account'      => [
-        'name'  => _('Account information'),
-        'icon'  => 'geticon.php?context=applications&icon=ldap&size=16',
+      'account' => [
+        'name' => _('Account information'),
+        'icon' => 'geticon.php?context=applications&icon=ldap&size=16',
         'attrs' => [
           new BaseSelectorAttribute(get_ou("userRDN")),
           new UidAttribute(
@@ -182,9 +182,9 @@ class user extends simplePlugin
           ),
         ]
       ],
-      'homecontact'  => [
-        'name'  => _('Personal contact information'),
-        'icon'  => 'geticon.php?context=types&icon=user&size=16',
+      'homecontact' => [
+        'name' => _('Personal contact information'),
+        'icon' => 'geticon.php?context=types&icon=user&size=16',
         'attrs' => [
           new StringAttribute(
             _('Display name'), _('Name this user should appear as. Used by Exchange.'),
@@ -201,8 +201,8 @@ class user extends simplePlugin
         ]
       ],
       'organization' => [
-        'name'  => _('Organizational information'),
-        'icon'  => 'geticon.php?context=places&icon=folder&size=16',
+        'name' => _('Organizational information'),
+        'icon' => 'geticon.php?context=places&icon=folder&size=16',
         'attrs' => [
           new SetAttribute(
             new StringAttribute(
@@ -266,10 +266,10 @@ class user extends simplePlugin
     // verify if the attribute password is locked
     $this->was_locked = $this->attributesAccess['userPassword']->isLocked();
 
-    if ($this->was_locked){
+    if ($this->was_locked) {
       $this->read_only = TRUE;
       // This will update the parent class (simplePlugin) via class-level state allowing children to get read only state.
-      self::setUserLocked(true);
+      self::setUserLocked(TRUE);
     }
 
     if ($this->is_template && !$this->initially_was_account) {
-- 
GitLab