Browse Source

Fix various phpstan issues.

pull/840/head
James Cole 4 months ago
parent
commit
51c31b171a
  1. 14
      app/Console/Commands/AutoImport.php
  2. 17
      app/Console/Commands/Import.php
  3. 11
      app/Console/Commands/ShowVersion.php

14
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));

17
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);

11
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';
/**

Loading…
Cancel
Save