From cbb8461ecaf48b1b7b539c65d037ca2639ae4012 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come.chilliet@fusiondirectory.org> Date: Thu, 3 Sep 2020 17:15:12 +0200 Subject: [PATCH] :ambulance: fix(core) Fix code errors spotted by PHPStan issue #6114 --- html/index.php | 2 +- include/class_divSelectBox.inc | 2 +- include/class_ldap.inc | 4 ++-- include/class_ldapFilter.inc | 2 +- include/class_passwordRecovery.inc | 5 ++++- include/class_standAlonePage.inc | 4 +++- include/class_userinfo.inc | 4 ++-- include/login/class_LoginMethod.inc | 2 ++ include/management/class_management.inc | 2 ++ include/management/snapshot/class_SnapshotHandler.inc | 2 ++ include/simpleplugin/attributes/class_SelectAttribute.inc | 8 ++++---- include/simpleplugin/class_multiPlugin.inc | 2 +- plugins/admin/acl/class_aclManagement.inc | 2 +- plugins/admin/groups/class_ogroup.inc | 1 - 14 files changed, 26 insertions(+), 16 deletions(-) diff --git a/html/index.php b/html/index.php index efe328bb3..dcbfeb0d5 100644 --- a/html/index.php +++ b/html/index.php @@ -56,7 +56,7 @@ if (isset($_REQUEST['signout']) && $_REQUEST['signout']) { ); // Set the CA certificate that is the issuer of the cert phpCAS::setCasServerCACert($config->get_cfg_value('casServerCaCertPath')); - phpCas::logout(); + phpCAS::logout(); } $reason = 'Sign out'; if (isset($_REQUEST['message'])) { diff --git a/include/class_divSelectBox.inc b/include/class_divSelectBox.inc index 2392c4c45..fb6290a23 100644 --- a/include/class_divSelectBox.inc +++ b/include/class_divSelectBox.inc @@ -32,7 +32,7 @@ class divSelectBox { protected $headers = FALSE; protected $a_entries; - protected $summary; + protected $s_summary; protected $cols; protected $id; diff --git a/include/class_ldap.inc b/include/class_ldap.inc index 8019ba514..c858401bb 100644 --- a/include/class_ldap.inc +++ b/include/class_ldap.inc @@ -1129,7 +1129,7 @@ class LDAP // Check scope values $scope = trim($scope); if (!empty($scope) && !in_array($scope, ['base', 'one', 'sub', 'children'])) { - throw new LDIFExportException(sprintf('Invalid parameter for scope "%s", please use "base", "one", "sub" or "children".'), $scope); + throw new LDIFExportException(sprintf('Invalid parameter for scope "%s", please use "base", "one", "sub" or "children".', $scope)); } $scope = (empty($scope) ? '' : ' -s '.$scope); @@ -1522,7 +1522,7 @@ class LDAP } } - function get_naming_contexts ($server, $admin = '', $password = '') + public static function get_naming_contexts ($server, $admin = '', $password = '') { /* Build LDAP connection */ $ds = ldap_connect($server); diff --git a/include/class_ldapFilter.inc b/include/class_ldapFilter.inc index 98fdadf5e..245195353 100644 --- a/include/class_ldapFilter.inc +++ b/include/class_ldapFilter.inc @@ -100,7 +100,7 @@ class ldapFilter $filter .= ')'; $offset = 0; $level = 0; - $open; + $open = 0; while (preg_match('/[^\\\\](\\(|\\))/', $filter, $m, PREG_OFFSET_CAPTURE, $offset)) { $offset = $m[0][1] + 1; if ($m[1][0] == '(') { diff --git a/include/class_passwordRecovery.inc b/include/class_passwordRecovery.inc index bc532a2c0..199aaff55 100644 --- a/include/class_passwordRecovery.inc +++ b/include/class_passwordRecovery.inc @@ -31,6 +31,9 @@ class passwordRecovery extends standAlonePage /* Salt needed to mask the uniq id in the ldap */ protected $salt; + /* Uniq ID recovered from email */ + protected $uniq; + /* Delay allowed for the user to change his password (minutes) */ protected $delay_allowed; @@ -132,7 +135,7 @@ class passwordRecovery extends standAlonePage /* Check that password recovery is activated, read config in ldap * Returns a boolean saying if password recovery is activated */ - function readLdapConfig () + protected function readLdapConfig (): bool { global $config; $this->salt = $config->get_cfg_value('passwordRecoverySalt'); diff --git a/include/class_standAlonePage.inc b/include/class_standAlonePage.inc index 0633ae6a5..907832952 100644 --- a/include/class_standAlonePage.inc +++ b/include/class_standAlonePage.inc @@ -20,7 +20,7 @@ */ /* base class for passwordRecovery and such classes handling requests on their own */ -class standAlonePage +abstract class standAlonePage { protected $directories; protected $directory; @@ -56,6 +56,8 @@ class standAlonePage static::init(); } + abstract protected function readLdapConfig (): bool; + function checkDirectoryChooser () { global $config; diff --git a/include/class_userinfo.inc b/include/class_userinfo.inc index 682c68c6e..855931de3 100644 --- a/include/class_userinfo.inc +++ b/include/class_userinfo.inc @@ -214,7 +214,7 @@ class userinfo } break; default: - throw FusionDirectoryException('Unknown ACL member type '.$memberType); + throw new FusionDirectoryException('Unknown ACL member type '.$memberType); } } @@ -1103,7 +1103,7 @@ class userinfo $ui = static::getLdapUser($username); if ($ui === FALSE) { - throw new LoginFailureException(ldap::invalidCredentialsError()); + throw new LoginFailureException(LDAP::invalidCredentialsError()); } elseif (is_string($ui)) { throw new LoginFailureException($ui); } diff --git a/include/login/class_LoginMethod.inc b/include/login/class_LoginMethod.inc index 183f609d6..06d7c4a1a 100644 --- a/include/login/class_LoginMethod.inc +++ b/include/login/class_LoginMethod.inc @@ -215,6 +215,8 @@ class LoginMethod try { $method::loginProcess(); } catch (Exception $e) { + $lang = session::get('lang'); + $display = '<h1>'.htmlescape(_('An unrecoverable error occurred. Please contact your administator.')).'</h1><p>'; if (ini_get('display_errors') == 1) { $display .= nl2br(htmlescape((string)$e)); diff --git a/include/management/class_management.inc b/include/management/class_management.inc index 10bce9c51..4ac1951e7 100644 --- a/include/management/class_management.inc +++ b/include/management/class_management.inc @@ -73,6 +73,8 @@ class management /* Disable and hide configuration system */ protected $skipConfiguration = FALSE; + protected $columnConfiguration; + /* Default columns */ public static $columns = [ ['ObjectTypeColumn', []], diff --git a/include/management/snapshot/class_SnapshotHandler.inc b/include/management/snapshot/class_SnapshotHandler.inc index 2bd2a7dfe..34ad2e2fb 100644 --- a/include/management/snapshot/class_SnapshotHandler.inc +++ b/include/management/snapshot/class_SnapshotHandler.inc @@ -32,6 +32,8 @@ class SnapshotHandler { protected $enabled; + protected $snapshotRDN; + protected $snapshotsCache; static function plInfo () { diff --git a/include/simpleplugin/attributes/class_SelectAttribute.inc b/include/simpleplugin/attributes/class_SelectAttribute.inc index b55e36da2..96c640b97 100644 --- a/include/simpleplugin/attributes/class_SelectAttribute.inc +++ b/include/simpleplugin/attributes/class_SelectAttribute.inc @@ -129,10 +129,10 @@ class SelectAttribute extends Attribute if ($this->outputs !== NULL) { unset($this->outputs['']); } - } elseif (!$this->isRequired() && !in_array("", $this->choices, TRUE)) { - $this->choices[] = ""; - if (($this->outputs !== NULL) && !isset($this->output[''])) { - $this->output[''] = _('None'); + } elseif (!$this->isRequired() && !in_array('', $this->choices, TRUE)) { + $this->choices[] = ''; + if (($this->outputs !== NULL) && !isset($this->outputs[''])) { + $this->outputs[''] = _('None'); } } } diff --git a/include/simpleplugin/class_multiPlugin.inc b/include/simpleplugin/class_multiPlugin.inc index 85b31d008..8b011d9b3 100644 --- a/include/simpleplugin/class_multiPlugin.inc +++ b/include/simpleplugin/class_multiPlugin.inc @@ -106,7 +106,7 @@ class multiPlugin extends simplePlugin unset($plug); if (!$enabled) { $display = '<img alt="'._('Error').'" src="geticon.php?context=status&icon=dialog-error&size=16" align="middle"/> <b>'. - msgPool::noValidExtension()."</b>"; + msgPool::noValidExtension('').'</b>'; return $display; } } diff --git a/plugins/admin/acl/class_aclManagement.inc b/plugins/admin/acl/class_aclManagement.inc index 1c9a6dfad..75f946cbd 100644 --- a/plugins/admin/acl/class_aclManagement.inc +++ b/plugins/admin/acl/class_aclManagement.inc @@ -29,7 +29,7 @@ class aclAssignmentCreationDialog extends simplePlugin { return [ 'plShortName' => _('ACL assignment creation'), - 'plShortName' => _('ACL assignment creation'), + 'plTitle' => _('ACL assignment creation'), 'plDescription' => _('Create an ACL assignment on an arbitrary dn'), 'plCategory' => ['acl'], diff --git a/plugins/admin/groups/class_ogroup.inc b/plugins/admin/groups/class_ogroup.inc index 2b684c927..9dc759976 100644 --- a/plugins/admin/groups/class_ogroup.inc +++ b/plugins/admin/groups/class_ogroup.inc @@ -43,7 +43,6 @@ class ogroup extends simplePlugin return [ 'plShortName' => _('Object group'), 'plDescription' => _('Object group information'), - 'plFilter' => '(objectClass=groupOfNames)', 'plPriority' => 1, 'plObjectClass' => ['groupOfNames', 'gosaGroupOfNames'], 'plFilter' => '(objectClass=groupOfNames)', -- GitLab