Various code cleanup and phpstan suggestions

This commit is contained in:
James Cole
2022-11-02 06:25:37 +01:00
parent 74610a5d55
commit 8d8f81c27d
45 changed files with 147 additions and 27 deletions

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Generator\Report\Account;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Report\ReportGeneratorInterface;
use Illuminate\Support\Collection;
use Log;
@@ -42,7 +43,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Generate the report.
*
* @throws FireflyException
* @return string
*/
public function generate(): string
@@ -58,7 +59,9 @@ class MonthReportGenerator implements ReportGeneratorInterface
->render();
} catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.double.report: %s', $e->getMessage()));
Log::error($e->getTraceAsString());
$result = sprintf('Could not render report view: %s', $e->getMessage());
throw new FireflyException($result, 0, $e);
}
return $result;

View File

@@ -31,7 +31,6 @@ use FireflyIII\Models\Account;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Illuminate\Support\Collection;
use JetBrains\PhpStorm\ArrayShape;
use JsonException;
use Log;
use Throwable;
@@ -87,6 +86,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
Log::error(sprintf('Cannot render reports.audit.report: %s', $e->getMessage()));
Log::error($e->getTraceAsString());
$result = sprintf('Could not render report view: %s', $e->getMessage());
throw new FireflyException($result, 0, $e);
}
return $result;
@@ -102,8 +102,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
* @throws FireflyException
* @throws JsonException
*/
#[ArrayShape(['journals' => "array", 'currency' => "mixed", 'exists' => "bool", 'end' => "string", 'endBalance' => "mixed", 'dayBefore' => "string",
'dayBeforeBalance' => "mixed"])] public function getAuditReport(Account $account, Carbon $date): array
public function getAuditReport(Account $account, Carbon $date): array
{
/** @var AccountRepositoryInterface $accountRepository */
$accountRepository = app(AccountRepositoryInterface::class);

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Generator\Report\Budget;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Report\ReportGeneratorInterface;
use FireflyIII\Generator\Report\Support;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
@@ -74,6 +75,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
} catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.account.report: %s', $e->getMessage()));
$result = sprintf('Could not render report view: %s', $e->getMessage());
throw new FireflyException($result, 0, $e);
}
return $result;

View File

@@ -23,12 +23,12 @@ declare(strict_types=1);
namespace FireflyIII\Generator\Report\Category;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Report\ReportGeneratorInterface;
use FireflyIII\Generator\Report\Support;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\TransactionType;
use Illuminate\Support\Collection;
use JetBrains\PhpStorm\Pure;
use Log;
use Throwable;
@@ -56,7 +56,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* MonthReportGenerator constructor.
*/
#[Pure] public function __construct()
public function __construct()
{
$this->income = new Collection();
$this->expenses = new Collection();
@@ -83,6 +83,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
} catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.category.month: %s', $e->getMessage()));
$result = sprintf('Could not render report view: %s', $e->getMessage());
throw new FireflyException($result, 0, $e);
}
return $result;

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Generator\Report\Standard;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Report\ReportGeneratorInterface;
use Illuminate\Support\Collection;
use Log;
@@ -57,6 +58,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
} catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.default.month: %s', $e->getMessage()));
$result = 'Could not render report view.';
throw new FireflyException($result, 0, $e);
}
return $result;

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Generator\Report\Standard;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Report\ReportGeneratorInterface;
use Illuminate\Support\Collection;
use Log;
@@ -61,6 +62,7 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
} catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.default.multi-year: %s', $e->getMessage()));
$result = sprintf('Could not render report view: %s', $e->getMessage());
throw new FireflyException($result, 0, $e);
}
return $result;

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Generator\Report\Standard;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Report\ReportGeneratorInterface;
use Illuminate\Support\Collection;
use Log;
@@ -61,6 +62,7 @@ class YearReportGenerator implements ReportGeneratorInterface
} catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.account.report: %s', $e->getMessage()));
$result = 'Could not render report view.';
throw new FireflyException($result, 0, $e);
}
return $result;

View File

@@ -24,10 +24,10 @@ declare(strict_types=1);
namespace FireflyIII\Generator\Report\Tag;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Report\ReportGeneratorInterface;
use FireflyIII\Generator\Report\Support;
use Illuminate\Support\Collection;
use JetBrains\PhpStorm\Pure;
use Log;
use Throwable;
@@ -54,7 +54,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* MonthReportGenerator constructor.
*/
#[Pure] public function __construct()
public function __construct()
{
$this->expenses = new Collection();
$this->income = new Collection();
@@ -81,6 +81,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
} catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.tag.month: %s', $e->getMessage()));
$result = sprintf('Could not render report view: %s', $e->getMessage());
throw new FireflyException($result, 0, $e);
}
return $result;