Skip to content

Firefly III: a personal finances manager

Various code cleanup.

James Colef12744ad8c12
diff --git a/app/Api/V1/Controllers/Chart/AccountController.php b/app/Api/V1/Controllers/Chart/AccountController.php
index 10a40469fb..52187964a5 100644
--- a/app/Api/V1/Controllers/Chart/AccountController.php
+++ b/app/Api/V1/Controllers/Chart/AccountController.php
@@ -86,12 +86,12 @@ class AccountController extends Controller
$defaultSet = $this->repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray();
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
$default = app('amount')->getDefaultCurrency();
- // @codeCoverageIgnoreStart
+
if (0 === count($frontPage->data)) {
$frontPage->data = $defaultSet;
$frontPage->save();
}
- // @codeCoverageIgnoreEnd
+
// get accounts:
$accounts = $this->repository->getAccountsById($frontPage->data);
@@ -100,7 +100,7 @@ class AccountController extends Controller
foreach ($accounts as $account) {
$currency = $this->repository->getAccountCurrency($account);
if (null === $currency) {
- $currency = $default; // @codeCoverageIgnore
+ $currency = $default;
}
$currentSet = [
'label' => $account->name,
diff --git a/app/Api/V1/Controllers/Models/Transaction/UpdateController.php b/app/Api/V1/Controllers/Models/Transaction/UpdateController.php
index 2e7c76d7b9..53fc0f7a78 100644
--- a/app/Api/V1/Controllers/Models/Transaction/UpdateController.php
+++ b/app/Api/V1/Controllers/Models/Transaction/UpdateController.php
@@ -96,7 +96,7 @@ class UpdateController extends Controller
$selectedGroup = $collector->getGroups()->first();
if (null === $selectedGroup) {
- throw new NotFoundHttpException(); // @codeCoverageIgnore
+ throw new NotFoundHttpException();
}
/** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class);
diff --git a/app/Api/V1/Controllers/Models/TransactionCurrency/DestroyController.php b/app/Api/V1/Controllers/Models/TransactionCurrency/DestroyController.php
index c3f377f4ce..f933b068b5 100644
--- a/app/Api/V1/Controllers/Models/TransactionCurrency/DestroyController.php
+++ b/app/Api/V1/Controllers/Models/TransactionCurrency/DestroyController.php
@@ -75,13 +75,13 @@ class DestroyController extends Controller
if (!$this->userRepository->hasRole($admin, 'owner')) {
// access denied:
- throw new FireflyException('200005: You need the "owner" role to do this.'); // @codeCoverageIgnore
+ throw new FireflyException('200005: You need the "owner" role to do this.');
}
if ($this->repository->currencyInUse($currency)) {
- throw new FireflyException('200006: Currency in use.'); // @codeCoverageIgnore
+ throw new FireflyException('200006: Currency in use.');
}
if ($this->repository->isFallbackCurrency($currency)) {
- throw new FireflyException('200026: Currency is fallback.'); // @codeCoverageIgnore
+ throw new FireflyException('200026: Currency is fallback.');
}
$this->repository->destroy($currency);
diff --git a/app/Api/V1/Controllers/Models/TransactionLinkType/StoreController.php b/app/Api/V1/Controllers/Models/TransactionLinkType/StoreController.php
index 22f93456cf..087eeae6fd 100644
--- a/app/Api/V1/Controllers/Models/TransactionLinkType/StoreController.php
+++ b/app/Api/V1/Controllers/Models/TransactionLinkType/StoreController.php
@@ -80,7 +80,7 @@ class StoreController extends Controller
$admin = auth()->user();
if (!$this->userRepository->hasRole($admin, 'owner')) {
- throw new FireflyException('200005: You need the "owner" role to do this.'); // @codeCoverageIgnore
+ throw new FireflyException('200005: You need the "owner" role to do this.');
}
$data = $request->getAll();
// if currency ID is 0, find the currency by the code:
diff --git a/app/Api/V1/Controllers/Models/TransactionLinkType/UpdateController.php b/app/Api/V1/Controllers/Models/TransactionLinkType/UpdateController.php
index 5b49acdf06..d97d6a355a 100644
--- a/app/Api/V1/Controllers/Models/TransactionLinkType/UpdateController.php
+++ b/app/Api/V1/Controllers/Models/TransactionLinkType/UpdateController.php
@@ -86,7 +86,7 @@ class UpdateController extends Controller
$admin = auth()->user();
if (!$this->userRepository->hasRole($admin, 'owner')) {
- throw new FireflyException('200005: You need the "owner" role to do this.'); // @codeCoverageIgnore
+ throw new FireflyException('200005: You need the "owner" role to do this.');
}
$data = $request->getAll();
diff --git a/app/Api/V1/Controllers/System/ConfigurationController.php b/app/Api/V1/Controllers/System/ConfigurationController.php
index 0b84a57933..0ffbb1fc04 100644
--- a/app/Api/V1/Controllers/System/ConfigurationController.php
+++ b/app/Api/V1/Controllers/System/ConfigurationController.php
@@ -161,7 +161,7 @@ class ConfigurationController extends Controller
public function update(UpdateRequest $request, string $name): JsonResponse
{
if (!$this->repository->hasRole(auth()->user(), 'owner')) {
- throw new FireflyException('200005: You need the "owner" role to do this.'); // @codeCoverageIgnore
+ throw new FireflyException('200005: You need the "owner" role to do this.');
}
$data = $request->getAll();
$shortName = str_replace('configuration.', '', $name);
diff --git a/app/Api/V1/Controllers/System/UserController.php b/app/Api/V1/Controllers/System/UserController.php
index 5941af752e..62d48cfddf 100644
--- a/app/Api/V1/Controllers/System/UserController.php
+++ b/app/Api/V1/Controllers/System/UserController.php
@@ -83,7 +83,7 @@ class UserController extends Controller
return response()->json([], 204);
}
- throw new FireflyException('200025: No access to function.'); // @codeCoverageIgnore
+ throw new FireflyException('200025: No access to function.');
}
/**
diff --git a/app/Api/V1/Requests/System/UpdateRequest.php b/app/Api/V1/Requests/System/UpdateRequest.php
index a123e5477a..3386d17165 100644
--- a/app/Api/V1/Requests/System/UpdateRequest.php
+++ b/app/Api/V1/Requests/System/UpdateRequest.php
@@ -57,7 +57,7 @@ class UpdateRequest extends FormRequest
return ['value' => $this->integer('value')];
}
- return ['value' => $this->string('value')]; // @codeCoverageIgnore
+ return ['value' => $this->string('value')];
}
/**
@@ -80,6 +80,6 @@ class UpdateRequest extends FormRequest
return ['value' => 'required|numeric|min:464272080'];
}
- return ['value' => 'required']; // @codeCoverageIgnore
+ return ['value' => 'required'];
}
}
diff --git a/app/Console/Commands/Correction/DeleteEmptyJournals.php b/app/Console/Commands/Correction/DeleteEmptyJournals.php
index 01aa71d030..7fe3f66778 100644
--- a/app/Console/Commands/Correction/DeleteEmptyJournals.php
+++ b/app/Console/Commands/Correction/DeleteEmptyJournals.php
@@ -77,11 +77,11 @@ class DeleteEmptyJournals extends Command
// uneven number, delete journal and transactions:
try {
TransactionJournal::find((int)$row->transaction_journal_id)->delete();
- // @codeCoverageIgnoreStart
- } catch (Exception $e) {
+
+ } catch (Exception $e) { // @phpstan-ignore-line
Log::info(sprintf('Could not delete journal: %s', $e->getMessage()));
}
- // @codeCoverageIgnoreEnd
+
Transaction::where('transaction_journal_id', (int)$row->transaction_journal_id)->delete();
$this->info(sprintf('Deleted transaction journal #%d because it had an uneven number of transactions.', $row->transaction_journal_id));
@@ -105,11 +105,11 @@ class DeleteEmptyJournals extends Command
foreach ($set as $entry) {
try {
TransactionJournal::find($entry->id)->delete();
- // @codeCoverageIgnoreStart
- } catch (Exception $e) {
+
+ } catch (Exception $e) { // @phpstan-ignore-line
Log::info(sprintf('Could not delete entry: %s', $e->getMessage()));
}
- // @codeCoverageIgnoreEnd
+
$this->info(sprintf('Deleted empty transaction journal #%d', $entry->id));
++$count;
diff --git a/app/Console/Commands/Correction/DeleteOrphanedTransactions.php b/app/Console/Commands/Correction/DeleteOrphanedTransactions.php
index 71085e35b2..114353aff9 100644
--- a/app/Console/Commands/Correction/DeleteOrphanedTransactions.php
+++ b/app/Console/Commands/Correction/DeleteOrphanedTransactions.php
@@ -118,11 +118,11 @@ class DeleteOrphanedTransactions extends Command
if ($journal) {
try {
$journal->delete();
- // @codeCoverageIgnoreStart
- } catch (Exception $e) {
+
+ } catch (Exception $e) { // @phpstan-ignore-line
Log::info(sprintf('Could not delete journal %s', $e->getMessage()));
}
- // @codeCoverageIgnoreEnd
+
}
Transaction::where('transaction_journal_id', (int)$transaction->transaction_journal_id)->delete();
$this->line(
diff --git a/app/Console/Commands/Correction/DeleteZeroAmount.php b/app/Console/Commands/Correction/DeleteZeroAmount.php
index f96b426eee..9e99cb5573 100644
--- a/app/Console/Commands/Correction/DeleteZeroAmount.php
+++ b/app/Console/Commands/Correction/DeleteZeroAmount.php
@@ -64,11 +64,11 @@ class DeleteZeroAmount extends Command
$this->info(sprintf('Deleted transaction journal #%d because the amount is zero (0.00).', $journal->id));
try {
$journal->delete();
- // @codeCoverageIgnoreStart
- } catch (Exception $e) {
+
+ } catch (Exception $e) { // @phpstan-ignore-line
$this->line($e->getMessage());
}
- // @codeCoverageIgnoreEnd
+
Transaction::where('transaction_journal_id', $journal->id)->delete();
}
if (0 === $journals->count()) {
diff --git a/app/Console/Commands/Correction/FixAccountTypes.php b/app/Console/Commands/Correction/FixAccountTypes.php
index 5736970505..048c32d9b5 100644
--- a/app/Console/Commands/Correction/FixAccountTypes.php
+++ b/app/Console/Commands/Correction/FixAccountTypes.php
@@ -121,12 +121,12 @@ class FixAccountTypes extends Command
$destAccountType = $destAccount->accountType->type;
if (!array_key_exists($type, $this->expected)) {
- // @codeCoverageIgnoreStart
+
Log::info(sprintf('No source/destination info for transaction type %s.', $type));
$this->info(sprintf('No source/destination info for transaction type %s.', $type));
return;
- // @codeCoverageIgnoreEnd
+
}
if (!array_key_exists($sourceAccountType, $this->expected[$type])) {
Log::debug(sprintf('Going to fix journal #%d', $journal->id));
diff --git a/app/Console/Commands/Correction/FixPiggies.php b/app/Console/Commands/Correction/FixPiggies.php
index 274e5265b4..8076663b95 100644
--- a/app/Console/Commands/Correction/FixPiggies.php
+++ b/app/Console/Commands/Correction/FixPiggies.php
@@ -70,14 +70,14 @@ class FixPiggies extends Command
}
/** @var TransactionJournal $journal */
$journal = $event->transactionJournal;
- // @codeCoverageIgnoreStart
+
if (null === $journal) {
$event->transaction_journal_id = null;
$event->save();
$this->count++;
continue;
}
- // @codeCoverageIgnoreEnd
+
$type = $journal->transactionType->type;
if (TransactionType::TRANSFER !== $type) {
diff --git a/app/Console/Commands/Correction/FixUnevenAmount.php b/app/Console/Commands/Correction/FixUnevenAmount.php
index 28b28ab7e9..157e955164 100644
--- a/app/Console/Commands/Correction/FixUnevenAmount.php
+++ b/app/Console/Commands/Correction/FixUnevenAmount.php
@@ -91,7 +91,7 @@ class FixUnevenAmount extends Command
// one of the transactions is bad.
$journal = TransactionJournal::find($param);
if (!$journal) {
- return; // @codeCoverageIgnore
+ return;
}
/** @var Transaction $source */
$source = $journal->transactions()->where('amount', '<', 0)->first();
diff --git a/app/Console/Commands/DecryptDatabase.php b/app/Console/Commands/DecryptDatabase.php
index 41e8004fa8..a9e8cfb548 100644
--- a/app/Console/Commands/DecryptDatabase.php
+++ b/app/Console/Commands/DecryptDatabase.php
@@ -188,7 +188,7 @@ class DecryptDatabase extends Command
$value = Crypt::decrypt($value);
} catch (DecryptException $e) {
if ('The MAC is invalid.' === $e->getMessage()) {
- throw new FireflyException($e->getMessage()); // @codeCoverageIgnore
+ throw new FireflyException($e->getMessage(), 0, $e);
}
}
diff --git a/app/Console/Commands/Export/ExportData.php b/app/Console/Commands/Export/ExportData.php
index d5da37c14a..5f70ddef59 100644
--- a/app/Console/Commands/Export/ExportData.php
+++ b/app/Console/Commands/Export/ExportData.php
@@ -124,11 +124,11 @@ class ExportData extends Command
$exporter->setExportBills($options['export']['bills']);
$exporter->setExportPiggies($options['export']['piggies']);
$data = $exporter->export();
- if (empty($data)) {
+ if (0===count($data)) {
$this->error('You must export *something*. Use --export-transactions or another option. See docs.firefly-iii.org');
}
$returnCode = 0;
- if (!empty($data)) {
+ if (0!== count($data)) {
try {
$this->exportData($options, $data);
app('telemetry')->feature('system.command.executed', $this->signature);
diff --git a/app/Console/Commands/Upgrade/AccountCurrencies.php b/app/Console/Commands/Upgrade/AccountCurrencies.php
index e56a628672..78197894f9 100644
--- a/app/Console/Commands/Upgrade/AccountCurrencies.php
+++ b/app/Console/Commands/Upgrade/AccountCurrencies.php
@@ -114,7 +114,7 @@ class AccountCurrencies extends Command
return (bool)$configVar->data;
}
- return false; // @codeCoverageIgnore
+ return false;
}
/**
diff --git a/app/Console/Commands/Upgrade/BackToJournals.php b/app/Console/Commands/Upgrade/BackToJournals.php
index 832a03f0c2..10522e030c 100644
--- a/app/Console/Commands/Upgrade/BackToJournals.php
+++ b/app/Console/Commands/Upgrade/BackToJournals.php
@@ -58,7 +58,7 @@ class BackToJournals extends Command
*/
public function handle(): int
{
- // @codeCoverageIgnoreStart
+
$start = microtime(true);
if (!$this->isMigrated()) {
$this->error('Please run firefly-iii:migrate-to-groups first.');
@@ -71,7 +71,7 @@ class BackToJournals extends Command
if (true === $this->option('force')) {
$this->warn('Forcing the command.');
}
- // @codeCoverageIgnoreEnd
+
$this->migrateAll();
$end = round(microtime(true) - $start, 2);
@@ -87,7 +87,8 @@ class BackToJournals extends Command
private function isMigrated(): bool
{
$configVar = app('fireflyconfig')->get(MigrateToGroups::CONFIG_NAME, false);
- return (bool)$configVar->data;
+
+ return (bool)$configVar->data;
}
/**
@@ -96,7 +97,8 @@ class BackToJournals extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
- return (bool)$configVar->data;
+
+ return (bool)$configVar->data;
}
/**
@@ -137,15 +139,13 @@ class BackToJournals extends Command
*/
private function getIdsForBudgets(): array
{
- $transactions = DB::table('budget_transaction')->distinct()->get(['transaction_id'])->pluck('transaction_id')->toArray();
+ $transactions = DB::table('budget_transaction')->distinct()->get(['transaction_id'])->pluck('transaction_id')->toArray(); // @phpstan-ignore-line
$array = [];
$chunks = array_chunk($transactions, 500);
foreach ($chunks as $chunk) {
- $set = DB::table('transactions')
- ->whereIn('transactions.id', $chunk)
+ $set = DB::table('transactions')->whereIn('transactions.id', $chunk)
->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray();
- /** @noinspection SlowArrayOperationsInLoopInspection */
$array = array_merge($array, $set);
}
@@ -162,11 +162,11 @@ class BackToJournals extends Command
/** @var Transaction $transaction */
$transaction = $journal->transactions->first();
if (null === $transaction) {
- // @codeCoverageIgnoreStart
+
$this->info(sprintf('Transaction journal #%d has no transactions. Will be fixed later.', $journal->id));
return;
- // @codeCoverageIgnoreEnd
+
}
/** @var Budget $budget */
$budget = $transaction->budgets->first();
@@ -217,12 +217,12 @@ class BackToJournals extends Command
*/
private function getIdsForCategories(): array
{
- $transactions = DB::table('category_transaction')->distinct()->get(['transaction_id'])->pluck('transaction_id')->toArray();
+ $transactions = DB::table('category_transaction')->distinct()->get(['transaction_id'])->pluck('transaction_id')->toArray(); // @phpstan-ignore-line
$array = [];
$chunks = array_chunk($transactions, 500);
foreach ($chunks as $chunk) {
- $set = DB::table('transactions')
+ $set = DB::table('transactions') // @phpstan-ignore-line
->whereIn('transactions.id', $chunk)
->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray();
/** @noinspection SlowArrayOperationsInLoopInspection */
@@ -241,11 +241,11 @@ class BackToJournals extends Command
/** @var Transaction $transaction */
$transaction = $journal->transactions->first();
if (null === $transaction) {
- // @codeCoverageIgnoreStart
+
$this->info(sprintf('Transaction journal #%d has no transactions. Will be fixed later.', $journal->id));
return;
- // @codeCoverageIgnoreEnd
+
}
/** @var Category $category */
$category = $transaction->categories->first();
diff --git a/app/Console/Commands/Upgrade/BudgetLimitCurrency.php b/app/Console/Commands/Upgrade/BudgetLimitCurrency.php
index 0867427b99..9aed01b7f8 100644
--- a/app/Console/Commands/Upgrade/BudgetLimitCurrency.php
+++ b/app/Console/Commands/Upgrade/BudgetLimitCurrency.php
@@ -54,13 +54,13 @@ class BudgetLimitCurrency extends Command
public function handle(): int
{
$start = microtime(true);
- // @codeCoverageIgnoreStart
+
if ($this->isExecuted() && true !== $this->option('force')) {
$this->warn('This command has already been executed.');
return 0;
}
- // @codeCoverageIgnoreEnd
+
$count = 0;
$budgetLimits = BudgetLimit::get();
@@ -104,7 +104,7 @@ class BudgetLimitCurrency extends Command
return (bool)$configVar->data;
}
- return false; // @codeCoverageIgnore
+ return false;
}
/**
diff --git a/app/Console/Commands/Upgrade/CCLiabilities.php b/app/Console/Commands/Upgrade/CCLiabilities.php
index e5736d230f..64e596e75a 100644
--- a/app/Console/Commands/Upgrade/CCLiabilities.php
+++ b/app/Console/Commands/Upgrade/CCLiabilities.php
@@ -56,13 +56,13 @@ class CCLiabilities extends Command
{
$start = microtime(true);
- // @codeCoverageIgnoreStart
+
if ($this->isExecuted() && true !== $this->option('force')) {
$this->warn('This command has already been executed.');
return 0;
}
- // @codeCoverageIgnoreEnd
+
$ccType = AccountType::where('type', AccountType::CREDITCARD)->first();
$debtType = AccountType::where('type', AccountType::DEBT)->first();
@@ -101,7 +101,7 @@ class CCLiabilities extends Command
return (bool)$configVar->data;
}
- return false; // @codeCoverageIgnore
+ return false;
}
/**
diff --git a/app/Console/Commands/Upgrade/MigrateAttachments.php b/app/Console/Commands/Upgrade/MigrateAttachments.php
index 512adf9562..3c35ac9415 100644
--- a/app/Console/Commands/Upgrade/MigrateAttachments.php
+++ b/app/Console/Commands/Upgrade/MigrateAttachments.php
@@ -54,14 +54,14 @@ class MigrateAttachments extends Command
*/
public function handle(): int
{
- // @codeCoverageIgnoreStart
+
$start = microtime(true);
if ($this->isExecuted() && true !== $this->option('force')) {
$this->warn('This command has already been executed.');
return 0;
}
- // @codeCoverageIgnoreEnd
+
$attachments = Attachment::get();
$count = 0;
@@ -113,7 +113,7 @@ class MigrateAttachments extends Command
return (bool)$configVar->data;
}
- return false; // @codeCoverageIgnore
+ return false;
}
/**
diff --git a/app/Console/Commands/Upgrade/MigrateJournalNotes.php b/app/Console/Commands/Upgrade/MigrateJournalNotes.php
index 685e1a77a4..2eb21a5d0f 100644
--- a/app/Console/Commands/Upgrade/MigrateJournalNotes.php
+++ b/app/Console/Commands/Upgrade/MigrateJournalNotes.php
@@ -56,13 +56,13 @@ class MigrateJournalNotes extends Command
public function handle(): int
{
$start = microtime(true);
- // @codeCoverageIgnoreStart
+
if ($this->isExecuted() && true !== $this->option('force')) {
$this->warn('This command has already been executed.');
return 0;
}
- // @codeCoverageIgnoreEnd
+
$count = 0;
/** @noinspection PhpUndefinedMethodInspection */
$set = TransactionJournalMeta::whereName('notes')->get();
@@ -80,11 +80,11 @@ class MigrateJournalNotes extends Command
Log::debug(sprintf('Migrated meta note #%d to Note #%d', $meta->id, $note->id));
try {
$meta->delete();
- // @codeCoverageIgnoreStart
- } catch (Exception $e) {
+
+ } catch (Exception $e) { // @phpstan-ignore-line
Log::error(sprintf('Could not delete old meta entry #%d: %s', $meta->id, $e->getMessage()));
}
- // @codeCoverageIgnoreEnd
+
$count++;
}
@@ -112,7 +112,7 @@ class MigrateJournalNotes extends Command
return (bool)$configVar->data;
}
- return false; // @codeCoverageIgnore
+ return false;
}
/**
diff --git a/app/Console/Commands/Upgrade/MigrateRecurrenceMeta.php b/app/Console/Commands/Upgrade/MigrateRecurrenceMeta.php
index bb1365ac8f..857f4fbb09 100644
--- a/app/Console/Commands/Upgrade/MigrateRecurrenceMeta.php
+++ b/app/Console/Commands/Upgrade/MigrateRecurrenceMeta.php
@@ -87,7 +87,7 @@ class MigrateRecurrenceMeta extends Command
return (bool)$configVar->data;
}
- return false; // @codeCoverageIgnore
+ return false;
}
/**
diff --git a/app/Console/Commands/Upgrade/MigrateRecurrenceType.php b/app/Console/Commands/Upgrade/MigrateRecurrenceType.php
index 51d32603c1..0c5f1eb795 100644
--- a/app/Console/Commands/Upgrade/MigrateRecurrenceType.php
+++ b/app/Console/Commands/Upgrade/MigrateRecurrenceType.php
@@ -82,7 +82,7 @@ class MigrateRecurrenceType extends Command
return (bool)$configVar->data;
}
- return false; // @codeCoverageIgnore
+ return false;
}
/**
diff --git a/app/Console/Commands/Upgrade/MigrateTagLocations.php b/app/Console/Commands/Upgrade/MigrateTagLocations.php
index b201db99f2..9b8f41594c 100644
--- a/app/Console/Commands/Upgrade/MigrateTagLocations.php
+++ b/app/Console/Commands/Upgrade/MigrateTagLocations.php
@@ -80,7 +80,7 @@ class MigrateTagLocations extends Command
return (bool)$configVar->data;
}
- return false; // @codeCoverageIgnore
+ return false;
}
private function migrateTagLocations(): void
diff --git a/app/Console/Commands/Upgrade/MigrateToGroups.php b/app/Console/Commands/Upgrade/MigrateToGroups.php
index 48f5d709f4..7511eac1ff 100644
--- a/app/Console/Commands/Upgrade/MigrateToGroups.php
+++ b/app/Console/Commands/Upgrade/MigrateToGroups.php
@@ -75,7 +75,7 @@ class MigrateToGroups extends Command
{
$this->stupidLaravel();
$start = microtime(true);
- // @codeCoverageIgnoreStart
+
if ($this->isMigrated() && true !== $this->option('force')) {
$this->info('Database already seems to be migrated.');
@@ -85,7 +85,7 @@ class MigrateToGroups extends Command
if (true === $this->option('force')) {
$this->warn('Forcing the migration.');
}
- // @codeCoverageIgnoreEnd
+
Log::debug('---- start group migration ----');
$this->makeGroupsFromSplitJournals();
@@ -135,7 +135,7 @@ class MigrateToGroups extends Command
return (bool)$configVar->data;
}
- return false; // @codeCoverageIgnore
+ return false;
}
/**
@@ -165,11 +165,11 @@ class MigrateToGroups extends Command
{
// double check transaction count.
if ($journal->transactions->count() <= 2) {
- // @codeCoverageIgnoreStart
+
Log::debug(sprintf('Will not try to convert journal #%d because it has 2 or less transactions.', $journal->id));
return;
- // @codeCoverageIgnoreEnd
+
}
Log::debug(sprintf('Will now try to convert journal #%d', $journal->id));
@@ -217,7 +217,7 @@ class MigrateToGroups extends Command
$opposingTr = $this->findOpposingTransaction($journal, $transaction);
if (null === $opposingTr) {
- // @codeCoverageIgnoreStart
+
$this->error(
sprintf(
'Journal #%d has no opposing transaction for transaction #%d. Cannot upgrade this entry.',
@@ -226,7 +226,7 @@ class MigrateToGroups extends Command
)
);
continue;
- // @codeCoverageIgnoreEnd
+
}
// overrule journal category with transaction category.
diff --git a/app/Console/Commands/Upgrade/MigrateToRules.php b/app/Console/Commands/Upgrade/MigrateToRules.php
index 44024e4077..8f923915d1 100644
--- a/app/Console/Commands/Upgrade/MigrateToRules.php
+++ b/app/Console/Commands/Upgrade/MigrateToRules.php
@@ -73,13 +73,13 @@ class MigrateToRules extends Command
$this->stupidLaravel();
$start = microtime(true);
- // @codeCoverageIgnoreStart
+
if ($this->isExecuted() && true !== $this->option('force')) {
$this->warn('This command has already been executed.');
return 0;
}
- // @codeCoverageIgnoreEnd
+
$users = $this->userRepository->all();
/** @var User $user */
@@ -127,7 +127,7 @@ class MigrateToRules extends Command
return (bool)$configVar->data;
}
- return false; // @codeCoverageIgnore
+ return false;
}
/**
diff --git a/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php b/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php
index f274d63087..a06f6a6401 100644
--- a/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php
+++ b/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php
@@ -75,13 +75,13 @@ class OtherCurrenciesCorrections extends Command
{
$this->stupidLaravel();
$start = microtime(true);
- // @codeCoverageIgnoreStart
+
if ($this->isExecuted() && true !== $this->option('force')) {
$this->warn('This command has already been executed.');
return 0;
}
- // @codeCoverageIgnoreEnd
+
$this->updateOtherJournalsCurrencies();
$this->markAsExecuted();
@@ -120,7 +120,7 @@ class OtherCurrenciesCorrections extends Command
return (bool)$configVar->data;
}
- return false; // @codeCoverageIgnore
+ return false;
}
/**
@@ -154,18 +154,18 @@ class OtherCurrenciesCorrections extends Command
$leadTransaction = $this->getLeadTransaction($journal);
if (null === $leadTransaction) {
- // @codeCoverageIgnoreStart
+
$this->error(sprintf('Could not reliably determine which transaction is in the lead for transaction journal #%d.', $journal->id));
return;
- // @codeCoverageIgnoreEnd
+
}
/** @var Account $account */
$account = $leadTransaction->account;
$currency = $this->getCurrency($account);
if (null === $currency) {
- // @codeCoverageIgnoreStart
+
$this->error(
sprintf(
'Account #%d ("%s") has no currency preference, so transaction journal #%d can\'t be corrected', $account->id, $account->name, $journal->id
@@ -174,7 +174,7 @@ class OtherCurrenciesCorrections extends Command
$this->count++;
return;
- // @codeCoverageIgnoreEnd
+
}
// fix each transaction:
$journal->transactions->each(
@@ -246,18 +246,18 @@ class OtherCurrenciesCorrections extends Command
{
$accountId = $account->id;
if (array_key_exists($accountId, $this->accountCurrencies) && 0 === $this->accountCurrencies[$accountId]) {
- return null; // @codeCoverageIgnore
+ return null;
}
if (array_key_exists($accountId, $this->accountCurrencies) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) {
- return $this->accountCurrencies[$accountId]; // @codeCoverageIgnore
+ return $this->accountCurrencies[$accountId];
}
$currency = $this->accountRepos->getAccountCurrency($account);
if (null === $currency) {
- // @codeCoverageIgnoreStart
+
$this->accountCurrencies[$accountId] = 0;
return null;
- // @codeCoverageIgnoreEnd
+
}
$this->accountCurrencies[$accountId] = $currency;
diff --git a/app/Console/Commands/Upgrade/RenameAccountMeta.php b/app/Console/Commands/Upgrade/RenameAccountMeta.php
index 9e12c60d7b..37f86dd6cc 100644
--- a/app/Console/Commands/Upgrade/RenameAccountMeta.php
+++ b/app/Console/Commands/Upgrade/RenameAccountMeta.php
@@ -53,13 +53,13 @@ class RenameAccountMeta extends Command
public function handle(): int
{
$start = microtime(true);
- // @codeCoverageIgnoreStart
+
if ($this->isExecuted() && true !== $this->option('force')) {
$this->warn('This command has already been executed.');
return 0;
}
- // @codeCoverageIgnoreEnd
+
$array = [
'accountRole' => 'account_role',
'ccType' => 'cc_type',
@@ -104,7 +104,7 @@ class RenameAccountMeta extends Command
return (bool)$configVar->data;
}
- return false; // @codeCoverageIgnore
+ return false;
}
/**
diff --git a/app/Console/Commands/Upgrade/TransactionIdentifier.php b/app/Console/Commands/Upgrade/TransactionIdentifier.php
index 3628af9d9c..94165c25b2 100644
--- a/app/Console/Commands/Upgrade/TransactionIdentifier.php
+++ b/app/Console/Commands/Upgrade/TransactionIdentifier.php
@@ -72,7 +72,7 @@ class TransactionIdentifier extends Command
{
$this->stupidLaravel();
$start = microtime(true);
- // @codeCoverageIgnoreStart
+
if ($this->isExecuted() && true !== $this->option('force')) {
$this->warn('This command has already been executed.');
@@ -83,7 +83,7 @@ class TransactionIdentifier extends Command
if (!Schema::hasTable('transaction_journals')) {
return 0;
}
- // @codeCoverageIgnoreEnd
+
$journals = $this->cliRepository->getSplitJournals();
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
@@ -128,7 +128,7 @@ class TransactionIdentifier extends Command
return (bool)$configVar->data;
}
- return false; // @codeCoverageIgnore
+ return false;
}
/**
@@ -178,7 +178,7 @@ class TransactionIdentifier extends Command
->where('amount', $amount)->where('identifier', '=', 0)
->whereNotIn('id', $exclude)
->first();
- // @codeCoverageIgnoreStart
+
} catch (QueryException $e) {
Log::error($e->getMessage());
$this->error('Firefly III could not find the "identifier" field in the "transactions" table.');
@@ -189,7 +189,7 @@ class TransactionIdentifier extends Command
return null;
}
- // @codeCoverageIgnoreEnd
+
return $opposing;
}
diff --git a/app/Console/Commands/Upgrade/TransferCurrenciesCorrections.php b/app/Console/Commands/Upgrade/TransferCurrenciesCorrections.php
index 9524a85c4a..777b671b1b 100644
--- a/app/Console/Commands/Upgrade/TransferCurrenciesCorrections.php
+++ b/app/Console/Commands/Upgrade/TransferCurrenciesCorrections.php
@@ -72,13 +72,13 @@ class TransferCurrenciesCorrections extends Command
{
$this->stupidLaravel();
$start = microtime(true);
- // @codeCoverageIgnoreStart
+
if ($this->isExecuted() && true !== $this->option('force')) {
$this->warn('This command has already been executed.');
return 0;
}
- // @codeCoverageIgnoreEnd
+
$this->startUpdateRoutine();
$this->markAsExecuted();
@@ -140,7 +140,7 @@ class TransferCurrenciesCorrections extends Command
return (bool)$configVar->data;
}
- return false; // @codeCoverageIgnore
+ return false;
}
/**
@@ -167,27 +167,27 @@ class TransferCurrenciesCorrections extends Command
{
$this->resetInformation();
- // @codeCoverageIgnoreStart
+
if ($this->isSplitJournal($transfer)) {
$this->line(sprintf(sprintf('Transaction journal #%d is a split journal. Cannot continue.', $transfer->id)));
return;
}
- // @codeCoverageIgnoreEnd
+
$this->getSourceInformation($transfer);
$this->getDestinationInformation($transfer);
// unexpectedly, either one is null:
- // @codeCoverageIgnoreStart
+
if ($this->isEmptyTransactions()) {
$this->error(sprintf('Source or destination information for transaction journal #%d is null. Cannot fix this one.', $transfer->id));
return;
}
- // @codeCoverageIgnoreEnd
+
// both accounts must have currency preference:
- // @codeCoverageIgnoreStart
+
if ($this->isNoCurrencyPresent()) {
$this->error(
sprintf('Source or destination accounts for transaction journal #%d have no currency information. Cannot fix this one.', $transfer->id)
@@ -195,7 +195,7 @@ class TransferCurrenciesCorrections extends Command
return;
}
- // @codeCoverageIgnoreEnd
+
// fix source transaction having no currency.
$this->fixSourceNoCurrency();
@@ -270,18 +270,18 @@ class TransferCurrenciesCorrections extends Command
{
$accountId = $account->id;
if (array_key_exists($accountId, $this->accountCurrencies) && 0 === $this->accountCurrencies[$accountId]) {
- return null; // @codeCoverageIgnore
+ return null;
}
if (array_key_exists($accountId, $this->accountCurrencies) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) {
- return $this->accountCurrencies[$accountId]; // @codeCoverageIgnore
+ return $this->accountCurrencies[$accountId];
}
$currency = $this->accountRepos->getAccountCurrency($account);
if (null === $currency) {
- // @codeCoverageIgnoreStart
+
$this->accountCurrencies[$accountId] = 0;
return null;
- // @codeCoverageIgnoreEnd
+
}
$this->accountCurrencies[$accountId] = $currency;
diff --git a/app/Console/Commands/Upgrade/UpgradeSkeleton.php.stub b/app/Console/Commands/Upgrade/UpgradeSkeleton.php.stub
index 2ea03dbe8d..34d9ef22f0 100644
--- a/app/Console/Commands/Upgrade/UpgradeSkeleton.php.stub
+++ b/app/Console/Commands/Upgrade/UpgradeSkeleton.php.stub
@@ -56,7 +56,7 @@ class UpgradeSkeleton extends Command
return (bool)$configVar->data;
}
- return false; // @codeCoverageIgnore
+ return false;
}
diff --git a/app/Console/Commands/UpgradeFireflyInstructions.php b/app/Console/Commands/UpgradeFireflyInstructions.php
index b178a1f6ab..5c4903f0d6 100644
--- a/app/Console/Commands/UpgradeFireflyInstructions.php
+++ b/app/Console/Commands/UpgradeFireflyInstructions.php
@@ -73,7 +73,7 @@ class UpgradeFireflyInstructions extends Command
try {
app('telemetry')->feature('system.users.count', (string)User::count());
} catch (QueryException $e) {
- // ignore error.
+ // @ignoreException
}
return 0;
diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php
index d398408439..0d3a70f75b 100644
--- a/app/Exceptions/Handler.php
+++ b/app/Exceptions/Handler.php
@@ -31,6 +31,7 @@ use FireflyIII\Jobs\MailError;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Http\Request;
+use Illuminate\Session\TokenMismatchException;
use Illuminate\Support\Arr;
use Illuminate\Validation\ValidationException as LaravelValidationException;
use League\OAuth2\Server\Exception\OAuthServerException;
@@ -52,7 +53,8 @@ class Handler extends ExceptionHandler
AuthenticationException::class,
LaravelValidationException::class,
NotFoundHttpException::class,
- OAuthServerException::class
+ OAuthServerException::class,
+ TokenMismatchException::class,
];
/**
diff --git a/app/Factory/AccountFactory.php b/app/Factory/AccountFactory.php
index ea3d573ee4..e4d3394f34 100644
--- a/app/Factory/AccountFactory.php
+++ b/app/Factory/AccountFactory.php
@@ -257,7 +257,7 @@ class AccountFactory
$fields = $this->validAssetFields;
}
if ($account->accountType->type === AccountType::ASSET && 'ccAsset' === $data['account_role']) {
- $fields = $this->validCCFields; // @codeCoverageIgnore
+ $fields = $this->validCCFields;
}
/** @var AccountMetaFactory $factory */
@@ -265,14 +265,14 @@ class AccountFactory
foreach ($fields as $field) {
// if the field is set but NULL, skip it.
// if the field is set but "", update it.
- if (isset($data[$field]) && null !== $data[$field]) {
+ if (array_key_exists($field, $data) && null !== $data[$field]) {
// convert boolean value:
if (is_bool($data[$field]) && false === $data[$field]) {
- $data[$field] = 0; // @codeCoverageIgnore
+ $data[$field] = 0;
}
if (is_bool($data[$field]) && true === $data[$field]) {
- $data[$field] = 1; // @codeCoverageIgnore
+ $data[$field] = 1;
}
$factory->crud($account, $field, (string)$data[$field]);
diff --git a/app/Factory/AccountMetaFactory.php b/app/Factory/AccountMetaFactory.php
index ae74aeefb7..87133621b6 100644
--- a/app/Factory/AccountMetaFactory.php
+++ b/app/Factory/AccountMetaFactory.php
@@ -67,8 +67,8 @@ class AccountMetaFactory
if ('' === $value && null !== $entry) {
try {
$entry->delete();
- } catch (Exception $e) { // @codeCoverageIgnore
- Log::debug(sprintf('Could not delete entry: %s', $e->getMessage())); // @codeCoverageIgnore
+ } catch (Exception $e) { // @phpstan-ignore-line
+ Log::debug(sprintf('Could not delete entry: %s', $e->getMessage()));
}
return null;
diff --git a/app/Factory/AttachmentFactory.php b/app/Factory/AttachmentFactory.php
index 53a08866a3..87fb2375d1 100644
--- a/app/Factory/AttachmentFactory.php
+++ b/app/Factory/AttachmentFactory.php
@@ -54,7 +54,7 @@ class AttachmentFactory
/** @var Transaction $transaction */
$transaction = $this->user->transactions()->find((int)$data['attachable_id']);
if (null === $transaction) {
- throw new FireflyException('Unexpectedly could not find transaction'); // @codeCoverageIgnore
+ throw new FireflyException('Unexpectedly could not find transaction');
}
$data['attachable_id'] = $transaction->transaction_journal_id;
$model = TransactionJournal::class;
diff --git a/app/Factory/BillFactory.php b/app/Factory/BillFactory.php
index 88c2ad614e..417f72660d 100644
--- a/app/Factory/BillFactory.php
+++ b/app/Factory/BillFactory.php
@@ -76,7 +76,7 @@ class BillFactory
} catch (QueryException $e) {
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
- throw new FireflyException('400000: Could not store bill.');
+ throw new FireflyException('400000: Could not store bill.', 0, $e);
}
if (array_key_exists('notes', $data)) {
diff --git a/app/Factory/CategoryFactory.php b/app/Factory/CategoryFactory.php
index 2a5dcbe67f..6adc1800a0 100644
--- a/app/Factory/CategoryFactory.php
+++ b/app/Factory/CategoryFactory.php
@@ -76,7 +76,7 @@ class CategoryFactory
);
} catch (QueryException $e) {
Log::error($e->getMessage());
- throw new FireflyException('400003: Could not store new category.');
+ throw new FireflyException('400003: Could not store new category.', 0, $e);
}
}
diff --git a/app/Factory/RecurrenceFactory.php b/app/Factory/RecurrenceFactory.php
index 8b0c70e2f1..41a8082ce0 100644
--- a/app/Factory/RecurrenceFactory.php
+++ b/app/Factory/RecurrenceFactory.php
@@ -69,7 +69,7 @@ class RecurrenceFactory
Log::error($message);
Log::error($e->getTraceAsString());
- throw new FireflyException($message);
+ throw new FireflyException($message, 0, $e);
}
$firstDate = null;
$repeatUntil = null;
@@ -129,17 +129,16 @@ class RecurrenceFactory
$this->createRepetitions($recurrence, $data['repetitions'] ?? []);
try {
$this->createTransactions($recurrence, $data['transactions'] ?? []);
- // @codeCoverageIgnoreStart
+
} catch (FireflyException $e) {
Log::error($e->getMessage());
$recurrence->forceDelete();
$message = sprintf('Could not create recurring transaction: %s', $e->getMessage());
$this->errors->add('store', $message);
- throw new FireflyException($message);
+ throw new FireflyException($message, 0, $e);
}
- // @codeCoverageIgnoreEnd
return $recurrence;
}
diff --git a/app/Factory/TransactionCurrencyFactory.php b/app/Factory/TransactionCurrencyFactory.php
index 86bb2dacd0..ba769f5338 100644
--- a/app/Factory/TransactionCurrencyFactory.php
+++ b/app/Factory/TransactionCurrencyFactory.php
@@ -59,7 +59,7 @@ class TransactionCurrencyFactory
} catch (QueryException $e) {
$result = null;
Log::error(sprintf('Could not create new currency: %s', $e->getMessage()));
- throw new FireflyException('400004: Could not store new currency.');
+ throw new FireflyException('400004: Could not store new currency.', 0, $e);
}
return $result;
diff --git a/app/Factory/TransactionFactory.php b/app/Factory/TransactionFactory.php
index 759251a790..a41a871d68 100644
--- a/app/Factory/TransactionFactory.php
+++ b/app/Factory/TransactionFactory.php
@@ -102,17 +102,17 @@ class TransactionFactory
];
try {
$result = Transaction::create($data);
- // @codeCoverageIgnoreStart
+
} catch (QueryException $e) {
Log::error(sprintf('Could not create transaction: %s', $e->getMessage()), $data);
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
- throw new FireflyException('Query exception when creating transaction.');
+ throw new FireflyException('Query exception when creating transaction.', 0, $e);
}
if (null === $result) {
throw new FireflyException('Transaction is NULL.');
}
- // @codeCoverageIgnoreEnd
+
if (null !== $result) {
Log::debug(
sprintf(
diff --git a/app/Factory/TransactionGroupFactory.php b/app/Factory/TransactionGroupFactory.php
index 902004855f..8002561b6f 100644
--- a/app/Factory/TransactionGroupFactory.php
+++ b/app/Factory/TransactionGroupFactory.php
@@ -66,7 +66,7 @@ class TransactionGroupFactory
$collection = $this->journalFactory->create($data);
} catch (DuplicateTransactionException $e) {
Log::warning('GroupFactory::create() caught journalFactory::create() with a duplicate!');
- throw new DuplicateTransactionException($e->getMessage());
+ throw new DuplicateTransactionException($e->getMessage(), 0, $e);
}
$title = $data['group_title'] ?? null;
$title = '' === $title ? null : $title;
diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.php
index dc180a7f3b..96fa0566a1 100644
--- a/app/Factory/TransactionJournalFactory.php
+++ b/app/Factory/TransactionJournalFactory.php
@@ -128,13 +128,13 @@ class TransactionJournalFactory
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
$this->forceDeleteOnError($collection);
- throw new DuplicateTransactionException($e->getMessage());
+ throw new DuplicateTransactionException($e->getMessage(), 0, $e);
} catch (FireflyException $e) {
Log::warning('TransactionJournalFactory::create() caught an exception.');
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
$this->forceDeleteOnError($collection);
- throw new FireflyException($e->getMessage());
+ throw new FireflyException($e->getMessage(), 0, $e);
}
return $collection;
@@ -240,7 +240,7 @@ class TransactionJournalFactory
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
$this->forceDeleteOnError(new Collection([$journal]));
- throw new FireflyException($e->getMessage());
+ throw new FireflyException($e->getMessage(), 0, $e);
}
// and the destination one:
@@ -261,7 +261,7 @@ class TransactionJournalFactory
Log::warning('Delete negative transaction.');
$this->forceTrDelete($negative);
$this->forceDeleteOnError(new Collection([$journal]));
- throw new FireflyException($e->getMessage());
+ throw new FireflyException($e->getMessage(), 0, $e);
}
// verify that journal has two transactions. Otherwise, delete and cancel.
$journal->completed = true;
@@ -302,10 +302,10 @@ class TransactionJournalFactory
unset($dataRow['import_hash_v2'], $dataRow['original_source']);
$json = json_encode($dataRow, JSON_THROW_ON_ERROR, 512);
if (false === $json) {
- // @codeCoverageIgnoreStart
+
$json = json_encode((string)microtime(), JSON_THROW_ON_ERROR, 512);
Log::error(sprintf('Could not hash the original row! %s', json_last_error_msg()), $dataRow);
- // @codeCoverageIgnoreEnd
+
}
$hash = hash('sha256', $json);
Log::debug(sprintf('The hash is: %s', $hash), $dataRow);
@@ -358,7 +358,7 @@ class TransactionJournalFactory
// do something with result:
if (false === $validSource) {
- throw new FireflyException(sprintf('Source: %s', $this->accountValidator->sourceError)); // @codeCoverageIgnore
+ throw new FireflyException(sprintf('Source: %s', $this->accountValidator->sourceError));
}
Log::debug('Source seems valid.');
// validate destination account
@@ -367,7 +367,7 @@ class TransactionJournalFactory
$validDestination = $this->accountValidator->validateDestination($destinationId, $destinationName, null);
// do something with result:
if (false === $validDestination) {
- throw new FireflyException(sprintf('Destination: %s', $this->accountValidator->destError)); // @codeCoverageIgnore
+ throw new FireflyException(sprintf('Destination: %s', $this->accountValidator->destError));
}
}
@@ -485,7 +485,7 @@ class TransactionJournalFactory
{
try {
$transaction->delete();
- } catch (Exception $e) {
+ } catch (Exception $e) { // @phpstan-ignore-line
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
Log::error('Could not delete negative transaction.');
diff --git a/app/Factory/TransactionJournalMetaFactory.php b/app/Factory/TransactionJournalMetaFactory.php
index d3adb5777b..feff846ff9 100644
--- a/app/Factory/TransactionJournalMetaFactory.php
+++ b/app/Factory/TransactionJournalMetaFactory.php
@@ -49,8 +49,8 @@ class TransactionJournalMetaFactory
Log::debug('Value is empty, delete meta value.');
try {
$entry->delete();
- } catch (Exception $e) { // @codeCoverageIgnore
- Log::error(sprintf('Could not delete transaction journal meta: %s', $e->getMessage())); // @codeCoverageIgnore
+ } catch (Exception $e) { // @phpstan-ignore-line
+ Log::error(sprintf('Could not delete transaction journal meta: %s', $e->getMessage()));
}
return null;
@@ -67,8 +67,8 @@ class TransactionJournalMetaFactory
Log::debug('Will not store empty strings, delete meta value');
try {
$entry->delete();
- } catch (Exception $e) { // @codeCoverageIgnore
- Log::error(sprintf('Could not delete transaction journal meta: %s', $e->getMessage())); // @codeCoverageIgnore
+ } catch (Exception $e) { // @phpstan-ignore-line
+ Log::error(sprintf('Could not delete transaction journal meta: %s', $e->getMessage()));
}
}
diff --git a/app/Generator/Report/Account/MonthReportGenerator.php b/app/Generator/Report/Account/MonthReportGenerator.php
index 76ba7b89d9..e55ca69b50 100644
--- a/app/Generator/Report/Account/MonthReportGenerator.php
+++ b/app/Generator/Report/Account/MonthReportGenerator.php
@@ -56,7 +56,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
->with('start', $this->start)->with('end', $this->end)
->with('doubles', $this->expense)
->render();
- } catch (Throwable $e) {
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::error(sprintf('Cannot render reports.double.report: %s', $e->getMessage()));
$result = sprintf('Could not render report view: %s', $e->getMessage());
}
diff --git a/app/Generator/Report/Audit/MonthReportGenerator.php b/app/Generator/Report/Audit/MonthReportGenerator.php
index 754485d02f..009d8d0396 100644
--- a/app/Generator/Report/Audit/MonthReportGenerator.php
+++ b/app/Generator/Report/Audit/MonthReportGenerator.php
@@ -82,7 +82,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
$result = prefixView('reports.audit.report', compact('reportType', 'accountIds', 'auditData', 'hideable', 'defaultShow'))
->with('start', $this->start)->with('end', $this->end)->with('accounts', $this->accounts)
->render();
- } catch (Throwable $e) {
+ } catch (Throwable $e) { // @phpstan-ignore-line
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());
@@ -254,7 +254,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
return [
'journals' => $journals,
'currency' => $currency,
- 'exists' => !empty($journals),
+ 'exists' => 0!==count($journals),
'end' => $this->end->formatLocalized((string)trans('config.month_and_day', [], $locale)),
'endBalance' => app('steam')->balance($account, $this->end),
'dayBefore' => $date->formatLocalized((string)trans('config.month_and_day', [], $locale)),
diff --git a/app/Generator/Report/Budget/MonthReportGenerator.php b/app/Generator/Report/Budget/MonthReportGenerator.php
index 9e4bc6bcbd..f6c9af7e0c 100644
--- a/app/Generator/Report/Budget/MonthReportGenerator.php
+++ b/app/Generator/Report/Budget/MonthReportGenerator.php
@@ -73,7 +73,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
->with('budgets', $this->budgets)
->with('accounts', $this->accounts)
->render();
- } catch (Throwable $e) {
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::error(sprintf('Cannot render reports.account.report: %s', $e->getMessage()));
$result = sprintf('Could not render report view: %s', $e->getMessage());
}
diff --git a/app/Generator/Report/Category/MonthReportGenerator.php b/app/Generator/Report/Category/MonthReportGenerator.php
index df2bc0df4d..bfc91dbde4 100644
--- a/app/Generator/Report/Category/MonthReportGenerator.php
+++ b/app/Generator/Report/Category/MonthReportGenerator.php
@@ -81,7 +81,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
->with('categories', $this->categories)
->with('accounts', $this->accounts)
->render();
- } catch (Throwable $e) {
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::error(sprintf('Cannot render reports.category.month: %s', $e->getMessage()));
$result = sprintf('Could not render report view: %s', $e->getMessage());
}
diff --git a/app/Generator/Report/Standard/MonthReportGenerator.php b/app/Generator/Report/Standard/MonthReportGenerator.php
index 4071de53aa..1b7caea103 100644
--- a/app/Generator/Report/Standard/MonthReportGenerator.php
+++ b/app/Generator/Report/Standard/MonthReportGenerator.php
@@ -54,7 +54,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
try {
return prefixView('reports.default.month', compact('accountIds', 'reportType'))->with('start', $this->start)->with('end', $this->end)->render();
- } catch (Throwable $e) {
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::error(sprintf('Cannot render reports.default.month: %s', $e->getMessage()));
$result = 'Could not render report view.';
}
diff --git a/app/Generator/Report/Standard/MultiYearReportGenerator.php b/app/Generator/Report/Standard/MultiYearReportGenerator.php
index b535f7a105..1a8025b68d 100644
--- a/app/Generator/Report/Standard/MultiYearReportGenerator.php
+++ b/app/Generator/Report/Standard/MultiYearReportGenerator.php
@@ -58,7 +58,7 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
'reports.default.multi-year',
compact('accountIds', 'reportType')
)->with('start', $this->start)->with('end', $this->end)->render();
- } catch (Throwable $e) {
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::error(sprintf('Cannot render reports.default.multi-year: %s', $e->getMessage()));
$result = sprintf('Could not render report view: %s', $e->getMessage());
}
diff --git a/app/Generator/Report/Standard/YearReportGenerator.php b/app/Generator/Report/Standard/YearReportGenerator.php
index 7b0f7ec6c2..8da980de7f 100644
--- a/app/Generator/Report/Standard/YearReportGenerator.php
+++ b/app/Generator/Report/Standard/YearReportGenerator.php
@@ -58,7 +58,7 @@ class YearReportGenerator implements ReportGeneratorInterface
'reports.default.year',
compact('accountIds', 'reportType')
)->with('start', $this->start)->with('end', $this->end)->render();
- } catch (Throwable $e) {
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::error(sprintf('Cannot render reports.account.report: %s', $e->getMessage()));
$result = 'Could not render report view.';
}
diff --git a/app/Generator/Report/Tag/MonthReportGenerator.php b/app/Generator/Report/Tag/MonthReportGenerator.php
index a6d6c67b9f..008b9e27eb 100644
--- a/app/Generator/Report/Tag/MonthReportGenerator.php
+++ b/app/Generator/Report/Tag/MonthReportGenerator.php
@@ -79,7 +79,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
'reports.tag.month',
compact('accountIds', 'reportType', 'tagIds')
)->with('start', $this->start)->with('end', $this->end)->with('tags', $this->tags)->with('accounts', $this->accounts)->render();
- } catch (Throwable $e) {
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::error(sprintf('Cannot render reports.tag.month: %s', $e->getMessage()));
$result = sprintf('Could not render report view: %s', $e->getMessage());
}
diff --git a/app/Handlers/Events/APIEventHandler.php b/app/Handlers/Events/APIEventHandler.php
index 1e9542f6d2..bb944b84fe 100644
--- a/app/Handlers/Events/APIEventHandler.php
+++ b/app/Handlers/Events/APIEventHandler.php
@@ -69,14 +69,14 @@ class APIEventHandler
try {
Log::debug('Trying to send message...');
Mail::to($email)->send(new AccessTokenCreatedMail($email, $ipAddress));
- // @codeCoverageIgnoreStart
- } catch (Exception $e) {
+
+ } catch (Exception $e) { // @phpstan-ignore-line
Log::debug('Send message failed! :(');
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
Session::flash('error', 'Possible email error: ' . $e->getMessage());
}
- // @codeCoverageIgnoreEnd
+
Log::debug('If no error above this line, message was sent.');
}
diff --git a/app/Handlers/Events/AdminEventHandler.php b/app/Handlers/Events/AdminEventHandler.php
index 1b16371383..01bc3b9be4 100644
--- a/app/Handlers/Events/AdminEventHandler.php
+++ b/app/Handlers/Events/AdminEventHandler.php
@@ -67,15 +67,15 @@ class AdminEventHandler
try {
Log::debug('Trying to send message...');
Mail::to($email)->send(new AdminTestMail($email, $ipAddress));
- // @codeCoverageIgnoreStart
+
// Laravel cannot pretend this process failed during testing.
- } catch (Exception $e) {
+ } catch (Exception $e) { // @phpstan-ignore-line
Log::debug('Send message failed! :(');
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
Session::flash('error', 'Possible email error: ' . $e->getMessage());
}
- // @codeCoverageIgnoreEnd
+
Log::debug('If no error above this line, message was sent.');
}
diff --git a/app/Handlers/Events/AutomationHandler.php b/app/Handlers/Events/AutomationHandler.php
index e65abbb55d..6939b01009 100644
--- a/app/Handlers/Events/AutomationHandler.php
+++ b/app/Handlers/Events/AutomationHandler.php
@@ -48,7 +48,7 @@ class AutomationHandler
$sendReport = config('firefly.send_report_journals');
if (false === $sendReport) {
- return true; // @codeCoverageIgnore
+ return true;
}
Log::debug('In reportJournals.');
@@ -73,13 +73,13 @@ class AutomationHandler
try {
Log::debug('Trying to mail...');
Mail::to($user->email)->send(new ReportNewJournalsMail($email, '127.0.0.1', $event->groups));
- // @codeCoverageIgnoreStart
- } catch (Exception $e) {
+
+ } catch (Exception $e) { // @phpstan-ignore-line
Log::debug('Send message failed! :(');
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
}
- // @codeCoverageIgnoreEnd
+
Log::debug('Done!');
}
diff --git a/app/Handlers/Events/UserEventHandler.php b/app/Handlers/Events/UserEventHandler.php
index 095ca2f773..2d4da84c7d 100644
--- a/app/Handlers/Events/UserEventHandler.php
+++ b/app/Handlers/Events/UserEventHandler.php
@@ -154,8 +154,8 @@ class UserEventHandler
if (false === $entry['notified']) {
try {
Mail::to($email)->send(new NewIPAddressWarningMail($ipAddress));
- // @codeCoverageIgnoreStart
- } catch (Exception $e) {
+
+ } catch (Exception $e) { // @phpstan-ignore-line
Log::error($e->getMessage());
}
}
@@ -182,12 +182,12 @@ class UserEventHandler
$uri = route('profile.confirm-email-change', [$token->data]);
try {
Mail::to($newEmail)->send(new ConfirmEmailChangeMail($newEmail, $oldEmail, $uri, $ipAddress));
- // @codeCoverageIgnoreStart
- } catch (Exception $e) {
+
+ } catch (Exception $e) { // @phpstan-ignore-line
Log::error($e->getMessage());
}
- // @codeCoverageIgnoreEnd
+
return true;
}
@@ -210,12 +210,12 @@ class UserEventHandler
$uri = route('profile.undo-email-change', [$token->data, $hashed]);
try {
Mail::to($oldEmail)->send(new UndoEmailChangeMail($newEmail, $oldEmail, $uri, $ipAddress));
- // @codeCoverageIgnoreStart
- } catch (Exception $e) {
+
+ } catch (Exception $e) { // @phpstan-ignore-line
Log::error($e->getMessage());
}
- // @codeCoverageIgnoreEnd
+
return true;
}
@@ -238,12 +238,12 @@ class UserEventHandler
// send email.
try {
Mail::to($email)->send(new RequestedNewPasswordMail($url, $ipAddress));
- // @codeCoverageIgnoreStart
- } catch (Exception $e) {
+
+ } catch (Exception $e) { // @phpstan-ignore-line
Log::error($e->getMessage());
}
- // @codeCoverageIgnoreEnd
+
return true;
}
@@ -274,11 +274,11 @@ class UserEventHandler
// send email.
try {
Mail::to($email)->send(new RegisteredUserMail($uri, $ipAddress));
- // @codeCoverageIgnoreStart
- } catch (Exception $e) {
+
+ } catch (Exception $e) { // @phpstan-ignore-line
Log::error($e->getMessage());
}
- // @codeCoverageIgnoreEnd
+
}
return true;
diff --git a/app/Helpers/Attachments/AttachmentHelper.php b/app/Helpers/Attachments/AttachmentHelper.php
index f5ac7b738d..e69ab16ffa 100644
--- a/app/Helpers/Attachments/AttachmentHelper.php
+++ b/app/Helpers/Attachments/AttachmentHelper.php
@@ -156,11 +156,11 @@ class AttachmentHelper implements AttachmentHelperInterface
{
$resource = tmpfile();
if (false === $resource) {
- // @codeCoverageIgnoreStart
+
Log::error('Cannot create temp-file for file upload.');
return false;
- // @codeCoverageIgnoreEnd
+
}
if ('' === $content) {
@@ -204,7 +204,7 @@ class AttachmentHelper implements AttachmentHelperInterface
public function saveAttachmentsForModel(object $model, ?array $files): bool
{
if (!($model instanceof Model)) {
- return false; // @codeCoverageIgnore
+ return false;
}
Log::debug(sprintf('Now in saveAttachmentsForModel for model %s', get_class($model)));
@@ -218,7 +218,7 @@ class AttachmentHelper implements AttachmentHelperInterface
}
Log::debug('Done processing uploads.');
}
- if (!is_array($files) || empty($files)) {
+ if (!is_array($files)) {
Log::debug('Array of files is not an array. Probably nothing uploaded. Will not store attachments.');
}
@@ -263,7 +263,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$fileObject->rewind();
if (0 === $file->getSize()) {
- throw new FireflyException('Cannot upload empty or non-existent file.'); // @codeCoverageIgnore
+ throw new FireflyException('Cannot upload empty or non-existent file.');
}
$content = $fileObject->fread($file->getSize());
@@ -303,12 +303,12 @@ class AttachmentHelper implements AttachmentHelperInterface
$result = false;
}
- // @codeCoverageIgnoreStart
+
// can't seem to reach this point.
if (true === $result && !$this->validSize($file)) {
$result = false;
}
- // @codeCoverageIgnoreEnd
+
if (true === $result && $this->hasFile($file, $model)) {
$result = false;
}
diff --git a/app/Helpers/Collector/GroupCollector.php b/app/Helpers/Collector/GroupCollector.php
index 6db7a7bfd8..b6ef342f54 100644
--- a/app/Helpers/Collector/GroupCollector.php
+++ b/app/Helpers/Collector/GroupCollector.php
@@ -338,7 +338,7 @@ class GroupCollector implements GroupCollectorInterface
*/
public function setJournalIds(array $journalIds): GroupCollectorInterface
{
- if (!empty($journalIds)) {
+ if (0!==count($journalIds)) {
$this->query->whereIn('transaction_journals.id', $journalIds);
}
@@ -691,7 +691,7 @@ class GroupCollector implements GroupCollectorInterface
$result['date']->setTimezone(config('app.timezone'));
$result['created_at']->setTimezone(config('app.timezone'));
$result['updated_at']->setTimezone(config('app.timezone'));
- } catch (Exception $e) {
+ } catch (Exception $e) { // @phpstan-ignore-line
Log::error($e->getMessage());
}
@@ -699,7 +699,7 @@ class GroupCollector implements GroupCollectorInterface
$result = $this->convertToInteger($result);
$result['reconciled'] = 1 === (int)$result['reconciled'];
- if (isset($augumentedJournal['tag_id'])) { // assume the other fields are present as well.
+ if (array_key_exists('tag_id', $result)) { // assume the other fields are present as well.
$tagId = (int)$augumentedJournal['tag_id'];
$tagDate = null;
try {
@@ -717,7 +717,7 @@ class GroupCollector implements GroupCollectorInterface
}
// also merge attachments:
- if (isset($augumentedJournal['attachment_id'])) {
+ if (array_key_exists('attachment_id', $result)) {
$attachmentId = (int)$augumentedJournal['attachment_id'];
$result['attachments'][$attachmentId] = [
'id' => $attachmentId,
@@ -744,7 +744,7 @@ class GroupCollector implements GroupCollectorInterface
$currencyId = (int)$transaction['currency_id'];
// set default:
- if (!isset($groups[$groudId]['sums'][$currencyId])) {
+ if (!array_key_exists($currencyId, $groups[$groudId]['sums'])) {
$groups[$groudId]['sums'][$currencyId]['currency_id'] = $currencyId;
$groups[$groudId]['sums'][$currencyId]['currency_code'] = $transaction['currency_code'];
$groups[$groudId]['sums'][$currencyId]['currency_symbol'] = $transaction['currency_symbol'];
@@ -757,7 +757,7 @@ class GroupCollector implements GroupCollectorInterface
$currencyId = (int)$transaction['foreign_currency_id'];
// set default:
- if (!isset($groups[$groudId]['sums'][$currencyId])) {
+ if (!array_key_exists($currencyId, $groups[$groudId]['sums'])) {
$groups[$groudId]['sums'][$currencyId]['currency_id'] = $currencyId;
$groups[$groudId]['sums'][$currencyId]['currency_code'] = $transaction['foreign_currency_code'];
$groups[$groudId]['sums'][$currencyId]['currency_symbol'] = $transaction['foreign_currency_symbol'];
diff --git a/app/Helpers/Help/Help.php b/app/Helpers/Help/Help.php
index f7fc1415b1..a76ef6df23 100644
--- a/app/Helpers/Help/Help.php
+++ b/app/Helpers/Help/Help.php
@@ -84,7 +84,7 @@ class Help implements HelpInterface
$res = $client->request('GET', $uri, $opt);
$statusCode = $res->getStatusCode();
$content = trim($res->getBody()->getContents());
- } catch (Exception $e) {
+ } catch (Exception $e) { // @phpstan-ignore-line
Log::info($e->getMessage());
Log::info($e->getTraceAsString());
}
diff --git a/app/Helpers/Report/NetWorth.php b/app/Helpers/Report/NetWorth.php
index 01303273f9..45986cf22b 100644
--- a/app/Helpers/Report/NetWorth.php
+++ b/app/Helpers/Report/NetWorth.php
@@ -72,7 +72,7 @@ class NetWorth implements NetWorthInterface
$cache->addProperty('net-worth-by-currency');
$cache->addProperty(implode(',', $accounts->pluck('id')->toArray()));
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
$netWorth = [];
diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php
index 9221359b0a..5deebb3292 100644
--- a/app/Helpers/Report/ReportHelper.php
+++ b/app/Helpers/Report/ReportHelper.php
@@ -128,7 +128,7 @@ class ReportHelper implements ReportHelperInterface
while ($start <= $end) {
$year = $fiscalHelper->endOfFiscalYear($start)->year; // current year
- if (!isset($months[$year])) {
+ if (!array_key_exists($year, $months)) {
$months[$year] = [
'fiscal_start' => $fiscalHelper->startOfFiscalYear($start)->format('Y-m-d'),
'fiscal_end' => $fiscalHelper->endOfFiscalYear($start)->format('Y-m-d'),
diff --git a/app/Http/Controllers/Account/CreateController.php b/app/Http/Controllers/Account/CreateController.php
index d426f13fe7..392e03cb2b 100644
--- a/app/Http/Controllers/Account/CreateController.php
+++ b/app/Http/Controllers/Account/CreateController.php
@@ -156,7 +156,7 @@ class CreateController extends Controller
}
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
- $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
+ $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));
}
// redirect to previous URL.
diff --git a/app/Http/Controllers/Account/DeleteController.php b/app/Http/Controllers/Account/DeleteController.php
index 09ac8cff5e..7e49118d40 100644
--- a/app/Http/Controllers/Account/DeleteController.php
+++ b/app/Http/Controllers/Account/DeleteController.php
@@ -72,7 +72,7 @@ class DeleteController extends Controller
public function delete(Account $account)
{
if (!$this->isEditableAccount($account)) {
- return $this->redirectAccountToAccount($account); // @codeCoverageIgnore
+ return $this->redirectAccountToAccount($account);
}
$typeName = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type));
@@ -98,7 +98,7 @@ class DeleteController extends Controller
public function destroy(Request $request, Account $account)
{
if (!$this->isEditableAccount($account)) {
- return $this->redirectAccountToAccount($account); // @codeCoverageIgnore
+ return $this->redirectAccountToAccount($account);
}
$type = $account->accountType->type;
diff --git a/app/Http/Controllers/Account/EditController.php b/app/Http/Controllers/Account/EditController.php
index cfbc085ce1..be6a0e1da8 100644
--- a/app/Http/Controllers/Account/EditController.php
+++ b/app/Http/Controllers/Account/EditController.php
@@ -84,7 +84,7 @@ class EditController extends Controller
public function edit(Request $request, Account $account, AccountRepositoryInterface $repository)
{
if (!$this->isEditableAccount($account)) {
- return $this->redirectAccountToAccount($account); // @codeCoverageIgnore
+ return $this->redirectAccountToAccount($account);
}
$objectType = config('firefly.shortNamesByFullName')[$account->accountType->type];
@@ -177,7 +177,7 @@ class EditController extends Controller
public function update(AccountFormRequest $request, Account $account)
{
if (!$this->isEditableAccount($account)) {
- return $this->redirectAccountToAccount($account); // @codeCoverageIgnore
+ return $this->redirectAccountToAccount($account);
}
$data = $request->getAccountData();
@@ -195,7 +195,7 @@ class EditController extends Controller
}
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
- $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
+ $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));
}
// redirect
diff --git a/app/Http/Controllers/Account/ReconcileController.php b/app/Http/Controllers/Account/ReconcileController.php
index 5ccb8543d5..4232e35712 100644
--- a/app/Http/Controllers/Account/ReconcileController.php
+++ b/app/Http/Controllers/Account/ReconcileController.php
@@ -91,14 +91,14 @@ class ReconcileController extends Controller
public function reconcile(Account $account, Carbon $start = null, Carbon $end = null)
{
if (!$this->isEditableAccount($account)) {
- return $this->redirectAccountToAccount($account); // @codeCoverageIgnore
+ return $this->redirectAccountToAccount($account);
}
if (AccountType::ASSET !== $account->accountType->type) {
- // @codeCoverageIgnoreStart
+
session()->flash('error', (string)trans('firefly.must_be_asset_account'));
return redirect(route('accounts.index', [config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type))]));
- // @codeCoverageIgnoreEnd
+
}
$currency = $this->accountRepos->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();
@@ -106,7 +106,7 @@ class ReconcileController extends Controller
$range = app('preferences')->get('viewRange', '1M')->data;
// get start and end
- // @codeCoverageIgnoreStart
+
if (null === $start && null === $end) {
/** @var Carbon $start */
@@ -118,7 +118,7 @@ class ReconcileController extends Controller
/** @var Carbon $end */
$end = app('navigation')->endOfPeriod($start, $range);
}
- // @codeCoverageIgnoreEnd
+
if ($end->lt($start)) {
[$start, $end] = [$end, $start];
}
@@ -168,7 +168,7 @@ class ReconcileController extends Controller
public function submit(ReconciliationStoreRequest $request, Account $account, Carbon $start, Carbon $end)
{
if (!$this->isEditableAccount($account)) {
- return $this->redirectAccountToAccount($account); // @codeCoverageIgnore
+ return $this->redirectAccountToAccount($account);
}
Log::debug('In ReconcileController::submit()');
@@ -217,7 +217,7 @@ class ReconcileController extends Controller
private function createReconciliation(Account $account, Carbon $start, Carbon $end, string $difference)
{
if (!$this->isEditableAccount($account)) {
- return $this->redirectAccountToAccount($account); // @codeCoverageIgnore
+ return $this->redirectAccountToAccount($account);
}
$reconciliation = $this->accountRepos->getReconciliation($account);
diff --git a/app/Http/Controllers/Account/ShowController.php b/app/Http/Controllers/Account/ShowController.php
index 2b10139176..4b7274227e 100644
--- a/app/Http/Controllers/Account/ShowController.php
+++ b/app/Http/Controllers/Account/ShowController.php
@@ -91,7 +91,7 @@ class ShowController extends Controller
$objectType = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type));
if (!$this->isEditableAccount($account)) {
- return $this->redirectAccountToAccount($account); // @codeCoverageIgnore
+ return $this->redirectAccountToAccount($account);
}
/** @var Carbon $start */
@@ -100,7 +100,7 @@ class ShowController extends Controller
$end = $end ?? session('end');
if ($end < $start) {
- [$start, $end] = [$end, $start]; // @codeCoverageIgnore
+ [$start, $end] = [$end, $start];
}
$location = $this->repository->getLocation($account);
$attachments = $this->repository->getAttachments($account);
@@ -164,7 +164,7 @@ class ShowController extends Controller
public function showAll(Request $request, Account $account)
{
if (!$this->isEditableAccount($account)) {
- return $this->redirectAccountToAccount($account); // @codeCoverageIgnore
+ return $this->redirectAccountToAccount($account);
}
$location = $this->repository->getLocation($account);
$isLiability = $this->repository->isLiability($account);
diff --git a/app/Http/Controllers/Admin/LinkController.php b/app/Http/Controllers/Admin/LinkController.php
index 68256d93d6..8b78623e9d 100644
--- a/app/Http/Controllers/Admin/LinkController.php
+++ b/app/Http/Controllers/Admin/LinkController.php
@@ -163,7 +163,7 @@ class LinkController extends Controller
// put previous url in session if not redirect from store (not "return_to_edit").
if (true !== session('link-types.edit.fromUpdate')) {
- $this->rememberPreviousUri('link-types.edit.uri'); // @codeCoverageIgnore
+ $this->rememberPreviousUri('link-types.edit.uri');
}
$request->session()->forget('link-types.edit.fromUpdate');
diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php
index d898fdc448..06608a4df9 100644
--- a/app/Http/Controllers/Admin/UserController.php
+++ b/app/Http/Controllers/Admin/UserController.php
@@ -219,11 +219,11 @@ class UserController extends Controller
app('preferences')->mark();
$redirect = redirect($this->getPreviousUri('users.edit.uri'));
if (1 === (int)$request->get('return_to_edit')) {
- // @codeCoverageIgnoreStart
+
session()->put('users.edit.fromUpdate', true);
$redirect = redirect(route('admin.users.edit', [$user->id]))->withInput(['return_to_edit' => 1]);
- // @codeCoverageIgnoreEnd
+
}
// redirect to previous URL.
diff --git a/app/Http/Controllers/AttachmentController.php b/app/Http/Controllers/AttachmentController.php
index 47a5f37fd4..4bb4af6bc1 100644
--- a/app/Http/Controllers/AttachmentController.php
+++ b/app/Http/Controllers/AttachmentController.php
@@ -197,11 +197,11 @@ class AttachmentController extends Controller
$redirect = redirect($this->getPreviousUri('attachments.edit.uri'));
if (1 === (int)$request->get('return_to_edit')) {
- // @codeCoverageIgnoreStart
+
$request->session()->put('attachments.edit.fromUpdate', true);
$redirect = redirect(route('attachments.edit', [$attachment->id]))->withInput(['return_to_edit' => 1]);
- // @codeCoverageIgnoreEnd
+
}
// redirect to previous URL.
diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php
index b17e8652a7..01372e02ef 100644
--- a/app/Http/Controllers/Auth/ForgotPasswordController.php
+++ b/app/Http/Controllers/Auth/ForgotPasswordController.php
@@ -72,14 +72,14 @@ class ForgotPasswordController extends Controller
{
Log::info('Start of sendResetLinkEmail()');
$loginProvider = config('firefly.login_provider');
- // @codeCoverageIgnoreStart
+
if ('eloquent' !== $loginProvider) {
$message = sprintf('Cannot reset password when authenticating over "%s".', $loginProvider);
Log::error($message);
return prefixView('error', compact('message'));
}
- // @codeCoverageIgnoreEnd
+
$this->validateEmail($request);
@@ -102,7 +102,7 @@ class ForgotPasswordController extends Controller
return back()->with('status', trans($response));
}
- return back()->withErrors(['email' => trans($response)]); // @codeCoverageIgnore
+ return back()->withErrors(['email' => trans($response)]);
}
/**
diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php
index e64eb3e487..0295bc0388 100644
--- a/app/Http/Controllers/Auth/LoginController.php
+++ b/app/Http/Controllers/Auth/LoginController.php
@@ -83,7 +83,7 @@ class LoginController extends Controller
Log::info(sprintf('User is trying to login.'));
if ('ldap' === config('auth.providers.users.driver')) {
/** @var Adldap\Connections\Provider $provider */
- Adldap::getProvider('default');
+ Adldap::getProvider('default'); // @phpstan-ignore-line
}
$this->validateLogin($request);
@@ -96,7 +96,7 @@ class LoginController extends Controller
Log::channel('audit')->info(sprintf('Login for user "%s" was locked out.', $request->get('email')));
$this->fireLockoutEvent($request);
- return $this->sendLockoutResponse($request);
+ $this->sendLockoutResponse($request);
}
/** Copied directly from AuthenticatesUsers, but with logging added: */
@@ -190,7 +190,7 @@ class LoginController extends Controller
$loginProvider = config('firefly.login_provider');
$title = (string)trans('firefly.login_page_title');
if (0 === $count && 'eloquent' === $loginProvider) {
- return redirect(route('register')); // @codeCoverageIgnore
+ return redirect(route('register'));
}
// is allowed to?
diff --git a/app/Http/Controllers/Bill/CreateController.php b/app/Http/Controllers/Bill/CreateController.php
index 41b69d5c17..8efdbc45b5 100644
--- a/app/Http/Controllers/Bill/CreateController.php
+++ b/app/Http/Controllers/Bill/CreateController.php
@@ -34,6 +34,7 @@ use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
+use Log;
/**
* Class CreateController
@@ -124,7 +125,7 @@ class CreateController extends Controller
}
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
- $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
+ $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));
}
return redirect(route('rules.create-from-bill', [$bill->id]));
diff --git a/app/Http/Controllers/Bill/EditController.php b/app/Http/Controllers/Bill/EditController.php
index 690d9b4faa..108e5bcf49 100644
--- a/app/Http/Controllers/Bill/EditController.php
+++ b/app/Http/Controllers/Bill/EditController.php
@@ -138,16 +138,16 @@ class EditController extends Controller
// flash messages
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
- $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
+ $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));
}
$redirect = redirect($this->getPreviousUri('bills.edit.uri'));
if (1 === (int)$request->get('return_to_edit')) {
- // @codeCoverageIgnoreStart
+
$request->session()->put('bills.edit.fromUpdate', true);
$redirect = redirect(route('bills.edit', [$bill->id]))->withInput(['return_to_edit' => 1]);
- // @codeCoverageIgnoreEnd
+
}
return $redirect;
diff --git a/app/Http/Controllers/Bill/ShowController.php b/app/Http/Controllers/Bill/ShowController.php
index d597d1dce4..0c3f0ffe07 100644
--- a/app/Http/Controllers/Bill/ShowController.php
+++ b/app/Http/Controllers/Bill/ShowController.php
@@ -168,7 +168,7 @@ class ShowController extends Controller
$collection = $this->repository->getAttachments($bill);
$attachments = new Collection;
- // @codeCoverageIgnoreStart
+
if ($collection->count() > 0) {
/** @var AttachmentTransformer $transformer */
$transformer = app(AttachmentTransformer::class);
@@ -179,7 +179,7 @@ class ShowController extends Controller
);
}
- // @codeCoverageIgnoreEnd
+
return prefixView('bills.show', compact('attachments', 'groups', 'rules', 'yearAverage', 'overallAverage', 'year', 'object', 'bill', 'subTitle'));
}
diff --git a/app/Http/Controllers/Budget/CreateController.php b/app/Http/Controllers/Budget/CreateController.php
index d7aca5491b..32ced8a890 100644
--- a/app/Http/Controllers/Budget/CreateController.php
+++ b/app/Http/Controllers/Budget/CreateController.php
@@ -131,17 +131,17 @@ class CreateController extends Controller
}
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
- $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
+ $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));
}
$redirect = redirect($this->getPreviousUri('budgets.create.uri'));
if (1 === (int)$request->get('create_another')) {
- // @codeCoverageIgnoreStart
+
$request->session()->put('budgets.create.fromStore', true);
$redirect = redirect(route('budgets.create'))->withInput();
- // @codeCoverageIgnoreEnd
+
}
return $redirect;
diff --git a/app/Http/Controllers/Budget/EditController.php b/app/Http/Controllers/Budget/EditController.php
index 1205a19a67..8422595a05 100644
--- a/app/Http/Controllers/Budget/EditController.php
+++ b/app/Http/Controllers/Budget/EditController.php
@@ -144,15 +144,15 @@ class EditController extends Controller
}
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
- $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
+ $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));
}
if (1 === (int)$request->get('return_to_edit')) {
- // @codeCoverageIgnoreStart
+
$request->session()->put('budgets.edit.fromUpdate', true);
$redirect = redirect(route('budgets.edit', [$budget->id]))->withInput(['return_to_edit' => 1]);
- // @codeCoverageIgnoreEnd
+
}
return $redirect;
diff --git a/app/Http/Controllers/Budget/IndexController.php b/app/Http/Controllers/Budget/IndexController.php
index d796956cb4..10387daf30 100644
--- a/app/Http/Controllers/Budget/IndexController.php
+++ b/app/Http/Controllers/Budget/IndexController.php
@@ -219,7 +219,7 @@ class IndexController extends Controller
/** @var TransactionCurrency $currency */
foreach ($currencies as $currency) {
$spentArr = $this->opsRepository->sumExpenses($start, $end, null, new Collection([$current]), $currency);
- if (isset($spentArr[$currency->id]['sum'])) {
+ if (array_key_exists('sum', $spentArr[$currency->id])) {
$array['spent'][$currency->id]['spent'] = $spentArr[$currency->id]['sum'];
$array['spent'][$currency->id]['currency_id'] = $currency->id;
$array['spent'][$currency->id]['currency_symbol'] = $currency->symbol;
diff --git a/app/Http/Controllers/Budget/ShowController.php b/app/Http/Controllers/Budget/ShowController.php
index b176c3d2c0..b16e8142d5 100644
--- a/app/Http/Controllers/Budget/ShowController.php
+++ b/app/Http/Controllers/Budget/ShowController.php
@@ -180,7 +180,7 @@ class ShowController extends Controller
public function showByBudgetLimit(Request $request, Budget $budget, BudgetLimit $budgetLimit)
{
if ($budgetLimit->budget->id !== $budget->id) {
- throw new FireflyException('This budget limit is not part of this budget.'); // @codeCoverageIgnore
+ throw new FireflyException('This budget limit is not part of this budget.');
}
$page = (int)$request->get('page');
diff --git a/app/Http/Controllers/Category/CreateController.php b/app/Http/Controllers/Category/CreateController.php
index c35c44ce94..024d71dc06 100644
--- a/app/Http/Controllers/Category/CreateController.php
+++ b/app/Http/Controllers/Category/CreateController.php
@@ -105,16 +105,16 @@ class CreateController extends Controller
}
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
- $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
+ $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));
}
$redirect = redirect(route('categories.index'));
if (1 === (int)$request->get('create_another')) {
- // @codeCoverageIgnoreStart
+
$request->session()->put('categories.create.fromStore', true);
$redirect = redirect(route('categories.create'))->withInput();
- // @codeCoverageIgnoreEnd
+
}
return $redirect;
diff --git a/app/Http/Controllers/Category/EditController.php b/app/Http/Controllers/Category/EditController.php
index 16940cfb70..02355d2cc6 100644
--- a/app/Http/Controllers/Category/EditController.php
+++ b/app/Http/Controllers/Category/EditController.php
@@ -115,16 +115,16 @@ class EditController extends Controller
}
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
- $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
+ $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));
}
$redirect = redirect($this->getPreviousUri('categories.edit.uri'));
if (1 === (int)$request->get('return_to_edit')) {
- // @codeCoverageIgnoreStart
+
$request->session()->put('categories.edit.fromUpdate', true);
$redirect = redirect(route('categories.edit', [$category->id]));
- // @codeCoverageIgnoreEnd
+
}
return $redirect;
diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php
index 75894437eb..91d9ec0266 100644
--- a/app/Http/Controllers/Chart/AccountController.php
+++ b/app/Http/Controllers/Chart/AccountController.php
@@ -95,7 +95,7 @@ class AccountController extends Controller
$cache->addProperty($end);
$cache->addProperty('chart.account.expense-accounts');
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
$start->subDay();
@@ -203,7 +203,7 @@ class AccountController extends Controller
$cache->addProperty($end);
$cache->addProperty('chart.account.expense-budget');
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
@@ -217,7 +217,7 @@ class AccountController extends Controller
$budgetId = (int)$journal['budget_id'];
$key = sprintf('%d-%d', $budgetId, $journal['currency_id']);
$budgetIds[] = $budgetId;
- if (!isset($result[$key])) {
+ if (!array_key_exists($key, $result)) {
$result[$key] = [
'total' => '0',
'budget_id' => $budgetId,
@@ -277,7 +277,7 @@ class AccountController extends Controller
$cache->addProperty($end);
$cache->addProperty('chart.account.expense-category');
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
/** @var GroupCollectorInterface $collector */
@@ -290,7 +290,7 @@ class AccountController extends Controller
/** @var array $journal */
foreach ($journals as $journal) {
$key = sprintf('%d-%d', $journal['category_id'], $journal['currency_id']);
- if (!isset($result[$key])) {
+ if (!array_key_exists($key, $result)) {
$result[$key] = [
'total' => '0',
'category_id' => (int)$journal['category_id'],
@@ -373,7 +373,7 @@ class AccountController extends Controller
$cache->addProperty($end);
$cache->addProperty('chart.account.income-category');
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
// grab all journals:
@@ -387,7 +387,7 @@ class AccountController extends Controller
/** @var array $journal */
foreach ($journals as $journal) {
$key = sprintf('%d-%d', $journal['category_id'], $journal['currency_id']);
- if (!isset($result[$key])) {
+ if (!array_key_exists($key, $result)) {
$result[$key] = [
'total' => '0',
'category_id' => $journal['category_id'],
@@ -431,7 +431,7 @@ class AccountController extends Controller
$cache->addProperty($end);
$cache->addProperty($account->id);
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
$currencies = $this->accountRepository->getUsedCurrencies($account);
@@ -488,7 +488,7 @@ class AccountController extends Controller
$current->addDay();
}
break;
- // @codeCoverageIgnoreStart
+
case '1W':
case '1M':
case '1Y':
@@ -499,7 +499,7 @@ class AccountController extends Controller
$current = app('navigation')->addPeriod($current, $step, 0);
}
break;
- // @codeCoverageIgnoreEnd
+
}
$result['entries'] = $entries;
@@ -540,7 +540,7 @@ class AccountController extends Controller
$cache->addProperty($end);
$cache->addProperty('chart.account.revenue-accounts');
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
$start->subDay();
diff --git a/app/Http/Controllers/Chart/BillController.php b/app/Http/Controllers/Chart/BillController.php
index de009a6f45..f92c40f28a 100644
--- a/app/Http/Controllers/Chart/BillController.php
+++ b/app/Http/Controllers/Chart/BillController.php
@@ -67,7 +67,7 @@ class BillController extends Controller
$cache->addProperty($end);
$cache->addProperty('chart.bill.frontpage');
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
/** @var CurrencyRepositoryInterface $currencyRepository */
$currencyRepository = app(CurrencyRepositoryInterface::class);
@@ -109,7 +109,7 @@ class BillController extends Controller
$cache->addProperty('chart.bill.single');
$cache->addProperty($bill->id);
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
$locale = app('steam')->getLocale();
@@ -147,7 +147,7 @@ class BillController extends Controller
$chartData[1]['entries'][$date] = $bill->amount_max; // maximum amount of bill
// append amount because there are more than one per moment:
- if (!isset($chartData[2]['entries'][$date])) {
+ if (!array_key_exists($date, $chartData[2]['entries'])) {
$chartData[2]['entries'][$date] = '0';
}
$amount = bcmul($journal['amount'], '-1');
diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php
index 6ba5cff53f..a0afd439dc 100644
--- a/app/Http/Controllers/Chart/BudgetController.php
+++ b/app/Http/Controllers/Chart/BudgetController.php
@@ -98,7 +98,7 @@ class BudgetController extends Controller
$cache->addProperty($budget->id);
if ($cache->has()) {
- //return response()->json($cache->get()); // @codeCoverageIgnore
+ //return response()->json($cache->get());
}
$step = $this->calculateStep($start, $end); // depending on diff, do something with range of chart.
$collection = new Collection([$budget]);
@@ -169,7 +169,7 @@ class BudgetController extends Controller
$cache->addProperty($budget->id);
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
$locale = app('steam')->getLocale();
$entries = [];
@@ -224,7 +224,7 @@ class BudgetController extends Controller
$cache->addProperty($end);
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
$collector->setRange($start, $end);
$collector->setBudget($budget);
@@ -291,7 +291,7 @@ class BudgetController extends Controller
$cache->addProperty($end);
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
$collector->setRange($start, $end);
$collector->setBudget($budget)->withCategoryInformation();
@@ -355,7 +355,7 @@ class BudgetController extends Controller
$cache->addProperty($end);
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
$collector->setRange($start, $end);
$collector->setTypes([TransactionType::WITHDRAWAL])->setBudget($budget)->withAccountInformation();
@@ -410,7 +410,7 @@ class BudgetController extends Controller
$cache->addProperty($end);
$cache->addProperty('chart.budget.frontpage');
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
$chartGenerator = app(FrontpageChartGenerator::class);
@@ -447,7 +447,7 @@ class BudgetController extends Controller
$cache->addProperty($currency->id);
$cache->addProperty('chart.budget.period');
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
$titleFormat = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
$preferredRange = app('navigation')->preferredRangeFormat($start, $end);
@@ -521,7 +521,7 @@ class BudgetController extends Controller
$cache->addProperty($currency->id);
$cache->addProperty('chart.budget.no-budget');
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
// the expenses:
diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php
index bcf58c25c6..de6a3a5ab5 100644
--- a/app/Http/Controllers/Chart/CategoryController.php
+++ b/app/Http/Controllers/Chart/CategoryController.php
@@ -76,7 +76,7 @@ class CategoryController extends Controller
$cache->addProperty('chart.category.all');
$cache->addProperty($category->id);
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
/** @var CategoryRepositoryInterface $repository */
$repository = app(CategoryRepositoryInterface::class);
@@ -102,8 +102,8 @@ class CategoryController extends Controller
$carbon = null;
try {
$carbon = today(config('app.timezone'));
- } catch (Exception $e) {
- $e->getMessage();
+ } catch (Exception $e) { // @phpstan-ignore-line
+ // @ignoreException
}
return $carbon;
@@ -125,7 +125,7 @@ class CategoryController extends Controller
$cache->addProperty($end);
$cache->addProperty('chart.category.frontpage');
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
$frontPageGenerator = new FrontpageChartGenerator($start, $end);
@@ -156,7 +156,7 @@ class CategoryController extends Controller
$cache->addProperty($accounts->pluck('id')->toArray());
$cache->addProperty($category);
if ($cache->has()) {
- return response()->json($cache->get());// @codeCoverageIgnore
+ return response()->json($cache->get());
}
$data = $this->reportPeriodChart($accounts, $start, $end, $category);
@@ -270,7 +270,7 @@ class CategoryController extends Controller
$cache->addProperty('chart.category.period.no-cat');
$cache->addProperty($accounts->pluck('id')->toArray());
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
$data = $this->reportPeriodChart($accounts, $start, $end, null);
@@ -294,7 +294,7 @@ class CategoryController extends Controller
$start = app('navigation')->startOfPeriod($date, $range);
$end = session()->get('end');
if ($end < $start) {
- [$end, $start] = [$start, $end]; // @codeCoverageIgnore
+ [$end, $start] = [$start, $end];
}
$cache = new CacheProperties;
@@ -303,7 +303,7 @@ class CategoryController extends Controller
$cache->addProperty($category->id);
$cache->addProperty('chart.category.period-chart');
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
/** @var WholePeriodChartGenerator $chartGenerator */
diff --git a/app/Http/Controllers/Chart/ExpenseReportController.php b/app/Http/Controllers/Chart/ExpenseReportController.php
index bfda695e27..b4041c0c2f 100644
--- a/app/Http/Controllers/Chart/ExpenseReportController.php
+++ b/app/Http/Controllers/Chart/ExpenseReportController.php
@@ -88,7 +88,7 @@ class ExpenseReportController extends Controller
$cache->addProperty($start);
$cache->addProperty($end);
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
@@ -184,11 +184,11 @@ class ExpenseReportController extends Controller
$newSet = [];
foreach ($chartData as $key => $entry) {
if (0 === !array_sum($entry['entries'])) {
- $newSet[$key] = $chartData[$key]; // @codeCoverageIgnore
+ $newSet[$key] = $chartData[$key];
}
}
- if (empty($newSet)) {
- $newSet = $chartData; // @codeCoverageIgnore
+ if (0===count($newSet)) {
+ $newSet = $chartData;
}
$data = $this->generator->multiSet($newSet);
$cache->store($data);
diff --git a/app/Http/Controllers/Chart/PiggyBankController.php b/app/Http/Controllers/Chart/PiggyBankController.php
index 96d7287638..c0c451ed0a 100644
--- a/app/Http/Controllers/Chart/PiggyBankController.php
+++ b/app/Http/Controllers/Chart/PiggyBankController.php
@@ -73,7 +73,7 @@ class PiggyBankController extends Controller
$cache->addProperty('chart.piggy-bank.history');
$cache->addProperty($piggyBank->id);
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
$set = $repository->getEvents($piggyBank);
$set = $set->reverse();
diff --git a/app/Http/Controllers/Chart/ReportController.php b/app/Http/Controllers/Chart/ReportController.php
index 9e736e5ea9..4f7b7f91e5 100644
--- a/app/Http/Controllers/Chart/ReportController.php
+++ b/app/Http/Controllers/Chart/ReportController.php
@@ -78,7 +78,7 @@ class ReportController extends Controller
$cache->addProperty(implode(',', $accounts->pluck('id')->toArray()));
$cache->addProperty($end);
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
$locale = app('steam')->getLocale();
$current = clone $start;
@@ -113,7 +113,7 @@ class ReportController extends Controller
foreach ($result as $netWorthItem) {
$currencyId = $netWorthItem['currency']->id;
$label = $current->formatLocalized((string)trans('config.month_and_day', [], $locale));
- if (!isset($chartData[$currencyId])) {
+ if (!array_key_exists($currencyId, $chartData)) {
$chartData[$currencyId] = [
'label' => 'Net worth in ' . $netWorthItem['currency']->name,
'type' => 'line',
@@ -152,7 +152,7 @@ class ReportController extends Controller
$cache->addProperty($accounts);
$cache->addProperty($end);
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
Log::debug('Going to do operations for accounts ', $accounts->pluck('id')->toArray());
$format = app('navigation')->preferredCarbonFormat($start, $end);
diff --git a/app/Http/Controllers/Chart/TransactionController.php b/app/Http/Controllers/Chart/TransactionController.php
index f6d1aca390..76b8cc1fb8 100644
--- a/app/Http/Controllers/Chart/TransactionController.php
+++ b/app/Http/Controllers/Chart/TransactionController.php
@@ -66,7 +66,7 @@ class TransactionController extends Controller
$cache->addProperty($end);
$cache->addProperty('chart.transactions.budgets');
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
@@ -111,7 +111,7 @@ class TransactionController extends Controller
$cache->addProperty($objectType);
$cache->addProperty('chart.transactions.categories');
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
@@ -169,7 +169,7 @@ class TransactionController extends Controller
$cache->addProperty($objectType);
$cache->addProperty('chart.transactions.destinations');
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
@@ -226,7 +226,7 @@ class TransactionController extends Controller
$cache->addProperty($objectType);
$cache->addProperty('chart.transactions.sources');
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
diff --git a/app/Http/Controllers/CurrencyController.php b/app/Http/Controllers/CurrencyController.php
index 1f950ed0b0..695b6d4739 100644
--- a/app/Http/Controllers/CurrencyController.php
+++ b/app/Http/Controllers/CurrencyController.php
@@ -130,12 +130,12 @@ class CurrencyController extends Controller
/** @var User $user */
$user = auth()->user();
if (!$this->userRepository->hasRole($user, 'owner')) {
- // @codeCoverageIgnoreStart
+
$request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
Log::channel('audit')->info(sprintf('Tried to visit page to delete currency %s but is not site owner.', $currency->code));
return redirect(route('currencies.index'));
- // @codeCoverageIgnoreEnd
+
}
if ($this->repository->currencyInUse($currency)) {
@@ -168,12 +168,12 @@ class CurrencyController extends Controller
/** @var User $user */
$user = auth()->user();
if (!$this->userRepository->hasRole($user, 'owner')) {
- // @codeCoverageIgnoreStart
+
$request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
Log::channel('audit')->info(sprintf('Tried to delete currency %s but is not site owner.', $currency->code));
return redirect(route('currencies.index'));
- // @codeCoverageIgnoreEnd
+
}
if ($this->repository->currencyInUse($currency)) {
@@ -212,12 +212,12 @@ class CurrencyController extends Controller
/** @var User $user */
$user = auth()->user();
if (!$this->userRepository->hasRole($user, 'owner')) {
- // @codeCoverageIgnoreStart
+
$request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
Log::channel('audit')->info(sprintf('Tried to disable currency %s but is not site owner.', $currency->code));
return redirect(route('currencies.index'));
- // @codeCoverageIgnoreEnd
+
}
if ($this->repository->currencyInUse($currency)) {
@@ -268,12 +268,12 @@ class CurrencyController extends Controller
/** @var User $user */
$user = auth()->user();
if (!$this->userRepository->hasRole($user, 'owner')) {
- // @codeCoverageIgnoreStart
+
$request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
Log::channel('audit')->info(sprintf('Tried to edit currency %s but is not owner.', $currency->code));
return redirect(route('currencies.index'));
- // @codeCoverageIgnoreEnd
+
}
$subTitleIcon = 'fa-pencil';
@@ -355,12 +355,12 @@ class CurrencyController extends Controller
$user = auth()->user();
$data = $request->getCurrencyData();
if (!$this->userRepository->hasRole($user, 'owner')) {
- // @codeCoverageIgnoreStart
+
Log::error('User ' . auth()->user()->id . ' is not admin, but tried to store a currency.');
Log::channel('audit')->info('Tried to create (POST) currency without admin rights.', $data);
return redirect($this->getPreviousUri('currencies.create.uri'));
- // @codeCoverageIgnoreEnd
+
}
$data['enabled'] = true;
@@ -378,11 +378,11 @@ class CurrencyController extends Controller
$request->session()->flash('success', (string) trans('firefly.created_currency', ['name' => $currency->name]));
Log::channel('audit')->info('Created (POST) currency.', $data);
if (1 === (int) $request->get('create_another')) {
- // @codeCoverageIgnoreStart
+
$request->session()->put('currencies.create.fromStore', true);
$redirect = redirect(route('currencies.create'))->withInput();
- // @codeCoverageIgnoreEnd
+
}
}
@@ -406,12 +406,12 @@ class CurrencyController extends Controller
$data['enabled'] = true;
}
if (!$this->userRepository->hasRole($user, 'owner')) {
- // @codeCoverageIgnoreStart
+
$request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
Log::channel('audit')->info('Tried to update (POST) currency without admin rights.', $data);
return redirect(route('currencies.index'));
- // @codeCoverageIgnoreEnd
+
}
$currency = $this->repository->update($currency, $data);
Log::channel('audit')->info('Updated (POST) currency.', $data);
@@ -419,11 +419,11 @@ class CurrencyController extends Controller
app('preferences')->mark();
if (1 === (int) $request->get('return_to_edit')) {
- // @codeCoverageIgnoreStart
+
$request->session()->put('currencies.edit.fromUpdate', true);
return redirect(route('currencies.edit', [$currency->id]));
- // @codeCoverageIgnoreEnd
+
}
return redirect($this->getPreviousUri('currencies.edit.uri'));
diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.php
index 2430a6d5ae..fca31fc302 100644
--- a/app/Http/Controllers/DebugController.php
+++ b/app/Http/Controllers/DebugController.php
@@ -98,12 +98,11 @@ class DebugController extends Controller
Log::debug('Call twig:clean...');
try {
Artisan::call('twig:clean');
- // @codeCoverageIgnoreStart
- } catch (Exception $e) {
- // don't care
- Log::debug(sprintf('Called twig:clean: %s', $e->getMessage()));
+
+ } catch (Exception $e) { // @phpstan-ignore-line
+ // @ignoreException
}
- // @codeCoverageIgnoreEnd
+
Log::debug('Call view:clear...');
Artisan::call('view:clear');
Log::debug('Done! Redirecting...');
@@ -179,12 +178,11 @@ class DebugController extends Controller
if (null !== $logFile) {
try {
$logContent = file_get_contents($logFile);
- // @codeCoverageIgnoreStart
- } catch (Exception $e) {
- // don't care
- Log::debug(sprintf('Could not read log file. %s', $e->getMessage()));
+
+ } catch (Exception $e) { // @phpstan-ignore-line
+ // @ignoreException
}
- // @codeCoverageIgnoreEnd
+
}
}
}
diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php
index 1d1317511a..7f436b37e8 100644
--- a/app/Http/Controllers/HomeController.php
+++ b/app/Http/Controllers/HomeController.php
@@ -39,7 +39,6 @@ use Illuminate\Routing\Redirector;
use Illuminate\Support\Collection;
use Illuminate\View\View;
use Log;
-use DB;
/**
* Class HomeController.
@@ -108,8 +107,8 @@ class HomeController extends Controller
*/
public function index(AccountRepositoryInterface $repository)
{
- $types = config('firefly.accountTypesByIdentifier.asset');
- $count = $repository->count($types);
+ $types = config('firefly.accountTypesByIdentifier.asset');
+ $count = $repository->count($types);
Log::channel('audit')->info('User visits homepage.');
if (0 === $count) {
diff --git a/app/Http/Controllers/Json/BoxController.php b/app/Http/Controllers/Json/BoxController.php
index ebaf03c2de..31bfea6235 100644
--- a/app/Http/Controllers/Json/BoxController.php
+++ b/app/Http/Controllers/Json/BoxController.php
@@ -72,7 +72,7 @@ class BoxController extends Controller
$cache->addProperty($today);
$cache->addProperty('box-available');
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
$leftPerDayAmount = '0';
$leftToSpendAmount = '0';
@@ -142,7 +142,7 @@ class BoxController extends Controller
$cache->addProperty($end);
$cache->addProperty('box-balance');
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get());
}
// prep some arrays:
$incomes = [];
@@ -189,7 +189,7 @@ class BoxController extends Controller
$incomes[$currencyId] = app('amount')->formatAnything($currency, $incomes[$currencyId] ?? '0', false);
$expenses[$currencyId] = app('amount')->formatAnything($currency, $expenses[$currencyId] ?? '0', false);
}
- if (empty($sums)) {
+ if (0===count($sums)) {
$currency = app('amount')->getDefaultCurrency();
$sums[$currency->id] = app('amount')->formatAnything($currency, '0', false);
$incomes[$currency->id] = app('amount')->formatAnything($currency, '0', false);
diff --git a/app/Http/Controllers/Json/FrontpageController.php b/app/Http/Controllers/Json/FrontpageController.php
index bb79b73df8..110c5ec743 100644
--- a/app/Http/Controllers/Json/FrontpageController.php
+++ b/app/Http/Controllers/Json/FrontpageController.php
@@ -64,15 +64,15 @@ class FrontpageController extends Controller
}
}
$html = '';
- if (!empty($info)) {
+ if (0!==count($info)) {
try {
$html = prefixView('json.piggy-banks', compact('info'))->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::error(sprintf('Cannot render json.piggy-banks: %s', $e->getMessage()));
$html = 'Could not render view.';
}
- // @codeCoverageIgnoreEnd
+
}
return response()->json(['html' => $html]);
diff --git a/app/Http/Controllers/Json/IntroController.php b/app/Http/Controllers/Json/IntroController.php
index c9ff62b25b..2f703d31bd 100644
--- a/app/Http/Controllers/Json/IntroController.php
+++ b/app/Http/Controllers/Json/IntroController.php
@@ -54,7 +54,7 @@ class IntroController extends Controller
return response()->json($steps);
}
if ($this->hasOutroStep($route)) {
- // @codeCoverageIgnoreStart
+
// save last step:
$lastStep = $steps[count($steps) - 1];
// remove last step:
@@ -62,7 +62,7 @@ class IntroController extends Controller
// merge arrays and add last step again
$steps = array_merge($steps, $specificSteps);
$steps[] = $lastStep;
- // @codeCoverageIgnoreEnd
+
}
if (!$this->hasOutroStep($route)) {
$steps = array_merge($steps, $specificSteps);
diff --git a/app/Http/Controllers/Json/ReconcileController.php b/app/Http/Controllers/Json/ReconcileController.php
index 5bc1a296f1..b36fe4c681 100644
--- a/app/Http/Controllers/Json/ReconcileController.php
+++ b/app/Http/Controllers/Json/ReconcileController.php
@@ -153,12 +153,12 @@ class ReconcileController extends Controller
'selectedIds'
)
)->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('View error: %s', $e->getMessage()));
$view = sprintf('Could not render accounts.reconcile.overview: %s', $e->getMessage());
}
- // @codeCoverageIgnoreEnd
+
$return = [
'post_uri' => $route,
'html' => $view,
@@ -181,7 +181,7 @@ class ReconcileController extends Controller
Log::debug(sprintf('User submitted %s #%d: "%s"', $journal['transaction_type_type'], $journal['transaction_journal_id'], $journal['description']));
// not much magic below we need to cover using tests.
- // @codeCoverageIgnoreStart
+
if ($account->id === $journal['source_account_id']) {
if ($currency->id === $journal['currency_id']) {
$toAdd = $journal['amount'];
@@ -198,7 +198,7 @@ class ReconcileController extends Controller
$toAdd = bcmul($journal['foreign_amount'], '-1');
}
}
- // @codeCoverageIgnoreEnd
+
Log::debug(sprintf('Going to add %s to %s', $toAdd, $amount));
$amount = bcadd($amount, $toAdd);
@@ -250,13 +250,13 @@ class ReconcileController extends Controller
'accounts.reconcile.transactions',
compact('account', 'journals', 'currency', 'start', 'end', 'selectionStart', 'selectionEnd')
)->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Could not render: %s', $e->getMessage()));
$html = sprintf('Could not render accounts.reconcile.transactions: %s', $e->getMessage());
}
- // @codeCoverageIgnoreEnd
+
return response()->json(['html' => $html, 'startBalance' => $startBalance, 'endBalance' => $endBalance]);
}
@@ -275,7 +275,7 @@ class ReconcileController extends Controller
/** @var array $journal */
foreach ($array as $journal) {
$inverse = false;
- // @codeCoverageIgnoreStart
+
if (TransactionType::DEPOSIT === $journal['transaction_type_type']) {
$inverse = true;
}
@@ -296,7 +296,7 @@ class ReconcileController extends Controller
$journal['foreign_amount'] = app('steam')->positive($journal['foreign_amount']);
}
}
- // @codeCoverageIgnoreEnd
+
$journals[] = $journal;
}
diff --git a/app/Http/Controllers/Json/RuleController.php b/app/Http/Controllers/Json/RuleController.php
index 9fe3d32b02..a55f82d111 100644
--- a/app/Http/Controllers/Json/RuleController.php
+++ b/app/Http/Controllers/Json/RuleController.php
@@ -51,13 +51,13 @@ class RuleController extends Controller
}
try {
$view = prefixView('rules.partials.action', compact('actions', 'count'))->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::error(sprintf('Cannot render rules.partials.action: %s', $e->getMessage()));
$view = 'Could not render view.';
}
- // @codeCoverageIgnoreEnd
+
return response()->json(['html' => $view]);
}
@@ -84,7 +84,7 @@ class RuleController extends Controller
try {
$view = prefixView('rules.partials.trigger', compact('triggers', 'count'))->render();
- } catch (Throwable $e) {
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::error(sprintf('Cannot render rules.partials.trigger: %s', $e->getMessage()));
$view = 'Could not render view.';
}
diff --git a/app/Http/Controllers/ObjectGroup/EditController.php b/app/Http/Controllers/ObjectGroup/EditController.php
index e2d966afb7..f83b75541d 100644
--- a/app/Http/Controllers/ObjectGroup/EditController.php
+++ b/app/Http/Controllers/ObjectGroup/EditController.php
@@ -92,11 +92,11 @@ class EditController extends Controller
$redirect = redirect($this->getPreviousUri('object-groups.edit.uri'));
if (1 === (int)$request->get('return_to_edit')) {
- // @codeCoverageIgnoreStart
+
session()->put('object-groups.edit.fromUpdate', true);
$redirect = redirect(route('object-groups.edit', [$piggyBank->id]));
- // @codeCoverageIgnoreEnd
+
}
return $redirect;
diff --git a/app/Http/Controllers/PiggyBank/CreateController.php b/app/Http/Controllers/PiggyBank/CreateController.php
index 6ad6f2b4b7..daf969a5ce 100644
--- a/app/Http/Controllers/PiggyBank/CreateController.php
+++ b/app/Http/Controllers/PiggyBank/CreateController.php
@@ -111,16 +111,16 @@ class CreateController extends Controller
}
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
- $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
+ $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));
}
$redirect = redirect($this->getPreviousUri('piggy-banks.create.uri'));
if (1 === (int)$request->get('create_another')) {
- // @codeCoverageIgnoreStart
+
session()->put('piggy-banks.create.fromStore', true);
$redirect = redirect(route('piggy-banks.create'))->withInput();
- // @codeCoverageIgnoreEnd
+
}
return $redirect;
diff --git a/app/Http/Controllers/PiggyBank/EditController.php b/app/Http/Controllers/PiggyBank/EditController.php
index 694f1c787d..783a6b1b78 100644
--- a/app/Http/Controllers/PiggyBank/EditController.php
+++ b/app/Http/Controllers/PiggyBank/EditController.php
@@ -132,16 +132,16 @@ class EditController extends Controller
}
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
- $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
+ $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));
}
$redirect = redirect($this->getPreviousUri('piggy-banks.edit.uri'));
if (1 === (int)$request->get('return_to_edit')) {
- // @codeCoverageIgnoreStart
+
session()->put('piggy-banks.edit.fromUpdate', true);
$redirect = redirect(route('piggy-banks.edit', [$piggyBank->id]));
- // @codeCoverageIgnoreEnd
+
}
return $redirect;
diff --git a/app/Http/Controllers/PiggyBank/IndexController.php b/app/Http/Controllers/PiggyBank/IndexController.php
index c14bac0b50..571c79c4bb 100644
--- a/app/Http/Controllers/PiggyBank/IndexController.php
+++ b/app/Http/Controllers/PiggyBank/IndexController.php
@@ -112,7 +112,7 @@ class IndexController extends Controller
$account = $accountTransformer->transform($piggy->account);
$accountId = (int)$account['id'];
$array['attachments'] = $this->piggyRepos->getAttachments($piggy);
- if (!isset($accounts[$accountId])) {
+ if (!array_key_exists($accountId, $accounts)) {
// create new:
$accounts[$accountId] = $account;
diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php
index ec39081f30..9a799f1957 100644
--- a/app/Http/Controllers/PreferencesController.php
+++ b/app/Http/Controllers/PreferencesController.php
@@ -32,6 +32,7 @@ use Illuminate\Http\Request;
use Illuminate\Routing\Redirector;
use Illuminate\View\View;
use JsonException;
+use Log;
/**
* Class PreferencesController.
@@ -198,18 +199,18 @@ class PreferencesController extends Controller
// optional fields for transactions:
$setOptions = $request->get('tj');
$optionalTj = [
- 'interest_date' => isset($setOptions['interest_date']),
- 'book_date' => isset($setOptions['book_date']),
- 'process_date' => isset($setOptions['process_date']),
- 'due_date' => isset($setOptions['due_date']),
- 'payment_date' => isset($setOptions['payment_date']),
- 'invoice_date' => isset($setOptions['invoice_date']),
- 'internal_reference' => isset($setOptions['internal_reference']),
- 'notes' => isset($setOptions['notes']),
- 'attachments' => isset($setOptions['attachments']),
- 'external_uri' => isset($setOptions['external_uri']),
- 'location' => isset($setOptions['location']),
- 'links' => isset($setOptions['links']),
+ 'interest_date' => array_key_exists('interest_date', $setOptions),
+ 'book_date' => array_key_exists('book_date', $setOptions),
+ 'process_date' => array_key_exists('process_date', $setOptions),
+ 'due_date' => array_key_exists('due_date', $setOptions),
+ 'payment_date' => array_key_exists('payment_date', $setOptions),
+ 'invoice_date' => array_key_exists('invoice_date', $setOptions),
+ 'internal_reference' => array_key_exists('internal_reference', $setOptions),
+ 'notes' => array_key_exists('notes', $setOptions),
+ 'attachments' => array_key_exists('attachments', $setOptions),
+ 'external_uri' => array_key_exists('external_uri', $setOptions),
+ 'location' => array_key_exists('location', $setOptions),
+ 'links' => array_key_exists('links', $setOptions),
];
app('preferences')->set('transaction_journal_optional_fields', $optionalTj);
diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php
index 5d09146c0c..e4f0d932ca 100644
--- a/app/Http/Controllers/ProfileController.php
+++ b/app/Http/Controllers/ProfileController.php
@@ -241,9 +241,9 @@ class ProfileController extends Controller
public function confirmEmailChange(UserRepositoryInterface $repository, string $token)
{
if (!$this->internalAuth || !$this->internalIdentity) {
- // @codeCoverageIgnoreStart
+
throw new FireflyException(trans('firefly.external_user_mgt_disabled'));
- // @codeCoverageIgnoreEnd
+
}
// find preference with this token value.
/** @var Collection $set */
diff --git a/app/Http/Controllers/Recurring/CreateController.php b/app/Http/Controllers/Recurring/CreateController.php
index 1f19e1bfd7..fcc81e3a7b 100644
--- a/app/Http/Controllers/Recurring/CreateController.php
+++ b/app/Http/Controllers/Recurring/CreateController.php
@@ -240,7 +240,7 @@ class CreateController extends Controller
}
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
- $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
+ $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));
}
$redirect = redirect($this->getPreviousUri('recurring.create.uri'));
diff --git a/app/Http/Controllers/Recurring/EditController.php b/app/Http/Controllers/Recurring/EditController.php
index 2bf0ecc4ca..b67f3722ea 100644
--- a/app/Http/Controllers/Recurring/EditController.php
+++ b/app/Http/Controllers/Recurring/EditController.php
@@ -103,7 +103,7 @@ class EditController extends Controller
$repetition = $recurrence->recurrenceRepetitions()->first();
$currentRepType = $repetition->repetition_type;
if ('' !== $repetition->repetition_moment) {
- $currentRepType .= ',' . $repetition->repetition_moment; // @codeCoverageIgnore
+ $currentRepType .= ',' . $repetition->repetition_moment;
}
// put previous url in session if not redirect from store (not "return_to_edit").
@@ -119,10 +119,10 @@ class EditController extends Controller
'times' => (string)trans('firefly.repeat_times'),
];
if (null !== $recurrence->repeat_until) {
- $repetitionEnd = 'until_date'; // @codeCoverageIgnore
+ $repetitionEnd = 'until_date';
}
if ($recurrence->repetitions > 0) {
- $repetitionEnd = 'times'; // @codeCoverageIgnore
+ $repetitionEnd = 'times';
}
$weekendResponses = [
@@ -177,7 +177,7 @@ class EditController extends Controller
}
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
- $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
+ $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));
}
app('preferences')->mark();
$redirect = redirect($this->getPreviousUri('recurrences.edit.uri'));
diff --git a/app/Http/Controllers/Report/AccountController.php b/app/Http/Controllers/Report/AccountController.php
index 1fba3e855f..2bd37602a3 100644
--- a/app/Http/Controllers/Report/AccountController.php
+++ b/app/Http/Controllers/Report/AccountController.php
@@ -55,7 +55,7 @@ class AccountController extends Controller
$cache->addProperty('account-report');
$cache->addProperty($accounts->pluck('id')->toArray());
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
/** @var AccountTaskerInterface $accountTasker */
@@ -63,12 +63,12 @@ class AccountController extends Controller
$accountReport = $accountTasker->getAccountReport($accounts, $start, $end);
try {
$result = prefixView('reports.partials.accounts', compact('accountReport'))->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Could not render reports.partials.accounts: %s', $e->getMessage()));
$result = 'Could not render view.';
}
- // @codeCoverageIgnoreEnd
+
$cache->store($result);
return $result;
diff --git a/app/Http/Controllers/Report/BalanceController.php b/app/Http/Controllers/Report/BalanceController.php
index 4613e1c506..88f79205e7 100644
--- a/app/Http/Controllers/Report/BalanceController.php
+++ b/app/Http/Controllers/Report/BalanceController.php
@@ -137,8 +137,8 @@ class BalanceController extends Controller
}
try {
$result = prefixView('reports.partials.balance', compact('report'))->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Could not render reports.partials.balance: %s', $e->getMessage()));
$result = 'Could not render view.';
}
diff --git a/app/Http/Controllers/Report/BillController.php b/app/Http/Controllers/Report/BillController.php
index 4f92954c24..0c14c605ac 100644
--- a/app/Http/Controllers/Report/BillController.php
+++ b/app/Http/Controllers/Report/BillController.php
@@ -49,19 +49,19 @@ class BillController extends Controller
$cache->addProperty('bill-report');
$cache->addProperty($accounts->pluck('id')->toArray());
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
/** @var ReportHelperInterface $helper */
$helper = app(ReportHelperInterface::class);
$report = $helper->getBillReport($accounts, $start, $end);
try {
$result = prefixView('reports.partials.bills', compact('report'))->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Could not render reports.partials.budgets: %s', $e->getMessage()));
$result = 'Could not render view.';
}
- // @codeCoverageIgnoreEnd
+
$cache->store($result);
return $result;
diff --git a/app/Http/Controllers/Report/BudgetController.php b/app/Http/Controllers/Report/BudgetController.php
index d455ba5e3d..31efb8aee7 100644
--- a/app/Http/Controllers/Report/BudgetController.php
+++ b/app/Http/Controllers/Report/BudgetController.php
@@ -197,8 +197,8 @@ class BudgetController extends Controller
try {
$result = prefixView('reports.budget.partials.avg-expenses', compact('result'))->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
$result = sprintf('Could not render view: %s', $e->getMessage());
}
@@ -316,7 +316,7 @@ class BudgetController extends Controller
$cache->addProperty('budget-period-report');
$cache->addProperty($accounts->pluck('id')->toArray());
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
$periods = app('navigation')->listOfPeriods($start, $end);
@@ -352,12 +352,12 @@ class BudgetController extends Controller
}
try {
$result = prefixView('reports.partials.budget-period', compact('report', 'periods'))->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
$result = 'Could not render view.';
}
- // @codeCoverageIgnoreEnd
+
$cache->store($result);
return $result;
@@ -404,8 +404,8 @@ class BudgetController extends Controller
try {
$result = prefixView('reports.budget.partials.top-expenses', compact('result'))->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
$result = sprintf('Could not render view: %s', $e->getMessage());
}
diff --git a/app/Http/Controllers/Report/CategoryController.php b/app/Http/Controllers/Report/CategoryController.php
index 15561046e8..9ea883acbc 100644
--- a/app/Http/Controllers/Report/CategoryController.php
+++ b/app/Http/Controllers/Report/CategoryController.php
@@ -311,8 +311,8 @@ class CategoryController extends Controller
try {
$result = prefixView('reports.category.partials.avg-expenses', compact('result'))->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
$result = sprintf('Could not render view: %s', $e->getMessage());
}
@@ -363,8 +363,8 @@ class CategoryController extends Controller
try {
$result = prefixView('reports.category.partials.avg-income', compact('result'))->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
$result = sprintf('Could not render view: %s', $e->getMessage());
}
@@ -497,7 +497,7 @@ class CategoryController extends Controller
$cache->addProperty('category-period-expenses-report');
$cache->addProperty($accounts->pluck('id')->toArray());
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
// depending on the carbon format (a reliable way to determine the general date difference)
@@ -547,12 +547,12 @@ class CategoryController extends Controller
try {
$result = prefixView('reports.partials.category-period', compact('report', 'periods'))->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::error(sprintf('Could not render category::expenses: %s', $e->getMessage()));
$result = sprintf('An error prevented Firefly III from rendering: %s. Apologies.', $e->getMessage());
}
- // @codeCoverageIgnoreEnd
+
$cache->store($result);
@@ -577,7 +577,7 @@ class CategoryController extends Controller
$cache->addProperty('category-period-income-report');
$cache->addProperty($accounts->pluck('id')->toArray());
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
// depending on the carbon format (a reliable way to determine the general date difference)
@@ -626,12 +626,12 @@ class CategoryController extends Controller
try {
$result = prefixView('reports.partials.category-period', compact('report', 'periods'))->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::error(sprintf('Could not render category::expenses: %s', $e->getMessage()));
$result = sprintf('An error prevented Firefly III from rendering: %s. Apologies.', $e->getMessage());
}
- // @codeCoverageIgnoreEnd
+
$cache->store($result);
@@ -657,7 +657,7 @@ class CategoryController extends Controller
$cache->addProperty('category-report');
$cache->addProperty($accounts->pluck('id')->toArray());
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
/** @var CategoryReportGenerator $generator */
@@ -668,16 +668,16 @@ class CategoryController extends Controller
$generator->operations();
$report = $generator->getReport();
- // @codeCoverageIgnoreStart
+
try {
$result = prefixView('reports.partials.categories', compact('report'))->render();
$cache->store($result);
- } catch (Throwable $e) {
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::error(sprintf('Could not render category::expenses: %s', $e->getMessage()));
$result = sprintf('An error prevented Firefly III from rendering: %s. Apologies.', $e->getMessage());
}
- // @codeCoverageIgnoreEnd
+
return $result;
}
@@ -723,8 +723,8 @@ class CategoryController extends Controller
try {
$result = prefixView('reports.category.partials.top-expenses', compact('result'))->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
$result = sprintf('Could not render view: %s', $e->getMessage());
}
@@ -773,8 +773,8 @@ class CategoryController extends Controller
try {
$result = prefixView('reports.category.partials.top-income', compact('result'))->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
$result = sprintf('Could not render view: %s', $e->getMessage());
}
diff --git a/app/Http/Controllers/Report/DoubleController.php b/app/Http/Controllers/Report/DoubleController.php
index 0cd1bf0bc5..4436c6f3a6 100644
--- a/app/Http/Controllers/Report/DoubleController.php
+++ b/app/Http/Controllers/Report/DoubleController.php
@@ -111,8 +111,8 @@ class DoubleController extends Controller
try {
$result = prefixView('reports.double.partials.avg-expenses', compact('result'))->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
$result = sprintf('Could not render view: %s', $e->getMessage());
}
@@ -163,8 +163,8 @@ class DoubleController extends Controller
try {
$result = prefixView('reports.double.partials.avg-income', compact('result'))->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
$result = sprintf('Could not render view: %s', $e->getMessage());
}
@@ -457,8 +457,8 @@ class DoubleController extends Controller
try {
$result = prefixView('reports.double.partials.top-expenses', compact('result'))->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
$result = sprintf('Could not render view: %s', $e->getMessage());
}
@@ -507,8 +507,8 @@ class DoubleController extends Controller
try {
$result = prefixView('reports.double.partials.top-income', compact('result'))->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
$result = sprintf('Could not render view: %s', $e->getMessage());
}
diff --git a/app/Http/Controllers/Report/OperationsController.php b/app/Http/Controllers/Report/OperationsController.php
index 0dc06329eb..2863f049df 100644
--- a/app/Http/Controllers/Report/OperationsController.php
+++ b/app/Http/Controllers/Report/OperationsController.php
@@ -76,18 +76,18 @@ class OperationsController extends Controller
$cache->addProperty('expense-report');
$cache->addProperty($accounts->pluck('id')->toArray());
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
$report = $this->tasker->getExpenseReport($start, $end, $accounts);
$type = 'expense-entry';
try {
$result = prefixView('reports.partials.income-expenses', compact('report', 'type'))->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Could not render reports.partials.income-expense: %s', $e->getMessage()));
$result = 'Could not render view.';
}
- // @codeCoverageIgnoreEnd
+
$cache->store($result);
return $result;
@@ -111,18 +111,18 @@ class OperationsController extends Controller
$cache->addProperty('income-report');
$cache->addProperty($accounts->pluck('id')->toArray());
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
$report = $this->tasker->getIncomeReport($start, $end, $accounts);
$type = 'income-entry';
try {
$result = prefixView('reports.partials.income-expenses', compact('report', 'type'))->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Could not render reports.partials.income-expenses: %s', $e->getMessage()));
$result = 'Could not render view.';
}
- // @codeCoverageIgnoreEnd
+
$cache->store($result);
return $result;
@@ -146,7 +146,7 @@ class OperationsController extends Controller
$cache->addProperty('inc-exp-report');
$cache->addProperty($accounts->pluck('id')->toArray());
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
$incomes = $this->tasker->getIncomeReport($start, $end, $accounts);
@@ -172,7 +172,7 @@ class OperationsController extends Controller
try {
$result = prefixView('reports.partials.operations', compact('sums'))->render();
- } catch (Throwable $e) {
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Could not render reports.partials.operations: %s', $e->getMessage()));
$result = 'Could not render view.';
}
diff --git a/app/Http/Controllers/Report/TagController.php b/app/Http/Controllers/Report/TagController.php
index 48a506d581..d5c980ad91 100644
--- a/app/Http/Controllers/Report/TagController.php
+++ b/app/Http/Controllers/Report/TagController.php
@@ -305,8 +305,8 @@ class TagController extends Controller
try {
$result = prefixView('reports.tag.partials.avg-expenses', compact('result'))->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
$result = sprintf('Could not render view: %s', $e->getMessage());
}
@@ -357,8 +357,8 @@ class TagController extends Controller
try {
$result = prefixView('reports.tag.partials.avg-income', compact('result'))->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
$result = sprintf('Could not render view: %s', $e->getMessage());
}
@@ -515,8 +515,8 @@ class TagController extends Controller
try {
$result = prefixView('reports.tag.partials.top-expenses', compact('result'))->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
$result = sprintf('Could not render view: %s', $e->getMessage());
}
@@ -565,8 +565,8 @@ class TagController extends Controller
try {
$result = prefixView('reports.tag.partials.top-income', compact('result'))->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
$result = sprintf('Could not render view: %s', $e->getMessage());
}
diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php
index d4e5c9f2a7..6fe28b026b 100644
--- a/app/Http/Controllers/ReportController.php
+++ b/app/Http/Controllers/ReportController.php
@@ -88,7 +88,7 @@ class ReportController extends Controller
public function auditReport(Collection $accounts, Carbon $start, Carbon $end)
{
if ($end < $start) {
- return prefixView('error')->with('message', (string)trans('firefly.end_after_start_date')); // @codeCoverageIgnore
+ return prefixView('error')->with('message', (string)trans('firefly.end_after_start_date'));
}
$this->repository->cleanupBudgets();
@@ -124,7 +124,7 @@ class ReportController extends Controller
public function budgetReport(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end)
{
if ($end < $start) {
- return prefixView('error')->with('message', (string)trans('firefly.end_after_start_date')); // @codeCoverageIgnore
+ return prefixView('error')->with('message', (string)trans('firefly.end_after_start_date'));
}
$this->repository->cleanupBudgets();
@@ -161,7 +161,7 @@ class ReportController extends Controller
public function categoryReport(Collection $accounts, Collection $categories, Carbon $start, Carbon $end)
{
if ($end < $start) {
- return prefixView('error')->with('message', (string)trans('firefly.end_after_start_date')); // @codeCoverageIgnore
+ return prefixView('error')->with('message', (string)trans('firefly.end_after_start_date'));
}
$this->repository->cleanupBudgets();
@@ -421,7 +421,7 @@ class ReportController extends Controller
public function tagReport(Collection $accounts, Collection $tags, Carbon $start, Carbon $end)
{
if ($end < $start) {
- return prefixView('error')->with('message', (string)trans('firefly.end_after_start_date')); // @codeCoverageIgnore
+ return prefixView('error')->with('message', (string)trans('firefly.end_after_start_date'));
}
$this->repository->cleanupBudgets();
diff --git a/app/Http/Controllers/Rule/CreateController.php b/app/Http/Controllers/Rule/CreateController.php
index d993936df4..4c3106d773 100644
--- a/app/Http/Controllers/Rule/CreateController.php
+++ b/app/Http/Controllers/Rule/CreateController.php
@@ -267,21 +267,21 @@ class CreateController extends Controller
// redirect to show bill.
if ('true' === $request->get('return_to_bill') && (int)$request->get('bill_id') > 0) {
- return redirect(route('bills.show', [(int)$request->get('bill_id')])); // @codeCoverageIgnore
+ return redirect(route('bills.show', [(int)$request->get('bill_id')]));
}
// redirect to new bill creation.
if ((int)$request->get('bill_id') > 0) {
- return redirect($this->getPreviousUri('bills.create.uri')); // @codeCoverageIgnore
+ return redirect($this->getPreviousUri('bills.create.uri'));
}
$redirect = redirect($this->getPreviousUri('rules.create.uri'));
if (1 === (int)$request->get('create_another')) {
- // @codeCoverageIgnoreStart
+
session()->put('rules.create.fromStore', true);
$redirect = redirect(route('rules.create', [$data['rule_group_id']]))->withInput();
- // @codeCoverageIgnoreEnd
+
}
return $redirect;
diff --git a/app/Http/Controllers/Rule/EditController.php b/app/Http/Controllers/Rule/EditController.php
index 8dcec9c785..9ba0f7fd6f 100644
--- a/app/Http/Controllers/Rule/EditController.php
+++ b/app/Http/Controllers/Rule/EditController.php
@@ -168,7 +168,7 @@ class EditController extends Controller
'triggers' => $triggers,
]
)->render();
- } catch (Throwable $e) {
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Throwable was thrown in getPreviousTriggers(): %s', $e->getMessage()));
Log::error($e->getTraceAsString());
}
@@ -195,11 +195,11 @@ class EditController extends Controller
app('preferences')->mark();
$redirect = redirect($this->getPreviousUri('rules.edit.uri'));
if (1 === (int)$request->get('return_to_edit')) {
- // @codeCoverageIgnoreStart
+
session()->put('rules.edit.fromUpdate', true);
$redirect = redirect(route('rules.edit', [$rule->id]))->withInput(['return_to_edit' => 1]);
- // @codeCoverageIgnoreEnd
+
}
return $redirect;
diff --git a/app/Http/Controllers/Rule/SelectController.php b/app/Http/Controllers/Rule/SelectController.php
index 4872b52db7..0df6c605e9 100644
--- a/app/Http/Controllers/Rule/SelectController.php
+++ b/app/Http/Controllers/Rule/SelectController.php
@@ -145,7 +145,7 @@ class SelectController extends Controller
// warn if nothing.
if (0 === count($textTriggers)) {
- return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]); // @codeCoverageIgnore
+ return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]);
}
foreach ($textTriggers as $textTrigger) {
@@ -168,21 +168,21 @@ class SelectController extends Controller
// Warn the user if only a subset of transactions is returned
$warning = '';
if (0 === count($collection)) {
- $warning = (string)trans('firefly.warning_no_matching_transactions'); // @codeCoverageIgnore
+ $warning = (string)trans('firefly.warning_no_matching_transactions');
}
// Return json response
$view = 'ERROR, see logs.';
try {
$view = prefixView('list.journals-array-tiny', ['groups' => $collection])->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $exception) {
+
+ } catch (Throwable $exception) { // @phpstan-ignore-line
Log::error(sprintf('Could not render view in testTriggers(): %s', $exception->getMessage()));
Log::error($exception->getTraceAsString());
$view = sprintf('Could not render list.journals-tiny: %s', $exception->getMessage());
}
- // @codeCoverageIgnoreEnd
+
return response()->json(['html' => $view, 'warning' => $warning]);
}
@@ -201,7 +201,7 @@ class SelectController extends Controller
$triggers = $rule->ruleTriggers;
if (0 === count($triggers)) {
- return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]); // @codeCoverageIgnore
+ return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]);
}
// create new rule engine:
$newRuleEngine = app(RuleEngineInterface::class);
@@ -213,20 +213,20 @@ class SelectController extends Controller
$warning = '';
if (0 === count($collection)) {
- $warning = (string)trans('firefly.warning_no_matching_transactions'); // @codeCoverageIgnore
+ $warning = (string)trans('firefly.warning_no_matching_transactions');
}
// Return json response
$view = 'ERROR, see logs.';
try {
$view = prefixView('list.journals-array-tiny', ['groups' => $collection])->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $exception) {
+
+ } catch (Throwable $exception) { // @phpstan-ignore-line
Log::error(sprintf('Could not render view in testTriggersByRule(): %s', $exception->getMessage()));
Log::error($exception->getTraceAsString());
}
- // @codeCoverageIgnoreEnd
+
return response()->json(['html' => $view, 'warning' => $warning]);
}
diff --git a/app/Http/Controllers/RuleGroup/CreateController.php b/app/Http/Controllers/RuleGroup/CreateController.php
index 9c4456544e..bf901a11e4 100644
--- a/app/Http/Controllers/RuleGroup/CreateController.php
+++ b/app/Http/Controllers/RuleGroup/CreateController.php
@@ -96,11 +96,11 @@ class CreateController extends Controller
$redirect = redirect($this->getPreviousUri('rule-groups.create.uri'));
if (1 === (int)$request->get('create_another')) {
- // @codeCoverageIgnoreStart
+
session()->put('rule-groups.create.fromStore', true);
$redirect = redirect(route('rule-groups.create'))->withInput();
- // @codeCoverageIgnoreEnd
+
}
return $redirect;
diff --git a/app/Http/Controllers/RuleGroup/EditController.php b/app/Http/Controllers/RuleGroup/EditController.php
index 57157f8a96..0a962da6ee 100644
--- a/app/Http/Controllers/RuleGroup/EditController.php
+++ b/app/Http/Controllers/RuleGroup/EditController.php
@@ -147,11 +147,11 @@ class EditController extends Controller
app('preferences')->mark();
$redirect = redirect($this->getPreviousUri('rule-groups.edit.uri'));
if (1 === (int)$request->get('return_to_edit')) {
- // @codeCoverageIgnoreStart
+
session()->put('rule-groups.edit.fromUpdate', true);
$redirect = redirect(route('rule-groups.edit', [$ruleGroup->id]))->withInput(['return_to_edit' => 1]);
- // @codeCoverageIgnoreEnd
+
}
// redirect to previous URL.
diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php
index aa55db88ba..7cc816ed54 100644
--- a/app/Http/Controllers/SearchController.php
+++ b/app/Http/Controllers/SearchController.php
@@ -116,13 +116,13 @@ class SearchController extends Controller
try {
$html = prefixView('search.search', compact('groups', 'hasPages', 'searchTime'))->render();
- // @codeCoverageIgnoreStart
- } catch (Throwable $e) {
+
+ } catch (Throwable $e) { // @phpstan-ignore-line
Log::error(sprintf('Cannot render search.search: %s', $e->getMessage()));
$html = 'Could not render view.';
}
- // @codeCoverageIgnoreEnd
+
return response()->json(['count' => $groups->count(), 'html' => $html]);
}
diff --git a/app/Http/Controllers/System/InstallController.php b/app/Http/Controllers/System/InstallController.php
index 4f4242c9db..931c0a3725 100644
--- a/app/Http/Controllers/System/InstallController.php
+++ b/app/Http/Controllers/System/InstallController.php
@@ -193,7 +193,7 @@ class InstallController extends Controller
Artisan::call($command, $args);
Log::debug(Artisan::output());
}
- } catch (Exception $e) {
+ } catch (Exception $e) { // @phpstan-ignore-line
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
if (strpos($e->getMessage(), 'open_basedir restriction in effect')) {
diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php
index 5f32e14a81..e28c06a657 100644
--- a/app/Http/Controllers/TagController.php
+++ b/app/Http/Controllers/TagController.php
@@ -327,15 +327,15 @@ class TagController extends Controller
}
if (count($this->attachmentsHelper->getMessages()->get('attachments')) > 0) {
- $request->session()->flash('info', $this->attachmentsHelper->getMessages()->get('attachments')); // @codeCoverageIgnore
+ $request->session()->flash('info', $this->attachmentsHelper->getMessages()->get('attachments'));
}
$redirect = redirect($this->getPreviousUri('tags.create.uri'));
if (1 === (int)$request->get('create_another')) {
- // @codeCoverageIgnoreStart
+
session()->put('tags.create.fromStore', true);
$redirect = redirect(route('tags.create'))->withInput();
- // @codeCoverageIgnoreEnd
+
}
return $redirect;
@@ -368,15 +368,15 @@ class TagController extends Controller
}
if (count($this->attachmentsHelper->getMessages()->get('attachments')) > 0) {
- $request->session()->flash('info', $this->attachmentsHelper->getMessages()->get('attachments')); // @codeCoverageIgnore
+ $request->session()->flash('info', $this->attachmentsHelper->getMessages()->get('attachments'));
}
$redirect = redirect($this->getPreviousUri('tags.edit.uri'));
if (1 === (int)$request->get('return_to_edit')) {
- // @codeCoverageIgnoreStart
+
session()->put('tags.edit.fromUpdate', true);
$redirect = redirect(route('tags.edit', [$tag->id]))->withInput(['return_to_edit' => 1]);
- // @codeCoverageIgnoreEnd
+
}
// redirect to previous URL.
diff --git a/app/Http/Controllers/Transaction/ConvertController.php b/app/Http/Controllers/Transaction/ConvertController.php
index 4c513d5c4b..8e62d6c105 100644
--- a/app/Http/Controllers/Transaction/ConvertController.php
+++ b/app/Http/Controllers/Transaction/ConvertController.php
@@ -91,7 +91,7 @@ class ConvertController extends Controller
public function index(TransactionType $destinationType, TransactionGroup $group)
{
if (!$this->isEditableGroup($group)) {
- return $this->redirectGroupToAccount($group); // @codeCoverageIgnore
+ return $this->redirectGroupToAccount($group);
}
/** @var TransactionGroupTransformer $transformer */
@@ -159,21 +159,21 @@ class ConvertController extends Controller
$role = (string)$this->accountRepository->getMetaValue($account, 'account_role');
$name = $account->name;
if ('' === $role) {
- $role = 'no_account_type'; // @codeCoverageIgnore
+ $role = 'no_account_type';
}
// maybe it's a liability thing:
if (in_array($account->accountType->type, $liabilityTypes, true)) {
- $role = 'l_' . $account->accountType->type; // @codeCoverageIgnore
+ $role = 'l_' . $account->accountType->type;
}
if (AccountType::CASH === $account->accountType->type) {
- // @codeCoverageIgnoreStart
+
$role = 'cash_account';
$name = sprintf('(%s)', trans('firefly.cash'));
- // @codeCoverageIgnoreEnd
+
}
if (AccountType::REVENUE === $account->accountType->type) {
- $role = 'revenue_account'; // @codeCoverageIgnore
+ $role = 'revenue_account';
}
$key = (string)trans('firefly.opt_group_' . $role);
@@ -200,21 +200,21 @@ class ConvertController extends Controller
$role = (string)$this->accountRepository->getMetaValue($account, 'account_role');
$name = $account->name;
if ('' === $role) {
- $role = 'no_account_type'; // @codeCoverageIgnore
+ $role = 'no_account_type';
}
// maybe it's a liability thing:
if (in_array($account->accountType->type, $liabilityTypes, true)) {
- $role = 'l_' . $account->accountType->type; // @codeCoverageIgnore
+ $role = 'l_' . $account->accountType->type;
}
if (AccountType::CASH === $account->accountType->type) {
- // @codeCoverageIgnoreStart
+
$role = 'cash_account';
$name = sprintf('(%s)', trans('firefly.cash'));
- // @codeCoverageIgnoreEnd
+
}
if (AccountType::EXPENSE === $account->accountType->type) {
- $role = 'expense_account'; // @codeCoverageIgnore
+ $role = 'expense_account';
}
$key = (string)trans('firefly.opt_group_' . $role);
@@ -264,7 +264,7 @@ class ConvertController extends Controller
$currency = $this->accountRepository->getAccountCurrency($account) ?? $defaultCurrency;
$role = (string)$this->accountRepository->getMetaValue($account, 'account_role');
if ('' === $role) {
- $role = 'no_account_type'; // @codeCoverageIgnore
+ $role = 'no_account_type';
}
$key = (string)trans('firefly.opt_group_' . $role);
@@ -288,7 +288,7 @@ class ConvertController extends Controller
public function postIndex(Request $request, TransactionType $destinationType, TransactionGroup $group)
{
if (!$this->isEditableGroup($group)) {
- return $this->redirectGroupToAccount($group); // @codeCoverageIgnore
+ return $this->redirectGroupToAccount($group);
}
/** @var TransactionJournal $journal */
diff --git a/app/Http/Controllers/Transaction/DeleteController.php b/app/Http/Controllers/Transaction/DeleteController.php
index 348c2bf266..0695367159 100644
--- a/app/Http/Controllers/Transaction/DeleteController.php
+++ b/app/Http/Controllers/Transaction/DeleteController.php
@@ -72,7 +72,7 @@ class DeleteController extends Controller
public function delete(TransactionGroup $group)
{
if (!$this->isEditableGroup($group)) {
- return $this->redirectGroupToAccount($group); // @codeCoverageIgnore
+ return $this->redirectGroupToAccount($group);
}
Log::debug(sprintf('Start of delete view for group #%d', $group->id));
@@ -101,7 +101,7 @@ class DeleteController extends Controller
public function destroy(TransactionGroup $group): RedirectResponse
{
if (!$this->isEditableGroup($group)) {
- return $this->redirectGroupToAccount($group); // @codeCoverageIgnore
+ return $this->redirectGroupToAccount($group);
}
$journal = $group->transactionJournals->first();
diff --git a/app/Http/Controllers/Transaction/EditController.php b/app/Http/Controllers/Transaction/EditController.php
index 8b54d047e1..ff9f2a9c37 100644
--- a/app/Http/Controllers/Transaction/EditController.php
+++ b/app/Http/Controllers/Transaction/EditController.php
@@ -67,7 +67,7 @@ class EditController extends Controller
app('preferences')->mark();
if (!$this->isEditableGroup($transactionGroup)) {
- return $this->redirectGroupToAccount($transactionGroup); // @codeCoverageIgnore
+ return $this->redirectGroupToAccount($transactionGroup);
}
/** @var AccountRepositoryInterface $repository */
diff --git a/app/Http/Controllers/Transaction/MassController.php b/app/Http/Controllers/Transaction/MassController.php
index b3a3bb7c28..7a2ade3c32 100644
--- a/app/Http/Controllers/Transaction/MassController.php
+++ b/app/Http/Controllers/Transaction/MassController.php
@@ -168,7 +168,7 @@ class MassController extends Controller
$journalIds = $request->get('journals');
if (!is_array($journalIds)) {
// TODO something error.
- throw new FireflyException('This is not an array.'); // @codeCoverageIgnore
+ throw new FireflyException('This is not an array.');
}
$count = 0;
/** @var string $journalId */
@@ -177,8 +177,8 @@ class MassController extends Controller
try {
$this->updateJournal($integer, $request);
$count++;
- } catch (FireflyException $e) { // @codeCoverageIgnore
- // do something with error.
+ } catch (FireflyException $e) {
+ // @ignoreException
}
}
@@ -199,7 +199,7 @@ class MassController extends Controller
{
$journal = $this->repository->findNull($journalId);
if (null === $journal) {
- throw new FireflyException(sprintf('Trying to edit non-existent or deleted journal #%d', $journalId)); // @codeCoverageIgnore
+ throw new FireflyException(sprintf('Trying to edit non-existent or deleted journal #%d', $journalId));
}
$service = app(JournalUpdateService::class);
// for each field, call the update service.
@@ -240,7 +240,7 @@ class MassController extends Controller
if (!is_array($value)) {
return null;
}
- if (!isset($value[$journalId])) {
+ if (!array_key_exists($journalId, $value)) {
return null;
}
try {
@@ -268,7 +268,7 @@ class MassController extends Controller
if (!is_array($value)) {
return null;
}
- if (!isset($value[$journalId])) {
+ if (!array_key_exists($journalId, $value)) {
return null;
}
@@ -289,7 +289,7 @@ class MassController extends Controller
if (!is_array($value)) {
return null;
}
- if (!isset($value[$journalId])) {
+ if (!array_key_exists($journalId, $value)) {
return null;
}
diff --git a/app/Http/Controllers/Transaction/ShowController.php b/app/Http/Controllers/Transaction/ShowController.php
index 1b5e3901cf..e6deb0e5c7 100644
--- a/app/Http/Controllers/Transaction/ShowController.php
+++ b/app/Http/Controllers/Transaction/ShowController.php
@@ -137,7 +137,7 @@ class ShowController extends Controller
$amounts = [];
foreach ($group['transactions'] as $transaction) {
$symbol = $transaction['currency_symbol'];
- if (!isset($amounts[$symbol])) {
+ if (!array_key_exists($symbol, $amounts)) {
$amounts[$symbol] = [
'amount' => '0',
'symbol' => $symbol,
@@ -148,7 +148,7 @@ class ShowController extends Controller
if (null !== $transaction['foreign_amount']) {
// same for foreign currency:
$foreignSymbol = $transaction['foreign_currency_symbol'];
- if (!isset($amounts[$foreignSymbol])) {
+ if (!array_key_exists($foreignSymbol, $amounts)) {
$amounts[$foreignSymbol] = [
'amount' => '0',
'symbol' => $foreignSymbol,
diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php
index bfc785315f..cac8a6a2b4 100644
--- a/app/Http/Middleware/Authenticate.php
+++ b/app/Http/Middleware/Authenticate.php
@@ -87,7 +87,7 @@ class Authenticate
protected function authenticate($request, array $guards)
{
- if (empty($guards)) {
+ if (0 === count($guards)) {
try {
// go for default guard:
/** @noinspection PhpUndefinedMethodInspection */
@@ -109,21 +109,21 @@ class Authenticate
}
}
} catch (QueryException $e) {
- // @codeCoverageIgnoreStart
+
throw new FireflyException(
sprintf(
'It seems the database has not yet been initialized. Did you run the correct upgrade or installation commands? Error: %s',
$e->getMessage()
- )
+ ), 0, $e
);
- // @codeCoverageIgnoreEnd
+
}
/** @noinspection PhpUndefinedMethodInspection */
return $this->auth->authenticate();
}
- // @codeCoverageIgnoreStart
+
foreach ($guards as $guard) {
if ($this->auth->guard($guard)->check()) {
/** @noinspection PhpVoidFunctionResultUsedInspection */
@@ -132,6 +132,6 @@ class Authenticate
}
throw new AuthenticationException('Unauthenticated.', $guards);
- // @codeCoverageIgnoreEnd
+
}
}
diff --git a/app/Http/Middleware/Binder.php b/app/Http/Middleware/Binder.php
index 3785604353..70ca7259d1 100644
--- a/app/Http/Middleware/Binder.php
+++ b/app/Http/Middleware/Binder.php
@@ -57,7 +57,6 @@ class Binder
$this->auth = $auth;
}
- /** @noinspection PhpUnusedParameterInspection */
/**
* Handle an incoming request.
*
@@ -70,7 +69,7 @@ class Binder
public function handle($request, Closure $next)
{
foreach ($request->route()->parameters() as $key => $value) {
- if (isset($this->binders[$key])) {
+ if (array_key_exists($key, $this->binders)) {
$boundObject = $this->performBinding($key, $value, $request->route());
$request->route()->setParameter($key, $boundObject);
}
diff --git a/app/Http/Middleware/Installer.php b/app/Http/Middleware/Installer.php
index cb728680f9..465b5f51fb 100644
--- a/app/Http/Middleware/Installer.php
+++ b/app/Http/Middleware/Installer.php
@@ -95,7 +95,9 @@ class Installer
$message = $e->getMessage();
Log::error(sprintf('Error message trying to access users-table: %s', $message));
if ($this->isAccessDenied($message)) {
- throw new FireflyException('It seems your database configuration is not correct. Please verify the username and password in your .env file.');
+ throw new FireflyException(
+ 'It seems your database configuration is not correct. Please verify the username and password in your .env file.', 0, $e
+ );
}
if ($this->noTablesExist($message)) {
// redirect to UpdateController
@@ -103,7 +105,7 @@ class Installer
return true;
}
- throw new FireflyException(sprintf('Could not access the database: %s', $message));
+ throw new FireflyException(sprintf('Could not access the database: %s', $message), 0, $e);
}
Log::debug('Everything seems OK with the tables.');
diff --git a/app/Http/Middleware/IsDemoUser.php b/app/Http/Middleware/IsDemoUser.php
index 1ee13d555b..04e5457db0 100644
--- a/app/Http/Middleware/IsDemoUser.php
+++ b/app/Http/Middleware/IsDemoUser.php
@@ -60,7 +60,7 @@ class IsDemoUser
return response()->redirectTo($previous);
}
- return response()->redirectTo(route('index')); // @codeCoverageIgnore
+ return response()->redirectTo(route('index'));
}
return $next($request);
diff --git a/app/Http/Middleware/Range.php b/app/Http/Middleware/Range.php
index a58d45405c..3afa83902a 100644
--- a/app/Http/Middleware/Range.php
+++ b/app/Http/Middleware/Range.php
@@ -109,7 +109,7 @@ class Range
// send error to view if could not set money format
if (false === $moneyResult) {
Log::error('Could not set locale. The following array doesnt work: ', $localeArray);
- app('view')->share('invalidMonetaryLocale', true); // @codeCoverageIgnore
+ app('view')->share('invalidMonetaryLocale', true);
}
// save some formats:
diff --git a/app/Http/Requests/ReconciliationStoreRequest.php b/app/Http/Requests/ReconciliationStoreRequest.php
index d76a6b85d9..ad5bdd5f65 100644
--- a/app/Http/Requests/ReconciliationStoreRequest.php
+++ b/app/Http/Requests/ReconciliationStoreRequest.php
@@ -45,7 +45,7 @@ class ReconciliationStoreRequest extends FormRequest
{
$transactions = $this->get('journals');
if (!is_array($transactions)) {
- $transactions = []; // @codeCoverageIgnore
+ $transactions = [];
}
$data = [
'start' => $this->date('start'),
diff --git a/app/Http/Requests/RecurrenceFormRequest.php b/app/Http/Requests/RecurrenceFormRequest.php
index 83e385b51b..a7026eb65b 100644
--- a/app/Http/Requests/RecurrenceFormRequest.php
+++ b/app/Http/Requests/RecurrenceFormRequest.php
@@ -109,7 +109,7 @@ class RecurrenceFormRequest extends FormRequest
// fill in source and destination account data
switch ($this->string('transaction_type')) {
default:
- throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->string('transaction_type'))); // @codeCoverageIgnore
+ throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->string('transaction_type')));
case 'withdrawal':
$return['transactions'][0]['source_id'] = $this->integer('source_id');
$return['transactions'][0]['destination_id'] = $this->integer('withdrawal_destination_id');
@@ -251,7 +251,7 @@ class RecurrenceFormRequest extends FormRequest
break;
default:
- throw new FireflyException(sprintf('Cannot handle transaction type of type "%s"', $this->string('transaction_type'))); // @codeCoverageIgnore
+ throw new FireflyException(sprintf('Cannot handle transaction type of type "%s"', $this->string('transaction_type')));
}
// update some rules in case the user is editing a post:
@@ -308,7 +308,7 @@ class RecurrenceFormRequest extends FormRequest
switch ($this->string('transaction_type')) {
default:
- throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->string('transaction_type'))); // @codeCoverageIgnore
+ throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->string('transaction_type')));
case 'withdrawal':
$sourceId = (int)$data['source_id'];
$destinationId = (int)$data['withdrawal_destination_id'];
diff --git a/app/Http/Requests/ReportFormRequest.php b/app/Http/Requests/ReportFormRequest.php
index b2e24bfc37..212fa59ad7 100644
--- a/app/Http/Requests/ReportFormRequest.php
+++ b/app/Http/Requests/ReportFormRequest.php
@@ -149,12 +149,12 @@ class ReportFormRequest extends FormRequest
if (2 === count($parts)) {
try {
$date = new Carbon($parts[1]);
- // @codeCoverageIgnoreStart
+
} catch (Exception $e) {
$error = sprintf('"%s" is not a valid date range: %s', $range, $e->getMessage());
Log::error($error);
- throw new FireflyException($error);
- // @codeCoverageIgnoreEnd
+ throw new FireflyException($error, 0, $e);
+
}
}
@@ -177,12 +177,12 @@ class ReportFormRequest extends FormRequest
if (2 === count($parts)) {
try {
$date = new Carbon($parts[0]);
- // @codeCoverageIgnoreStart
+
} catch (Exception $e) {
$error = sprintf('"%s" is not a valid date range: %s', $range, $e->getMessage());
Log::error($error);
- throw new FireflyException($error);
- // @codeCoverageIgnoreEnd
+ throw new FireflyException($error, 0, $e);
+
}
}
diff --git a/app/Jobs/CreateRecurringTransactions.php b/app/Jobs/CreateRecurringTransactions.php
index 37e5471b77..cdfe37b62f 100644
--- a/app/Jobs/CreateRecurringTransactions.php
+++ b/app/Jobs/CreateRecurringTransactions.php
@@ -106,7 +106,7 @@ class CreateRecurringTransactions implements ShouldQueue
Log::debug(sprintf('Left after filtering is %d', $filtered->count()));
/** @var Recurrence $recurrence */
foreach ($filtered as $recurrence) {
- if (!isset($result[$recurrence->user_id])) {
+ if (!array_key_exists($recurrence->user_id, $result)) {
$result[$recurrence->user_id] = new Collection;
}
$this->repository->setUser($recurrence->user);
@@ -373,10 +373,10 @@ class CreateRecurringTransactions implements ShouldQueue
$groupTitle = null;
if ($recurrence->recurrenceTransactions->count() > 1) {
/** @var RecurrenceTransaction $first */
- // @codeCoverageIgnoreStart
+
$first = $recurrence->recurrenceTransactions()->first();
$groupTitle = $first->description;
- // @codeCoverageIgnoreEnd
+
}
$array = [
diff --git a/app/Jobs/MailError.php b/app/Jobs/MailError.php
index f58c737dcb..1ecce5dba6 100644
--- a/app/Jobs/MailError.php
+++ b/app/Jobs/MailError.php
@@ -39,14 +39,10 @@ class MailError extends Job implements ShouldQueue
{
use InteractsWithQueue, SerializesModels;
- /** @var string Destination */
- protected $destination;
- /** @var array Exception information */
- protected $exception;
- /** @var string IP address */
- protected $ipAddress;
- /** @var array User information */
- protected $userData;
+ protected string $destination;
+ protected array $exception;
+ protected string $ipAddress;
+ protected array $userData;
/**
* MailError constructor.
@@ -89,7 +85,7 @@ class MailError extends Job implements ShouldQueue
}
}
);
- } catch (Exception $e) {
+ } catch (Exception $e) { // @phpstan-ignore-line
Log::error('Exception when mailing: ' . $e->getMessage());
}
}
diff --git a/app/Jobs/SubmitTelemetryData.php b/app/Jobs/SubmitTelemetryData.php
index 7054d68a17..a30cd6567b 100644
--- a/app/Jobs/SubmitTelemetryData.php
+++ b/app/Jobs/SubmitTelemetryData.php
@@ -46,10 +46,8 @@ class SubmitTelemetryData implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
- /** @var Carbon The current date */
- private $date;
- /** @var bool Force the transaction to be created no matter what. */
- private $force;
+ private Carbon $date;
+ private bool $force;
/**
* Create a new job instance.
@@ -86,7 +84,7 @@ class SubmitTelemetryData implements ShouldQueue
} catch (JsonException $e) {
Log::error($e->getMessage());
Log::error('Could not parse JSON.');
- throw new FireflyException(sprintf('Could not parse telemetry JSON: %s', $e->getMessage()));
+ throw new FireflyException(sprintf('Could not parse telemetry JSON: %s', $e->getMessage()), 0, $e);
}
$client = new Client;
@@ -105,7 +103,7 @@ class SubmitTelemetryData implements ShouldQueue
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
Log::error('Could not submit telemetry.');
- throw new FireflyException(sprintf('Could not submit telemetry: %s', $e->getMessage()));
+ throw new FireflyException(sprintf('Could not submit telemetry: %s', $e->getMessage()), 0, $e);
}
$body = (string)$result->getBody();
$statusCode = $result->getStatusCode();
diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php
index 53c0a39d18..c6aa1de879 100644
--- a/app/Models/TransactionJournal.php
+++ b/app/Models/TransactionJournal.php
@@ -35,54 +35,54 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\SoftDeletes;
-use Illuminate\Support\Collection;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
+
/**
* FireflyIII\Models\TransactionJournal
*
- * @property int $id
- * @property \Carbon\Carbon|null $created_at
- * @property \Carbon\Carbon|null $updated_at
- * @property \Carbon\Carbon|null $deleted_at
- * @property int $user_id
- * @property int $transaction_type_id
- * @property int|null $transaction_group_id
- * @property int|null $bill_id
- * @property int|null $transaction_currency_id
- * @property string $description
- * @property \Carbon\Carbon $date
- * @property \Carbon\Carbon|null $interest_date
- * @property \Carbon\Carbon|null $book_date
- * @property \Carbon\Carbon|null $process_date
- * @property int $order
- * @property int $tag_count
- * @property bool $encrypted
- * @property bool $completed
- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Attachment[] $attachments
- * @property-read int|null $attachments_count
- * @property-read \FireflyIII\Models\Bill|null $bill
- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Budget[] $budgets
- * @property-read int|null $budgets_count
- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Category[] $categories
- * @property-read int|null $categories_count
+ * @property int $id
+ * @property \Carbon\Carbon|null $created_at
+ * @property \Carbon\Carbon|null $updated_at
+ * @property \Carbon\Carbon|null $deleted_at
+ * @property int $user_id
+ * @property int $transaction_type_id
+ * @property int|null $transaction_group_id
+ * @property int|null $bill_id
+ * @property int|null $transaction_currency_id
+ * @property string $description
+ * @property \Carbon\Carbon $date
+ * @property \Carbon\Carbon|null $interest_date
+ * @property \Carbon\Carbon|null $book_date
+ * @property \Carbon\Carbon|null $process_date
+ * @property int $order
+ * @property int $tag_count
+ * @property bool $encrypted
+ * @property bool $completed
+ * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Attachment[] $attachments
+ * @property-read int|null $attachments_count
+ * @property-read \FireflyIII\Models\Bill|null $bill
+ * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Budget[] $budgets
+ * @property-read int|null $budgets_count
+ * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Category[] $categories
+ * @property-read int|null $categories_count
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournalLink[] $destJournalLinks
- * @property-read int|null $dest_journal_links_count
- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Note[] $notes
- * @property-read int|null $notes_count
- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\PiggyBankEvent[] $piggyBankEvents
- * @property-read int|null $piggy_bank_events_count
+ * @property-read int|null $dest_journal_links_count
+ * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Note[] $notes
+ * @property-read int|null $notes_count
+ * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\PiggyBankEvent[] $piggyBankEvents
+ * @property-read int|null $piggy_bank_events_count
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournalLink[] $sourceJournalLinks
- * @property-read int|null $source_journal_links_count
- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Tag[] $tags
- * @property-read int|null $tags_count
- * @property-read \FireflyIII\Models\TransactionCurrency|null $transactionCurrency
- * @property-read \FireflyIII\Models\TransactionGroup|null $transactionGroup
+ * @property-read int|null $source_journal_links_count
+ * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Tag[] $tags
+ * @property-read int|null $tags_count
+ * @property-read \FireflyIII\Models\TransactionCurrency|null $transactionCurrency
+ * @property-read \FireflyIII\Models\TransactionGroup|null $transactionGroup
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournalMeta[] $transactionJournalMeta
- * @property-read int|null $transaction_journal_meta_count
- * @property-read \FireflyIII\Models\TransactionType $transactionType
- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Transaction[] $transactions
- * @property-read int|null $transactions_count
- * @property-read User $user
+ * @property-read int|null $transaction_journal_meta_count
+ * @property-read \FireflyIII\Models\TransactionType $transactionType
+ * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Transaction[] $transactions
+ * @property-read int|null $transactions_count
+ * @property-read User $user
* @method static EloquentBuilder|TransactionJournal after(\Carbon\Carbon $date)
* @method static EloquentBuilder|TransactionJournal before(\Carbon\Carbon $date)
* @method static EloquentBuilder|TransactionJournal newModelQuery()
@@ -111,8 +111,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static \Illuminate\Database\Query\Builder|TransactionJournal withTrashed()
* @method static \Illuminate\Database\Query\Builder|TransactionJournal withoutTrashed()
* @mixin Eloquent
- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Location[] $locations
- * @property-read int|null $locations_count
+ * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Location[] $locations
+ * @property-read int|null $locations_count
*/
class TransactionJournal extends Model
{
@@ -175,14 +175,14 @@ class TransactionJournal extends Model
*
* @param string $value
*
- * @throws NotFoundHttpException
- * @throws FireflyException
* @return TransactionJournal
+ * @throws FireflyException
+ * @throws NotFoundHttpException
*/
public static function routeBinder(string $value): TransactionJournal
{
if (auth()->check()) {
- $journalId = (int) $value;
+ $journalId = (int)$value;
/** @var User $user */
$user = auth()->user();
/** @var TransactionJournal $journal */
@@ -317,7 +317,7 @@ class TransactionJournal extends Model
if (!self::isJoined($query, 'transaction_types')) {
$query->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id');
}
- if (!empty($types)) {
+ if (0 !== count($types)) {
$query->whereIn('transaction_types.type', $types);
}
}
diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php
index 1876d368fc..fcd48ce4c4 100644
--- a/app/Providers/AuthServiceProvider.php
+++ b/app/Providers/AuthServiceProvider.php
@@ -53,7 +53,7 @@ class AuthServiceProvider extends ServiceProvider
{
Auth::provider(
'remote_user_provider', function ($app, array $config) {
- return new RemoteUserProvider($app, $config);
+ return new RemoteUserProvider;
}
);
diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php
index a31b381d4e..34bdfe4209 100644
--- a/app/Providers/EventServiceProvider.php
+++ b/app/Providers/EventServiceProvider.php
@@ -169,8 +169,7 @@ class EventServiceProvider extends ServiceProvider
try {
Log::debug('Trying to send message...');
Mail::to($email)->send(new OAuthTokenCreatedMail($email, $ipAddress, $oauthClient));
- // @codeCoverageIgnoreStart
- } catch (Exception $e) {
+ } catch (Exception $e) { // @phpstan-ignore-line
Log::debug('Send message failed! :(');
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php
index 2720e9afa1..b8e9224a67 100644
--- a/app/Repositories/Account/AccountRepository.php
+++ b/app/Repositories/Account/AccountRepository.php
@@ -125,7 +125,7 @@ class AccountRepository implements AccountRepositoryInterface
{
$query = $this->user->accounts()->where('iban', '!=', '')->whereNotNull('iban');
- if (!empty($types)) {
+ if (0!==count($types)) {
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$query->whereIn('account_types.type', $types);
}
@@ -153,7 +153,7 @@ class AccountRepository implements AccountRepositoryInterface
{
$query = $this->user->accounts();
- if (!empty($types)) {
+ if (0 !== count($types)) {
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$query->whereIn('account_types.type', $types);
}
@@ -223,7 +223,7 @@ class AccountRepository implements AccountRepositoryInterface
/** @var Collection $result */
$query = $this->user->accounts();
- if (!empty($accountIds)) {
+ if (0 !== count($accountIds)) {
$query->whereIn('accounts.id', $accountIds);
}
$query->orderBy('accounts.order', 'ASC');
@@ -242,7 +242,7 @@ class AccountRepository implements AccountRepositoryInterface
{
/** @var Collection $result */
$query = $this->user->accounts();
- if (!empty($types)) {
+ if (0 !== count($types)) {
$query->accountTypeIn($types);
}
$res = array_intersect([AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT], $types);
@@ -269,7 +269,7 @@ class AccountRepository implements AccountRepositoryInterface
$query->where('name', 'account_role');
}, 'attachments']
);
- if (!empty($types)) {
+ if (0 !== count($types)) {
$query->accountTypeIn($types);
}
$query->where('active', 1);
@@ -330,7 +330,7 @@ class AccountRepository implements AccountRepositoryInterface
$query->where('name', 'account_role');
}]
);
- if (!empty($types)) {
+ if (0 !== count($types)) {
$query->accountTypeIn($types);
}
$query->where('active', 0);
@@ -668,7 +668,7 @@ class AccountRepository implements AccountRepositoryInterface
}
}
- if (!empty($types)) {
+ if (0 !== count($types)) {
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$dbQuery->whereIn('account_types.type', $types);
}
@@ -706,7 +706,7 @@ class AccountRepository implements AccountRepositoryInterface
);
}
}
- if (!empty($types)) {
+ if (0 !== count($types)) {
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$dbQuery->whereIn('account_types.type', $types);
}
diff --git a/app/Repositories/Account/AccountTasker.php b/app/Repositories/Account/AccountTasker.php
index 90e606a992..18f45aa92f 100644
--- a/app/Repositories/Account/AccountTasker.php
+++ b/app/Repositories/Account/AccountTasker.php
@@ -268,7 +268,7 @@ class AccountTasker implements AccountTaskerInterface
$sourceId = (int)$journal['source_account_id'];
$currencyId = (int)$journal['currency_id'];
$key = sprintf('%s-%s', $sourceId, $currencyId);
- if (!isset($report['accounts'][$key])) {
+ if (!array_key_exists($key, $report['accounts'])) {
$currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepos->findNull($currencyId);
$report['accounts'][$key] = [
'id' => $sourceId,
diff --git a/app/Repositories/Attachment/AttachmentRepository.php b/app/Repositories/Attachment/AttachmentRepository.php
index 6a51a73345..b7923a4370 100644
--- a/app/Repositories/Attachment/AttachmentRepository.php
+++ b/app/Repositories/Attachment/AttachmentRepository.php
@@ -59,8 +59,8 @@ class AttachmentRepository implements AttachmentRepositoryInterface
$path = $helper->getAttachmentLocation($attachment);
try {
Storage::disk('upload')->delete($path);
- } catch (Exception $e) {
- Log::error(sprintf('Could not delete file for attachment %d: %s', $attachment->id, $e->getMessage()));
+ } catch (Exception $e) { // @phpstan-ignore-line
+ // @ignoreException
}
$attachment->delete();
@@ -209,8 +209,8 @@ class AttachmentRepository implements AttachmentRepositoryInterface
if (null !== $dbNote) {
try {
$dbNote->delete();
- } catch (Exception $e) {
- Log::debug(sprintf('Could not delete note: %s', $e->getMessage()));
+ } catch (Exception $e) { // @phpstan-ignore-line
+ // @ignoreException
}
}
diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php
index fd6b073fb5..4451b501a5 100644
--- a/app/Repositories/Bill/BillRepository.php
+++ b/app/Repositories/Bill/BillRepository.php
@@ -648,7 +648,7 @@ class BillRepository implements BillRepositoryInterface
$cache->addProperty('nextDateMatch');
$cache->addProperty($date);
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
// find the most recent date for this bill NOT in the future. Cache this date:
$start = clone $bill->date;
@@ -682,7 +682,7 @@ class BillRepository implements BillRepositoryInterface
$cache->addProperty('nextExpectedMatch');
$cache->addProperty($date);
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
// find the most recent date for this bill NOT in the future. Cache this date:
$start = clone $bill->date;
diff --git a/app/Repositories/Budget/AvailableBudgetRepository.php b/app/Repositories/Budget/AvailableBudgetRepository.php
index 64854c7c29..f5f40ca3c9 100644
--- a/app/Repositories/Budget/AvailableBudgetRepository.php
+++ b/app/Repositories/Budget/AvailableBudgetRepository.php
@@ -55,8 +55,8 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
{
try {
$availableBudget->delete();
- } catch (Exception $e) {
- Log::error(sprintf('Could not delete available budget: %s', $e->getMessage()));
+ } catch (Exception $e) { // @phpstan-ignore-line
+ // @ignoreException
}
}
@@ -262,7 +262,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
*/
public function update(AvailableBudget $availableBudget, array $data): AvailableBudget
{
- if (isset($data['amount'])) {
+ if (array_key_exists('amount', $data)) {
$availableBudget->amount = $data['amount'];
}
$availableBudget->save();
diff --git a/app/Repositories/Budget/BudgetLimitRepository.php b/app/Repositories/Budget/BudgetLimitRepository.php
index e8553b0180..1474ec94f5 100644
--- a/app/Repositories/Budget/BudgetLimitRepository.php
+++ b/app/Repositories/Budget/BudgetLimitRepository.php
@@ -124,8 +124,8 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
{
try {
$budgetLimit->delete();
- } catch (Exception $e) {
- Log::info(sprintf('Could not delete budget limit: %s', $e->getMessage()));
+ } catch (Exception $e) { // @phpstan-ignore-line
+ // @ignoreException
}
}
@@ -320,25 +320,25 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
// find the budget:
$budget = $this->user->budgets()->find((int)$data['budget_id']);
if (null === $budget) {
- throw new FireflyException('200004: Budget does not exist.'); // @codeCoverageIgnore
+ throw new FireflyException('200004: Budget does not exist.');
}
// find limit with same date range and currency.
$limit = $budget->budgetlimits()
- ->where('budget_limits.start_date', $data['start_date']->format('Y-m-d 00:00:00'))
- ->where('budget_limits.end_date', $data['end_date']->format('Y-m-d 23:59:59'))
+ ->where('budget_limits.start_date', $data['start_date']->format('Y-m-d'))
+ ->where('budget_limits.end_date', $data['end_date']->format('Y-m-d'))
->where('budget_limits.transaction_currency_id', $currency->id)
- ->get(['budget_limits.*'])->first();
+ ->first(['budget_limits.*']);
if (null !== $limit) {
- throw new FireflyException('200027: Budget limit already exists.'); // @codeCoverageIgnore
+ throw new FireflyException('200027: Budget limit already exists.');
}
Log::debug('No existing budget limit, create a new one');
// or create one and return it.
$limit = new BudgetLimit;
$limit->budget()->associate($budget);
- $limit->start_date = $data['start_date']->format('Y-m-d 00:00:00');
- $limit->end_date = $data['end_date']->format('Y-m-d 23:59:59');
+ $limit->start_date = $data['start_date']->format('Y-m-d');
+ $limit->end_date = $data['end_date']->format('Y-m-d');
$limit->amount = $data['amount'];
$limit->transaction_currency_id = $currency->id;
$limit->save();
@@ -397,7 +397,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
$limits = $budget->budgetlimits()
->where('budget_limits.start_date', $start->format('Y-m-d 00:00:00'))
->where('budget_limits.end_date', $end->format('Y-m-d 00:00:00'))
- ->get(['budget_limits.*'])->count();
+ ->count(['budget_limits.*']);
Log::debug(sprintf('Found %d budget limits.', $limits));
// there might be a budget limit for these dates:
@@ -423,8 +423,8 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
Log::debug(sprintf('%s is zero, delete budget limit #%d', $amount, $limit->id));
try {
$limit->delete();
- } catch (Exception $e) {
- Log::debug(sprintf('Could not delete limit: %s', $e->getMessage()));
+ } catch (Exception $e) { // @phpstan-ignore-line
+ // @ignoreException
}
return null;
}
diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php
index 0a92850bfd..833b4cb041 100644
--- a/app/Repositories/Budget/BudgetRepository.php
+++ b/app/Repositories/Budget/BudgetRepository.php
@@ -58,8 +58,8 @@ class BudgetRepository implements BudgetRepositoryInterface
// delete limits with amount 0:
try {
BudgetLimit::where('amount', 0)->delete();
- } catch (Exception $e) {
- Log::debug(sprintf('Could not delete budget limit: %s', $e->getMessage()));
+ } catch (Exception $e) { // @phpstan-ignore-line
+ // @ignoreException
}
$budgets = $this->getActiveBudgets();
/**
@@ -326,7 +326,7 @@ class BudgetRepository implements BudgetRepositoryInterface
} catch (QueryException $e) {
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
- throw new FireflyException('400002: Could not store budget.');
+ throw new FireflyException('400002: Could not store budget.', 0, $e);
}
if (!array_key_exists('auto_budget_type', $data)) {
return $newBudget;
diff --git a/app/Repositories/Budget/NoBudgetRepository.php b/app/Repositories/Budget/NoBudgetRepository.php
index cf960845a5..56eeb24d85 100644
--- a/app/Repositories/Budget/NoBudgetRepository.php
+++ b/app/Repositories/Budget/NoBudgetRepository.php
@@ -75,7 +75,7 @@ class NoBudgetRepository implements NoBudgetRepositoryInterface
];
$date = $journal['date']->format($carbonFormat);
- if (!isset($data[$currencyId]['entries'][$date])) {
+ if (!array_key_exists($date, $data[$currencyId]['entries'])) {
$data[$currencyId]['entries'][$date] = '0';
}
$data[$currencyId]['entries'][$date] = bcadd($data[$currencyId]['entries'][$date], $journal['amount']);
@@ -118,7 +118,7 @@ class NoBudgetRepository implements NoBudgetRepositoryInterface
/** @var array $journal */
foreach ($journals as $journal) {
$code = $journal['currency_code'];
- if (!isset($currencies[$code])) {
+ if (!array_key_exists($code, $currencies)) {
$currencies[$code] = [
'id' => $journal['currency_id'],
'name' => $journal['currency_name'],
@@ -126,7 +126,7 @@ class NoBudgetRepository implements NoBudgetRepositoryInterface
'decimal_places' => $journal['currency_decimal_places'],
];
}
- $total[$code] = isset($total[$code]) ? bcadd($total[$code], $journal['amount']) : $journal['amount'];
+ $total[$code] = array_key_exists($code, $total) ? bcadd($total[$code], $journal['amount']) : $journal['amount'];
}
foreach ($total as $code => $spent) {
/** @var TransactionCurrency $currency */
diff --git a/app/Repositories/Budget/OperationsRepository.php b/app/Repositories/Budget/OperationsRepository.php
index d054290e14..35995e1460 100644
--- a/app/Repositories/Budget/OperationsRepository.php
+++ b/app/Repositories/Budget/OperationsRepository.php
@@ -237,7 +237,7 @@ class OperationsRepository implements OperationsRepositoryInterface
/** @var array $transaction */
foreach ($group['transactions'] as $transaction) {
$code = $transaction['currency_code'];
- if (!isset($currencies[$code])) {
+ if (!array_key_exists($code, $currencies)) {
$currencies[$code] = [
'id' => $transaction['currency_id'],
'decimal_places' => $transaction['currency_decimal_places'],
@@ -246,7 +246,7 @@ class OperationsRepository implements OperationsRepositoryInterface
'symbol' => $transaction['currency_symbol'],
];
}
- $total[$code] = isset($total[$code]) ? bcadd($total[$code], $transaction['amount']) : $transaction['amount'];
+ $total[$code] = array_key_exists($code, $total) ? bcadd($total[$code], $transaction['amount']) : $transaction['amount'];
}
}
/**
diff --git a/app/Repositories/Journal/JournalCLIRepository.php b/app/Repositories/Journal/JournalCLIRepository.php
index 691e2c6638..53d7294f09 100644
--- a/app/Repositories/Journal/JournalCLIRepository.php
+++ b/app/Repositories/Journal/JournalCLIRepository.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Repositories\Journal;
+
use Carbon\Carbon;
use DB;
use Exception;
@@ -29,7 +30,6 @@ use FireflyIII\Models\TransactionJournal;
use FireflyIII\Support\CacheProperties;
use FireflyIII\User;
use Illuminate\Support\Collection;
-use Log;
use stdClass;
/**
@@ -128,9 +128,9 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
if ($cache->has()) {
$result = null;
try {
- $result = new Carbon($cache->get()); // @codeCoverageIgnore
- } catch (Exception $e) {
- $e->getMessage();
+ $result = new Carbon($cache->get());
+ } catch (Exception $e) { // @phpstan-ignore-line
+ // @ignoreException
}
return $result;
@@ -143,13 +143,12 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
$value = null;
try {
$value = new Carbon($entry->data);
- } catch (Exception $e) {
- $e->getMessage();
-
- return null;
+ } catch (Exception $e) { // @phpstan-ignore-line
+ // @ignoreException
+ }
+ if (null !== $value) {
+ $cache->store($value);
}
-
- $cache->store($entry->data);
return $value;
}
@@ -170,7 +169,7 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
$cache->addProperty($field);
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
$entry = $journal->transactionJournalMeta()->where('name', $field)->first();
@@ -188,13 +187,11 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
}
// return when something else:
+ $return = (string)$value;
try {
- $return = (string)$value;
$cache->store($return);
- } catch (Exception $e) {
- Log::error($e->getMessage());
-
- return '';
+ } catch (Exception $e) { // @phpstan-ignore-line
+ // @ignoreException
}
return $return;
diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php
index 1268306c39..42300fa746 100644
--- a/app/Repositories/Journal/JournalRepository.php
+++ b/app/Repositories/Journal/JournalRepository.php
@@ -137,7 +137,7 @@ class JournalRepository implements JournalRepositoryInterface
$cache->addProperty($journal->id);
$cache->addProperty('destination-account-list');
if ($useCache && $cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
$transactions = $journal->transactions()->where('amount', '>', 0)->orderBy('transactions.account_id')->with('account')->get();
$list = new Collection;
@@ -165,7 +165,7 @@ class JournalRepository implements JournalRepositoryInterface
$cache->addProperty($journal->id);
$cache->addProperty('source-account-list');
if ($useCache && $cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
$transactions = $journal->transactions()->where('amount', '<', 0)->orderBy('transactions.account_id')->with('account')->get();
$list = new Collection;
@@ -192,7 +192,7 @@ class JournalRepository implements JournalRepositoryInterface
$cache->addProperty($journal->id);
$cache->addProperty('amount-positive');
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
// saves on queries:
@@ -250,7 +250,7 @@ class JournalRepository implements JournalRepositoryInterface
$cache->addProperty($field);
if ($cache->has()) {
- return new Carbon($cache->get()); // @codeCoverageIgnore
+ return new Carbon($cache->get());
}
$entry = TransactionJournalMeta::where('transaction_journal_id', $journalId)
->where('name', $field)->first();
diff --git a/app/Repositories/LinkType/LinkTypeRepository.php b/app/Repositories/LinkType/LinkTypeRepository.php
index c6a0028461..65ffb69c92 100644
--- a/app/Repositories/LinkType/LinkTypeRepository.php
+++ b/app/Repositories/LinkType/LinkTypeRepository.php
@@ -379,8 +379,8 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
if (null !== $dbNote && '' === $text) {
try {
$dbNote->delete();
- } catch (Exception $e) {
- Log::debug(sprintf('Could not delete note: %s', $e->getMessage()));
+ } catch (Exception $e) { // @phpstan-ignore-line
+ // @ignoreException
}
}
diff --git a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php b/app/Repositories/PiggyBank/ModifiesPiggyBanks.php
index 84793d7e5d..5235d66d27 100644
--- a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php
+++ b/app/Repositories/PiggyBank/ModifiesPiggyBanks.php
@@ -304,7 +304,7 @@ trait ModifiesPiggyBanks
$piggyBank = PiggyBank::create($piggyData);
} catch (QueryException $e) {
Log::error(sprintf('Could not store piggy bank: %s', $e->getMessage()), $piggyData);
- throw new FireflyException('400005: Could not store new piggy bank.');
+ throw new FireflyException('400005: Could not store new piggy bank.',0,$e);
}
// reset order then set order:
@@ -315,7 +315,7 @@ trait ModifiesPiggyBanks
// repetition is auto created.
$repetition = $this->getRepetition($piggyBank);
- if (null !== $repetition && isset($data['current_amount']) && '' !== $data['current_amount']) {
+ if (null !== $repetition && array_key_exists('current_amount',$data) && '' !== $data['current_amount']) {
$repetition->currentamount = $data['current_amount'];
$repetition->save();
}
@@ -422,8 +422,8 @@ trait ModifiesPiggyBanks
if (null !== $dbNote) {
try {
$dbNote->delete();
- } catch (Exception $e) {
- Log::debug(sprintf('Could not delete note: %s', $e->getMessage()));
+ } catch (Exception $e) { // @phpstan-ignore-line
+ // @ignoreException
}
}
diff --git a/app/Repositories/Recurring/RecurringRepository.php b/app/Repositories/Recurring/RecurringRepository.php
index 9b9072ded5..ec04b519d0 100644
--- a/app/Repositories/Recurring/RecurringRepository.php
+++ b/app/Repositories/Recurring/RecurringRepository.php
@@ -55,6 +55,7 @@ class RecurringRepository implements RecurringRepositoryInterface
use CalculateRangeOccurrences, CalculateXOccurrences, CalculateXOccurrencesSince, FiltersWeekends;
private User $user;
+
/**
* Destroy a recurring transaction.
*
@@ -169,7 +170,7 @@ class RecurringRepository implements RecurringRepositoryInterface
$query->where('transaction_journals.date', '<=', $end->format('Y-m-d 00:00:00'));
}
- return $query->get(['transaction_journals.*'])->count();
+ return $query->count(['transaction_journals.id']);
}
/**
@@ -240,6 +241,7 @@ class RecurringRepository implements RecurringRepositoryInterface
if ('yearly' === $repetition->repetition_type) {
$occurrences = $this->getYearlyInRange($mutator, $end, $skipMod, $repetition->repetition_moment);
}
+
// filter out all the weekend days:
return $this->filterWeekends($repetition, $occurrences);
}
@@ -332,7 +334,7 @@ class RecurringRepository implements RecurringRepositoryInterface
foreach ($journalMeta as $journalId) {
$search[] = (int)$journalId;
}
- if (empty($search)) {
+ if (0 === count($search)) {
return new Collection;
}
diff --git a/app/Rules/BelongsUser.php b/app/Rules/BelongsUser.php
index 74f895ecde..cc71d832dd 100644
--- a/app/Rules/BelongsUser.php
+++ b/app/Rules/BelongsUser.php
@@ -74,7 +74,7 @@ class BelongsUser implements Rule
{
$attribute = $this->parseAttribute($attribute);
if (!auth()->check()) {
- return true; // @codeCoverageIgnore
+ return true;
}
$attribute = (string)$attribute;
Log::debug(sprintf('Going to validate %s', $attribute));
@@ -97,7 +97,7 @@ class BelongsUser implements Rule
case 'destination_id':
return $this->validateAccountId((int)$value);
default:
- throw new FireflyException(sprintf('Rule BelongUser cannot handle "%s"', $attribute)); // @codeCoverageIgnore
+ throw new FireflyException(sprintf('Rule BelongUser cannot handle "%s"', $attribute));
}
}
@@ -116,7 +116,7 @@ class BelongsUser implements Rule
return $parts[2];
}
- return $attribute; // @codeCoverageIgnore
+ return $attribute;
}
/**
diff --git a/app/Rules/UniqueAccountNumber.php b/app/Rules/UniqueAccountNumber.php
index 62cc70010c..dd5c1c2554 100644
--- a/app/Rules/UniqueAccountNumber.php
+++ b/app/Rules/UniqueAccountNumber.php
@@ -87,10 +87,10 @@ class UniqueAccountNumber implements Rule
public function passes($attribute, $value): bool
{
if (!auth()->check()) {
- return true; // @codeCoverageIgnore
+ return true;
}
if (null === $this->expectedType) {
- return true; // @codeCoverageIgnore
+ return true;
}
$maxCounts = $this->getMaxOccurrences();
diff --git a/app/Rules/UniqueIban.php b/app/Rules/UniqueIban.php
index 325a6ef689..7958170cff 100644
--- a/app/Rules/UniqueIban.php
+++ b/app/Rules/UniqueIban.php
@@ -84,10 +84,10 @@ class UniqueIban implements Rule
public function passes($attribute, $value): bool
{
if (!auth()->check()) {
- return true; // @codeCoverageIgnore
+ return true;
}
if (null === $this->expectedType) {
- return true; // @codeCoverageIgnore
+ return true;
}
$maxCounts = $this->getMaxOccurrences();
diff --git a/app/Services/Internal/Support/AccountServiceTrait.php b/app/Services/Internal/Support/AccountServiceTrait.php
index 8b1a2fcd2e..3ba02f78b9 100644
--- a/app/Services/Internal/Support/AccountServiceTrait.php
+++ b/app/Services/Internal/Support/AccountServiceTrait.php
@@ -85,7 +85,7 @@ trait AccountServiceTrait
// not set, so false.
return false;
}
- // if isset, but is empty:
+ // if is set, but is empty:
if (
(array_key_exists('opening_balance', $data) && '' === $data['opening_balance'])
|| (array_key_exists('opening_balance_date', $data) && '' === $data['opening_balance_date'])
@@ -126,7 +126,7 @@ trait AccountServiceTrait
}
if ($account->accountType->type === AccountType::ASSET && array_key_exists('account_role', $data) && 'ccAsset' === $data['account_role']) {
- $fields = $this->validCCFields; // @codeCoverageIgnore
+ $fields = $this->validCCFields;
}
/** @var AccountMetaFactory $factory */
$factory = app(AccountMetaFactory::class);
@@ -137,10 +137,10 @@ trait AccountServiceTrait
// convert boolean value:
if (is_bool($data[$field]) && false === $data[$field]) {
- $data[$field] = 0; // @codeCoverageIgnore
+ $data[$field] = 0;
}
if (is_bool($data[$field]) && true === $data[$field]) {
- $data[$field] = 1; // @codeCoverageIgnore
+ $data[$field] = 1;
}
$factory->crud($account, $field, (string)$data[$field]);
@@ -191,7 +191,7 @@ trait AccountServiceTrait
{
$data['opening_balance'] = (string)($data['opening_balance'] ?? '');
if ('' !== $data['opening_balance'] && 0 === bccomp($data['opening_balance'], '0')) {
- $data['opening_balance'] = ''; // @codeCoverageIgnore
+ $data['opening_balance'] = '';
}
if ('' !== $data['opening_balance'] && array_key_exists('opening_balance_date', $data) && '' !== $data['opening_balance_date']) {
Log::debug('Array has valid opening balance data.');
@@ -350,11 +350,11 @@ trait AccountServiceTrait
$sourceId = $account->id;
}
if (0 === bccomp($amount, '0')) {
- // @codeCoverageIgnoreStart
+
Log::debug('Amount is zero, so will not make an OB group.');
return null;
- // @codeCoverageIgnoreEnd
+
}
$amount = app('steam')->positive($amount);
if (!array_key_exists('currency_id', $data)) {
@@ -402,13 +402,13 @@ trait AccountServiceTrait
try {
$group = $factory->create($submission);
- // @codeCoverageIgnoreStart
+
} catch (FireflyException $e) {
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
}
- // @codeCoverageIgnoreEnd
+
return $group;
}
diff --git a/app/Services/Internal/Support/RecurringTransactionTrait.php b/app/Services/Internal/Support/RecurringTransactionTrait.php
index e349b33e83..45089c8d4c 100644
--- a/app/Services/Internal/Support/RecurringTransactionTrait.php
+++ b/app/Services/Internal/Support/RecurringTransactionTrait.php
@@ -136,11 +136,11 @@ trait RecurringTransactionTrait
$validator->setUser($recurrence->user);
$validator->setTransactionType($recurrence->transactionType->type);
if (!$validator->validateSource($source->id, null, null)) {
- throw new FireflyException(sprintf('Source invalid: %s', $validator->sourceError)); // @codeCoverageIgnore
+ throw new FireflyException(sprintf('Source invalid: %s', $validator->sourceError));
}
if (!$validator->validateDestination($destination->id, null, null)) {
- throw new FireflyException(sprintf('Destination invalid: %s', $validator->destError)); // @codeCoverageIgnore
+ throw new FireflyException(sprintf('Destination invalid: %s', $validator->destError));
}
if (array_key_exists('foreign_amount', $array) && '' === (string)$array['foreign_amount']) {
unset($array['foreign_amount']);
@@ -220,11 +220,11 @@ trait RecurringTransactionTrait
if (!in_array($expectedType, $cannotCreate, true)) {
try {
$result = $factory->findOrCreate($accountName, $expectedType);
- // @codeCoverageIgnoreStart
+
} catch (FireflyException $e) {
Log::error($e->getMessage());
}
- // @codeCoverageIgnoreEnd
+
}
}
diff --git a/app/Services/Internal/Support/TransactionTypeTrait.php b/app/Services/Internal/Support/TransactionTypeTrait.php
index ffaa0552a7..650b75ccdb 100644
--- a/app/Services/Internal/Support/TransactionTypeTrait.php
+++ b/app/Services/Internal/Support/TransactionTypeTrait.php
@@ -48,8 +48,8 @@ trait TransactionTypeTrait
$factory = app(TransactionTypeFactory::class);
$transactionType = $factory->find($type);
if (null === $transactionType) {
- Log::error(sprintf('Could not find transaction type for "%s"', $type)); // @codeCoverageIgnore
- throw new FireflyException(sprintf('Could not find transaction type for "%s"', $type)); // @codeCoverageIgnore
+ Log::error(sprintf('Could not find transaction type for "%s"', $type));
+ throw new FireflyException(sprintf('Could not find transaction type for "%s"', $type));
}
return $transactionType;
diff --git a/app/Support/Amount.php b/app/Support/Amount.php
index cf46bd1e12..f16e7037a3 100644
--- a/app/Support/Amount.php
+++ b/app/Support/Amount.php
@@ -115,7 +115,7 @@ class Amount
$cache = new CacheProperties;
$cache->addProperty('getCurrencyCode');
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
$currencyPreference = app('preferences')->get('currencyPreference', config('firefly.default_currency', 'EUR'));
@@ -152,7 +152,7 @@ class Amount
$cache->addProperty('getDefaultCurrency');
$cache->addProperty($user->id);
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
$currencyPreference = app('preferences')->getForUser($user, 'currencyPreference', config('firefly.default_currency', 'EUR'));
$currencyPrefStr = $currencyPreference ? $currencyPreference->data : 'EUR';
diff --git a/app/Support/Binder/BudgetList.php b/app/Support/Binder/BudgetList.php
index c0bb888b4f..ba4daf89f2 100644
--- a/app/Support/Binder/BudgetList.php
+++ b/app/Support/Binder/BudgetList.php
@@ -54,12 +54,12 @@ class BudgetList implements BinderInterface
$list = array_unique(array_map('\intval', explode(',', $value)));
- // @codeCoverageIgnoreStart
+
if (0 === count($list)) {
Log::warning('Budget list count is zero, return 404.');
throw new NotFoundHttpException;
}
- // @codeCoverageIgnoreEnd
+
/** @var Collection $collection */
$collection = auth()->user()->budgets()
diff --git a/app/Support/Binder/CategoryList.php b/app/Support/Binder/CategoryList.php
index de7f2a13f8..60a36b97d4 100644
--- a/app/Support/Binder/CategoryList.php
+++ b/app/Support/Binder/CategoryList.php
@@ -51,7 +51,7 @@ class CategoryList implements BinderInterface
$list = array_unique(array_map('\intval', explode(',', $value)));
if (0 === count($list)) {
- throw new NotFoundHttpException; // @codeCoverageIgnore
+ throw new NotFoundHttpException;
}
/** @var \Illuminate\Support\Collection $collection */
diff --git a/app/Support/Binder/JournalList.php b/app/Support/Binder/JournalList.php
index 2ae8f9ad94..c562ebebc6 100644
--- a/app/Support/Binder/JournalList.php
+++ b/app/Support/Binder/JournalList.php
@@ -69,7 +69,7 @@ class JournalList implements BinderInterface
{
$list = array_unique(array_map('\intval', explode(',', $value)));
if (0 === count($list)) {
- throw new NotFoundHttpException; // @codeCoverageIgnore
+ throw new NotFoundHttpException;
}
return $list;
diff --git a/app/Support/Binder/TagList.php b/app/Support/Binder/TagList.php
index a35a048bd3..07d2d5ab53 100644
--- a/app/Support/Binder/TagList.php
+++ b/app/Support/Binder/TagList.php
@@ -52,12 +52,12 @@ class TagList implements BinderInterface
}
$list = array_unique(array_map('\strtolower', explode(',', $value)));
Log::debug('List of tags is', $list);
- // @codeCoverageIgnoreStart
+
if (0 === count($list)) {
Log::error('Tag list is empty.');
throw new NotFoundHttpException;
}
- // @codeCoverageIgnoreEnd
+
/** @var TagRepositoryInterface $repository */
$repository = app(TagRepositoryInterface::class);
diff --git a/app/Support/Chart/Category/WholePeriodChartGenerator.php b/app/Support/Chart/Category/WholePeriodChartGenerator.php
index b79592cf19..97efb1a165 100644
--- a/app/Support/Chart/Category/WholePeriodChartGenerator.php
+++ b/app/Support/Chart/Category/WholePeriodChartGenerator.php
@@ -130,13 +130,13 @@ class WholePeriodChartGenerator
$step = '1D';
$months = $start->diffInMonths($end);
if ($months > 3) {
- $step = '1W'; // @codeCoverageIgnore
+ $step = '1W';
}
if ($months > 24) {
- $step = '1M'; // @codeCoverageIgnore
+ $step = '1M';
}
if ($months > 100) {
- $step = '1Y'; // @codeCoverageIgnore
+ $step = '1Y';
}
return $step;
diff --git a/app/Support/Http/Controllers/AugumentData.php b/app/Support/Http/Controllers/AugumentData.php
index 7ee0c9f0fd..19c28683a4 100644
--- a/app/Support/Http/Controllers/AugumentData.php
+++ b/app/Support/Http/Controllers/AugumentData.php
@@ -206,7 +206,7 @@ trait AugumentData
$cache->addProperty('get-limits');
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
$set = $blRepository->getBudgetLimits($budget, $start, $end);
diff --git a/app/Support/Http/Controllers/ChartGeneration.php b/app/Support/Http/Controllers/ChartGeneration.php
index 22f498f4bc..50415ca22c 100644
--- a/app/Support/Http/Controllers/ChartGeneration.php
+++ b/app/Support/Http/Controllers/ChartGeneration.php
@@ -57,7 +57,7 @@ trait ChartGeneration
$cache->addProperty('chart.account.account-balance-chart');
$cache->addProperty($accounts);
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
Log::debug('Regenerate chart.account.account-balance-chart from scratch.');
$locale = app('steam')->getLocale();
diff --git a/app/Support/Http/Controllers/CreateStuff.php b/app/Support/Http/Controllers/CreateStuff.php
index 8c4b7c80fc..28188f75ee 100644
--- a/app/Support/Http/Controllers/CreateStuff.php
+++ b/app/Support/Http/Controllers/CreateStuff.php
@@ -129,7 +129,7 @@ trait CreateStuff
$keys = RSA::createKey(4096);
}
- // @codeCoverageIgnoreStart
+
Log::alert('NO OAuth keys were found. They have been created.');
file_put_contents($publicKey, $keys['publickey']);
diff --git a/app/Support/Http/Controllers/DateCalculation.php b/app/Support/Http/Controllers/DateCalculation.php
index 0a70f06081..68d1ae743c 100644
--- a/app/Support/Http/Controllers/DateCalculation.php
+++ b/app/Support/Http/Controllers/DateCalculation.php
@@ -88,13 +88,13 @@ trait DateCalculation
$step = '1D';
$months = $start->diffInMonths($end);
if ($months > 3) {
- $step = '1W'; // @codeCoverageIgnore
+ $step = '1W';
}
if ($months > 24) {
- $step = '1M'; // @codeCoverageIgnore
+ $step = '1M';
}
if ($months > 100) {
- $step = '1Y'; // @codeCoverageIgnore
+ $step = '1Y';
}
return $step;
diff --git a/app/Support/Http/Controllers/PeriodOverview.php b/app/Support/Http/Controllers/PeriodOverview.php
index 7be27a72e7..374702dbf7 100644
--- a/app/Support/Http/Controllers/PeriodOverview.php
+++ b/app/Support/Http/Controllers/PeriodOverview.php
@@ -89,7 +89,7 @@ trait PeriodOverview
$cache->addProperty('account-show-period-entries');
$cache->addProperty($account->id);
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
/** @var array $dates */
$dates = app('navigation')->blockPeriods($start, $end, $range);
@@ -281,7 +281,7 @@ trait PeriodOverview
$cache->addProperty($category->id);
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
/** @var array $dates */
$dates = app('navigation')->blockPeriods($start, $end, $range);
@@ -356,7 +356,7 @@ trait PeriodOverview
$cache->addProperty('no-budget-period-entries');
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
/** @var array $dates */
@@ -415,7 +415,7 @@ trait PeriodOverview
$cache->addProperty('no-category-period-entries');
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
$dates = app('navigation')->blockPeriods($start, $end, $range);
@@ -490,7 +490,7 @@ trait PeriodOverview
$cache->addProperty('tag-period-entries');
$cache->addProperty($tag->id);
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
/** @var array $dates */
$dates = app('navigation')->blockPeriods($start, $end, $range);
@@ -564,7 +564,7 @@ trait PeriodOverview
$cache->addProperty('transactions-period-entries');
$cache->addProperty($transactionType);
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
/** @var array $dates */
$dates = app('navigation')->blockPeriods($start, $end, $range);
diff --git a/app/Support/Http/Controllers/RenderPartialViews.php b/app/Support/Http/Controllers/RenderPartialViews.php
index 181138a22c..23b3b2d0fe 100644
--- a/app/Support/Http/Controllers/RenderPartialViews.php
+++ b/app/Support/Http/Controllers/RenderPartialViews.php
@@ -65,7 +65,7 @@ trait RenderPartialViews
$account = $accountRepos->findNull((int)$attributes['accountId']);
$journals = $popupHelper->balanceForBudget($budget, $account, $attributes);
- // @codeCoverageIgnoreStart
+
try {
$view = prefixView('popup.report.balance-amount', compact('journals', 'budget', 'account'))->render();
} catch (Throwable $e) { // @phpstan-ignore-line
@@ -73,7 +73,7 @@ trait RenderPartialViews
$view = 'Firefly III could not render the view. Please see the log files.';
}
- // @codeCoverageIgnoreEnd
+
return $view;
}
@@ -88,7 +88,7 @@ trait RenderPartialViews
/** @var BudgetRepositoryInterface $repository */
$repository = app(BudgetRepositoryInterface::class);
$budgets = $repository->getBudgets();
- // @codeCoverageIgnoreStart
+
try {
$result = prefixView('reports.options.budget', compact('budgets'))->render();
} catch (Throwable $e) {// @phpstan-ignore-line
@@ -96,7 +96,7 @@ trait RenderPartialViews
$result = 'Could not render view.';
}
- // @codeCoverageIgnoreEnd
+
return $result;
}
@@ -121,7 +121,7 @@ trait RenderPartialViews
$budget = new Budget;
}
$journals = $popupHelper->byBudget($budget, $attributes);
- // @codeCoverageIgnoreStart
+
try {
$view = prefixView('popup.report.budget-spent-amount', compact('journals', 'budget'))->render();
} catch (Throwable $e) { // @phpstan-ignore-line
@@ -129,7 +129,7 @@ trait RenderPartialViews
$view = 'Firefly III could not render the view. Please see the log files.';
}
- // @codeCoverageIgnoreEnd
+
return $view;
}
@@ -171,7 +171,7 @@ trait RenderPartialViews
/** @var CategoryRepositoryInterface $repository */
$repository = app(CategoryRepositoryInterface::class);
$categories = $repository->getCategories();
- // @codeCoverageIgnoreStart
+
try {
$result = prefixView('reports.options.category', compact('categories'))->render();
} catch (Throwable $e) { // @phpstan-ignore-line
@@ -179,7 +179,7 @@ trait RenderPartialViews
$result = 'Could not render view.';
}
- // @codeCoverageIgnoreEnd
+
return $result;
}
@@ -214,7 +214,7 @@ trait RenderPartialViews
}
}
- // @codeCoverageIgnoreStart
+
try {
$result = prefixView('reports.options.double', compact('set'))->render();
} catch (Throwable $e) { // @phpstan-ignore-line
@@ -222,7 +222,7 @@ trait RenderPartialViews
$result = 'Could not render view.';
}
- // @codeCoverageIgnoreEnd
+
return $result;
}
@@ -249,7 +249,7 @@ trait RenderPartialViews
}
$journals = $popupHelper->byExpenses($account, $attributes);
- // @codeCoverageIgnoreStart
+
try {
$view = prefixView('popup.report.expense-entry', compact('journals', 'account'))->render();
} catch (Throwable $e) { // @phpstan-ignore-line
@@ -257,7 +257,7 @@ trait RenderPartialViews
$view = 'Firefly III could not render the view. Please see the log files.';
}
- // @codeCoverageIgnoreEnd
+
return $view;
}
@@ -288,12 +288,12 @@ trait RenderPartialViews
'count' => $count,
]
)->render();
- // @codeCoverageIgnoreStart
+
} catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Throwable was thrown in getCurrentActions(): %s', $e->getMessage()));
Log::error($e->getTraceAsString());
}
- // @codeCoverageIgnoreEnd
+
++$index;
}
@@ -339,12 +339,12 @@ trait RenderPartialViews
'triggers' => $triggers,
]
)->render();
- // @codeCoverageIgnoreStart
+
} catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Throwable was thrown in getCurrentTriggers(): %s', $e->getMessage()));
Log::error($e->getTraceAsString());
}
- // @codeCoverageIgnoreEnd
+
++$index;
}
}
@@ -373,7 +373,7 @@ trait RenderPartialViews
}
$journals = $popupHelper->byIncome($account, $attributes);
- // @codeCoverageIgnoreStart
+
try {
$view = prefixView('popup.report.income-entry', compact('journals', 'account'))->render();
} catch (Throwable $e) { // @phpstan-ignore-line
@@ -381,7 +381,7 @@ trait RenderPartialViews
$view = 'Firefly III could not render the view. Please see the log files.';
}
- // @codeCoverageIgnoreEnd
+
return $view;
}
@@ -393,7 +393,7 @@ trait RenderPartialViews
*/
protected function noReportOptions(): string // render a view
{
- // @codeCoverageIgnoreStart
+
try {
$result = prefixView('reports.options.no-options')->render();
} catch (Throwable $e) { // @phpstan-ignore-line
@@ -401,7 +401,7 @@ trait RenderPartialViews
$result = 'Could not render view.';
}
- // @codeCoverageIgnoreEnd
+
return $result;
}
@@ -417,7 +417,7 @@ trait RenderPartialViews
$repository = app(TagRepositoryInterface::class);
$tags = $repository->get();
- // @codeCoverageIgnoreStart
+
try {
$result = prefixView('reports.options.tag', compact('tags'))->render();
} catch (Throwable $e) { // @phpstan-ignore-line
@@ -425,7 +425,7 @@ trait RenderPartialViews
$result = 'Could not render view.';
}
- // @codeCoverageIgnoreEnd
+
return $result;
}
diff --git a/app/Support/Http/Controllers/RequestInformation.php b/app/Support/Http/Controllers/RequestInformation.php
index 12e328d0c2..99ee491d86 100644
--- a/app/Support/Http/Controllers/RequestInformation.php
+++ b/app/Support/Http/Controllers/RequestInformation.php
@@ -113,7 +113,7 @@ trait RequestInformation
return $content;
}
- return '<p>' . trans('firefly.route_has_no_help') . '</p>'; // @codeCoverageIgnore
+ return '<p>' . trans('firefly.route_has_no_help') . '</p>';
}
/**
@@ -180,7 +180,7 @@ trait RequestInformation
$shownDemo = app('preferences')->get($key, false)->data;
}
if (!is_bool($shownDemo)) {
- $shownDemo = true; // @codeCoverageIgnore
+ $shownDemo = true;
}
return $shownDemo;
diff --git a/app/Support/Http/Controllers/UserNavigation.php b/app/Support/Http/Controllers/UserNavigation.php
index 65f888dbef..455e1b2c54 100644
--- a/app/Support/Http/Controllers/UserNavigation.php
+++ b/app/Support/Http/Controllers/UserNavigation.php
@@ -60,7 +60,7 @@ trait UserNavigation
Log::debug(sprintf('The URI is %s', $uri));
if (false !== strpos($uri, 'jscript')) {
- $uri = $this->redirectUri; // @codeCoverageIgnore
+ $uri = $this->redirectUri;
Log::debug(sprintf('URI is now %s (uri contains jscript)', $uri));
}
diff --git a/app/Support/Steam.php b/app/Support/Steam.php
index 19fce854c2..063ea03783 100644
--- a/app/Support/Steam.php
+++ b/app/Support/Steam.php
@@ -56,7 +56,7 @@ class Steam
$cache->addProperty($date);
$cache->addProperty($currency ? $currency->id : 0);
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
@@ -101,7 +101,7 @@ class Steam
$cache->addProperty('balance-no-virtual');
$cache->addProperty($date);
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
@@ -170,7 +170,7 @@ class Steam
$cache->addProperty($start);
$cache->addProperty($end);
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
$start->subDay();
@@ -250,7 +250,7 @@ class Steam
$cache->addProperty('balance-per-currency');
$cache->addProperty($date);
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
$query = $account->transactions()
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
@@ -284,7 +284,7 @@ class Steam
$cache->addProperty('balances');
$cache->addProperty($date);
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
// need to do this per account.
@@ -316,7 +316,7 @@ class Steam
$cache->addProperty('balances-per-currency');
$cache->addProperty($date);
if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
+ return $cache->get();
}
// need to do this per account.
diff --git a/app/TransactionRules/Actions/AddTag.php b/app/TransactionRules/Actions/AddTag.php
index db64b8adfd..22b8345cef 100644
--- a/app/TransactionRules/Actions/AddTag.php
+++ b/app/TransactionRules/Actions/AddTag.php
@@ -55,14 +55,14 @@ class AddTag implements ActionInterface
$factory = app(TagFactory::class);
$factory->setUser(User::find($journal['user_id']));
$tag = $factory->findOrCreate($this->action->action_value);
- // @codeCoverageIgnoreStart
+
if (null === $tag) {
// could not find, could not create tag.
Log::error(sprintf('RuleAction AddTag. Could not find or create tag "%s"', $this->action->action_value));
return false;
}
- // @codeCoverageIgnoreEnd
+
$count = DB::table('tag_transaction_journal')
->where('tag_id', $tag->id)
->where('transaction_journal_id', $journal['transaction_journal_id'])
diff --git a/app/TransactionRules/Actions/ConvertToTransfer.php b/app/TransactionRules/Actions/ConvertToTransfer.php
index c9a4bf1904..d13e00a083 100644
--- a/app/TransactionRules/Actions/ConvertToTransfer.php
+++ b/app/TransactionRules/Actions/ConvertToTransfer.php
@@ -91,7 +91,7 @@ class ConvertToTransfer implements ActionInterface
return $this->convertDepositArray($journal, $asset);
}
- return false; // @codeCoverageIgnore
+ return false;
}
/**
diff --git a/app/TransactionRules/Actions/ConvertToWithdrawal.php b/app/TransactionRules/Actions/ConvertToWithdrawal.php
index 2781206d7c..fa028db3f9 100644
--- a/app/TransactionRules/Actions/ConvertToWithdrawal.php
+++ b/app/TransactionRules/Actions/ConvertToWithdrawal.php
@@ -73,7 +73,7 @@ class ConvertToWithdrawal implements ActionInterface
return $this->convertTransferArray($journal);
}
- return false; // @codeCoverageIgnore
+ return false;
}
private function convertDepositArray(array $journal): bool
diff --git a/app/Transformers/BillTransformer.php b/app/Transformers/BillTransformer.php
index 224287d539..300dab679b 100644
--- a/app/Transformers/BillTransformer.php
+++ b/app/Transformers/BillTransformer.php
@@ -209,7 +209,7 @@ class BillTransformer extends AbstractTransformer
protected function lastPaidDate(Collection $dates, Carbon $default): Carbon
{
if (0 === $dates->count()) {
- return $default; // @codeCoverageIgnore
+ return $default;
}
$latest = $dates->first()->date;
/** @var TransactionJournal $journal */