mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 00:27:30 +00:00
Reformat various code.
This commit is contained in:
@@ -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));
|
||||
|
@@ -77,7 +77,7 @@ class AppendBudgetLimitPeriods extends Command
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
|
||||
return (bool)$configVar->data;
|
||||
return (bool) $configVar->data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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();
|
||||
|
@@ -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;
|
||||
|
@@ -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');
|
||||
|
||||
|
@@ -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' => [
|
||||
[
|
||||
|
@@ -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();
|
||||
|
@@ -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;
|
||||
|
@@ -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 */
|
||||
|
@@ -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(
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user