diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index 0458f481c..4a3992232 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -671,13 +671,16 @@ function getRequiredExtensions() { * meta HTML code. This allows to have a common design for all module pages. * * @param string|null $module Name of account module - * @param htmlElement|htmlElement[] $input htmlElement or array of htmlElement elements + * @param htmlElement|htmlElement[]|null $input htmlElement or array of htmlElement elements * @param array $values List of values which override the defaults in $input (name => value) * @param boolean $restricted If true then no buttons will be displayed * @param string|null $scope Account type * @return array List of input field names and their type (name => type) */ function parseHtml($module, $input, $values, $restricted, $scope) { + if ($input === null) { + return []; + } if ($input instanceof htmlElement) { return $input->generateHTML($module, $input, $values, $restricted, $scope); } diff --git a/lam/lib/modules/fixed_ip.inc b/lam/lib/modules/fixed_ip.inc index d53a932e4..d3f6f2839 100644 --- a/lam/lib/modules/fixed_ip.inc +++ b/lam/lib/modules/fixed_ip.inc @@ -911,7 +911,7 @@ class fixed_ip extends baseModule { */ public function getListRenderFunction(string $attributeName): ?callable { if ($attributeName === 'fixed_ips') { - return function(array $entry, string $attribute): ?htmlElement { + return function(array $entry, string $attribute): htmlElement { // find all fixed addresses: $entries = searchLDAP($entry['dn'], 'objectClass=dhcpHost', ['dhcpstatements', 'dhcphwaddress', 'cn']); if (count($entries) > 0) { @@ -959,7 +959,7 @@ class fixed_ip extends baseModule { } return $group; } - return null; + return new htmlGroup(); }; } return null; diff --git a/lam/lib/modules/imapAccess.inc b/lam/lib/modules/imapAccess.inc index 73494f0e1..e78186fa0 100644 --- a/lam/lib/modules/imapAccess.inc +++ b/lam/lib/modules/imapAccess.inc @@ -411,7 +411,7 @@ class imapAccess extends baseModule { /** * Creates the mailbox for a user. * - * @param Horde_Imap_Client_Socket $client IMAP client + * @param Client $client IMAP client * @param string $userName user name * @param string $email_domain email domain * @return array error messages @@ -452,7 +452,7 @@ class imapAccess extends baseModule { /** * Sets the mailbox quota for a user. * - * @param Horde_Imap_Client_Socket $client IMAP client + * @param Client $client IMAP client * @param string $userName user name * @param string $email_domain email domain * @param string $quota mailbox quota @@ -927,27 +927,31 @@ class imapAccess extends baseModule { /** * Returns if the mailbox exists. * - * @param $client IMAP client + * @param Client $client IMAP client * @param string $path mailbox path * @return bool is existing */ private function isMailboxExisting($client, string $path): bool { $list = $client->getConnection()->folders($path); - return ($list !== null) && is_array($list->data()) && (count($list->data()) >= 1); + return is_array($list->data()) && (count($list->data()) >= 1); } /** * Returns the quota data for the user. * - * @param $client IMAP client + * @param Client $client IMAP client * @param string $user user name * @return array array with keys QUOTA_USAGE and QUOTA_LIMIT */ private function getQuota($client, string $user): array { - $user = $client->getConnection()->escapeString($user); + $connection = $client->getConnection(); + if (!($connection instanceof ImapProtocol)) { + return []; + } + $user = $connection->escapeString($user); $quota_values = []; try { - $quota = $client->getConnection()->requestAndResponse('GETQUOTA', [$user]); + $quota = $connection->requestAndResponse('GETQUOTA', [$user]); $quota = $quota->data(); if (isset($quota[0][2][0]) && ($quota[0][2][0] === 'STORAGE')) { $quota_values = [ diff --git a/lam/lib/modules/inetOrgPerson.inc b/lam/lib/modules/inetOrgPerson.inc index b0fd58312..968e4544d 100644 --- a/lam/lib/modules/inetOrgPerson.inc +++ b/lam/lib/modules/inetOrgPerson.inc @@ -4138,7 +4138,7 @@ class inetOrgPerson extends baseModule implements passwordService, AccountStatus }; } elseif ($attributeName === 'jpegphoto') { - return function(array $entry, string $attribute): ?htmlElement { + return function(array $entry, string $attribute): htmlElement { if (isset($entry[$attribute][0]) && ($entry[$attribute][0] !== '')) { if (strlen($entry[$attribute][0]) < 100) { // looks like we have read broken binary data, reread photo @@ -4162,7 +4162,7 @@ class inetOrgPerson extends baseModule implements passwordService, AccountStatus $image->setCSSClasses(['thumbnail']); return $image; } - return null; + return new htmlGroup(); }; } return null; diff --git a/lam/lib/modules/range.inc b/lam/lib/modules/range.inc index c4296f2eb..b025b7151 100644 --- a/lam/lib/modules/range.inc +++ b/lam/lib/modules/range.inc @@ -820,7 +820,7 @@ class range extends baseModule { */ public function getListRenderFunction(string $attributeName): ?callable { if ($attributeName === 'dhcprange') { - return function(array $entry, string $attribute): ?htmlElement { + return function(array $entry, string $attribute): htmlElement { if (!empty($entry[$attribute][0])) { $table = new htmlTable(); $table->setCSSClasses(['nowrap']); @@ -861,7 +861,7 @@ class range extends baseModule { } return $table; } - return null; + return new htmlGroup(); }; } return null; diff --git a/lam/lib/modules/sambaSamAccount.inc b/lam/lib/modules/sambaSamAccount.inc index 4fec23dd6..7e529bf61 100644 --- a/lam/lib/modules/sambaSamAccount.inc +++ b/lam/lib/modules/sambaSamAccount.inc @@ -3089,7 +3089,7 @@ class sambaSamAccount extends baseModule implements passwordService, AccountStat */ public function getListRenderFunction(string $attributeName): ?callable { if ($attributeName === 'sambakickofftime') { - return function(array $entry, string $attribute): ?htmlElement { + return function(array $entry, string $attribute): htmlElement { if (!empty($entry[$attribute][0])) { if ($entry[$attribute][0] > 2147483648) { return new htmlOutputText("∞"); @@ -3099,7 +3099,7 @@ class sambaSamAccount extends baseModule implements passwordService, AccountStat return new htmlOutputText($date->format('d.m.Y')); } } - return null; + return new htmlGroup(); }; } return null; diff --git a/lam/lib/modules/shadowAccount.inc b/lam/lib/modules/shadowAccount.inc index 2391f9e91..d54358bd7 100644 --- a/lam/lib/modules/shadowAccount.inc +++ b/lam/lib/modules/shadowAccount.inc @@ -1036,12 +1036,12 @@ class shadowAccount extends baseModule implements passwordService, AccountStatus */ public function getListRenderFunction(string $attributeName): ?callable { if (($attributeName === 'shadowexpire') || ($attributeName === 'shadowlastchange')) { - return function(array $entry, string $attribute): ?htmlElement { + return function(array $entry, string $attribute): htmlElement { if (!empty($entry[$attribute][0])) { $time = new DateTime('@' . $entry[$attribute][0] * 24 * 3600, getTimeZone()); return new htmlOutputText($time->format('d.m.Y')); } - return null; + return new htmlGroup(); }; } return null; diff --git a/lam/lib/modules/windowsGroup.inc b/lam/lib/modules/windowsGroup.inc index 11ffea3d4..65175f63f 100644 --- a/lam/lib/modules/windowsGroup.inc +++ b/lam/lib/modules/windowsGroup.inc @@ -1126,7 +1126,7 @@ class windowsGroup extends baseModule { }; } elseif (($attributeName === 'managedby') || ($attributeName === 'member')) { - return function(array $entry, string $attribute): ?htmlElement { + return function(array $entry, string $attribute): htmlElement { if (!empty($entry[$attribute][0])) { $typeManager = new TypeManager(); $values = $entry[$attribute]; @@ -1149,7 +1149,7 @@ class windowsGroup extends baseModule { } return new htmlDiv(null, new htmlOutputText(implode('
', $values), false), ['rightToLeftText']); } - return null; + return new htmlGroup(); }; } return null; diff --git a/lam/lib/modules/windowsHost.inc b/lam/lib/modules/windowsHost.inc index d2cf8088d..a78267fb1 100644 --- a/lam/lib/modules/windowsHost.inc +++ b/lam/lib/modules/windowsHost.inc @@ -414,7 +414,7 @@ class windowsHost extends baseModule { }; } elseif ($attributeName === 'managedby') { - return function(array $entry, string $attribute): ?htmlElement { + return function(array $entry, string $attribute): htmlElement { if (!empty($entry[$attribute][0])) { $value = $entry[$attribute][0]; $typeManager = new TypeManager(); @@ -431,7 +431,7 @@ class windowsHost extends baseModule { } return new htmlDiv(null, new htmlOutputText($value, false), ['rightToLeftText']); } - return null; + return new htmlGroup(); }; } return null; diff --git a/lam/lib/modules/windowsUser.inc b/lam/lib/modules/windowsUser.inc index af362454b..bd07b822f 100644 --- a/lam/lib/modules/windowsUser.inc +++ b/lam/lib/modules/windowsUser.inc @@ -4808,7 +4808,7 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr }; } elseif (($attributeName === 'jpegphoto') || ($attributeName === 'thumbnailphoto')) { - return function(array $entry, string $attribute): ?htmlElement { + return function(array $entry, string $attribute): htmlElement { if (isset($entry[$attribute][0]) && ($entry[$attribute][0] !== '')) { if (strlen($entry[$attribute][0]) < 100) { // looks like we have read broken binary data, reread photo @@ -4832,7 +4832,7 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr $image->setCSSClasses(['thumbnail']); return $image; } - return null; + return new htmlGroup(); }; } elseif ($attributeName === 'accountexpires') { @@ -4848,7 +4848,7 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr }; } elseif ($attributeName === 'manager') { - return function(array $entry, string $attribute): ?htmlElement { + return function(array $entry, string $attribute): htmlElement { if (!empty($entry[$attribute][0])) { $value = $entry[$attribute][0]; $typeManager = new TypeManager(); @@ -4865,7 +4865,7 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr } return new htmlDiv(null, new htmlOutputText($value, false), ['rightToLeftText']); } - return null; + return new htmlGroup(); }; } return null; diff --git a/lam/templates/tests/schemaTest.php b/lam/templates/tests/schemaTest.php index 2e35fa61e..63558cdd2 100644 --- a/lam/templates/tests/schemaTest.php +++ b/lam/templates/tests/schemaTest.php @@ -6,6 +6,7 @@ use \htmlStatusMessage; use \htmlSubTitle; use \htmlOutputText; use \htmlImage; +use LAM\SCHEMA\ObjectClass; use function \LAM\SCHEMA\get_schema_objectclasses; use function \LAM\SCHEMA\get_cached_schema; /* diff --git a/phpstan.neon b/phpstan.neon index b234094a3..60a4350fd 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -15,7 +15,6 @@ parameters: analyseAndScan: - */lists/changePassword.php ignoreErrors: - - '#.* on an unknown class .*#' - '#.* has invalid type .*#' - '#Function [a-zA-Z0-9\\_-]+ not found.#' - '#Used function [a-zA-Z0-9\\_-]+ not found.#'