From 51c31b171acad5d3aeb60bb656e10a316c0a42d0 Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 24 Jun 2025 07:42:45 +0200 Subject: [PATCH] Fix various phpstan issues. --- app/Console/Commands/AutoImport.php | 14 +------------- app/Console/Commands/Import.php | 17 +++-------------- app/Console/Commands/ShowVersion.php | 11 ----------- 3 files changed, 4 insertions(+), 38 deletions(-) diff --git a/app/Console/Commands/AutoImport.php b/app/Console/Commands/AutoImport.php index 404dada9..3ba0a8be 100644 --- a/app/Console/Commands/AutoImport.php +++ b/app/Console/Commands/AutoImport.php @@ -40,18 +40,7 @@ final class AutoImport extends Command use HaveAccess; use VerifyJSON; - /** - * The console command description. - * - * @var string - */ protected $description = 'Will automatically import from the given directory and use the JSON and importable files found.'; - - /** - * The name and signature of the console command. - * - * @var string - */ protected $signature = 'importer:auto-import {directory : The directory from which to import automatically.}'; /** @@ -67,9 +56,8 @@ final class AutoImport extends Command return ExitCode::NO_CONNECTION->value; } - $argument = (string) ($this->argument('directory') ?? './'); + $argument = (string) ($this->argument('directory') ?? './'); // @phpstan-ignore-line - /** @phpstan-ignore-line */ $directory = realpath($argument); if (false === $directory) { $this->error(sprintf('Path "%s" is not a valid location.', $argument)); diff --git a/app/Console/Commands/Import.php b/app/Console/Commands/Import.php index b7eddbdf..ed24da57 100644 --- a/app/Console/Commands/Import.php +++ b/app/Console/Commands/Import.php @@ -43,18 +43,7 @@ final class Import extends Command use HaveAccess; use VerifyJSON; - /** - * The console command description. - * - * @var string - */ protected $description = 'Import into Firefly III. Requires a configuration file and optionally a configuration file.'; - - /** - * The name and signature of the console command. - * - * @var string - */ protected $signature = 'importer:import {config : The configuration file. } {file? : Optionally, the importable file you want to import} @@ -102,7 +91,7 @@ final class Import extends Command } } - if (!file_exists($config) || (file_exists($config) && !is_file($config))) { + if (!file_exists($config) || !is_file($config)) { $message = sprintf('The importer can\'t import: configuration file "%s" does not exist or could not be read.', $config); $this->error($message); app('log')->error($message); @@ -119,8 +108,8 @@ final class Import extends Command return ExitCode::CANNOT_PARSE_CONFIG->value; } - $configuration = Configuration::fromArray(json_decode(file_get_contents($config), true)); - if ('file' === $configuration->getFlow() && (!file_exists($file) || (file_exists($file) && !is_file($file)))) { + $configuration = Configuration::fromArray(json_decode((string) file_get_contents($config), true)); + if ('file' === $configuration->getFlow() && (!file_exists($file) || !is_file($file))) { $message = sprintf('The importer can\'t import: importable file "%s" does not exist or could not be read.', $file); $this->error($message); app('log')->error($message); diff --git a/app/Console/Commands/ShowVersion.php b/app/Console/Commands/ShowVersion.php index 12dde3cc..a6831aee 100644 --- a/app/Console/Commands/ShowVersion.php +++ b/app/Console/Commands/ShowVersion.php @@ -32,18 +32,7 @@ use Illuminate\Console\Command; */ final class ShowVersion extends Command { - /** - * The console command description. - * - * @var string - */ protected $description = 'Echoes the current version and some debug info.'; - - /** - * The name and signature of the console command. - * - * @var string - */ protected $signature = 'importer:version'; /**