#451 PHPStan level 5

This commit is contained in:
Roland Gruber 2025-09-06 21:38:36 +02:00
parent 30ac0025bf
commit 7121649cc9

View file

@ -1407,7 +1407,7 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr
$userPrincipalNameLabel->setMarkAsRequired(true); $userPrincipalNameLabel->setMarkAsRequired(true);
$containerLeft->addLabel($userPrincipalNameLabel); $containerLeft->addLabel($userPrincipalNameLabel);
$userPrincipalNameGroup = new htmlGroup(); $userPrincipalNameGroup = new htmlGroup();
$userPrincipalNameGroup->addElement(new htmlInputField('userPrincipalName', $userPrincipalName, '15')); $userPrincipalNameGroup->addElement(new htmlInputField('userPrincipalName', $userPrincipalName, 15));
$userPrincipalNameGroup->addElement(new htmlSelect('userPrincipalNameDomain', $domains, [$userPrincipalNameDomain])); $userPrincipalNameGroup->addElement(new htmlSelect('userPrincipalNameDomain', $domains, [$userPrincipalNameDomain]));
$userPrincipalNameGroup->addElement(new htmlHelpLink('userPrincipalName')); $userPrincipalNameGroup->addElement(new htmlHelpLink('userPrincipalName'));
$containerLeft->addField($userPrincipalNameGroup); $containerLeft->addField($userPrincipalNameGroup);
@ -2192,9 +2192,9 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr
// determine action // determine action
if (str_contains($buttonName, '_change')) { if (str_contains($buttonName, '_change')) {
$date = DateTime::createFromFormat('Y-m-d', $_POST['accountexpires'], new DateTimeZone('UTC')); $date = DateTime::createFromFormat('Y-m-d', $_POST['accountexpires'], new DateTimeZone('UTC'));
$year = $date->format('Y'); $year = (int) $date->format('Y');
$month = $date->format('m'); $month = (int) $date->format('m');
$day = $date->format('d'); $day = (int) $date->format('d');
// set new time // set new time
$this->setExpirationDate($year, $month, $day); $this->setExpirationDate($year, $month, $day);
// sync other modules // sync other modules
@ -2291,7 +2291,7 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr
} }
$this->addDoubleSelectionArea($return, _("Selected groups"), _("Available groups"), $this->addDoubleSelectionArea($return, _("Selected groups"), _("Available groups"),
$selectedGroups, null, $availableGroups, null, 'groups', $groupDisplayContainsDn, true); $selectedGroups, [], $availableGroups, [], 'groups', $groupDisplayContainsDn, true);
// sync options // sync options
$typeManager = new TypeManager(); $typeManager = new TypeManager();
@ -2902,13 +2902,13 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr
elseif ($hr >= 24 * 7) { elseif ($hr >= 24 * 7) {
$hr -= 24 * 7; $hr -= 24 * 7;
} }
$checkbox = new htmlInputCheckbox('lh_' . $hr, $hour[$hr]); $checkbox = new htmlInputCheckbox('lh_' . $hr, ($hour[$hr] === '1'));
$boxes[$i % 24][floor($i / 24)] = $checkbox; $boxes[$i % 24][floor($i / 24)] = $checkbox;
} }
for ($h = 0; $h < 24; $h++) { for ($h = 0; $h < 24; $h++) {
$hour = str_pad($h, 2, '0', STR_PAD_LEFT); $hour = str_pad((string) $h, 2, '0', STR_PAD_LEFT);
$row = []; $row = [];
$row[] = new htmlOutputText("$hour:00 - " . str_pad($h + 1, 2, '0', STR_PAD_LEFT) . ":00"); $row[] = new htmlOutputText("$hour:00 - " . str_pad((string) ($h + 1), 2, '0', STR_PAD_LEFT) . ":00");
for ($d = 1; $d < 7; $d++) { for ($d = 1; $d < 7; $d++) {
$row[] = $boxes[$h][$d]; $row[] = $boxes[$h][$d];
} }
@ -3028,7 +3028,7 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr
*/ */
public function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules, &$type) { public function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules, &$type) {
$errors = []; $errors = [];
// get list of existing groups // get the list of existing groups
$groupList = $this->findGroups(); $groupList = $this->findGroups();
$groupMap = []; $groupMap = [];
foreach ($groupList as $dn) { foreach ($groupList as $dn) {
@ -3238,7 +3238,8 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr
} }
// other telephone // other telephone
if (!$this->isBooleanConfigOptionSet('windowsUser_hideotherTelephone')) { if (!$this->isBooleanConfigOptionSet('windowsUser_hideotherTelephone')) {
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_otherTelephone', 'otherTelephone', 'telephone', $this->messages['otherTelephone'][1], $errors, '/;[ ]*/'); $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_otherTelephone',
'otherTelephone', 'telephone', $this->messages['otherTelephone'][1], $errors, '/;[ ]*/');
} }
// fax number // fax number
if (!$this->isBooleanConfigOptionSet('windowsUser_hidefacsimileTelephoneNumber')) { if (!$this->isBooleanConfigOptionSet('windowsUser_hidefacsimileTelephoneNumber')) {
@ -3251,7 +3252,8 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr
} }
// other websites // other websites
if (!$this->isBooleanConfigOptionSet('windowsUser_hideurl')) { if (!$this->isBooleanConfigOptionSet('windowsUser_hideurl')) {
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_otherWebSites', 'url', null, null, $errors, '/;[ ]*/'); $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_otherWebSites',
'url', null, [], $errors, '/;[ ]*/');
} }
// user account control // user account control
$userAccountControlAttr['useraccountcontrol'][0] = self::DEFAULT_ACCOUNT_CONTROL; $userAccountControlAttr['useraccountcontrol'][0] = self::DEFAULT_ACCOUNT_CONTROL;
@ -3277,7 +3279,7 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr
if (!empty($rawAccounts[$i][$ids['windowsUser_accountExpires']])) { if (!empty($rawAccounts[$i][$ids['windowsUser_accountExpires']])) {
if (get_preg($rawAccounts[$i][$ids['windowsUser_accountExpires']], 'date')) { if (get_preg($rawAccounts[$i][$ids['windowsUser_accountExpires']], 'date')) {
$dateParts = explode('-', $rawAccounts[$i][$ids['windowsUser_accountExpires']]); $dateParts = explode('-', $rawAccounts[$i][$ids['windowsUser_accountExpires']]);
$partialAccounts[$i]['accountexpires'] = $this->buildExpirationDate($dateParts[2], $dateParts[1], $dateParts[0]); $partialAccounts[$i]['accountexpires'] = $this->buildExpirationDate((int) $dateParts[2], (int) $dateParts[1], (int) $dateParts[0]);
} }
else { else {
$errMsg = $this->messages['accountexpires'][1]; $errMsg = $this->messages['accountexpires'][1];
@ -3374,7 +3376,8 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr
} }
// title // title
if (!$this->isBooleanConfigOptionSet('windowsUser_hidetitle', true)) { if (!$this->isBooleanConfigOptionSet('windowsUser_hidetitle', true)) {
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_title', 'title', 'title', $this->messages['title'][1], $errors); $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_title',
'title', 'title', $this->messages['title'][1], $errors);
} }
// room number // room number
if (!$this->isBooleanConfigOptionSet('windowsUser_hideroomnumber', true)) { if (!$this->isBooleanConfigOptionSet('windowsUser_hideroomnumber', true)) {
@ -3391,28 +3394,33 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr
} }
// employee type // employee type
if (!$this->isBooleanConfigOptionSet('windowsUser_hideemployeeType', true)) { if (!$this->isBooleanConfigOptionSet('windowsUser_hideemployeeType', true)) {
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_employeeType', 'employeeType', $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_employeeType',
'employeeType', $this->messages['employeeType'][1], $errors); 'employeeType', 'employeeType', $this->messages['employeeType'][1], $errors);
} }
// business category // business category
if (!$this->isBooleanConfigOptionSet('windowsUser_hidebusinessCategory', true)) { if (!$this->isBooleanConfigOptionSet('windowsUser_hidebusinessCategory', true)) {
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_businessCategory', 'businessCategory', 'businessCategory', $this->messages['businessCategory'][1], $errors, '/;[ ]*/'); $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_businessCategory',
'businessCategory', 'businessCategory', $this->messages['businessCategory'][1], $errors, '/;[ ]*/');
} }
// departments // departments
if (!$this->isBooleanConfigOptionSet('windowsUser_hidedepartment', true)) { if (!$this->isBooleanConfigOptionSet('windowsUser_hidedepartment', true)) {
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_department', 'department', null, null, $errors); $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_department',
'department', null, [], $errors);
} }
// department numbers // department numbers
if (!$this->isBooleanConfigOptionSet('windowsUser_hidedepartmentNumber', true)) { if (!$this->isBooleanConfigOptionSet('windowsUser_hidedepartmentNumber', true)) {
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_departmentNumber', 'departmentNumber', null, null, $errors, '/;[ ]*/'); $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_departmentNumber',
'departmentNumber', null, [], $errors, '/;[ ]*/');
} }
// organisational unit // organisational unit
if (!$this->isBooleanConfigOptionSet('windowsUser_hideou', true)) { if (!$this->isBooleanConfigOptionSet('windowsUser_hideou', true)) {
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_ou', 'ou', null, null, $errors, '/;[ ]*/'); $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_ou',
'ou', null, [], $errors, '/;[ ]*/');
} }
// organisation // organisation
if (!$this->isBooleanConfigOptionSet('windowsUser_hideo', true)) { if (!$this->isBooleanConfigOptionSet('windowsUser_hideo', true)) {
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_o', 'o', null, null, $errors, '/;[ ]*/'); $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_o',
'o', null, [], $errors, '/;[ ]*/');
} }
// manager // manager
if (!$this->isBooleanConfigOptionSet('windowsUser_hidemanager', true)) { if (!$this->isBooleanConfigOptionSet('windowsUser_hidemanager', true)) {
@ -3445,7 +3453,7 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr
// Proxy-Addresses // Proxy-Addresses
if (!$this->isBooleanConfigOptionSet('windowsUser_hideproxyAddresses', true)) { if (!$this->isBooleanConfigOptionSet('windowsUser_hideproxyAddresses', true)) {
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_proxyAddresses', 'proxyAddresses', $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_proxyAddresses', 'proxyAddresses',
null, null, $errors, '/;[ ]*/'); null, [], $errors, '/;[ ]*/');
} }
} }
return $errors; return $errors;
@ -3722,7 +3730,7 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr
$date = new DateTime('now', getTimeZone()); $date = new DateTime('now', getTimeZone());
$toAdd = new DateInterval('P' . $numDays . 'D'); $toAdd = new DateInterval('P' . $numDays . 'D');
$dateTarget = $date->add($toAdd); $dateTarget = $date->add($toAdd);
$this->setExpirationDate($dateTarget->format('Y'), $dateTarget->format('m'), $dateTarget->format('d')); $this->setExpirationDate((int) $dateTarget->format('Y'), (int) $dateTarget->format('m'), (int) $dateTarget->format('d'));
} }
// departments // departments
if (!$this->isBooleanConfigOptionSet('windowsUser_hidedepartment') if (!$this->isBooleanConfigOptionSet('windowsUser_hidedepartment')
@ -4058,7 +4066,7 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr
$lockoutDurationSeconds = substr($lockoutDuration, 0, -7); $lockoutDurationSeconds = substr($lockoutDuration, 0, -7);
$lockoutTime = self::getFileTime($attrs['lockouttime'][0]); $lockoutTime = self::getFileTime($attrs['lockouttime'][0]);
$unlockTime = clone $lockoutTime; $unlockTime = clone $lockoutTime;
$unlockTime->add(new DateInterval('PT' . abs($lockoutDurationSeconds) . 'S')); $unlockTime->add(new DateInterval('PT' . abs((int) $lockoutDurationSeconds) . 'S'));
$now = new DateTime('now', getTimeZone()); $now = new DateTime('now', getTimeZone());
if ($unlockTime > $now) { if ($unlockTime > $now) {
$unlockTime->setTimezone(getTimeZone()); $unlockTime->setTimezone(getTimeZone());