diff --git a/lam/lib/baseModule.inc b/lam/lib/baseModule.inc index 27d9f0357..7adff2f90 100644 --- a/lam/lib/baseModule.inc +++ b/lam/lib/baseModule.inc @@ -554,10 +554,10 @@ abstract class baseModule { * (e.g. posixAccount_homeDirectory) to avoid naming conflicts. * * @param string $typeId type id (user, group, host, ...) - * @return htmlElement meta HTML object + * @return htmlResponsiveRow|null meta HTML object * * @see baseModule::get_metaData() - * @see htmlElement + * @see htmlResponsiveRow */ public function get_profileOptions($typeId) { return $this->meta['profile_options'] ?? null; diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index ba7d17536..c9a518ad7 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -853,16 +853,12 @@ class accountContainer { /** * Returns the account module with the given class name * - * @param string $name class name (e.g. posixAccount) - * @return baseModule account module + * @template T of baseModule + * @param class-string $name class name (e.g. posixAccount) + * @return T|null account module */ - public function getAccountModule($name) { - if (isset($this->module[$name])) { - return $this->module[$name]; - } - else { - return null; - } + public function getAccountModule(string $name): ?baseModule { + return $this->module[$name] ?? null; } /** diff --git a/lam/lib/modules/windowsUser.inc b/lam/lib/modules/windowsUser.inc index 8c7cf2818..ea484c799 100644 --- a/lam/lib/modules/windowsUser.inc +++ b/lam/lib/modules/windowsUser.inc @@ -3751,21 +3751,7 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr } /** - * Checks if all input values are correct and returns the LDAP attributes which should be changed. - *
Return values: - *
messages: array of parameters to create status messages - *
add: array of attributes to add - *
del: array of attributes to remove - *
mod: array of attributes to modify - *
info: array of values with informational value (e.g. to be used later by pre/postModify actions) - * - * Calling this method does not require the existence of an enclosing {@link accountContainer}. - * - * @param string $fields input fields - * @param array $attributes LDAP attributes - * @param boolean $passwordChangeOnly indicates that the user is only allowed to change his password and no LDAP content is readable - * @param array $readOnlyFields list of read-only fields - * @return array messages and attributes (array('messages' => [], 'add' => array('mail' => array('test@test.com')), 'del' => [], 'mod' => [], 'info' => [])) + * {@inheritDoc} */ function checkSelfServiceOptions($fields, $attributes, $passwordChangeOnly, $readOnlyFields) { $return = ['messages' => [], 'add' => [], 'del' => [], 'mod' => [], 'info' => []]; @@ -3936,14 +3922,14 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr * Returns if the account is currently deactivated. * * @param array $attrs LDAP attributes - * @return boolean is deactivated + * @return bool is deactivated */ - public static function isDeactivated($attrs) { + public static function isDeactivated($attrs): bool { $myAttrs = array_change_key_case($attrs); if (!isset($myAttrs['useraccountcontrol'][0])) { return false; } - return intval($myAttrs['useraccountcontrol'][0]) & self::AC_ACCOUNT_DISABLED; + return (intval($myAttrs['useraccountcontrol'][0]) & self::AC_ACCOUNT_DISABLED) === self::AC_ACCOUNT_DISABLED; } /** @@ -4007,9 +3993,9 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr /** * Unlocks the user password. This resets 'lockoutTime' to 0. * - * @param array|null $attributes LDAP attributes + * @param array|string>|null $attributes LDAP attributes */ - public function unlockPassword(?array &$attributes = null) { + public function unlockPassword(?array &$attributes = null): void { if ($attributes === null) { $attributes = &$this->attributes; } @@ -4022,7 +4008,7 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr * Sets if the account is currently deactivated. * * @param boolean $deactivated is deactivated - * @param array $attrs LDAP attributes to modify (default $this->attributes) + * @param array|string>|null $attrs LDAP attributes to modify (default $this->attributes) */ public function setIsDeactivated($deactivated, &$attrs = null) { if ($attrs == null) { @@ -4044,13 +4030,13 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr * Returns if the account requires a smartcard to login. * * @param array $attrs LDAP attributes - * @return boolean requires a smartcard + * @return bool requires a smartcard */ - public static function isSmartCardRequired($attrs) { + public static function isSmartCardRequired($attrs): bool { if (!isset($attrs['useraccountcontrol'][0])) { return false; } - return intval($attrs['useraccountcontrol'][0]) & self::AC_SMARTCARD_REQUIRED; + return (intval($attrs['useraccountcontrol'][0]) & self::AC_SMARTCARD_REQUIRED) === self::AC_SMARTCARD_REQUIRED; } /** @@ -4076,13 +4062,13 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr * Returns if the account never expires. * * @param array $attrs LDAP attributes - * @return boolean never expires + * @return bool never expires */ - public static function isNeverExpiring($attrs) { + public static function isNeverExpiring($attrs): bool { if (!isset($attrs['useraccountcontrol'][0])) { return false; } - return intval($attrs['useraccountcontrol'][0]) & self::AC_PWD_NEVER_EXPIRES; + return (intval($attrs['useraccountcontrol'][0]) & self::AC_PWD_NEVER_EXPIRES) === self::AC_PWD_NEVER_EXPIRES; } /** @@ -4286,9 +4272,9 @@ 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 - * @return DateTime time value + * @return DateTime|null time value */ - public static function getFileTime($value) { + public static function getFileTime($value): ?DateTime { if (empty($value) || !get_preg($value, 'digit')) { return null; } @@ -4806,7 +4792,7 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr */ public function getListRenderFunction(string $attributeName): ?callable { if ($attributeName === 'mail') { - return function(array $entry, string $attribute): ?htmlElement { + return function(array $entry, string $attribute): htmlElement { $group = new htmlGroup(); if (isset($entry[$attribute][0]) && ($entry[$attribute][0] != '')) { for ($i = 0; $i < count($entry[$attribute]); $i++) { @@ -4848,10 +4834,10 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr }; } elseif ($attributeName === 'accountexpires') { - return fn(array $entry, string $attribute): ?htmlElement => new htmlOutputText($this->formatAccountExpires($entry)); + return fn(array $entry, string $attribute): htmlElement => new htmlOutputText($this->formatAccountExpires($entry)); } elseif (($attributeName === 'whencreated') || ($attributeName === 'whenchanged')) { - return function(array $entry, string $attribute): ?htmlElement { + return function(array $entry, string $attribute): htmlElement { $value = ' - '; if (!empty($entry[$attribute][0])) { $value = formatLDAPTimestamp($entry[$attribute][0]); diff --git a/lam/lib/status.inc b/lam/lib/status.inc index 550517dbf..5290e6f39 100644 --- a/lam/lib/status.inc +++ b/lam/lib/status.inc @@ -38,12 +38,12 @@ *
It may be formatted with special color/link/bold tags. * @param string $MessageText The text of the status message. *
It may be formatted with special color/link/bold tags. This parameter is optional. - * @param array|string $MessageVariables The variables that are used to replace the spacers (%s) in the + * @param array|string|null $MessageVariables The variables that are used to replace the spacers (%s) in the * submitted text. This parameter is optional. * @param bool $returnOutput if set to true this function will return the generated HTML code instead of printing it directly (default: false) * @return string HTML code if $returnOutput is set to true, otherwise null */ -function StatusMessage($MessageTyp, $MessageHeadline, $MessageText = '', array|string $MessageVariables = [], bool $returnOutput = false): string { +function StatusMessage($MessageTyp, $MessageHeadline, $MessageText = '', array|string|null $MessageVariables = [], bool $returnOutput = false): string { /* Setting CSS-StyleSheet class depending on the $MessageTyp and rewriting $MessageTyp with a readable string. */ if ($MessageTyp == "INFO") { $class = "class=\"statusInfo lam-status-message\""; @@ -75,9 +75,12 @@ function StatusMessage($MessageTyp, $MessageHeadline, $MessageText = '', array|s $output = $format; } } - else { + elseif ($MessageVariables !== null) { $output = sprintf($format, $MessageVariables); } + else { + $output = $format; + } if ($returnOutput) { return $output; }