From 3c005187eab9ac158012cd8c2cef1800a0e8f9f0 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 6 Sep 2025 09:49:39 +0200 Subject: [PATCH 1/4] #451 PHPStan level 5 --- lam/lib/modules/windowsUser.inc | 14 +++----------- lam/lib/persistence.inc | 6 +++--- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/lam/lib/modules/windowsUser.inc b/lam/lib/modules/windowsUser.inc index 74a95e044..aa0af56db 100644 --- a/lam/lib/modules/windowsUser.inc +++ b/lam/lib/modules/windowsUser.inc @@ -5277,8 +5277,8 @@ if (interface_exists('\LAM\JOB\Job', false)) { /** * Returns if the job should run. * - * @param $pdo PDO - * @param $jobId job id + * @param PDO $pdo PDO + * @param string $jobId job id * @param DateTime $baseDate base date * @param int $monthInterval month interval * @return bool should run @@ -5512,15 +5512,7 @@ if (interface_exists('\LAM\JOB\Job', false)) { } /** - * Checks if a user is expired. - * - * @param integer $jobID job ID - * @param array $options job settings - * @param PDO $pdo PDO - * @param DateTime $now current time - * @param array $policyOptions list of policy options by getPolicyOptions() - * @param array $user user attributes - * @param boolean $isDryRun just do a dry run, nothing is modified + * {@inheritDoc} */ protected function checkSingleUser($jobID, $options, &$pdo, $now, $policyOptions, $user, $isDryRun) { $seconds = substr($user['accountexpires'][0], 0, -7); diff --git a/lam/lib/persistence.inc b/lam/lib/persistence.inc index da850299c..169d6e05f 100644 --- a/lam/lib/persistence.inc +++ b/lam/lib/persistence.inc @@ -342,7 +342,7 @@ class ConfigDataImporter { $steps[] = new ImporterStep(_('General settings'), 'mainConfig', $value); break; case 'certificates': - $steps[] = new ImporterStep(_('SSL certificates'), 'certificates', $value); + $steps[] = new ImporterStep(_('SSL certificates'), 'certificates', [$value]); break; case 'serverProfiles': $mainStep = new ImporterStep(_('Server profiles'), 'serverProfiles', $value); @@ -424,7 +424,7 @@ class ConfigDataImporter { * Runs the actual import. * * @param ImporterStep[] $steps import steps - * @throws LAMException if error occurred + * @throws LAMException if an error occurred */ public function runImport($steps) { foreach ($steps as $step) { @@ -434,7 +434,7 @@ class ConfigDataImporter { $key = $step->getKey(); match ($key) { 'mainConfig' => $this->importMainConfig($step->getValue()), - 'certificates' => $this->importCertificates($step->getValue()), + 'certificates' => $this->importCertificates($step->getValue()[0]), 'serverProfiles' => $this->importServerProfiles($step), 'accountProfiles' => $this->importAccountProfiles($step), 'accountProfileTemplates' => $this->importAccountProfileTemplates($step), From 23044ac06e8a54589bfe7026271cdfc5c95cd917 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 6 Sep 2025 09:58:14 +0200 Subject: [PATCH 2/4] #451 PHPStan level 5 --- lam/lib/modules/shadowAccount.inc | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/lam/lib/modules/shadowAccount.inc b/lam/lib/modules/shadowAccount.inc index c7dd7cd89..1f71fd3eb 100644 --- a/lam/lib/modules/shadowAccount.inc +++ b/lam/lib/modules/shadowAccount.inc @@ -1110,15 +1110,7 @@ if (interface_exists('\LAM\JOB\Job', false)) { } /** - * Checks if a user needs to change his password. - * - * @param integer $jobID job ID - * @param array $options job settings - * @param PDO $pdo PDO - * @param DateTime $now current time - * @param array $policyOptions list of max age values (policy DN => maxAge) - * @param array $user user attributes - * @param boolean $isDryRun just do a dry run, nothing is modified + * {@inheritDoc} */ protected function checkSingleUser($jobID, $options, &$pdo, $now, $policyOptions, $user, $isDryRun) { // skip if user is locked @@ -1220,15 +1212,7 @@ if (interface_exists('\LAM\JOB\Job', false)) { } /** - * Checks if a user needs to change his password. - * - * @param integer $jobID job ID - * @param array $options job settings - * @param PDO $pdo PDO - * @param DateTime $now current time - * @param array $policyOptions list of max age values (policy DN => maxAge) - * @param array $user user attributes - * @param boolean $isDryRun just do a dry run, nothing is modified + * {@inheritDoc} */ protected function checkSingleUser($jobID, $options, &$pdo, $now, $policyOptions, $user, $isDryRun) { $dn = $user['dn']; @@ -1313,15 +1297,7 @@ if (interface_exists('\LAM\JOB\Job', false)) { } /** - * Checks if a user is expired. - * - * @param integer $jobID job ID - * @param array $options job settings - * @param PDO $pdo PDO - * @param DateTime $now current time - * @param array $policyOptions list of policy options by getPolicyOptions() - * @param array $user user attributes - * @param boolean $isDryRun just do a dry run, nothing is modified + * {@inheritDoc} */ protected function checkSingleUser($jobID, $options, &$pdo, $now, $policyOptions, $user, $isDryRun) { $expireTimeUnix = $user['shadowexpire'][0] * 3600 * 24; From b6cf9b2b88c9ffa8ee723869d1d72a7ea77158ee Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 6 Sep 2025 10:07:18 +0200 Subject: [PATCH 3/4] #451 PHPStan level 5 --- lam/lib/modules/windowsUser.inc | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/lam/lib/modules/windowsUser.inc b/lam/lib/modules/windowsUser.inc index aa0af56db..85a403c7a 100644 --- a/lam/lib/modules/windowsUser.inc +++ b/lam/lib/modules/windowsUser.inc @@ -4396,11 +4396,11 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr /** * Sets the expiration date of this account. - * If all parameters are null the expiration date will be removed. + * If all parameters are null, the expiration date will be removed. * - * @param String $year year (e.g. 2040) - * @param String $month month (e.g. 8) - * @param String $day day (e.g. 27) + * @param int|null $year year (e.g. 2040) + * @param int|null $month month (e.g. 8) + * @param int|null $day day (e.g. 27) */ public function setExpirationDate($year, $month, $day) { if (($year == null) && ($month == null) && ($day == null)) { @@ -5017,31 +5017,23 @@ if (interface_exists('\LAM\JOB\Job', false)) { } /** - * Checks if a user needs to change his password. - * - * @param integer $jobID job ID - * @param array $options job settings - * @param PDO $pdo PDO - * @param DateTime $now current time - * @param array $policyOptions not used - * @param array $user user attributes - * @param boolean $isDryRun just do a dry run, nothing is modified + * {@inheritDoc} */ protected function checkSingleUser($jobID, $options, &$pdo, $now, $policyOptions, $user, $isDryRun) { $dn = $user['dn']; - // skip if password does not expire at all + // skip if the password does not expire at all if (windowsUser::isNeverExpiring($user)) { $this->jobResultLog->logDebug($dn . ' does not expire.'); return; } - // skip if password does not expire + // skip if the password does not expire if (empty($user['msds-userpasswordexpirytimecomputed'][0]) || ($user['msds-userpasswordexpirytimecomputed'][0] == windowsUser::ACCOUNT_DOES_NOT_EXPIRE) || ($user['msds-userpasswordexpirytimecomputed'][0] == '0')) { $this->jobResultLog->logDebug($dn . ': password does not expire.'); return; } - // skip if account itself is expired + // skip if the account itself is expired if (!empty($user['accountexpires'][0])) { $accountExpiration = windowsUser::getFileTime($user['accountexpires'][0]); if ($accountExpiration <= $now) { @@ -5049,7 +5041,7 @@ if (interface_exists('\LAM\JOB\Job', false)) { return; } } - // skip if account is deactivated + // skip if the account is deactivated if (windowsUser::isDeactivated($user)) { $this->jobResultLog->logDebug($dn . ' is deactivated.'); return; From 30ac0025bf2c470dbb6a0b6daaa72033ea69b749 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 6 Sep 2025 10:14:33 +0200 Subject: [PATCH 4/4] #451 PHPStan level 5 --- lam/lib/modules/windowsUser.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lam/lib/modules/windowsUser.inc b/lam/lib/modules/windowsUser.inc index 85a403c7a..39cccc9b7 100644 --- a/lam/lib/modules/windowsUser.inc +++ b/lam/lib/modules/windowsUser.inc @@ -4347,7 +4347,7 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr * Returns the formatted value for the password expiration date. * * @param array $attributes user attributes ($this->attributes if null) - * @return String date or - + * @return string date or - */ private function formatPasswordExpires($attributes = null) { if ($attributes == null) { @@ -4363,8 +4363,8 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr /** * Formats a value in file time (100 ns since 1601-01-01). * - * @param integer $value time value - * @return String formatted value + * @param string $value time value + * @return string formatted value */ private function formatFileTime($value) { if (empty($value) || ($value == '-1')) { @@ -4380,7 +4380,7 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr /** * Returns a value in file time (100 ns since 1601-01-01). * - * @param integer $value time value as int + * @param string $value time value as int * @return DateTime|null time value */ public static function getFileTime($value): ?DateTime {