From cad5261aba8b123158ed7039e955f0a842254141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Mon, 2 Feb 2026 23:26:18 +0100 Subject: [PATCH] Fixed phpstan issues --- phpstan.dist.neon | 6 ++++++ src/Command/MaintenanceModeCommand.php | 2 +- src/Services/System/CommandRunHelper.php | 2 -- src/Services/System/UpdateAvailableFacade.php | 2 -- src/Services/System/UpdateChecker.php | 7 ++----- src/Services/System/UpdateExecutor.php | 2 ++ 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/phpstan.dist.neon b/phpstan.dist.neon index fc7b3524..eb629314 100644 --- a/phpstan.dist.neon +++ b/phpstan.dist.neon @@ -6,6 +6,9 @@ parameters: - src # - tests + banned_code: + non_ignorable: false # Allow to ignore some banned code + excludePaths: - src/DataTables/Adapter/* - src/Configuration/* @@ -61,3 +64,6 @@ parameters: # Ignore error of unused WithPermPresetsTrait, as it is used in the migrations which are not analyzed by Phpstan - '#Trait App\\Migration\\WithPermPresetsTrait is used zero times and is not analysed#' + - + message: '#Should not use function "shell_exec"#' + path: src/Services/System/UpdateExecutor.php diff --git a/src/Command/MaintenanceModeCommand.php b/src/Command/MaintenanceModeCommand.php index 7fdea97e..47b1eaef 100644 --- a/src/Command/MaintenanceModeCommand.php +++ b/src/Command/MaintenanceModeCommand.php @@ -106,7 +106,7 @@ class MaintenanceModeCommand extends Command if ($enable) { // Use provided message or fallback to a default English message - $reason = is_string($message) && $message !== '' + $reason = is_string($message) ? $message : 'The system is temporarily unavailable due to maintenance.'; diff --git a/src/Services/System/CommandRunHelper.php b/src/Services/System/CommandRunHelper.php index 7a144d5f..19bc8548 100644 --- a/src/Services/System/CommandRunHelper.php +++ b/src/Services/System/CommandRunHelper.php @@ -28,8 +28,6 @@ use Symfony\Component\Process\Process; class CommandRunHelper { - private UpdateExecutor $updateExecutor; - public function __construct( #[Autowire(param: 'kernel.project_dir')] private readonly string $project_dir ) diff --git a/src/Services/System/UpdateAvailableFacade.php b/src/Services/System/UpdateAvailableFacade.php index d9f18997..ac3a46c0 100644 --- a/src/Services/System/UpdateAvailableFacade.php +++ b/src/Services/System/UpdateAvailableFacade.php @@ -33,8 +33,6 @@ use Version\Version; */ class UpdateAvailableFacade { - - private const API_URL = 'https://api.github.com/repos/Part-DB/Part-DB-server/releases/latest'; private const CACHE_KEY = 'uam_latest_version'; private const CACHE_TTL = 60 * 60 * 24 * 2; // 2 day diff --git a/src/Services/System/UpdateChecker.php b/src/Services/System/UpdateChecker.php index e388d51f..fdb8d9dd 100644 --- a/src/Services/System/UpdateChecker.php +++ b/src/Services/System/UpdateChecker.php @@ -145,15 +145,12 @@ class UpdateChecker /** * Get all available releases from GitHub (cached). * - * @return array + * @return array */ public function getAvailableReleases(int $limit = 10): array { if (!$this->privacySettings->checkForUpdates) { - return [ //If we don't want to check for updates, we can return dummy data - 'version' => '0.0.1', - 'url' => 'update-checking-disabled' - ]; + return []; } return $this->updateCache->get(self::CACHE_KEY_RELEASES, function (ItemInterface $item) use ($limit) { diff --git a/src/Services/System/UpdateExecutor.php b/src/Services/System/UpdateExecutor.php index 1dfc3dc1..2fe54173 100644 --- a/src/Services/System/UpdateExecutor.php +++ b/src/Services/System/UpdateExecutor.php @@ -863,6 +863,8 @@ class UpdateExecutor // Execute in background using shell_exec for proper detachment // shell_exec with & runs the command in background + + //@php-ignore-next-line We really need to use shell_exec here $output = shell_exec($command); // Give it a moment to start