Skip to content

Firefly III: a personal finances manager

Use PSR-12 code style

James Colebdcd9825ecd5
diff --git a/app/Console/Commands/Correction/CorrectOpeningBalanceCurrencies.php b/app/Console/Commands/Correction/CorrectOpeningBalanceCurrencies.php
index 6c5fba45c9..de1617c0ee 100644
--- a/app/Console/Commands/Correction/CorrectOpeningBalanceCurrencies.php
+++ b/app/Console/Commands/Correction/CorrectOpeningBalanceCurrencies.php
@@ -62,8 +62,7 @@ class CorrectOpeningBalanceCurrencies extends Command
{
Log::debug(sprintf('Now in %s', __METHOD__));
// get all OB journals:
- $set = TransactionJournal
- ::leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
+ $set = TransactionJournal::leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
->whereNull('transaction_journals.deleted_at')
->where('transaction_types.type', TransactionType::OPENING_BALANCE)->get(['transaction_journals.*']);
diff --git a/app/Console/Commands/Correction/CreateLinkTypes.php b/app/Console/Commands/Correction/CreateLinkTypes.php
index 0bdf1d924d..bec99fd9d5 100644
--- a/app/Console/Commands/Correction/CreateLinkTypes.php
+++ b/app/Console/Commands/Correction/CreateLinkTypes.php
@@ -63,7 +63,7 @@ class CreateLinkTypes extends Command
$link = LinkType::where('name', $name)
->first();
if (null === $link) {
- $link = new LinkType;
+ $link = new LinkType();
$link->name = $name;
$link->inward = $values[1];
$link->outward = $values[0];
diff --git a/app/Console/Commands/Correction/DeleteEmptyGroups.php b/app/Console/Commands/Correction/DeleteEmptyGroups.php
index bb5a0c52bf..9c6324e867 100644
--- a/app/Console/Commands/Correction/DeleteEmptyGroups.php
+++ b/app/Console/Commands/Correction/DeleteEmptyGroups.php
@@ -58,8 +58,7 @@ class DeleteEmptyGroups extends Command
Log::debug(sprintf('Now in %s', __METHOD__));
$start = microtime(true);
$groupIds
- = TransactionGroup
- ::leftJoin('transaction_journals', 'transaction_groups.id', '=', 'transaction_journals.transaction_group_id')
+ = TransactionGroup::leftJoin('transaction_journals', 'transaction_groups.id', '=', 'transaction_journals.transaction_group_id')
->whereNull('transaction_journals.id')->get(['transaction_groups.id'])->pluck('id')->toArray();
$total = count($groupIds);
diff --git a/app/Console/Commands/Correction/DeleteEmptyJournals.php b/app/Console/Commands/Correction/DeleteEmptyJournals.php
index d1b4d4451a..74f97d2518 100644
--- a/app/Console/Commands/Correction/DeleteEmptyJournals.php
+++ b/app/Console/Commands/Correction/DeleteEmptyJournals.php
@@ -66,8 +66,7 @@ class DeleteEmptyJournals extends Command
*/
private function deleteUnevenJournals(): void
{
- $set = Transaction
- ::whereNull('deleted_at')
+ $set = Transaction::whereNull('deleted_at')
->groupBy('transactions.transaction_journal_id')
->get([DB::raw('COUNT(transactions.transaction_journal_id) as the_count'), 'transaction_journal_id']);
$total = 0;
@@ -78,7 +77,6 @@ class DeleteEmptyJournals extends Command
// uneven number, delete journal and transactions:
try {
TransactionJournal::find((int) $row->transaction_journal_id)->delete();
-
} catch (Exception $e) { // @phpstan-ignore-line
Log::info(sprintf('Could not delete journal: %s', $e->getMessage()));
}
@@ -106,7 +104,6 @@ class DeleteEmptyJournals extends Command
foreach ($set as $entry) {
try {
TransactionJournal::find($entry->id)->delete();
-
} catch (Exception $e) { // @phpstan-ignore-line
Log::info(sprintf('Could not delete entry: %s', $e->getMessage()));
}
@@ -121,5 +118,4 @@ class DeleteEmptyJournals extends Command
$end = round(microtime(true) - $start, 2);
$this->info(sprintf('Verified empty journals in %s seconds', $end));
}
-
}
diff --git a/app/Console/Commands/Correction/DeleteOrphanedTransactions.php b/app/Console/Commands/Correction/DeleteOrphanedTransactions.php
index 46c327c1fb..bd26c549bd 100644
--- a/app/Console/Commands/Correction/DeleteOrphanedTransactions.php
+++ b/app/Console/Commands/Correction/DeleteOrphanedTransactions.php
@@ -72,8 +72,7 @@ class DeleteOrphanedTransactions extends Command
private function deleteOrphanedTransactions(): void
{
$count = 0;
- $set = Transaction
- ::leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
+ $set = Transaction::leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->whereNotNull('transaction_journals.deleted_at')
->whereNull('transactions.deleted_at')
->whereNotNull('transactions.id')
@@ -109,8 +108,7 @@ class DeleteOrphanedTransactions extends Command
private function deleteFromOrphanedAccounts(): void
{
$set
- = Transaction
- ::leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')
+ = Transaction::leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')
->whereNotNull('accounts.deleted_at')
->get(['transactions.*']);
$count = 0;
@@ -121,11 +119,9 @@ class DeleteOrphanedTransactions extends Command
if ($journal) {
try {
$journal->delete();
-
} catch (Exception $e) { // @phpstan-ignore-line
Log::info(sprintf('Could not delete journal %s', $e->getMessage()));
}
-
}
Transaction::where('transaction_journal_id', (int) $transaction->transaction_journal_id)->delete();
$this->line(
@@ -144,8 +140,7 @@ class DeleteOrphanedTransactions extends Command
private function deleteOrphanedJournals(): void
{
- $set = TransactionJournal
- ::leftJoin('transaction_groups', 'transaction_journals.transaction_group_id', 'transaction_groups.id')
+ $set = TransactionJournal::leftJoin('transaction_groups', 'transaction_journals.transaction_group_id', 'transaction_groups.id')
->whereNotNull('transaction_groups.deleted_at')
->whereNull('transaction_journals.deleted_at')
->get(['transaction_journals.id', 'transaction_journals.transaction_group_id']);
diff --git a/app/Console/Commands/Correction/DeleteZeroAmount.php b/app/Console/Commands/Correction/DeleteZeroAmount.php
index 6ff620ce97..67fe97aef3 100644
--- a/app/Console/Commands/Correction/DeleteZeroAmount.php
+++ b/app/Console/Commands/Correction/DeleteZeroAmount.php
@@ -62,7 +62,6 @@ class DeleteZeroAmount extends Command
$this->info(sprintf('Deleted transaction journal #%d because the amount is zero (0.00).', $journal->id));
try {
$journal->delete();
-
} catch (Exception $e) { // @phpstan-ignore-line
$this->line($e->getMessage());
}
diff --git a/app/Console/Commands/Correction/EnableCurrencies.php b/app/Console/Commands/Correction/EnableCurrencies.php
index 3e1aaee2d1..9cf7f5b434 100644
--- a/app/Console/Commands/Correction/EnableCurrencies.php
+++ b/app/Console/Commands/Correction/EnableCurrencies.php
@@ -88,9 +88,10 @@ class EnableCurrencies extends Command
$found = array_values(array_unique($found));
$found = array_values(
array_filter(
- $found, function (int $currencyId) {
- return $currencyId !== 0;
- }
+ $found,
+ function (int $currencyId) {
+ return $currencyId !== 0;
+ }
)
);
$message = sprintf('%d different currencies are currently in use.', count($found));
diff --git a/app/Console/Commands/Correction/FixAccountTypes.php b/app/Console/Commands/Correction/FixAccountTypes.php
index 048c32d9b5..a9cd3ff80a 100644
--- a/app/Console/Commands/Correction/FixAccountTypes.php
+++ b/app/Console/Commands/Correction/FixAccountTypes.php
@@ -48,7 +48,7 @@ class FixAccountTypes extends Command
*
* @var string
*/
- protected $signature = 'firefly-iii:fix-account-types';
+ protected $signature = 'firefly-iii:fix-account-types';
private int $count;
private array $expected;
private AccountFactory $factory;
@@ -121,12 +121,10 @@ class FixAccountTypes extends Command
$destAccountType = $destAccount->accountType->type;
if (!array_key_exists($type, $this->expected)) {
-
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;
-
}
if (!array_key_exists($sourceAccountType, $this->expected[$type])) {
Log::debug(sprintf('Going to fix journal #%d', $journal->id));
@@ -211,8 +209,12 @@ class FixAccountTypes extends Command
$dest->account()->associate($result);
$dest->save();
$message = sprintf(
- 'Transaction journal #%d, destination account changed from #%d ("%s") to #%d ("%s").', $journal->id, $oldDest->id, $oldDest->name,
- $result->id, $result->name
+ 'Transaction journal #%d, destination account changed from #%d ("%s") to #%d ("%s").',
+ $journal->id,
+ $oldDest->id,
+ $oldDest->name,
+ $result->id,
+ $result->name
);
$this->info($message);
Log::debug($message);
@@ -227,8 +229,12 @@ class FixAccountTypes extends Command
$source->account()->associate($result);
$source->save();
$message = sprintf(
- 'Transaction journal #%d, source account changed from #%d ("%s") to #%d ("%s").', $journal->id, $oldSource->id, $oldSource->name,
- $result->id, $result->name
+ 'Transaction journal #%d, source account changed from #%d ("%s") to #%d ("%s").',
+ $journal->id,
+ $oldSource->id,
+ $oldSource->name,
+ $result->id,
+ $result->name
);
$this->info($message);
Log::debug($message);
@@ -244,7 +250,6 @@ class FixAccountTypes extends Command
Log::debug($message);
break;
-
}
}
}
diff --git a/app/Console/Commands/Correction/FixGroupAccounts.php b/app/Console/Commands/Correction/FixGroupAccounts.php
index 9ed55a330e..a5028d8533 100644
--- a/app/Console/Commands/Correction/FixGroupAccounts.php
+++ b/app/Console/Commands/Correction/FixGroupAccounts.php
@@ -57,8 +57,7 @@ class FixGroupAccounts extends Command
public function handle(): int
{
$groups = [];
- $res = TransactionJournal
- ::groupBy('transaction_group_id')
+ $res = TransactionJournal::groupBy('transaction_group_id')
->get(['transaction_group_id', DB::raw('COUNT(transaction_group_id) as the_count')]);
/** @var TransactionJournal $journal */
foreach ($res as $journal) {
@@ -66,7 +65,7 @@ class FixGroupAccounts extends Command
$groups[] = (int) $journal->transaction_group_id;
}
}
- $handler = new UpdatedGroupEventHandler;
+ $handler = new UpdatedGroupEventHandler();
foreach ($groups as $groupId) {
$group = TransactionGroup::find($groupId);
$event = new UpdatedTransactionGroup($group);
diff --git a/app/Console/Commands/Correction/FixIbans.php b/app/Console/Commands/Correction/FixIbans.php
index 6ecf3a1a62..c1a330ef11 100644
--- a/app/Console/Commands/Correction/FixIbans.php
+++ b/app/Console/Commands/Correction/FixIbans.php
@@ -57,7 +57,6 @@ class FixIbans extends Command
foreach ($accounts as $account) {
$iban = $account->iban;
if (str_contains($iban, ' ')) {
-
$iban = app('steam')->filterSpaces((string) $account->iban);
if ('' !== $iban) {
$account->iban = $iban;
diff --git a/app/Console/Commands/Correction/FixPiggies.php b/app/Console/Commands/Correction/FixPiggies.php
index 22ea9c0967..13e64be2bf 100644
--- a/app/Console/Commands/Correction/FixPiggies.php
+++ b/app/Console/Commands/Correction/FixPiggies.php
@@ -61,7 +61,6 @@ class FixPiggies extends Command
/** @var PiggyBankEvent $event */
foreach ($set as $event) {
-
if (null === $event->transaction_journal_id) {
continue;
}
diff --git a/app/Console/Commands/Correction/FixPostgresSequences.php b/app/Console/Commands/Correction/FixPostgresSequences.php
index 0b1862e295..babdc6a333 100644
--- a/app/Console/Commands/Correction/FixPostgresSequences.php
+++ b/app/Console/Commands/Correction/FixPostgresSequences.php
@@ -52,7 +52,6 @@ class FixPostgresSequences extends Command
*/
public function handle(): int
{
-
if (DB::connection()->getName() !== 'pgsql') {
$this->info('Command executed successfully.');
diff --git a/app/Console/Commands/Correction/FixTransactionTypes.php b/app/Console/Commands/Correction/FixTransactionTypes.php
index 8ca46f9507..b37661d1d9 100644
--- a/app/Console/Commands/Correction/FixTransactionTypes.php
+++ b/app/Console/Commands/Correction/FixTransactionTypes.php
@@ -85,8 +85,7 @@ class FixTransactionTypes extends Command
*/
private function collectJournals(): Collection
{
- return TransactionJournal
- ::with(['transactionType', 'transactions', 'transactions.account', 'transactions.account.accountType'])
+ return TransactionJournal::with(['transactionType', 'transactions', 'transactions.account', 'transactions.account.accountType'])
->get();
}
@@ -109,10 +108,15 @@ class FixTransactionTypes extends Command
$expectedType = (string) config(sprintf('firefly.account_to_transaction.%s.%s', $source->accountType->type, $destination->accountType->type));
if ($expectedType !== $type) {
$this->line(
- sprintf('Transaction journal #%d was of type "%s" but is corrected to "%s" (%s -> %s)',
- $journal->id, $type, $expectedType,
- $source->accountType->type, $destination->accountType->type,
- ));
+ sprintf(
+ 'Transaction journal #%d was of type "%s" but is corrected to "%s" (%s -> %s)',
+ $journal->id,
+ $type,
+ $expectedType,
+ $source->accountType->type,
+ $destination->accountType->type,
+ )
+ );
$this->changeJournal($journal, $expectedType);
return true;
diff --git a/app/Console/Commands/CreateFirstUser.php b/app/Console/Commands/CreateFirstUser.php
index aa7a4d10b6..427ef53727 100644
--- a/app/Console/Commands/CreateFirstUser.php
+++ b/app/Console/Commands/CreateFirstUser.php
@@ -47,7 +47,7 @@ class CreateFirstUser extends Command
*
* @var string
*/
- protected $signature = 'firefly-iii:create-first-user {email}';
+ protected $signature = 'firefly-iii:create-first-user {email}';
private UserRepositoryInterface $repository;
/**
@@ -97,6 +97,5 @@ class CreateFirstUser extends Command
private function stupidLaravel(): void
{
$this->repository = app(UserRepositoryInterface::class);
-
}
}
diff --git a/app/Console/Commands/Export/ExportData.php b/app/Console/Commands/Export/ExportData.php
index 7aea9a3df4..7419aaa36c 100644
--- a/app/Console/Commands/Export/ExportData.php
+++ b/app/Console/Commands/Export/ExportData.php
@@ -56,7 +56,7 @@ class ExportData extends Command
*
* @var string
*/
- protected $signature = 'firefly-iii:export-data
+ protected $signature = 'firefly-iii:export-data
{--user=1 : The user ID that the export should run for.}
{--token= : The user\'s access token.}
{--start= : First transaction to export. Defaults to your very first transaction. Only applies to transaction export.}
@@ -230,8 +230,8 @@ class ExportData extends Command
*/
private function getAccountsParameter(): Collection
{
- $final = new Collection;
- $accounts = new Collection;
+ $final = new Collection();
+ $accounts = new Collection();
$accountList = $this->option('accounts');
$types = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE];
if (null !== $accountList && '' !== (string) $accountList) {
diff --git a/app/Console/Commands/Integrity/ReportEmptyObjects.php b/app/Console/Commands/Integrity/ReportEmptyObjects.php
index fe1d9eaa3b..73c8814261 100644
--- a/app/Console/Commands/Integrity/ReportEmptyObjects.php
+++ b/app/Console/Commands/Integrity/ReportEmptyObjects.php
@@ -131,7 +131,6 @@ class ReportEmptyObjects extends Command
/** @var stdClass $entry */
foreach ($set as $entry) {
-
$line = sprintf(
'User #%d (%s) has tag #%d ("%s") which has no transaction journals.',
$entry->user_id,
diff --git a/app/Console/Commands/Integrity/ReportIntegrity.php b/app/Console/Commands/Integrity/ReportIntegrity.php
index c4f7122fb6..e9bc2dbfa2 100644
--- a/app/Console/Commands/Integrity/ReportIntegrity.php
+++ b/app/Console/Commands/Integrity/ReportIntegrity.php
@@ -34,7 +34,6 @@ use Schema;
*/
class ReportIntegrity extends Command
{
-
/**
* The console command description.
*
diff --git a/app/Console/Commands/Integrity/ReportSum.php b/app/Console/Commands/Integrity/ReportSum.php
index f88fe087d1..7365299de1 100644
--- a/app/Console/Commands/Integrity/ReportSum.php
+++ b/app/Console/Commands/Integrity/ReportSum.php
@@ -79,6 +79,5 @@ class ReportSum extends Command
}
$end = round(microtime(true) - $start, 2);
$this->info(sprintf('Report on total sum finished in %s seconds', $end));
-
}
}
diff --git a/app/Console/Commands/Tools/ApplyRules.php b/app/Console/Commands/Tools/ApplyRules.php
index 0e4cf33cfb..7f620eca71 100644
--- a/app/Console/Commands/Tools/ApplyRules.php
+++ b/app/Console/Commands/Tools/ApplyRules.php
@@ -56,7 +56,7 @@ class ApplyRules extends Command
*
* @var string
*/
- protected $signature
+ protected $signature
= 'firefly-iii:apply-rules
{--user=1 : The user ID.}
{--token= : The user\'s access token.}
@@ -161,13 +161,13 @@ class ApplyRules extends Command
private function stupidLaravel(): void
{
$this->allRules = false;
- $this->accounts = new Collection;
+ $this->accounts = new Collection();
$this->ruleSelection = [];
$this->ruleGroupSelection = [];
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->acceptedAccounts = [AccountType::DEFAULT, AccountType::DEBT, AccountType::ASSET, AccountType::LOAN, AccountType::MORTGAGE];
- $this->groups = new Collection;
+ $this->groups = new Collection();
}
/**
@@ -205,7 +205,7 @@ class ApplyRules extends Command
return false;
}
- $finalList = new Collection;
+ $finalList = new Collection();
$accountList = explode(',', $accountString);
/** @var AccountRepositoryInterface $accountRepository */
@@ -227,7 +227,6 @@ class ApplyRules extends Command
$this->accounts = $finalList;
return true;
-
}
/**
@@ -325,7 +324,7 @@ class ApplyRules extends Command
*/
private function getRulesToApply(): Collection
{
- $rulesToApply = new Collection;
+ $rulesToApply = new Collection();
/** @var RuleGroup $group */
foreach ($this->groups as $group) {
$rules = $this->ruleGroupRepository->getActiveStoreRules($group);
diff --git a/app/Console/Commands/Tools/Cron.php b/app/Console/Commands/Tools/Cron.php
index 6818d119f7..c4a85e8625 100644
--- a/app/Console/Commands/Tools/Cron.php
+++ b/app/Console/Commands/Tools/Cron.php
@@ -129,7 +129,7 @@ class Cron extends Command
*/
private function recurringCronJob(bool $force, ?Carbon $date): void
{
- $recurring = new RecurringCronjob;
+ $recurring = new RecurringCronjob();
$recurring->setForce($force);
// set date in cron job:
@@ -156,7 +156,7 @@ class Cron extends Command
*/
private function autoBudgetCronJob(bool $force, ?Carbon $date): void
{
- $autoBudget = new AutoBudgetCronjob;
+ $autoBudget = new AutoBudgetCronjob();
$autoBudget->setForce($force);
// set date in cron job:
if (null !== $date) {
@@ -174,7 +174,6 @@ class Cron extends Command
if ($autoBudget->jobSucceeded) {
$this->info(sprintf('"Create auto budgets" cron ran with success: %s', $autoBudget->message));
}
-
}
/**
@@ -184,7 +183,7 @@ class Cron extends Command
*/
private function billWarningCronJob(bool $force, ?Carbon $date): void
{
- $autoBudget = new BillWarningCronjob;
+ $autoBudget = new BillWarningCronjob();
$autoBudget->setForce($force);
// set date in cron job:
if (null !== $date) {
@@ -202,7 +201,6 @@ class Cron extends Command
if ($autoBudget->jobSucceeded) {
$this->info(sprintf('"Send bill warnings" cron ran with success: %s', $autoBudget->message));
}
-
}
/**
@@ -212,7 +210,7 @@ class Cron extends Command
*/
private function exchangeRatesCronJob(bool $force, ?Carbon $date): void
{
- $exchangeRates = new ExchangeRatesCronjob;
+ $exchangeRates = new ExchangeRatesCronjob();
$exchangeRates->setForce($force);
// set date in cron job:
if (null !== $date) {
@@ -230,6 +228,5 @@ class Cron extends Command
if ($exchangeRates->jobSucceeded) {
$this->info(sprintf('"Exchange rates" cron ran with success: %s', $exchangeRates->message));
}
-
}
}
diff --git a/app/Console/Commands/Upgrade/AppendBudgetLimitPeriods.php b/app/Console/Commands/Upgrade/AppendBudgetLimitPeriods.php
index 0558fe99c4..48cfa23172 100644
--- a/app/Console/Commands/Upgrade/AppendBudgetLimitPeriods.php
+++ b/app/Console/Commands/Upgrade/AppendBudgetLimitPeriods.php
@@ -103,7 +103,10 @@ class AppendBudgetLimitPeriods extends Command
if (null === $period) {
$message = sprintf(
- 'Could not guesstimate budget limit #%d (%s - %s) period.', $limit->id, $limit->start_date->format('Y-m-d'), $limit->end_date->format('Y-m-d')
+ 'Could not guesstimate budget limit #%d (%s - %s) period.',
+ $limit->id,
+ $limit->start_date->format('Y-m-d'),
+ $limit->end_date->format('Y-m-d')
);
$this->warn($message);
Log::warning($message);
@@ -114,10 +117,13 @@ class AppendBudgetLimitPeriods extends Command
$limit->save();
$msg = sprintf(
- 'Budget limit #%d (%s - %s) period is "%s".', $limit->id, $limit->start_date->format('Y-m-d'), $limit->end_date->format('Y-m-d'), $period
+ 'Budget limit #%d (%s - %s) period is "%s".',
+ $limit->id,
+ $limit->start_date->format('Y-m-d'),
+ $limit->end_date->format('Y-m-d'),
+ $period
);
Log::debug($msg);
-
}
/**
@@ -159,8 +165,8 @@ class AppendBudgetLimitPeriods extends Command
$start = ['1-1', '1-7'];
$end = ['30-6', '31-12'];
if (
- in_array($limit->start_date->format('j-n'), $start) // start of quarter
- && in_array($limit->end_date->format('j-n'), $end) // end of quarter
+ in_array($limit->start_date->format('j-n'), $start, true) // start of quarter
+ && in_array($limit->end_date->format('j-n'), $end, true) // end of quarter
&& 5 === $limit->start_date->diffInMonths($limit->end_date)
) {
return 'half_year';
diff --git a/app/Console/Commands/Upgrade/BackToJournals.php b/app/Console/Commands/Upgrade/BackToJournals.php
index bd55811b05..15298a237f 100644
--- a/app/Console/Commands/Upgrade/BackToJournals.php
+++ b/app/Console/Commands/Upgrade/BackToJournals.php
@@ -60,7 +60,6 @@ class BackToJournals extends Command
*/
public function handle(): int
{
-
$start = microtime(true);
if (!$this->isMigrated()) {
$this->error('Please run firefly-iii:migrate-to-groups first.');
@@ -128,7 +127,7 @@ class BackToJournals extends Command
*/
private function migrateBudgets(): void
{
- $journals = new Collection;
+ $journals = new Collection();
$allIds = $this->getIdsForBudgets();
$chunks = array_chunk($allIds, 500);
foreach ($chunks as $journalIds) {
@@ -164,16 +163,13 @@ class BackToJournals extends Command
*/
private function migrateBudgetsForJournal(TransactionJournal $journal): void
{
-
// grab category from first transaction
/** @var Transaction $transaction */
$transaction = $journal->transactions->first();
if (null === $transaction) {
-
$this->info(sprintf('Transaction journal #%d has no transactions. Will be fixed later.', $journal->id));
return;
-
}
/** @var Budget $budget */
$budget = $transaction->budgets->first();
@@ -201,7 +197,7 @@ class BackToJournals extends Command
private function migrateCategories(): void
{
Log::debug('Now in migrateCategories()');
- $journals = new Collection;
+ $journals = new Collection();
$allIds = $this->getIdsForCategories();
Log::debug(sprintf('Total: %d', count($allIds)));
@@ -247,11 +243,9 @@ class BackToJournals extends Command
/** @var Transaction $transaction */
$transaction = $journal->transactions->first();
if (null === $transaction) {
-
$this->info(sprintf('Transaction journal #%d has no transactions. Will be fixed later.', $journal->id));
return;
-
}
/** @var Category $category */
$category = $transaction->categories->first();
diff --git a/app/Console/Commands/Upgrade/MigrateAttachments.php b/app/Console/Commands/Upgrade/MigrateAttachments.php
index da66743e5f..b323cb1749 100644
--- a/app/Console/Commands/Upgrade/MigrateAttachments.php
+++ b/app/Console/Commands/Upgrade/MigrateAttachments.php
@@ -56,7 +56,6 @@ class MigrateAttachments extends Command
*/
public function handle(): int
{
-
$start = microtime(true);
if ($this->isExecuted() && true !== $this->option('force')) {
$this->warn('This command has already been executed.');
@@ -70,15 +69,13 @@ class MigrateAttachments extends Command
/** @var Attachment $att */
foreach ($attachments as $att) {
-
// move description:
$attDescription = (string) $att->description;
if ('' !== $attDescription) {
-
// find or create note:
$note = $att->notes()->first();
if (null === $note) {
- $note = new Note;
+ $note = new Note();
$note->noteable()->associate($att);
}
$note->text = $attDescription;
diff --git a/app/Console/Commands/Upgrade/MigrateJournalNotes.php b/app/Console/Commands/Upgrade/MigrateJournalNotes.php
index 8469fa7285..33add64d5a 100644
--- a/app/Console/Commands/Upgrade/MigrateJournalNotes.php
+++ b/app/Console/Commands/Upgrade/MigrateJournalNotes.php
@@ -81,7 +81,6 @@ class MigrateJournalNotes extends Command
Log::debug(sprintf('Migrated meta note #%d to Note #%d', $meta->id, $note->id));
try {
$meta->delete();
-
} catch (Exception $e) { // @phpstan-ignore-line
Log::error(sprintf('Could not delete old meta entry #%d: %s', $meta->id, $e->getMessage()));
}
diff --git a/app/Console/Commands/Upgrade/MigrateTagLocations.php b/app/Console/Commands/Upgrade/MigrateTagLocations.php
index ad36e4a605..e3170acbd4 100644
--- a/app/Console/Commands/Upgrade/MigrateTagLocations.php
+++ b/app/Console/Commands/Upgrade/MigrateTagLocations.php
@@ -34,7 +34,6 @@ use Illuminate\Console\Command;
*/
class MigrateTagLocations extends Command
{
-
public const CONFIG_NAME = '500_migrate_tag_locations';
/**
* The console command description.
@@ -114,7 +113,7 @@ class MigrateTagLocations extends Command
*/
private function migrateLocationDetails(Tag $tag): void
{
- $location = new Location;
+ $location = new Location();
$location->longitude = $tag->longitude;
$location->latitude = $tag->latitude;
$location->zoom_level = $tag->zoomLevel;
diff --git a/app/Console/Commands/Upgrade/MigrateToGroups.php b/app/Console/Commands/Upgrade/MigrateToGroups.php
index 7085092e7a..c4ee070bb8 100644
--- a/app/Console/Commands/Upgrade/MigrateToGroups.php
+++ b/app/Console/Commands/Upgrade/MigrateToGroups.php
@@ -59,7 +59,7 @@ class MigrateToGroups extends Command
*
* @var string
*/
- protected $signature = 'firefly-iii:migrate-to-groups {--F|force : Force the migration, even if it fired before.}';
+ protected $signature = 'firefly-iii:migrate-to-groups {--F|force : Force the migration, even if it fired before.}';
private JournalCLIRepositoryInterface $cliRepository;
private int $count;
private TransactionGroupFactory $groupFactory;
@@ -169,11 +169,9 @@ class MigrateToGroups extends Command
{
// double check transaction count.
if ($journal->transactions->count() <= 2) {
-
Log::debug(sprintf('Will not try to convert journal #%d because it has 2 or less transactions.', $journal->id));
return;
-
}
Log::debug(sprintf('Will now try to convert journal #%d', $journal->id));
@@ -221,7 +219,6 @@ class MigrateToGroups extends Command
$opposingTr = $this->findOpposingTransaction($journal, $transaction);
if (null === $opposingTr) {
-
$this->error(
sprintf(
'Journal #%d has no opposing transaction for transaction #%d. Cannot upgrade this entry.',
@@ -230,7 +227,6 @@ class MigrateToGroups extends Command
)
);
continue;
-
}
// overrule journal category with transaction category.
diff --git a/app/Console/Commands/Upgrade/MigrateToRules.php b/app/Console/Commands/Upgrade/MigrateToRules.php
index 6f726a6ac8..b07eec0547 100644
--- a/app/Console/Commands/Upgrade/MigrateToRules.php
+++ b/app/Console/Commands/Upgrade/MigrateToRules.php
@@ -166,7 +166,6 @@ class MigrateToRules extends Command
foreach ($bills as $bill) {
$this->migrateBill($ruleGroup, $bill, $lang);
}
-
}
/**
diff --git a/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php b/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php
index 4dbe770611..d5f00056f7 100644
--- a/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php
+++ b/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php
@@ -159,26 +159,25 @@ class OtherCurrenciesCorrections extends Command
$leadTransaction = $this->getLeadTransaction($journal);
if (null === $leadTransaction) {
-
$this->error(sprintf('Could not reliably determine which transaction is in the lead for transaction journal #%d.', $journal->id));
return;
-
}
$account = $leadTransaction->account;
$currency = $this->getCurrency($account);
if (null === $currency) {
-
$this->error(
sprintf(
- 'Account #%d ("%s") has no currency preference, so transaction journal #%d can\'t be corrected', $account->id, $account->name, $journal->id
+ 'Account #%d ("%s") has no currency preference, so transaction journal #%d can\'t be corrected',
+ $account->id,
+ $account->name,
+ $journal->id
)
);
$this->count++;
return;
-
}
// fix each transaction:
$journal->transactions->each(
@@ -227,13 +226,19 @@ class OtherCurrenciesCorrections extends Command
case TransactionType::OPENING_BALANCE:
// whichever isn't an initial balance account:
$lead = $journal->transactions()->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')->leftJoin(
- 'account_types', 'accounts.account_type_id', '=', 'account_types.id'
+ 'account_types',
+ 'accounts.account_type_id',
+ '=',
+ 'account_types.id'
)->where('account_types.type', '!=', AccountType::INITIAL_BALANCE)->first(['transactions.*']);
break;
case TransactionType::RECONCILIATION:
// whichever isn't the reconciliation account:
$lead = $journal->transactions()->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')->leftJoin(
- 'account_types', 'accounts.account_type_id', '=', 'account_types.id'
+ 'account_types',
+ 'accounts.account_type_id',
+ '=',
+ 'account_types.id'
)->where('account_types.type', '!=', AccountType::RECONCILIATION)->first(['transactions.*']);
break;
}
@@ -257,11 +262,9 @@ class OtherCurrenciesCorrections extends Command
}
$currency = $this->accountRepos->getAccountCurrency($account);
if (null === $currency) {
-
$this->accountCurrencies[$accountId] = 0;
return null;
-
}
$this->accountCurrencies[$accountId] = $currency;
diff --git a/app/Console/Commands/Upgrade/TransactionIdentifier.php b/app/Console/Commands/Upgrade/TransactionIdentifier.php
index 752743716c..4672508f16 100644
--- a/app/Console/Commands/Upgrade/TransactionIdentifier.php
+++ b/app/Console/Commands/Upgrade/TransactionIdentifier.php
@@ -163,7 +163,6 @@ class TransactionIdentifier extends Command
}
++$identifier;
}
-
}
/**
@@ -183,7 +182,6 @@ class TransactionIdentifier extends Command
->where('amount', $amount)->where('identifier', '=', 0)
->whereNotIn('id', $exclude)
->first();
-
} catch (QueryException $e) {
Log::error($e->getMessage());
$this->error('Firefly III could not find the "identifier" field in the "transactions" table.');
diff --git a/app/Console/Commands/Upgrade/TransferCurrenciesCorrections.php b/app/Console/Commands/Upgrade/TransferCurrenciesCorrections.php
index 6113eb260b..11827e8584 100644
--- a/app/Console/Commands/Upgrade/TransferCurrenciesCorrections.php
+++ b/app/Console/Commands/Upgrade/TransferCurrenciesCorrections.php
@@ -51,7 +51,7 @@ class TransferCurrenciesCorrections extends Command
*
* @var string
*/
- protected $signature = 'firefly-iii:transfer-currencies {--F|force : Force the execution of this command.}';
+ protected $signature = 'firefly-iii:transfer-currencies {--F|force : Force the execution of this command.}';
private array $accountCurrencies;
private AccountRepositoryInterface $accountRepos;
private JournalCLIRepositoryInterface $cliRepos;
@@ -284,11 +284,9 @@ class TransferCurrenciesCorrections extends Command
}
$currency = $this->accountRepos->getAccountCurrency($account);
if (null === $currency) {
-
$this->accountCurrencies[$accountId] = 0;
return null;
-
}
$this->accountCurrencies[$accountId] = $currency;
diff --git a/app/Console/Commands/Upgrade/UpgradeDatabase.php b/app/Console/Commands/Upgrade/UpgradeDatabase.php
index b064a06f6f..d97c14e576 100644
--- a/app/Console/Commands/Upgrade/UpgradeDatabase.php
+++ b/app/Console/Commands/Upgrade/UpgradeDatabase.php
@@ -55,7 +55,6 @@ class UpgradeDatabase extends Command
*/
public function handle(): int
{
-
$this->callInitialCommands();
$commands = [
// there are 14 upgrade commands.
diff --git a/app/Console/Commands/Upgrade/UpgradeLiabilities.php b/app/Console/Commands/Upgrade/UpgradeLiabilities.php
index 7d971a12f1..8fb175caff 100644
--- a/app/Console/Commands/Upgrade/UpgradeLiabilities.php
+++ b/app/Console/Commands/Upgrade/UpgradeLiabilities.php
@@ -201,5 +201,4 @@ class UpgradeLiabilities extends Command
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
}
-
}