Reformat various code.

This commit is contained in:
James Cole
2022-03-29 14:56:27 +02:00
parent 9cdaf7076a
commit 1209c4e76a
145 changed files with 472 additions and 472 deletions

View File

@@ -155,7 +155,7 @@ class CorrectOpeningBalanceCurrencies extends Command
private function setCurrency(TransactionJournal $journal, TransactionCurrency $currency): int
{
$count = 0;
if ((int)$journal->transaction_currency_id !== (int)$currency->id) {
if ((int) $journal->transaction_currency_id !== (int) $currency->id) {
$journal->transaction_currency_id = $currency->id;
$journal->save();
$count = 1;
@@ -163,7 +163,7 @@ class CorrectOpeningBalanceCurrencies extends Command
/** @var Transaction $transaction */
foreach ($journal->transactions as $transaction) {
if ((int)$transaction->transaction_currency_id !== (int)$currency->id) {
if ((int) $transaction->transaction_currency_id !== (int) $currency->id) {
$transaction->transaction_currency_id = $currency->id;
$transaction->save();
$count = 1;

View File

@@ -73,18 +73,18 @@ class DeleteEmptyJournals extends Command
$total = 0;
/** @var Transaction $row */
foreach ($set as $row) {
$count = (int)$row->the_count;
$count = (int) $row->the_count;
if (1 === $count % 2) {
// uneven number, delete journal and transactions:
try {
TransactionJournal::find((int)$row->transaction_journal_id)->delete();
TransactionJournal::find((int) $row->transaction_journal_id)->delete();
} catch (Exception $e) { // @phpstan-ignore-line
Log::info(sprintf('Could not delete journal: %s', $e->getMessage()));
}
Transaction::where('transaction_journal_id', (int)$row->transaction_journal_id)->delete();
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));
$total++;
}

View File

@@ -84,7 +84,7 @@ class DeleteOrphanedTransactions extends Command
);
/** @var stdClass $entry */
foreach ($set as $entry) {
$transaction = Transaction::find((int)$entry->transaction_id);
$transaction = Transaction::find((int) $entry->transaction_id);
$transaction->delete();
$this->info(
sprintf(
@@ -106,7 +106,7 @@ class DeleteOrphanedTransactions extends Command
private function deleteFromOrphanedAccounts(): void
{
$set
= Transaction
= Transaction
::leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')
->whereNotNull('accounts.deleted_at')
->get(['transactions.*']);
@@ -114,7 +114,7 @@ class DeleteOrphanedTransactions extends Command
/** @var Transaction $transaction */
foreach ($set as $transaction) {
// delete journals
$journal = TransactionJournal::find((int)$transaction->transaction_journal_id);
$journal = TransactionJournal::find((int) $transaction->transaction_journal_id);
if ($journal) {
try {
$journal->delete();
@@ -124,7 +124,7 @@ class DeleteOrphanedTransactions extends Command
}
}
Transaction::where('transaction_journal_id', (int)$transaction->transaction_journal_id)->delete();
Transaction::where('transaction_journal_id', (int) $transaction->transaction_journal_id)->delete();
$this->line(
sprintf(
'Deleted transaction journal #%d because account #%d was already deleted.',

View File

@@ -63,30 +63,30 @@ class EnableCurrencies extends Command
/** @var Collection $meta */
$meta = AccountMeta::where('name', 'currency_id')->groupBy('data')->get(['data']);
foreach ($meta as $entry) {
$found[] = (int)$entry->data;
$found[] = (int) $entry->data;
}
// get all from journals:
$journals = TransactionJournal::groupBy('transaction_currency_id')->get(['transaction_currency_id']);
foreach ($journals as $entry) {
$found[] = (int)$entry->transaction_currency_id;
$found[] = (int) $entry->transaction_currency_id;
}
// get all from transactions
$transactions = Transaction::groupBy('transaction_currency_id', 'foreign_currency_id')->get(['transaction_currency_id', 'foreign_currency_id']);
foreach ($transactions as $entry) {
$found[] = (int)$entry->transaction_currency_id;
$found[] = (int)$entry->foreign_currency_id;
$found[] = (int) $entry->transaction_currency_id;
$found[] = (int) $entry->foreign_currency_id;
}
// get all from budget limits
$limits = BudgetLimit::groupBy('transaction_currency_id')->get(['transaction_currency_id']);
foreach ($limits as $entry) {
$found[] = (int)$entry->transaction_currency_id;
$found[] = (int) $entry->transaction_currency_id;
}
$found = array_values(array_unique($found));
$found = array_values(
$found = array_values(array_unique($found));
$found = array_values(
array_filter(
$found, function (int $currencyId) {
return $currencyId !== 0;

View File

@@ -88,7 +88,7 @@ class FixFrontpageAccounts extends Command
if (is_array($data)) {
/** @var string $accountId */
foreach ($data as $accountId) {
$accountIdInt = (int)$accountId;
$accountIdInt = (int) $accountId;
$account = $repository->find($accountIdInt);
if (null !== $account
&& in_array($account->accountType->type, [AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE], true)

View File

@@ -62,8 +62,8 @@ class FixGroupAccounts extends Command
->get(['transaction_group_id', DB::raw('COUNT(transaction_group_id) as the_count')]);
/** @var TransactionJournal $journal */
foreach ($res as $journal) {
if ((int)$journal->the_count > 1) {
$groups[] = (int)$journal->transaction_group_id;
if ((int) $journal->the_count > 1) {
$groups[] = (int) $journal->transaction_group_id;
}
}
$handler = new UpdatedGroupEventHandler;

View File

@@ -58,7 +58,7 @@ class FixIbans extends Command
$iban = $account->iban;
if (str_contains($iban, ' ')) {
$iban = app('steam')->filterSpaces((string)$account->iban);
$iban = app('steam')->filterSpaces((string) $account->iban);
if ('' !== $iban) {
$account->iban = $iban;
$account->save();

View File

@@ -68,7 +68,7 @@ class FixLongDescriptions extends Command
$groups = TransactionGroup::get(['id', 'title']);
/** @var TransactionGroup $group */
foreach ($groups as $group) {
if (strlen((string)$group->title) > self::MAX_LENGTH) {
if (strlen((string) $group->title) > self::MAX_LENGTH) {
$group->title = substr($group->title, 0, self::MAX_LENGTH);
$group->save();
$this->line(sprintf('Truncated description of transaction group #%d', $group->id));

View File

@@ -106,7 +106,7 @@ class FixTransactionTypes extends Command
return false;
}
$expectedType = (string)config(sprintf('firefly.account_to_transaction.%s.%s', $source->accountType->type, $destination->accountType->type));
$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"', $journal->id, $type, $expectedType));
$this->changeJournal($journal, $expectedType);

View File

@@ -65,11 +65,11 @@ class FixUnevenAmount extends Command
->get(['transaction_journal_id', DB::raw('SUM(amount) AS the_sum')]);
/** @var stdClass $entry */
foreach ($journals as $entry) {
if (0 !== bccomp((string)$entry->the_sum, '0')) {
if (0 !== bccomp((string) $entry->the_sum, '0')) {
$message = sprintf('Sum of journal #%d is %s instead of zero.', $entry->transaction_journal_id, $entry->the_sum);
$this->warn($message);
Log::warning($message);
$this->fixJournal((int)$entry->transaction_journal_id);
$this->fixJournal((int) $entry->transaction_journal_id);
$count++;
}
}
@@ -110,7 +110,7 @@ class FixUnevenAmount extends Command
return;
}
$amount = bcmul('-1', (string)$source->amount);
$amount = bcmul('-1', (string) $source->amount);
// fix amount of destination:
/** @var Transaction $destination */

View File

@@ -120,7 +120,7 @@ class DecryptDatabase extends Command
Log::error($e->getMessage());
}
if (null !== $configVar) {
return (bool)$configVar->data;
return (bool) $configVar->data;
}
return false;
@@ -150,7 +150,7 @@ class DecryptDatabase extends Command
if (null === $original) {
return;
}
$id = (int)$row->id;
$id = (int) $row->id;
$value = '';
try {
@@ -215,7 +215,7 @@ class DecryptDatabase extends Command
}
/** @var Preference $object */
$object = Preference::find((int)$id);
$object = Preference::find((int) $id);
if (null !== $object) {
$object->data = $newValue;
$object->save();

View File

@@ -202,7 +202,7 @@ class ExportData extends Command
$error = true;
}
}
if(null === $this->option($field)) {
if (null === $this->option($field)) {
Log::info(sprintf('No date given in field "%s"', $field));
$error = true;
}
@@ -234,7 +234,7 @@ class ExportData extends Command
$accounts = new Collection;
$accountList = $this->option('accounts');
$types = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE];
if (null !== $accountList && '' !== (string)$accountList) {
if (null !== $accountList && '' !== (string) $accountList) {
$accountIds = explode(',', $accountList);
$accounts = $this->accountRepository->getAccountsById($accountIds);
}
@@ -262,7 +262,7 @@ class ExportData extends Command
*/
private function getExportDirectory(): string
{
$directory = (string)$this->option('export_directory');
$directory = (string) $this->option('export_directory');
if (null === $directory) {
$directory = './';
}

View File

@@ -68,7 +68,7 @@ class ReportSum extends Command
/** @var User $user */
foreach ($userRepository->all() as $user) {
$sum = (string)$user->transactions()->sum('amount');
$sum = (string) $user->transactions()->sum('amount');
if (0 !== bccomp($sum, '0')) {
$message = sprintf('Error: Transactions for user #%d (%s) are off by %s!', $user->id, $user->email, $sum);
$this->error($message);

View File

@@ -75,7 +75,7 @@ class RestoreOAuthKeys extends Command
if ($this->keysInDatabase() && !$this->keysOnDrive()) {
Log::debug('Keys are in DB and keys are not on the drive. Restore.');
$result = $this->restoreKeysFromDB();
if(true === $result) {
if (true === $result) {
$this->line('Restored OAuth keys from database.');
return;

View File

@@ -212,7 +212,7 @@ class ApplyRules extends Command
$accountRepository = app(AccountRepositoryInterface::class);
$accountRepository->setUser($this->getUser());
foreach ($accountList as $accountId) {
$accountId = (int)$accountId;
$accountId = (int) $accountId;
$account = $accountRepository->find($accountId);
if (null !== $account && in_array($account->accountType->type, $this->acceptedAccounts, true)) {
$finalList->push($account);
@@ -243,7 +243,7 @@ class ApplyRules extends Command
$ruleGroupList = explode(',', $ruleGroupString);
foreach ($ruleGroupList as $ruleGroupId) {
$ruleGroup = $this->ruleGroupRepository->find((int)$ruleGroupId);
$ruleGroup = $this->ruleGroupRepository->find((int) $ruleGroupId);
if ($ruleGroup->active) {
$this->ruleGroupSelection[] = $ruleGroup->id;
}
@@ -268,7 +268,7 @@ class ApplyRules extends Command
$ruleList = explode(',', $ruleString);
foreach ($ruleList as $ruleId) {
$rule = $this->ruleRepository->find((int)$ruleId);
$rule = $this->ruleRepository->find((int) $ruleId);
if (null !== $rule && $rule->active) {
$this->ruleSelection[] = $rule->id;
}

View File

@@ -27,8 +27,8 @@ namespace FireflyIII\Console\Commands\Tools;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Support\Cronjobs\AutoBudgetCronjob;
use FireflyIII\Support\Cronjobs\RecurringCronjob;
use FireflyIII\Support\Cronjobs\BillWarningCronjob;
use FireflyIII\Support\Cronjobs\RecurringCronjob;
use Illuminate\Console\Command;
use InvalidArgumentException;
use Log;

View File

@@ -114,7 +114,7 @@ class AccountCurrencies extends Command
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool)$configVar->data;
return (bool) $configVar->data;
}
return false;
@@ -127,7 +127,7 @@ class AccountCurrencies extends Command
{
Log::debug('Now in updateAccountCurrencies()');
$users = $this->userRepos->all();
$defaultCurrencyCode = (string)config('firefly.default_currency', 'EUR');
$defaultCurrencyCode = (string) config('firefly.default_currency', 'EUR');
Log::debug(sprintf('Default currency is %s', $defaultCurrencyCode));
foreach ($users as $user) {
$this->updateCurrenciesForUser($user, $defaultCurrencyCode);
@@ -178,13 +178,13 @@ class AccountCurrencies extends Command
Log::debug(sprintf('Now in updateAccount(%d, %s)', $account->id, $currency->code));
$this->accountRepos->setUser($account->user);
$accountCurrency = (int)$this->accountRepos->getMetaValue($account, 'currency_id');
$accountCurrency = (int) $this->accountRepos->getMetaValue($account, 'currency_id');
Log::debug(sprintf('Account currency is #%d', $accountCurrency));
$openingBalance = $this->accountRepos->getOpeningBalance($account);
$obCurrency = 0;
if (null !== $openingBalance) {
$obCurrency = (int)$openingBalance->transaction_currency_id;
$obCurrency = (int) $openingBalance->transaction_currency_id;
Log::debug('Account has opening balance.');
}
Log::debug(sprintf('Account OB currency is #%d.', $obCurrency));

View File

@@ -77,7 +77,7 @@ class AppendBudgetLimitPeriods extends Command
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
return (bool)$configVar->data;
return (bool) $configVar->data;
}
/**

View File

@@ -91,7 +91,7 @@ class BackToJournals extends Command
{
$configVar = app('fireflyconfig')->get(MigrateToGroups::CONFIG_NAME, false);
return (bool)$configVar->data;
return (bool) $configVar->data;
}
/**
@@ -102,7 +102,7 @@ class BackToJournals extends Command
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
return (bool)$configVar->data;
return (bool) $configVar->data;
}
/**
@@ -179,7 +179,7 @@ class BackToJournals extends Command
// both have a budget, but they don't match.
if (null !== $budget && null !== $journalBudget && $budget->id !== $journalBudget->id) {
// sync to journal:
$journal->budgets()->sync([(int)$budget->id]);
$journal->budgets()->sync([(int) $budget->id]);
return;
}
@@ -187,7 +187,7 @@ class BackToJournals extends Command
// transaction has a budget, but the journal doesn't.
if (null !== $budget && null === $journalBudget) {
// sync to journal:
$journal->budgets()->sync([(int)$budget->id]);
$journal->budgets()->sync([(int) $budget->id]);
}
}
@@ -258,12 +258,12 @@ class BackToJournals extends Command
// both have a category, but they don't match.
if (null !== $category && null !== $journalCategory && $category->id !== $journalCategory->id) {
// sync to journal:
$journal->categories()->sync([(int)$category->id]);
$journal->categories()->sync([(int) $category->id]);
}
// transaction has a category, but the journal doesn't.
if (null !== $category && null === $journalCategory) {
$journal->categories()->sync([(int)$category->id]);
$journal->categories()->sync([(int) $category->id]);
}
}

View File

@@ -104,7 +104,7 @@ class BudgetLimitCurrency extends Command
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool)$configVar->data;
return (bool) $configVar->data;
}
return false;

View File

@@ -101,7 +101,7 @@ class CCLiabilities extends Command
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool)$configVar->data;
return (bool) $configVar->data;
}
return false;

View File

@@ -82,7 +82,7 @@ class CreateGroupMemberships extends Command
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool)$configVar->data;
return (bool) $configVar->data;
}
return false;

View File

@@ -72,7 +72,7 @@ class MigrateAttachments extends Command
foreach ($attachments as $att) {
// move description:
$attDescription = (string)$att->description;
$attDescription = (string) $att->description;
if ('' !== $attDescription) {
// find or create note:
@@ -113,7 +113,7 @@ class MigrateAttachments extends Command
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool)$configVar->data;
return (bool) $configVar->data;
}
return false;

View File

@@ -111,7 +111,7 @@ class MigrateJournalNotes extends Command
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool)$configVar->data;
return (bool) $configVar->data;
}
return false;

View File

@@ -89,7 +89,7 @@ class MigrateRecurrenceMeta extends Command
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool)$configVar->data;
return (bool) $configVar->data;
}
return false;

View File

@@ -82,7 +82,7 @@ class MigrateRecurrenceType extends Command
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool)$configVar->data;
return (bool) $configVar->data;
}
return false;
@@ -104,7 +104,7 @@ class MigrateRecurrenceType extends Command
private function migrateRecurrence(Recurrence $recurrence): void
{
$originalType = (int)$recurrence->transaction_type_id;
$originalType = (int) $recurrence->transaction_type_id;
$newType = $this->getInvalidType();
$recurrence->transaction_type_id = $newType->id;
$recurrence->save();

View File

@@ -80,7 +80,7 @@ class MigrateTagLocations extends Command
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool)$configVar->data;
return (bool) $configVar->data;
}
return false;

View File

@@ -134,7 +134,7 @@ class MigrateToGroups extends Command
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool)$configVar->data;
return (bool) $configVar->data;
}
return false;
@@ -328,7 +328,7 @@ class MigrateToGroups extends Command
{
$set = $journal->transactions->filter(
static function (Transaction $subject) use ($transaction) {
$amount = (float)$transaction->amount * -1 === (float)$subject->amount;
$amount = (float) $transaction->amount * -1 === (float) $subject->amount;
$identifier = $transaction->identifier === $subject->identifier;
Log::debug(sprintf('Amount the same? %s', var_export($amount, true)));
Log::debug(sprintf('ID the same? %s', var_export($identifier, true)));
@@ -356,7 +356,7 @@ class MigrateToGroups extends Command
if (null !== $budget) {
Log::debug(sprintf('Return budget #%d, from transaction #%d', $budget->id, $left->id));
return (int)$budget->id;
return (int) $budget->id;
}
// try to get a budget ID from the right transaction:
@@ -365,7 +365,7 @@ class MigrateToGroups extends Command
if (null !== $budget) {
Log::debug(sprintf('Return budget #%d, from transaction #%d', $budget->id, $right->id));
return (int)$budget->id;
return (int) $budget->id;
}
Log::debug('Neither left or right have a budget, return NULL');
@@ -389,7 +389,7 @@ class MigrateToGroups extends Command
if (null !== $category) {
Log::debug(sprintf('Return category #%d, from transaction #%d', $category->id, $left->id));
return (int)$category->id;
return (int) $category->id;
}
// try to get a category ID from the left transaction:
@@ -398,7 +398,7 @@ class MigrateToGroups extends Command
if (null !== $category) {
Log::debug(sprintf('Return category #%d, from transaction #%d', $category->id, $category->id));
return (int)$category->id;
return (int) $category->id;
}
Log::debug('Neither left or right have a category, return NULL');

View File

@@ -125,7 +125,7 @@ class MigrateToRules extends Command
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool)$configVar->data;
return (bool) $configVar->data;
}
return false;
@@ -146,14 +146,14 @@ class MigrateToRules extends Command
/** @var Preference $lang */
$lang = app('preferences')->getForUser($user, 'language', 'en_US');
$groupTitle = (string)trans('firefly.rulegroup_for_bills_title', [], $lang->data);
$groupTitle = (string) trans('firefly.rulegroup_for_bills_title', [], $lang->data);
$ruleGroup = $this->ruleGroupRepository->findByTitle($groupTitle);
if (null === $ruleGroup) {
$ruleGroup = $this->ruleGroupRepository->store(
[
'title' => (string)trans('firefly.rulegroup_for_bills_title', [], $lang->data),
'description' => (string)trans('firefly.rulegroup_for_bills_description', [], $lang->data),
'title' => (string) trans('firefly.rulegroup_for_bills_title', [], $lang->data),
'description' => (string) trans('firefly.rulegroup_for_bills_description', [], $lang->data),
'active' => true,
]
);
@@ -185,8 +185,8 @@ class MigrateToRules extends Command
'active' => true,
'strict' => false,
'stop_processing' => false, // field is no longer used.
'title' => (string)trans('firefly.rule_for_bill_title', ['name' => $bill->name], $language->data),
'description' => (string)trans('firefly.rule_for_bill_description', ['name' => $bill->name], $language->data),
'title' => (string) trans('firefly.rule_for_bill_title', ['name' => $bill->name], $language->data),
'description' => (string) trans('firefly.rule_for_bill_description', ['name' => $bill->name], $language->data),
'trigger' => 'store-journal',
'triggers' => [
[

View File

@@ -120,7 +120,7 @@ class OtherCurrenciesCorrections extends Command
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool)$configVar->data;
return (bool) $configVar->data;
}
return false;
@@ -187,8 +187,8 @@ class OtherCurrenciesCorrections extends Command
}
// when mismatch in transaction:
if ((int)$transaction->transaction_currency_id !== (int)$currency->id) {
$transaction->foreign_currency_id = (int)$transaction->transaction_currency_id;
if ((int) $transaction->transaction_currency_id !== (int) $currency->id) {
$transaction->foreign_currency_id = (int) $transaction->transaction_currency_id;
$transaction->foreign_amount = $transaction->amount;
$transaction->transaction_currency_id = $currency->id;
$transaction->save();

View File

@@ -104,7 +104,7 @@ class RenameAccountMeta extends Command
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool)$configVar->data;
return (bool) $configVar->data;
}
return false;

View File

@@ -128,7 +128,7 @@ class TransactionIdentifier extends Command
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool)$configVar->data;
return (bool) $configVar->data;
}
return false;
@@ -173,7 +173,7 @@ class TransactionIdentifier extends Command
private function findOpposing(Transaction $transaction, array $exclude): ?Transaction
{
// find opposing:
$amount = bcmul((string)$transaction->amount, '-1');
$amount = bcmul((string) $transaction->amount, '-1');
try {
/** @var Transaction $opposing */

View File

@@ -139,7 +139,7 @@ class TransferCurrenciesCorrections extends Command
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool)$configVar->data;
return (bool) $configVar->data;
}
return false;
@@ -368,7 +368,7 @@ class TransferCurrenciesCorrections extends Command
if (null === $this->sourceTransaction->transaction_currency_id && null !== $this->sourceCurrency) {
$this->sourceTransaction
->transaction_currency_id
= (int)$this->sourceCurrency->id;
= (int) $this->sourceCurrency->id;
$message = sprintf(
'Transaction #%d has no currency setting, now set to %s.',
$this->sourceTransaction->id,
@@ -389,7 +389,7 @@ class TransferCurrenciesCorrections extends Command
{
if (null !== $this->sourceCurrency
&& null === $this->sourceTransaction->foreign_amount
&& (int)$this->sourceTransaction->transaction_currency_id !== (int)$this->sourceCurrency->id
&& (int) $this->sourceTransaction->transaction_currency_id !== (int) $this->sourceCurrency->id
) {
$message = sprintf(
'Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',
@@ -401,7 +401,7 @@ class TransferCurrenciesCorrections extends Command
Log::debug($message);
$this->line($message);
$this->count++;
$this->sourceTransaction->transaction_currency_id = (int)$this->sourceCurrency->id;
$this->sourceTransaction->transaction_currency_id = (int) $this->sourceCurrency->id;
$this->sourceTransaction->save();
}
}
@@ -415,7 +415,7 @@ class TransferCurrenciesCorrections extends Command
if (null === $this->destinationTransaction->transaction_currency_id && null !== $this->destinationCurrency) {
$this->destinationTransaction
->transaction_currency_id
= (int)$this->destinationCurrency->id;
= (int) $this->destinationCurrency->id;
$message = sprintf(
'Transaction #%d has no currency setting, now set to %s.',
$this->destinationTransaction->id,
@@ -436,7 +436,7 @@ class TransferCurrenciesCorrections extends Command
{
if (null !== $this->destinationCurrency
&& null === $this->destinationTransaction->foreign_amount
&& (int)$this->destinationTransaction->transaction_currency_id !== (int)$this->destinationCurrency->id
&& (int) $this->destinationTransaction->transaction_currency_id !== (int) $this->destinationCurrency->id
) {
$message = sprintf(
'Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',
@@ -448,7 +448,7 @@ class TransferCurrenciesCorrections extends Command
Log::debug($message);
$this->line($message);
$this->count++;
$this->destinationTransaction->transaction_currency_id = (int)$this->destinationCurrency->id;
$this->destinationTransaction->transaction_currency_id = (int) $this->destinationCurrency->id;
$this->destinationTransaction->save();
}
}
@@ -460,7 +460,7 @@ class TransferCurrenciesCorrections extends Command
*/
private function fixInvalidForeignCurrency(): void
{
if ((int)$this->destinationCurrency->id === (int)$this->sourceCurrency->id) {
if ((int) $this->destinationCurrency->id === (int) $this->sourceCurrency->id) {
// update both transactions to match:
$this->sourceTransaction->foreign_amount = null;
$this->sourceTransaction->foreign_currency_id = null;
@@ -494,7 +494,7 @@ class TransferCurrenciesCorrections extends Command
*/
private function fixMismatchedForeignCurrency(): void
{
if ((int)$this->sourceCurrency->id !== (int)$this->destinationCurrency->id) {
if ((int) $this->sourceCurrency->id !== (int) $this->destinationCurrency->id) {
$this->sourceTransaction->transaction_currency_id = $this->sourceCurrency->id;
$this->sourceTransaction->foreign_currency_id = $this->destinationCurrency->id;
$this->destinationTransaction->transaction_currency_id = $this->sourceCurrency->id;
@@ -514,7 +514,7 @@ class TransferCurrenciesCorrections extends Command
private function fixSourceNullForeignAmount(): void
{
if (null === $this->sourceTransaction->foreign_amount && null !== $this->destinationTransaction->foreign_amount) {
$this->sourceTransaction->foreign_amount = bcmul((string)$this->destinationTransaction->foreign_amount, '-1');
$this->sourceTransaction->foreign_amount = bcmul((string) $this->destinationTransaction->foreign_amount, '-1');
$this->sourceTransaction->save();
$this->count++;
Log::debug(
@@ -534,7 +534,7 @@ class TransferCurrenciesCorrections extends Command
private function fixDestNullForeignAmount(): void
{
if (null === $this->destinationTransaction->foreign_amount && null !== $this->sourceTransaction->foreign_amount) {
$this->destinationTransaction->foreign_amount = bcmul((string)$this->sourceTransaction->foreign_amount, '-1');
$this->destinationTransaction->foreign_amount = bcmul((string) $this->sourceTransaction->foreign_amount, '-1');
$this->destinationTransaction->save();
$this->count++;
Log::debug(
@@ -554,7 +554,7 @@ class TransferCurrenciesCorrections extends Command
*/
private function fixTransactionJournalCurrency(TransactionJournal $journal): void
{
if ((int)$journal->transaction_currency_id !== (int)$this->sourceCurrency->id) {
if ((int) $journal->transaction_currency_id !== (int) $this->sourceCurrency->id) {
$oldCurrencyCode = $journal->transactionCurrency->code ?? '(nothing)';
$journal->transaction_currency_id = $this->sourceCurrency->id;
$message = sprintf(

View File

@@ -120,9 +120,9 @@ class UpgradeDatabase extends Command
echo $result;
}
// set new DB version.
app('fireflyconfig')->set('db_version', (int)config('firefly.db_version'));
app('fireflyconfig')->set('db_version', (int) config('firefly.db_version'));
// index will set FF3 version.
app('fireflyconfig')->set('ff3_version', (string)config('firefly.version'));
app('fireflyconfig')->set('ff3_version', (string) config('firefly.version'));
return 0;
}

View File

@@ -86,7 +86,7 @@ class UpgradeLiabilities extends Command
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool)$configVar->data;
return (bool) $configVar->data;
}
return false;
@@ -159,10 +159,10 @@ class UpgradeLiabilities extends Command
return;
}
// source MUST be the liability.
if ((int)$destination->account_id === (int)$account->id) {
if ((int) $destination->account_id === (int) $account->id) {
Log::debug(sprintf('Must switch around, because account #%d is the destination.', $destination->account_id));
// so if not, switch things around:
$sourceAccountId = (int)$source->account_id;
$sourceAccountId = (int) $source->account_id;
$source->account_id = $destination->account_id;
$destination->account_id = $sourceAccountId;
$source->save();

View File

@@ -54,10 +54,10 @@ class UpgradeFireflyInstructions extends Command
public function handle(): int
{
$this->generateInstallationId();
if ('update' === (string)$this->argument('task')) {
if ('update' === (string) $this->argument('task')) {
$this->updateInstructions();
}
if ('install' === (string)$this->argument('task')) {
if ('install' === (string) $this->argument('task')) {
$this->installInstructions();
}

View File

@@ -43,7 +43,7 @@ trait VerifiesAccessToken
*/
public function getUser(): User
{
$userId = (int)$this->option('user');
$userId = (int) $this->option('user');
/** @var UserRepositoryInterface $repository */
$repository = app(UserRepositoryInterface::class);
$user = $repository->find($userId);
@@ -71,8 +71,8 @@ trait VerifiesAccessToken
*/
protected function verifyAccessToken(): bool
{
$userId = (int)$this->option('user');
$token = (string)$this->option('token');
$userId = (int) $this->option('user');
$token = (string) $this->option('token');
/** @var UserRepositoryInterface $repository */
$repository = app(UserRepositoryInterface::class);
$user = $repository->find($userId);