From fff28020a35b05cccdb9958256e96c5dbde802e1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come.chilliet@fusiondirectory.org>
Date: Tue, 8 Sep 2020 15:13:38 +0200
Subject: [PATCH] :ambulance: fix(core) Fix small PHPStan spotted issues

issue #6072
---
 include/functions.inc                                  |  7 +------
 include/password-methods/class_passwordMethod.inc      |  2 +-
 include/php_setup.inc                                  | 10 +++++-----
 .../simpleplugin/attributes/class_FileAttribute.inc    |  2 +-
 phpstan.neon                                           |  6 ++++++
 .../personal/generic/class_UserPasswordAttribute.inc   |  2 +-
 setup/class_setupStepMigrate.inc                       |  4 ----
 7 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/include/functions.inc b/include/functions.inc
index 6217fa5d7..e67fdece1 100644
--- a/include/functions.inc
+++ b/include/functions.inc
@@ -885,7 +885,6 @@ function strict_uid_mode ()
 function gen_locked_message (array $locks, $dn, $allow_readonly = FALSE)
 {
   session::set('dn', $dn);
-  $remove = FALSE;
 
   /* Save variables from LOCK_VARS_TO_USE in session - for further editing */
   if (session::is_set('LOCK_VARS_TO_USE') && count(session::get('LOCK_VARS_TO_USE'))) {
@@ -937,11 +936,7 @@ function gen_locked_message (array $locks, $dn, $allow_readonly = FALSE)
   }
 
   $smarty->assign('dn', $msg);
-  if ($remove) {
-    $smarty->assign('action', _('Continue anyway'));
-  } else {
-    $smarty->assign('action', _('Edit anyway'));
-  }
+  $smarty->assign('action', _('Edit anyway'));
   $smarty->assign('message', sprintf(_("You're going to edit the LDAP entry/entries %s"), "<b>".$msg."</b>", ""));
   $smarty->assign('locks', $locks);
 
diff --git a/include/password-methods/class_passwordMethod.inc b/include/password-methods/class_passwordMethod.inc
index 31e3e19c8..30a1b74d7 100644
--- a/include/password-methods/class_passwordMethod.inc
+++ b/include/password-methods/class_passwordMethod.inc
@@ -167,7 +167,7 @@ abstract class passwordMethod
     /* Fill modification array */
     $modify = [];
     foreach ($userObject->by_object as $tab) {
-      if ($tab instanceof userTabLockingAction) {
+      if ($tab instanceof UserTabLockingAction) {
         $tab->fillLockingLDAPAttrs($mode, $modify);
       }
     }
diff --git a/include/php_setup.inc b/include/php_setup.inc
index 7740b8734..ff769d66b 100644
--- a/include/php_setup.inc
+++ b/include/php_setup.inc
@@ -340,11 +340,11 @@ $error_collector_mailto = "";
 set_error_handler('gosaRaiseError', E_WARNING | E_NOTICE | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE | E_STRICT);
 set_exception_handler('fusiondirectoryExceptionHandler');
 
-$variables_order = "ES";
-ini_set("track_vars", 1);
-ini_set("display_errors", 1);
-ini_set("report_memleaks", 1);
-ini_set("include_path", ".:$BASE_DIR/include:".PHP_DIR.":".PEAR_DIR);
+$variables_order = 'ES';
+ini_set('track_vars',       '1');
+ini_set('display_errors',   '1');
+ini_set('report_memleaks',  '1');
+ini_set('include_path',     ".:$BASE_DIR/include:".PHP_DIR.':'.PEAR_DIR);
 
 /* Do smarty setup */
 require(SMARTY);
diff --git a/include/simpleplugin/attributes/class_FileAttribute.inc b/include/simpleplugin/attributes/class_FileAttribute.inc
index 429dcec34..098e39887 100644
--- a/include/simpleplugin/attributes/class_FileAttribute.inc
+++ b/include/simpleplugin/attributes/class_FileAttribute.inc
@@ -137,7 +137,7 @@ class FileAttribute extends Attribute
       return sprintf(_('Attribute %s is disabled, its value could not be set'), $this->getLdapName());
     }
     if ($this->binary) {
-      $data = base64_decode($value);
+      $data = base64_decode($value, TRUE);
       if ($data === FALSE) {
         return sprintf(_('Invalid base64 data for attribute %s'), $this->getLdapName());
       }
diff --git a/phpstan.neon b/phpstan.neon
index 40acfd635..ea0e6fbb9 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -1,3 +1,6 @@
+includes:
+  - phpstan-baseline.neon
+
 parameters:
   bootstrapFiles:
     - include/php_setup.inc
@@ -12,3 +15,6 @@ parameters:
     - simplePlugin
   excludes_analyse:
     - */class_sieve*.inc
+    - */localfiles/*
+    - */vendor/*
+    - */test/*
diff --git a/plugins/personal/generic/class_UserPasswordAttribute.inc b/plugins/personal/generic/class_UserPasswordAttribute.inc
index 9337e4951..230002399 100644
--- a/plugins/personal/generic/class_UserPasswordAttribute.inc
+++ b/plugins/personal/generic/class_UserPasswordAttribute.inc
@@ -190,7 +190,7 @@ class UserPasswordAttribute extends CompositeAttribute
     if (!empty($value) || ($this->plugin->initially_was_account && !$istemplate)) {
       if ($istemplate) {
         if ($value == '%askme%') {
-          return ['%askme%', '', '', $value, ($locked ? 'TRUE' : 'FALSE')];
+          return ['%askme%', '', '', $value, 'FALSE'];
         }
         list($value, $password) = explode('|', $value, 2);
       }
diff --git a/setup/class_setupStepMigrate.inc b/setup/class_setupStepMigrate.inc
index 468684220..8ce431bdf 100644
--- a/setup/class_setupStepMigrate.inc
+++ b/setup/class_setupStepMigrate.inc
@@ -851,10 +851,6 @@ class setupStepMigrate extends setupStep
         );
       }
     }
-
-    // Reload base OC
-    $this->checks['baseOC']->run();
-    return '';
   }
 
   function check_adminAccount_create (&$checkobj)
-- 
GitLab