From 94b746ddf8867f71302150d58970a74ac8bab2a9 Mon Sep 17 00:00:00 2001 From: fs Date: Tue, 14 Apr 2026 08:48:29 +0200 Subject: [PATCH] refactor: remove 13 dead code artifacts across core/ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dead methods (9): - Command::bootstrapModuleApp() — unused by all subclasses - SearchConfig::providerCoverageGaps() — diagnostic method, never called - RequestInput::queryArray() — no callers - LocaleResolver::getAvailableLocales() / getDefaultLocale() — unused getters - EmailVerificationService::getExpiryMinutes() — constant wrapper, never called - AuthService::loginAndRedirect() — convenience wrapper, never called - DepartmentService::listForUserAssignments() — no callers - UserTenantContextService::getAvailableDepartmentsByTenant() — no callers Dead functions (3): - navActivePublicPages(), appNormalizeStringList(), appNormalizePositiveIntList() Dead constant (1): - PermissionService::API_DOCS_VIEW — duplicated via other paths Orphaned file (1): - bin/cli-bootstrap.php — never included anywhere Co-Authored-By: Claude Opus 4.6 --- bin/cli-bootstrap.php | 42 ------------------- core/Console/Command.php | 9 ---- core/Http/Input/RequestInput.php | 9 ---- core/Http/LocaleResolver.php | 10 ----- core/Service/Access/PermissionService.php | 1 - core/Service/Auth/AuthService.php | 33 --------------- .../Service/Auth/EmailVerificationService.php | 5 --- core/Service/Org/DepartmentService.php | 23 +--------- .../Service/User/UserTenantContextService.php | 42 ------------------- core/Support/SearchConfig.php | 21 ---------- core/Support/helpers/app.php | 28 ------------- core/Support/helpers/ui.php | 24 ----------- docs/reference-cli-commands.md | 1 - 13 files changed, 1 insertion(+), 247 deletions(-) delete mode 100644 bin/cli-bootstrap.php diff --git a/bin/cli-bootstrap.php b/bin/cli-bootstrap.php deleted file mode 100644 index 6601136..0000000 --- a/bin/cli-bootstrap.php +++ /dev/null @@ -1,42 +0,0 @@ - $channel, - 'method' => 'CLI', - 'path' => $path, - ]); - - if (!$container instanceof AppContainer) { - throw new RuntimeException('CLI app container bootstrap failed.'); - } - - return $container; -} diff --git a/core/Console/Command.php b/core/Console/Command.php index f603df0..b89a59d 100644 --- a/core/Console/Command.php +++ b/core/Console/Command.php @@ -3,7 +3,6 @@ namespace MintyPHP\Console; use MintyPHP\Console\Support\CliAppBootstrap; -use MintyPHP\Console\Support\ModuleCliRuntime; /** * Base class for CLI commands. @@ -50,12 +49,4 @@ abstract class Command CliAppBootstrap::bootstrap($channel, $path ?? 'bin/console ' . $this->name()); } - /** - * Bootstrap the app for module CLI commands. - * Loads the module CLI infrastructure (error policy, locking, app container). - */ - protected function bootstrapModuleApp(): void - { - ModuleCliRuntime::bootstrap(); - } } diff --git a/core/Http/Input/RequestInput.php b/core/Http/Input/RequestInput.php index 9e8cf9e..7d5d9b3 100644 --- a/core/Http/Input/RequestInput.php +++ b/core/Http/Input/RequestInput.php @@ -63,15 +63,6 @@ final class RequestInput return (int) $this->query($key, $default); } - /** - * @return array - */ - public function queryArray(string $key): array - { - $value = $this->query($key, []); - return is_array($value) ? $value : []; - } - /** * @return array */ diff --git a/core/Http/LocaleResolver.php b/core/Http/LocaleResolver.php index 7b23ba4..2816c15 100644 --- a/core/Http/LocaleResolver.php +++ b/core/Http/LocaleResolver.php @@ -109,16 +109,6 @@ class LocaleResolver return in_array($locale, $this->availableLocales, true); } - public function getAvailableLocales(): array - { - return $this->availableLocales; - } - - public function getDefaultLocale(): string - { - return $this->defaultLocale; - } - private function looksLikeLocale(string $candidate): bool { return preg_match('/^[a-z]{2}(?:-[a-z]{2})?$/i', $candidate) === 1; diff --git a/core/Service/Access/PermissionService.php b/core/Service/Access/PermissionService.php index 628dab5..fe6e04d 100644 --- a/core/Service/Access/PermissionService.php +++ b/core/Service/Access/PermissionService.php @@ -72,7 +72,6 @@ class PermissionService public const USERS_IMPORT_ASSIGNMENTS = 'users.import_assignments'; public const CUSTOM_FIELDS_MANAGE = 'custom_fields.manage'; public const CUSTOM_FIELDS_EDIT_VALUES = 'custom_fields.edit_values'; - public const API_DOCS_VIEW = 'api_docs.view'; public const DOCS_VIEW = 'docs.view'; public const MAIL_LOG_VIEW = 'mail_log.view'; public const STATS_VIEW = 'stats.view'; diff --git a/core/Service/Auth/AuthService.php b/core/Service/Auth/AuthService.php index dc07ec2..d3dfaa3 100644 --- a/core/Service/Auth/AuthService.php +++ b/core/Service/Auth/AuthService.php @@ -14,7 +14,6 @@ use MintyPHP\Service\Audit\AuditRecorderInterface; use MintyPHP\Service\User\UserAccountService; use MintyPHP\Service\User\UserTenantContextService; use MintyPHP\Session; -use MintyPHP\Support\Flash; /** * Orchestrates authentication flows: login, registration, logout, and session refresh. @@ -235,38 +234,6 @@ class AuthService return ['ok' => true, 'user' => $user]; } - public function loginAndRedirect( - string $email, - string $password, - string $successTarget = 'admin', - string $failTarget = 'login', - bool $remember = false - ): void { - $result = $this->login($email, $password); - - if (!($result['ok'] ?? false)) { - // Check if user needs to verify email - if (!empty($result['needs_verification'])) { - $this->sessionStore->set('email_verification_email', $result['email'] ?? $email); - Flash::error(t('Please verify your email first'), 'verify-email', 'login_not_verified'); - Router::redirect('verify-email'); - } - - $message = $result['message'] ?? 'Email/password not valid'; - $key = $result['flash_key'] ?? 'login_invalid'; - Flash::error($message, $failTarget, $key); - Router::redirect($failTarget); - } - - if ($remember) { - $userId = (int) ($this->sessionUser()['id'] ?? 0); - if ($userId > 0) { - $this->rememberMeService->rememberUser($userId); - } - } - Router::redirect($successTarget); - } - public function register(array $data): array { $email = trim((string) ($data['email'] ?? '')); diff --git a/core/Service/Auth/EmailVerificationService.php b/core/Service/Auth/EmailVerificationService.php index 8fe319f..bc8ab3a 100644 --- a/core/Service/Auth/EmailVerificationService.php +++ b/core/Service/Auth/EmailVerificationService.php @@ -142,11 +142,6 @@ class EmailVerificationService return $this->sendVerification((int) $user['id'], $locale); } - public function getExpiryMinutes(): int - { - return self::EXPIRY_MINUTES; - } - private function generateCode(): string { $max = (10 ** self::CODE_LENGTH) - 1; diff --git a/core/Service/Org/DepartmentService.php b/core/Service/Org/DepartmentService.php index e5e77de..523577d 100644 --- a/core/Service/Org/DepartmentService.php +++ b/core/Service/Org/DepartmentService.php @@ -79,28 +79,7 @@ class DepartmentService return $this->departmentRepository->listByIds($departmentIds); } - // Merges the tenant-scoped list with any already-selected departments outside the filter — - // ensures a user keeps visibility of departments they're already assigned to. - public function listForUserAssignments(array $tenantIds, array $selectedDepartmentIds): array - { - $departments = $tenantIds ? $this->listByTenantIds($tenantIds) : $this->list(); - $extraDepartments = $selectedDepartmentIds ? $this->listByIds($selectedDepartmentIds) : []; - if (!$extraDepartments) { - return $departments; - } - $departmentMap = []; - foreach ($departments as $department) { - if (isset($department['id'])) { - $departmentMap[(int) $department['id']] = $department; - } - } - foreach ($extraDepartments as $department) { - if (isset($department['id'])) { - $departmentMap[(int) $department['id']] = $department; - } - } - return array_values($departmentMap); - } + public function findByUuid(string $uuid): ?array { diff --git a/core/Service/User/UserTenantContextService.php b/core/Service/User/UserTenantContextService.php index ed21f46..d9ef5cd 100644 --- a/core/Service/User/UserTenantContextService.php +++ b/core/Service/User/UserTenantContextService.php @@ -132,48 +132,6 @@ class UserTenantContextService return $tenants; } - /** - * Get available departments grouped by tenant for a user. - * Returns an array of groups: ['tenant' => [...], 'departments' => [...]] - */ - public function getAvailableDepartmentsByTenant(int $userId): array - { - $tenants = $this->getAvailableTenants($userId); - if (!$tenants) { - return []; - } - - $groups = []; - foreach ($tenants as $tenant) { - $tenantId = (int) ($tenant['id'] ?? 0); - if ($tenantId <= 0) { - continue; - } - $departments = $this->directoryGateway->listDepartmentsByTenantIds([$tenantId]); - usort($departments, static function ($a, $b) { - return strcmp((string) ($a['description'] ?? ''), (string) ($b['description'] ?? '')); - }); - $departments = array_map(static function (array $department): array { - return [ - 'id' => (int) ($department['id'] ?? 0), - 'uuid' => $department['uuid'] ?? '', - 'description' => $department['description'] ?? '', - ]; - }, $departments); - - $groups[] = [ - 'tenant' => [ - 'id' => (int) ($tenant['id'] ?? 0), - 'uuid' => $tenant['uuid'] ?? '', - 'description' => $tenant['description'] ?? '', - ], - 'departments' => $departments, - ]; - } - - return $groups; - } - /** * Set the current tenant for a user (with validation) */ diff --git a/core/Support/SearchConfig.php b/core/Support/SearchConfig.php index f5102e2..149246e 100644 --- a/core/Support/SearchConfig.php +++ b/core/Support/SearchConfig.php @@ -241,25 +241,4 @@ class SearchConfig return SearchQueryNormalizer::normalizeScoreQuery($query); } - /** - * @return array{missingIcons: string[], missingListUrls: string[]} - */ - public static function providerCoverageGaps(): array - { - $missingIcons = []; - $missingListUrls = []; - foreach (SearchSqlResourceProvider::resourceKeys() as $key) { - if (!SearchUiMetaProvider::hasIconForKey($key)) { - $missingIcons[] = $key; - } - if (!SearchUiMetaProvider::hasListUrlForKey($key)) { - $missingListUrls[] = $key; - } - } - - return [ - 'missingIcons' => $missingIcons, - 'missingListUrls' => $missingListUrls, - ]; - } } diff --git a/core/Support/helpers/app.php b/core/Support/helpers/app.php index 4391015..f7973f5 100644 --- a/core/Support/helpers/app.php +++ b/core/Support/helpers/app.php @@ -354,34 +354,6 @@ function layoutHasAdminPanel(array $layoutAuth): bool return false; } -/** - * Normalize list-like input to sorted unique non-empty strings. - * - * @return list - */ -function appNormalizeStringList(mixed $value): array -{ - $raw = is_array($value) ? $value : explode(',', (string) $value); - $list = array_filter(array_map('trim', $raw), static fn ($item) => $item !== ''); - $list = array_values(array_unique($list)); - sort($list, SORT_STRING); - return $list; -} - -/** - * Normalize list-like input to sorted unique positive integers. - * - * @return list - */ -function appNormalizePositiveIntList(mixed $value): array -{ - $raw = is_array($value) ? $value : explode(',', (string) $value); - $list = array_values(array_unique(array_map('intval', $raw))); - $list = array_values(array_filter($list, static fn ($item) => $item > 0)); - sort($list, SORT_NUMERIC); - return $list; -} - /** * Reserved top-level keys in layout navigation context that modules must not override. * diff --git a/core/Support/helpers/ui.php b/core/Support/helpers/ui.php index ee757b0..347e33c 100644 --- a/core/Support/helpers/ui.php +++ b/core/Support/helpers/ui.php @@ -416,30 +416,6 @@ function navActive($path, bool $prefix = false): array ]; } -/** - * Resolve active state for public page links (static pages and page/* slugs). - * - * @param array $extraSlugs Additional public slugs that should be treated as active. - * @return array{class:string,aria:string,isActive:bool} - */ -function navActivePublicPages(array $extraSlugs = []): array -{ - $current = \MintyPHP\Http\Request::path(); - if ($current === '') { - return ['class' => '', 'aria' => '', 'isActive' => false]; - } - - // "page/" routes and known standalone slugs should highlight the same nav entry. - $publicSlugs = array_merge(['imprint', 'privacy', 'terms'], $extraSlugs); - $isActive = strpos($current, 'page/') === 0 || in_array($current, $publicSlugs, true); - - return [ - 'class' => $isActive ? 'active' : '', - 'aria' => $isActive ? 'aria-current="page"' : '', - 'isActive' => $isActive, - ]; -} - /** * Load and cache the asset registry config from config/assets.php. */ diff --git a/docs/reference-cli-commands.md b/docs/reference-cli-commands.md index 0493464..c421cf9 100644 --- a/docs/reference-cli-commands.md +++ b/docs/reference-cli-commands.md @@ -187,5 +187,4 @@ Die `Command`-Basisklasse stellt Helfer bereit: | Methode | Zweck | |---|---| | `$this->bootstrapApp($channel)` | App-Bootstrap fuer Nicht-Modul-Kommandos | -| `$this->bootstrapModuleApp()` | App-Bootstrap mit Modul-Error-Policy und Locking | | `$this->projectRoot()` | Gibt den absoluten Projekt-Root-Pfad zurueck |