diff --git a/lam/lib/html.inc b/lam/lib/html.inc index 63bd75f1b..f1820416b 100644 --- a/lam/lib/html.inc +++ b/lam/lib/html.inc @@ -1072,9 +1072,9 @@ class htmlButton extends htmlElement { /** * Constructor. * - * @param String $name button name - * @param String $value button text or image (16x16px, relative to graphics folder) - * @param String $isImageButton image or text button (default text) + * @param string $name button name + * @param string $value button text or image (16x16px, relative to graphics folder) + * @param bool $isImageButton image or text button (default text) */ function __construct($name, $value, $isImageButton = false) { $this->name = htmlspecialchars($name); diff --git a/lam/lib/profiles.inc b/lam/lib/profiles.inc index c07c733f1..77ac6bc96 100644 --- a/lam/lib/profiles.inc +++ b/lam/lib/profiles.inc @@ -204,7 +204,6 @@ class AccountProfilePersistenceManager { * @param string $confName server profile name * @return bool profile exists * @throws LAMException error while checking - * @throws LAMException error writing template */ public function isAccountProfileExisting(string $typeId, string $name, string $confName): bool { if (!$this->isValidAccountProfileName($name) diff --git a/lam/templates/tools/multiEdit.php b/lam/templates/tools/multiEdit.php index 1c0c90610..f6a0bcc21 100644 --- a/lam/templates/tools/multiEdit.php +++ b/lam/templates/tools/multiEdit.php @@ -1,26 +1,28 @@ \n"; $errors = []; $container = new htmlResponsiveRow(); - $container->add(new htmlTitle(_("Multi edit")), 12); + $container->add(new htmlTitle(_("Multi edit"))); // LDAP suffix $showRules = ['-' => ['otherSuffix']]; $hideRules = []; - $typeManager = new \LAM\TYPES\TypeManager(); + $typeManager = new TypeManager(); $types = $typeManager->getConfiguredTypes(); $suffixes = []; foreach ($types as $type) { @@ -144,16 +146,16 @@ function displayStartPage(): void { $suffixSelect->setSortElements(false); $suffixSelect->setTableRowsToShow($showRules); $suffixSelect->setTableRowsToHide($hideRules); - $container->add($suffixSelect, 12); - $valOtherSuffix = empty($_POST['otherSuffix']) ? '' : $_POST['otherSuffix']; - $container->add(new htmlResponsiveInputField(_('Other'), 'otherSuffix', $valOtherSuffix), 12); + $container->add($suffixSelect); + $valOtherSuffix = empty($_POST['otherSuffix']) ? '' : (string) $_POST['otherSuffix']; + $container->add(new htmlResponsiveInputField(_('Other'), 'otherSuffix', $valOtherSuffix)); // LDAP filter - $valFilter = empty($_POST['filter']) ? '(objectClass=inetOrgPerson)' : $_POST['filter']; - $container->add(new htmlResponsiveInputField(_('LDAP filter'), 'filter', $valFilter, '701'), 12); + $valFilter = empty($_POST['filter']) ? '(objectClass=inetOrgPerson)' : (string) $_POST['filter']; + $container->add(new htmlResponsiveInputField(_('LDAP filter'), 'filter', $valFilter, '701')); // operation fields $operationsTitle = new htmlSubTitle(_('Operations')); $operationsTitle->setHelpId('702'); - $container->add($operationsTitle, 12); + $container->add($operationsTitle); $operationsTitles = [_('Type'), _('Attribute name'), _('Value')]; $data = []; $opCount = empty($_POST['opcount']) ? '3' : $_POST['opcount']; @@ -168,9 +170,9 @@ function displayStartPage(): void { $opSelect->setHasDescriptiveElements(true); $data[$i][] = $opSelect; // attribute name - $attrVal = empty($_POST['attr_' . $i]) ? '' : $_POST['attr_' . $i]; + $attrVal = empty($_POST['attr_' . $i]) ? '' : (string) $_POST['attr_' . $i]; $data[$i][] = new htmlInputField('attr_' . $i, $attrVal); - $valVal = empty($_POST['val_' . $i]) ? '' : $_POST['val_' . $i]; + $valVal = empty($_POST['val_' . $i]) ? '' : (string) $_POST['val_' . $i]; $data[$i][] = new htmlInputField('val_' . $i, $valVal); // check input if (($selOp == ADD) && !empty($attrVal) && empty($valVal)) { @@ -181,17 +183,17 @@ function displayStartPage(): void { } } $operationsTable = new htmlResponsiveTable($operationsTitles, $data); - $container->add($operationsTable, 12); + $container->add($operationsTable); // add more fields $container->addVerticalSpacer('1rem'); - $container->add(new htmlButton('addFields', _('Add more fields')), 12); - $container->add(new htmlHiddenInput('opcount', $opCount), 12); + $container->add(new htmlButton('addFields', _('Add more fields'))); + $container->add(new htmlHiddenInput('opcount', $opCount)); // error messages if ($errors !== []) { $container->addVerticalSpacer('5rem'); foreach ($errors as $error) { $error->colspan = 5; - $container->add($error, 12); + $container->add($error); } } // action buttons @@ -205,7 +207,7 @@ function displayStartPage(): void { $dryRunButton = new htmlButton('dryRun', _('Dry run')); $dryRunButton->setCSSClasses(['lam-secondary']); $buttonGroup->addElement($dryRunButton); - $container->add($buttonGroup, 12); + $container->add($buttonGroup); $container->addVerticalSpacer('1rem'); // run actions @@ -226,13 +228,13 @@ function displayStartPage(): void { * * @param htmlResponsiveRow $container container */ -function runActions(htmlResponsiveRow &$container): void { +function runActions(htmlResponsiveRow $container): void { // LDAP suffix $suffix = ($_POST['suffix'] === '-') ? trim($_POST['otherSuffix']) : $_POST['suffix']; if (empty($suffix)) { $error = new htmlStatusMessage('ERROR', _('LDAP Suffix is invalid!')); $error->colspan = 5; - $container->add($error, 12); + $container->add($error); return; } // LDAP filter @@ -247,7 +249,7 @@ function runActions(htmlResponsiveRow &$container): void { if (count($operations) == 0) { $error = new htmlStatusMessage('ERROR', _('Please specify at least one operation.')); $error->colspan = 5; - $container->add($error, 12); + $container->add($error); return; } $_SESSION['multiEdit_suffix'] = $suffix; @@ -264,7 +266,7 @@ function runActions(htmlResponsiveRow &$container): void { $ajaxBlock = ' window.lam.multiedit.runActions(); '; - $container->add(new htmlJavaScript($ajaxBlock), 12); + $container->add(new htmlJavaScript($ajaxBlock)); } /** @@ -419,6 +421,7 @@ function generateActions(): array { * Prints the dryRun output. * * @return array status + * @throws LAMException error simulating actions */ function dryRun(): array { $pro = isLAMProVersion() ? ' Pro' : ''; diff --git a/lam/templates/tools/ou_edit.php b/lam/templates/tools/ou_edit.php index 25e54a7e3..1a394ef22 100644 --- a/lam/templates/tools/ou_edit.php +++ b/lam/templates/tools/ou_edit.php @@ -18,7 +18,7 @@ use LAM\TYPES\TypeManager; /* This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2003 - 2024 Roland Gruber + Copyright (C) 2003 - 2025 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -206,6 +206,9 @@ function display_main(?string $message, ?string $error): void { $optionsToInsert = []; foreach ($types as $typeId => $title) { $type = $typeManager->getConfiguredType($typeId); + if ($type === null) { + continue; + } $elements = []; $units = searchLDAP($type->getSuffix(), '(|(objectclass=organizationalunit)(objectclass=organization))', ['dn']); foreach ($units as $unit) { diff --git a/lam/templates/tools/serverInfo.php b/lam/templates/tools/serverInfo.php index f84a23eff..09dbc59a3 100644 --- a/lam/templates/tools/serverInfo.php +++ b/lam/templates/tools/serverInfo.php @@ -2,7 +2,7 @@ /* This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2009 - 2024 Roland Gruber + Copyright (C) 2009 - 2025 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -180,7 +180,7 @@ if (isset($monitorEntries['cn=time,cn=monitor']) || isset($monitorEntries['cn=st if (isset($monitorEntries['cn=start,cn=time,cn=monitor'])) { $time = formatLDAPTimestamp($monitorEntries['cn=start,cn=time,cn=monitor']['monitortimestamp'][0]); $container->addLabel(new htmlOutputText('' . _("Start time") . '', false)); - $container->addField(new htmlOutputText($time), 12); + $container->addField(new htmlOutputText($time)); } elseif (isset($monitorEntries['cn=monitor']['starttime'])) { // Fedora 389 $time = formatLDAPTimestamp($monitorEntries['cn=monitor']['starttime'][0]); diff --git a/phpstan.neon b/phpstan.neon index b8ee0ad32..005d0a82b 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -22,15 +22,12 @@ parameters: - '#Used function [a-zA-Z0-9\\_-]+ not found.#' - '#Variable \$helpArray might not be defined.#' - '#Function [a-zA-Z0-9\(\)\\_-]+ has invalid return type [a-zA-Z0-9\\_-]+.#' - - '#PHPDoc tag @throws with type LAMException is not subtype of Throwable#' - - '#Throwing object of an unknown class [a-zA-Z0-9\\_-]+.#' - '#Parameter \#[0-9] \$[a-zA-Z_]+ of function [a-zA-Z_]+ expects [(]?callable.*#' - '#Call to an undefined method object::.*#' - '#Parameter \#2 \$string of function explode expects string, .* given.#' - '#Parameter \#2 \$result of function ldap_.* expects LDAP\\Result, array\|LDAP\\Result given.#' - '#Cannot access an offset on mixed.#' - '#Cannot access offset .* on mixed.#' - - '#Cannot access offset .* on array\|int.#' - '#Cannot access an offset on array\|Countable.#' - '#Cannot assign new offset to list\\|string.#' - '#Parameter \#1 \$haystack of function str_starts_with expects string, int\|string given.#' @@ -40,7 +37,6 @@ parameters: - '#Parameter \#1 \$array of function array_keys expects array, mixed given.#' - '#Argument of an invalid type mixed supplied for foreach, only iterables are supported.#' - '#Parameter \#2 \$args of function call_user_func_array expects array, mixed given.#' - - '#Cannot access offset non-falsy-string on array\|object.#' - '#Unable to resolve the template type T in call to function array_values#' - '#Cannot call method .* on mixed.*#' - '#Cannot cast mixed to string.#' @@ -50,3 +46,4 @@ parameters: - '#Cannot access property .* on mixed#' - '#.* function lamEncrypt expects string.*#' - '#.*class htmlHiddenInput constructor expects string, mixed given.*#' + - '#Parameter \#1 \$string of class htmlOutputText constructor expects string, \(array\|float\|int\) given.#'