Skip to content

Firefly III: a personal finances manager

[chore] fix phpstan errors.

James Cole053b46ae63ab
diff --git a/.ci/phpstan.neon b/.ci/phpstan.neon
index 67f32eff3e..be6038a047 100644
--- a/.ci/phpstan.neon
+++ b/.ci/phpstan.neon
@@ -16,6 +16,9 @@ parameters:
- '#Dynamic call to static method#' # all the Laravel ORM things depend on this.
- identifier: varTag.nativeType
- identifier: varTag.type
+ -
+ identifier: larastan.noEnvCallsOutsideOfConfig
+ path: ../app/Console/Commands/System/CreatesDatabase.php
- identifier: missingType.iterableValue # not interesting enough to fix.
- identifier: missingType.generics # not interesting enough to fix.
- "#Parameter \\#[1-2] \\$num[1-2] of function bc[a-z]+ expects numeric-string, [a-z\\-|&]+ given#"
@@ -28,49 +31,6 @@ parameters:
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Relations\\HasMany::withTrashed#'
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Relations\\HasMany::accountTypeIn#'
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Relations\\BelongsTo::withTrashed#'
- # - '#Control structures using switch should not be used.#' # switch is fine in some cases.
- # - '#with no value type specified in iterable type array#' # remove this rule when all other issues are solved.
- # - '#has no value type specified in iterable type array#' # remove this rule when all other issues are solved.
- # - '#is not allowed to extend#'
- # - '#does not specify its types#'
- # - '#switch is forbidden to use#'
- # - '#is neither abstract nor final#'
- # - '#on left side of \?\?\= always exists and is not nullable#'
- # - '#has a nullable return type declaration#' # perhaps throw errors instead?
- # - '#with a nullable type declaration#' # decide what action should be if param is null.
- # - '#with null as default value#'
- # -
- # message: '#Constructor in [a-zA-Z0-9\\_]+ has parameter \$[a-zA-Z0-9\\_]+ with default value#'
- # paths:
- # - ../app/Exceptions/IntervalException.php
- # - ../app/Support/Navigation.php
- # -
- # message: '#but containers should not be injected#'
- # paths:
- # - ../app/Support/Authentication/RemoteUserGuard.php
- # -
- # message: '#Function compact\(\) should not be used#' # too useful in template rendering.
- # paths:
- # - ../app/Generator/Report/Account/MonthReportGenerator.php
- # - ../app/Generator/Report/Audit/MonthReportGenerator.php
- # - ../app/Generator/Report/Budget/MonthReportGenerator.php
- # - ../app/Generator/Report/Category/MonthReportGenerator.php
- # - ../app/Generator/Report/Standard/MonthReportGenerator.php
- # - ../app/Generator/Report/Standard/MultiYearReportGenerator.php
- # - ../app/Generator/Report/Standard/YearReportGenerator.php
- # - ../app/Generator/Report/Tag/MonthReportGenerator.php
- # - ../app/Http/Controllers/Account/*.php
- # - ../app/Http/Controllers/Admin/*.php
- # - ../app/Http/Controllers/*.php
- # - ../app/Support/ExpandedForm.php
- # - ../app/Support/Form/AccountForm.php
- # - ../app/Support/Form/CurrencyForm.php
- # - ../app/Support/Form/FormSupport.php
- # -
- # message: '#Either catch a more specific exception#'
- # paths:
- # - ../app/Support/Form/FormSupport.php
-
# The level 8 is the highest level. original was 5
# 7 is more than enough, higher just leaves NULL things.
diff --git a/app/Api/V1/Controllers/Controller.php b/app/Api/V1/Controllers/Controller.php
index b7a2638b51..d43423d082 100644
--- a/app/Api/V1/Controllers/Controller.php
+++ b/app/Api/V1/Controllers/Controller.php
@@ -80,7 +80,7 @@ abstract class Controller extends BaseController
if (auth()->check()) {
$language = Steam::getLanguage();
$this->convertToNative = Amount::convertToNative();
- $this->defaultCurrency = Amount::getDefaultCurrency();
+ $this->defaultCurrency = Amount::getNativeCurrency();
app()->setLocale($language);
}
diff --git a/app/Api/V1/Controllers/Insight/Expense/BillController.php b/app/Api/V1/Controllers/Insight/Expense/BillController.php
index 10a89eff60..4858e0c965 100644
--- a/app/Api/V1/Controllers/Insight/Expense/BillController.php
+++ b/app/Api/V1/Controllers/Insight/Expense/BillController.php
@@ -70,7 +70,7 @@ class BillController extends Controller
$start = $request->getStart();
$end = $request->getEnd();
$convertToNative = Amount::convertToNative();
- $default = Amount::getDefaultCurrency();
+ $default = Amount::getNativeCurrency();
$response = [];
// get all bills:
@@ -133,7 +133,7 @@ class BillController extends Controller
$start = $request->getStart();
$end = $request->getEnd();
$convertToNative = Amount::convertToNative();
- $default = Amount::getDefaultCurrency();
+ $default = Amount::getNativeCurrency();
$response = [];
// collect all expenses in this period (regardless of type) by the given bills and accounts.
diff --git a/app/Api/V1/Controllers/Insight/Expense/PeriodController.php b/app/Api/V1/Controllers/Insight/Expense/PeriodController.php
index b4d2c42450..3b5316dd10 100644
--- a/app/Api/V1/Controllers/Insight/Expense/PeriodController.php
+++ b/app/Api/V1/Controllers/Insight/Expense/PeriodController.php
@@ -48,7 +48,7 @@ class PeriodController extends Controller
$end = $request->getEnd();
$response = [];
$convertToNative = Amount::convertToNative();
- $default = Amount::getDefaultCurrency();
+ $default = Amount::getNativeCurrency();
// collect all expenses in this period (regardless of type)
$collector = app(GroupCollectorInterface::class);
diff --git a/app/Api/V1/Controllers/Insight/Expense/TagController.php b/app/Api/V1/Controllers/Insight/Expense/TagController.php
index 83f43eee37..ce58076857 100644
--- a/app/Api/V1/Controllers/Insight/Expense/TagController.php
+++ b/app/Api/V1/Controllers/Insight/Expense/TagController.php
@@ -69,7 +69,7 @@ class TagController extends Controller
$end = $request->getEnd();
$response = [];
$convertToNative = Amount::convertToNative();
- $default = Amount::getDefaultCurrency();
+ $default = Amount::getNativeCurrency();
// collect all expenses in this period (regardless of type) by the given bills and accounts.
$collector = app(GroupCollectorInterface::class);
diff --git a/app/Api/V1/Controllers/Insight/Income/PeriodController.php b/app/Api/V1/Controllers/Insight/Income/PeriodController.php
index 89d4c251c5..6c720700a3 100644
--- a/app/Api/V1/Controllers/Insight/Income/PeriodController.php
+++ b/app/Api/V1/Controllers/Insight/Income/PeriodController.php
@@ -47,7 +47,7 @@ class PeriodController extends Controller
$end = $request->getEnd();
$response = [];
$convertToNative = Amount::convertToNative();
- $default = Amount::getDefaultCurrency();
+ $default = Amount::getNativeCurrency();
// collect all expenses in this period (regardless of type)
$collector = app(GroupCollectorInterface::class);
diff --git a/app/Api/V1/Controllers/Insight/Income/TagController.php b/app/Api/V1/Controllers/Insight/Income/TagController.php
index e81186582e..f7cffd7f3a 100644
--- a/app/Api/V1/Controllers/Insight/Income/TagController.php
+++ b/app/Api/V1/Controllers/Insight/Income/TagController.php
@@ -69,7 +69,7 @@ class TagController extends Controller
$end = $request->getEnd();
$response = [];
$convertToNative = Amount::convertToNative();
- $default = Amount::getDefaultCurrency();
+ $default = Amount::getNativeCurrency();
// collect all expenses in this period (regardless of type) by the given bills and accounts.
$collector = app(GroupCollectorInterface::class);
diff --git a/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php b/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php
index a0d8213d5c..31a8b0886a 100644
--- a/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php
+++ b/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php
@@ -47,7 +47,7 @@ class PeriodController extends Controller
$end = $request->getEnd();
$response = [];
$convertToNative = Amount::convertToNative();
- $default = Amount::getDefaultCurrency();
+ $default = Amount::getNativeCurrency();
// collect all expenses in this period (regardless of type)
$collector = app(GroupCollectorInterface::class);
diff --git a/app/Api/V1/Controllers/Insight/Transfer/TagController.php b/app/Api/V1/Controllers/Insight/Transfer/TagController.php
index 1f83e6f823..6950f513e2 100644
--- a/app/Api/V1/Controllers/Insight/Transfer/TagController.php
+++ b/app/Api/V1/Controllers/Insight/Transfer/TagController.php
@@ -67,7 +67,7 @@ class TagController extends Controller
$end = $request->getEnd();
$response = [];
$convertToNative = Amount::convertToNative();
- $default = Amount::getDefaultCurrency();
+ $default = Amount::getNativeCurrency();
// collect all expenses in this period (regardless of type) by the given bills and accounts.
diff --git a/app/Api/V1/Controllers/Summary/BasicController.php b/app/Api/V1/Controllers/Summary/BasicController.php
index cea491fc4d..c5d94132a0 100644
--- a/app/Api/V1/Controllers/Summary/BasicController.php
+++ b/app/Api/V1/Controllers/Summary/BasicController.php
@@ -124,7 +124,7 @@ class BasicController extends Controller
{
// some config settings
$convertToNative = Amount::convertToNative();
- $default = Amount::getDefaultCurrency();
+ $default = Amount::getNativeCurrency();
// prep some arrays:
$incomes = [];
$expenses = [];
diff --git a/app/Api/V2/Controllers/Autocomplete/AccountController.php b/app/Api/V2/Controllers/Autocomplete/AccountController.php
index 1531c70ae0..946828aafb 100644
--- a/app/Api/V2/Controllers/Autocomplete/AccountController.php
+++ b/app/Api/V2/Controllers/Autocomplete/AccountController.php
@@ -55,7 +55,7 @@ class AccountController extends Controller
$userGroup = $this->validateUserGroup($request);
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUserGroup($userGroup);
- $this->default = app('amount')->getDefaultCurrency();
+ $this->default = app('amount')->getNativeCurrency();
$this->converter = app(ExchangeRateConverter::class);
return $next($request);
diff --git a/app/Api/V2/Controllers/Chart/AccountController.php b/app/Api/V2/Controllers/Chart/AccountController.php
index 1a75860b32..699774cf02 100644
--- a/app/Api/V2/Controllers/Chart/AccountController.php
+++ b/app/Api/V2/Controllers/Chart/AccountController.php
@@ -57,7 +57,7 @@ class AccountController extends Controller
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
$this->chartData = new ChartData();
- $this->default = app('amount')->getDefaultCurrency();
+ $this->default = app('amount')->getNativeCurrency();
return $next($request);
}
diff --git a/app/Api/V2/Controllers/Chart/BalanceController.php b/app/Api/V2/Controllers/Chart/BalanceController.php
index 89a1c9f8cd..d462695bf4 100644
--- a/app/Api/V2/Controllers/Chart/BalanceController.php
+++ b/app/Api/V2/Controllers/Chart/BalanceController.php
@@ -62,7 +62,7 @@ class BalanceController extends Controller
$this->repository->setUserGroup($userGroup);
$this->collector->setUserGroup($userGroup);
$this->chartData = new ChartData();
- // $this->default = app('amount')->getDefaultCurrency();
+ // $this->default = app('amount')->getNativeCurrency();
return $next($request);
}
@@ -87,7 +87,7 @@ class BalanceController extends Controller
// prepare for currency conversion and data collection:
/** @var TransactionCurrency $default */
- $default = app('amount')->getDefaultCurrency();
+ $default = app('amount')->getNativeCurrency();
// get journals for entire period:
diff --git a/app/Api/V2/Controllers/Chart/BudgetController.php b/app/Api/V2/Controllers/Chart/BudgetController.php
index b24f446a8a..3f730c587e 100644
--- a/app/Api/V2/Controllers/Chart/BudgetController.php
+++ b/app/Api/V2/Controllers/Chart/BudgetController.php
@@ -63,7 +63,7 @@ class BudgetController extends Controller
$this->repository = app(BudgetRepositoryInterface::class);
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->opsRepository = app(OperationsRepositoryInterface::class);
- $this->currency = app('amount')->getDefaultCurrency();
+ $this->currency = app('amount')->getNativeCurrency();
$userGroup = $this->validateUserGroup($request);
$this->repository->setUserGroup($userGroup);
$this->opsRepository->setUserGroup($userGroup);
diff --git a/app/Api/V2/Controllers/Chart/CategoryController.php b/app/Api/V2/Controllers/Chart/CategoryController.php
index 5dd6f107d0..893e718445 100644
--- a/app/Api/V2/Controllers/Chart/CategoryController.php
+++ b/app/Api/V2/Controllers/Chart/CategoryController.php
@@ -82,7 +82,7 @@ class CategoryController extends Controller
/** @var Carbon $end */
$end = $this->parameters->get('end');
$accounts = $this->accountRepos->getAccountsByType([AccountTypeEnum::DEBT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::ASSET->value, AccountTypeEnum::DEFAULT->value]);
- $default = app('amount')->getDefaultCurrency();
+ $default = app('amount')->getNativeCurrency();
$converter = new ExchangeRateConverter();
$currencies = [];
$return = [];
diff --git a/app/Api/V2/Controllers/Summary/BasicController.php b/app/Api/V2/Controllers/Summary/BasicController.php
index 1d988dba83..3f14113f43 100644
--- a/app/Api/V2/Controllers/Summary/BasicController.php
+++ b/app/Api/V2/Controllers/Summary/BasicController.php
@@ -118,7 +118,7 @@ class BasicController extends Controller
private function getBalanceInformation(Carbon $start, Carbon $end): array
{
$object = new SummaryBalanceGrouped();
- $default = app('amount')->getDefaultCurrency();
+ $default = app('amount')->getNativeCurrency();
$object->setDefault($default);
@@ -233,7 +233,7 @@ class BasicController extends Controller
$available = $this->abRepository->getAvailableBudgetWithCurrency($start, $end);
$budgets = $this->budgetRepository->getActiveBudgets();
$spent = $this->opsRepository->listExpenses($start, $end, null, $budgets);
- $default = app('amount')->getDefaultCurrency();
+ $default = app('amount')->getNativeCurrency();
$currencies = [];
$converter = new ExchangeRateConverter();
diff --git a/app/Console/Commands/System/CreatesDatabase.php b/app/Console/Commands/System/CreatesDatabase.php
index e74b9c6021..97d644445f 100644
--- a/app/Console/Commands/System/CreatesDatabase.php
+++ b/app/Console/Commands/System/CreatesDatabase.php
@@ -38,7 +38,7 @@ class CreatesDatabase extends Command
public function handle(): int
{
- if ('mysql' !== env('DB_CONNECTION')) {
+ if ('mysql' !== env('DB_CONNECTION')) { // @phpstan-ignore larastan.noEnvCallsOutsideOfConfig */
$this->friendlyInfo(sprintf('CreateDB does not apply to "%s", skipped.', env('DB_CONNECTION')));
return 0;
@@ -60,7 +60,7 @@ class CreatesDatabase extends Command
// when it fails, display error
try {
- $pdo = new \PDO($dsn, env('DB_USERNAME'), env('DB_PASSWORD'), $options);
+ $pdo = new \PDO($dsn, (string) env('DB_USERNAME'), (string) env('DB_PASSWORD'), $options);
} catch (\PDOException $e) {
$this->friendlyError(sprintf('Error when connecting to DB: %s', $e->getMessage()));
diff --git a/app/Factory/PiggyBankFactory.php b/app/Factory/PiggyBankFactory.php
index 199f324b75..fbe1b450fb 100644
--- a/app/Factory/PiggyBankFactory.php
+++ b/app/Factory/PiggyBankFactory.php
@@ -121,7 +121,7 @@ class PiggyBankFactory
private function getCurrency(array $data): TransactionCurrency
{
// currency:
- $defaultCurrency = app('amount')->getDefaultCurrency();
+ $defaultCurrency = app('amount')->getNativeCurrency();
$currency = null;
if (array_key_exists('transaction_currency_code', $data)) {
$currency = $this->currencyRepository->findByCode((string) ($data['transaction_currency_code'] ?? ''));
diff --git a/app/Helpers/Report/NetWorth.php b/app/Helpers/Report/NetWorth.php
index c6dfee68a7..4297f835dd 100644
--- a/app/Helpers/Report/NetWorth.php
+++ b/app/Helpers/Report/NetWorth.php
@@ -77,7 +77,7 @@ class NetWorth implements NetWorthInterface
return $cache->get();
}
Log::debug(sprintf('Now in byAccounts("%s", "%s")', $ids, $date->format('Y-m-d H:i:s')));
- $default = Amount::getDefaultCurrency();
+ $default = Amount::getNativeCurrency();
$netWorth = [];
$balances = Steam::finalAccountsBalance($accounts, $date);
diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php
index eacaa061f1..d472a8a6da 100644
--- a/app/Http/Controllers/Controller.php
+++ b/app/Http/Controllers/Controller.php
@@ -118,7 +118,7 @@ abstract class Controller extends BaseController
$this->defaultCurrency =null;
// get shown-intro-preference:
if (auth()->check()) {
- $this->defaultCurrency = Amount::getDefaultCurrency();
+ $this->defaultCurrency = Amount::getNativeCurrency();
$language = Steam::getLanguage();
$locale = Steam::getLocale();
$darkMode = app('preferences')->get('darkMode', 'browser')->data;
diff --git a/app/Http/Controllers/UserGroup/EditController.php b/app/Http/Controllers/UserGroup/EditController.php
index 476b6ec9b1..d0c4ea9a80 100644
--- a/app/Http/Controllers/UserGroup/EditController.php
+++ b/app/Http/Controllers/UserGroup/EditController.php
@@ -42,8 +42,7 @@ class EditController extends Controller
$mainTitleIcon = 'fa-book';
app('log')->debug(sprintf('Now at %s', __METHOD__));
- return view('administrations.edit') // @phpstan-ignore-line
- ->with(compact('title', 'subTitle', 'mainTitleIcon'))
+ return view('administrations.edit')->with(compact('title', 'subTitle', 'mainTitleIcon'))
;
}
}
diff --git a/app/Http/Middleware/InterestingMessage.php b/app/Http/Middleware/InterestingMessage.php
index f61399d6ce..27e5cc7b9f 100644
--- a/app/Http/Middleware/InterestingMessage.php
+++ b/app/Http/Middleware/InterestingMessage.php
@@ -159,6 +159,7 @@ class InterestingMessage
/** @var User $user */
$user = auth()->user();
+ /** @var UserGroup|null $userGroup */
$userGroup = UserGroup::find($userGroupId);
$valid = false;
$memberships = $user->groupMemberships()->get();
diff --git a/app/Http/Middleware/Range.php b/app/Http/Middleware/Range.php
index 3e0dc65f63..60ca8eee65 100644
--- a/app/Http/Middleware/Range.php
+++ b/app/Http/Middleware/Range.php
@@ -118,7 +118,7 @@ class Range
// save some formats:
$monthAndDayFormat = (string) trans('config.month_and_day_js', [], $locale);
$dateTimeFormat = (string) trans('config.date_time_js', [], $locale);
- $defaultCurrency = Amount::getDefaultCurrency();
+ $defaultCurrency = Amount::getNativeCurrency();
// also format for moment JS:
$madMomentJS = (string) trans('config.month_and_day_moment_js', [], $locale);
diff --git a/app/Http/Requests/PiggyBankStoreRequest.php b/app/Http/Requests/PiggyBankStoreRequest.php
index 5dfe510745..ddef5126e3 100644
--- a/app/Http/Requests/PiggyBankStoreRequest.php
+++ b/app/Http/Requests/PiggyBankStoreRequest.php
@@ -126,7 +126,7 @@ class PiggyBankStoreRequest extends FormRequest
$currencyId = (int) ($data['transaction_currency_id'] ?? 0);
$currency = TransactionCurrency::find($currencyId);
if (null === $currency) {
- return Amount::getDefaultCurrency();
+ return Amount::getNativeCurrency();
}
return $currency;
diff --git a/app/Http/Requests/PiggyBankUpdateRequest.php b/app/Http/Requests/PiggyBankUpdateRequest.php
index e3deddb188..249d948478 100644
--- a/app/Http/Requests/PiggyBankUpdateRequest.php
+++ b/app/Http/Requests/PiggyBankUpdateRequest.php
@@ -129,7 +129,7 @@ class PiggyBankUpdateRequest extends FormRequest
$currencyId = (int) ($data['transaction_currency_id'] ?? 0);
$currency = TransactionCurrency::find($currencyId);
if (null === $currency) {
- return Amount::getDefaultCurrency();
+ return Amount::getNativeCurrency();
}
return $currency;
diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php
index 5893cc7541..1966133d5d 100644
--- a/app/Repositories/Account/AccountRepository.php
+++ b/app/Repositories/Account/AccountRepository.php
@@ -355,7 +355,7 @@ class AccountRepository implements AccountRepositoryInterface
if (AccountTypeEnum::ASSET->value !== $account->accountType->type) {
throw new FireflyException(sprintf('%s is not an asset account.', $account->name));
}
- $currency = $this->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();
+ $currency = $this->getAccountCurrency($account) ?? app('amount')->getNativeCurrency();
$name = trans('firefly.reconciliation_account_name', ['name' => $account->name, 'currency' => $currency->code]);
/** @var AccountType $type */
diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php
index 35f58db12e..1d8bb2ebd2 100644
--- a/app/Repositories/Bill/BillRepository.php
+++ b/app/Repositories/Bill/BillRepository.php
@@ -275,7 +275,7 @@ class BillRepository implements BillRepositoryInterface
];
$result[$currencyId]['sum'] = bcadd($result[$currencyId]['sum'], $transaction->amount);
$result[$currencyId]['native_sum'] = bcadd($result[$currencyId]['native_sum'], $transaction->native_amount ?? '0');
- if ($journal->foreign_currency_id === Amount::getDefaultCurrency()->id) {
+ if ($journal->foreign_currency_id === Amount::getNativeCurrency()->id) {
$result[$currencyId]['native_sum'] = bcadd($result[$currencyId]['native_sum'], $transaction->amount);
}
++$result[$currencyId]['count'];
@@ -406,7 +406,7 @@ class BillRepository implements BillRepositoryInterface
];
$result[$currencyId]['sum'] = bcadd($result[$currencyId]['sum'], $transaction->amount);
$result[$currencyId]['native_sum'] = bcadd($result[$currencyId]['native_sum'], $transaction->native_amount ?? '0');
- if ($journal->foreign_currency_id === Amount::getDefaultCurrency()->id) {
+ if ($journal->foreign_currency_id === Amount::getNativeCurrency()->id) {
$result[$currencyId]['native_sum'] = bcadd($result[$currencyId]['native_sum'], $transaction->amount);
}
++$result[$currencyId]['count'];
@@ -530,7 +530,7 @@ class BillRepository implements BillRepositoryInterface
$bills = $this->getActiveBills();
$return = [];
$convertToNative = Amount::convertToNative($this->user);
- $default = app('amount')->getDefaultCurrency();
+ $default = app('amount')->getNativeCurrency();
/** @var Bill $bill */
foreach ($bills as $bill) {
@@ -575,7 +575,7 @@ class BillRepository implements BillRepositoryInterface
$bills = $this->getActiveBills();
$return = [];
$convertToNative = Amount::convertToNative($this->user);
- $default = app('amount')->getDefaultCurrency();
+ $default = app('amount')->getNativeCurrency();
/** @var Bill $bill */
foreach ($bills as $bill) {
diff --git a/app/Repositories/Budget/AvailableBudgetRepository.php b/app/Repositories/Budget/AvailableBudgetRepository.php
index fd9f1f4d5b..f991ed0d99 100644
--- a/app/Repositories/Budget/AvailableBudgetRepository.php
+++ b/app/Repositories/Budget/AvailableBudgetRepository.php
@@ -142,7 +142,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
// use native amount if necessary?
$convertToNative = Amount::convertToNative($this->user);
- $default = Amount::getDefaultCurrency();
+ $default = Amount::getNativeCurrency();
/** @var AvailableBudget $availableBudget */
foreach ($availableBudgets as $availableBudget) {
diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php
index 153e01b906..452f62e4d0 100644
--- a/app/Repositories/Budget/BudgetRepository.php
+++ b/app/Repositories/Budget/BudgetRepository.php
@@ -89,7 +89,7 @@ class BudgetRepository implements BudgetRepositoryInterface
$limitRepository = app(BudgetLimitRepository::class);
$limitRepository->setUser($this->user);
$budgets = $this->getActiveBudgets();
- $defaultCurrency = app('amount')->getDefaultCurrency();
+ $defaultCurrency = app('amount')->getNativeCurrency();
$converter = new ExchangeRateConverter();
/** @var Budget $budget */
diff --git a/app/Repositories/Category/OperationsRepository.php b/app/Repositories/Category/OperationsRepository.php
index 6a5fa3a77b..0845ddfa10 100644
--- a/app/Repositories/Category/OperationsRepository.php
+++ b/app/Repositories/Category/OperationsRepository.php
@@ -364,7 +364,7 @@ class OperationsRepository implements OperationsRepositoryInterface
$collector->setCategories($categories);
$journals = $collector->getExtractedJournals();
$convertToNative = Amount::convertToNative($this->user);
- $default = Amount::getDefaultCurrency();
+ $default = Amount::getNativeCurrency();
$array = [];
foreach ($journals as $journal) {
diff --git a/app/Repositories/UserGroups/Bill/BillRepository.php b/app/Repositories/UserGroups/Bill/BillRepository.php
index a6fc1e71b2..ffeb688792 100644
--- a/app/Repositories/UserGroups/Bill/BillRepository.php
+++ b/app/Repositories/UserGroups/Bill/BillRepository.php
@@ -69,7 +69,7 @@ class BillRepository implements BillRepositoryInterface
{
Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));
$bills = $this->getActiveBills();
- $default = app('amount')->getDefaultCurrency();
+ $default = app('amount')->getNativeCurrency();
$return = [];
$converter = new ExchangeRateConverter();
@@ -139,7 +139,7 @@ class BillRepository implements BillRepositoryInterface
Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));
$bills = $this->getActiveBills();
$return = [];
- $default = app('amount')->getDefaultCurrency();
+ $default = app('amount')->getNativeCurrency();
$converter = new ExchangeRateConverter();
/** @var Bill $bill */
diff --git a/app/Repositories/UserGroups/Budget/AvailableBudgetRepository.php b/app/Repositories/UserGroups/Budget/AvailableBudgetRepository.php
index 1870d48dd0..f1b9fa96f8 100644
--- a/app/Repositories/UserGroups/Budget/AvailableBudgetRepository.php
+++ b/app/Repositories/UserGroups/Budget/AvailableBudgetRepository.php
@@ -42,7 +42,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));
$return = [];
$converter = new ExchangeRateConverter();
- $default = app('amount')->getDefaultCurrency();
+ $default = app('amount')->getNativeCurrency();
$availableBudgets = $this->userGroup->availableBudgets()
->where('start_date', $start->format('Y-m-d'))
->where('end_date', $end->format('Y-m-d'))->get()
diff --git a/app/Support/Amount.php b/app/Support/Amount.php
index 3c5a915e11..f01ab27085 100644
--- a/app/Support/Amount.php
+++ b/app/Support/Amount.php
@@ -55,7 +55,7 @@ class Amount
public function getAmountFromJournal(array $journal): string
{
$convertToNative = $this->convertToNative();
- $currency = $this->getDefaultCurrency();
+ $currency = $this->getNativeCurrency();
$field = $convertToNative && $currency->id !== $journal['currency_id'] ? 'native_amount' : 'amount';
$amount = $journal[$field] ?? '0';
// Log::debug(sprintf('Field is %s, amount is %s', $field, $amount));
@@ -86,7 +86,7 @@ class Amount
public function getAmountFromJournalObject(TransactionJournal $journal): string
{
$convertToNative = $this->convertToNative();
- $currency = $this->getDefaultCurrency();
+ $currency = $this->getNativeCurrency();
$field = $convertToNative && $currency->id !== $journal->transaction_currency_id ? 'native_amount' : 'amount';
/** @var null|Transaction $sourceTransaction */
@@ -193,7 +193,7 @@ class Amount
return $cache->get();
}
- /** @var null|TransactionCurrency $default */
+ /** @var null|TransactionCurrency $native */
$native = $userGroup->currencies()->where('group_default', true)->first();
if (null === $native) {
$native = $this->getSystemCurrency();
diff --git a/app/Support/Export/ExportDataGenerator.php b/app/Support/Export/ExportDataGenerator.php
index 83a9bd62f6..b3ab0fa361 100644
--- a/app/Support/Export/ExportDataGenerator.php
+++ b/app/Support/Export/ExportDataGenerator.php
@@ -736,7 +736,7 @@ class ExportDataGenerator
$metaFields = config('firefly.journal_meta_fields');
$header = array_merge($header, $metaFields);
- $default = Amount::getDefaultCurrency();
+ $default = Amount::getNativeCurrency();
$collector = app(GroupCollectorInterface::class);
$collector->setUser($this->user);
diff --git a/app/Support/Form/CurrencyForm.php b/app/Support/Form/CurrencyForm.php
index b25e1fd541..aedff307a4 100644
--- a/app/Support/Form/CurrencyForm.php
+++ b/app/Support/Form/CurrencyForm.php
@@ -60,7 +60,7 @@ class CurrencyForm
$classes = $this->getHolderClasses($name);
$value = $this->fillFieldValue($name, $value);
$options['step'] = 'any';
- $defaultCurrency = $options['currency'] ?? app('amount')->getDefaultCurrency();
+ $defaultCurrency = $options['currency'] ?? app('amount')->getNativeCurrency();
/** @var Collection $currencies */
$currencies = app('amount')->getCurrencies();
@@ -128,7 +128,7 @@ class CurrencyForm
$classes = $this->getHolderClasses($name);
$value = $this->fillFieldValue($name, $value);
$options['step'] = 'any';
- $defaultCurrency = $options['currency'] ?? app('amount')->getDefaultCurrency();
+ $defaultCurrency = $options['currency'] ?? app('amount')->getNativeCurrency();
/** @var Collection $currencies */
$currencies = app('amount')->getAllCurrencies();
diff --git a/app/Support/Http/Controllers/ChartGeneration.php b/app/Support/Http/Controllers/ChartGeneration.php
index e1c9aea6ca..2dcc43fe18 100644
--- a/app/Support/Http/Controllers/ChartGeneration.php
+++ b/app/Support/Http/Controllers/ChartGeneration.php
@@ -66,7 +66,7 @@ trait ChartGeneration
/** @var AccountRepositoryInterface $accountRepos */
$accountRepos = app(AccountRepositoryInterface::class);
- $default = app('amount')->getDefaultCurrency();
+ $default = app('amount')->getNativeCurrency();
$chartData = [];
/** @var Account $account */
diff --git a/app/Support/JsonApi/Enrichments/AccountEnrichment.php b/app/Support/JsonApi/Enrichments/AccountEnrichment.php
index 4fc240b83a..d11c20720a 100644
--- a/app/Support/JsonApi/Enrichments/AccountEnrichment.php
+++ b/app/Support/JsonApi/Enrichments/AccountEnrichment.php
@@ -82,7 +82,7 @@ class AccountEnrichment implements EnrichmentInterface
Log::debug(sprintf('Now doing account enrichment for %d account(s)', $collection->count()));
// prep local fields
$this->collection = $collection;
- $this->default = app('amount')->getDefaultCurrency();
+ $this->default = app('amount')->getNativeCurrency();
$this->currencies = [];
$this->balances = [];
$this->objectGroups = [];
diff --git a/app/Support/Search/QueryParser/QueryParser.php b/app/Support/Search/QueryParser/QueryParser.php
index 2bd4ca7345..6e9c1ea1e2 100644
--- a/app/Support/Search/QueryParser/QueryParser.php
+++ b/app/Support/Search/QueryParser/QueryParser.php
@@ -155,7 +155,7 @@ class QueryParser implements QueryParserInterface
$fieldName = $tokenUnderConstruction;
$tokenUnderConstruction = '';
}
- if ('' === $tokenUnderConstruction) {
+ if ('' === $tokenUnderConstruction) { // @phpstan-ignore-line
// In any other location, it's just a normal character
$tokenUnderConstruction .= $char;
}
diff --git a/app/Support/Steam.php b/app/Support/Steam.php
index 7adee6137b..d6beb4af98 100644
--- a/app/Support/Steam.php
+++ b/app/Support/Steam.php
@@ -407,7 +407,7 @@ class Steam
return [];
}
- $defaultCurrency = app('amount')->getDefaultCurrency();
+ $defaultCurrency = app('amount')->getNativeCurrency();
if ($convertToNative) {
if ($defaultCurrency->id === $currency?->id) {
Log::debug(sprintf('Unset "native_balance" and "%s" for account #%d', $defaultCurrency->code, $account->id));
diff --git a/app/Support/Twig/AmountFormat.php b/app/Support/Twig/AmountFormat.php
index 015378ab29..278b2ea12c 100644
--- a/app/Support/Twig/AmountFormat.php
+++ b/app/Support/Twig/AmountFormat.php
@@ -48,7 +48,7 @@ class AmountFormat extends AbstractExtension
return new TwigFilter(
'formatAmount',
static function (string $string): string {
- $currency = app('amount')->getDefaultCurrency();
+ $currency = app('amount')->getNativeCurrency();
return app('amount')->formatAnything($currency, $string, true);
},
@@ -61,7 +61,7 @@ class AmountFormat extends AbstractExtension
return new TwigFilter(
'formatAmountPlain',
static function (string $string): string {
- $currency = app('amount')->getDefaultCurrency();
+ $currency = app('amount')->getNativeCurrency();
return app('amount')->formatAnything($currency, $string, false);
},
@@ -93,7 +93,7 @@ class AmountFormat extends AbstractExtension
/** @var AccountRepositoryInterface $accountRepos */
$accountRepos = app(AccountRepositoryInterface::class);
- $currency = $accountRepos->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();
+ $currency = $accountRepos->getAccountCurrency($account) ?? app('amount')->getNativeCurrency();
return app('amount')->formatAnything($currency, $amount, $coloured);
},
diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php
index 31c57ca5e7..8f88e69cb3 100644
--- a/app/Support/Twig/General.php
+++ b/app/Support/Twig/General.php
@@ -69,7 +69,7 @@ class General extends AbstractExtension
$date = session('end', today(config('app.timezone'))->endOfMonth());
$info = Steam::finalAccountBalance($account, $date);
$currency = Steam::getAccountCurrency($account);
- $default = Amount::getDefaultCurrency();
+ $default = Amount::getNativeCurrency();
$convertToNative = Amount::convertToNative();
$useNative = $convertToNative && $default->id !== $currency->id;
$strings = [];
diff --git a/app/Transformers/AccountTransformer.php b/app/Transformers/AccountTransformer.php
index 9db039f734..0e10391f28 100644
--- a/app/Transformers/AccountTransformer.php
+++ b/app/Transformers/AccountTransformer.php
@@ -50,7 +50,7 @@ class AccountTransformer extends AbstractTransformer
$this->parameters = new ParameterBag();
$this->repository = app(AccountRepositoryInterface::class);
$this->convertToNative = Amount::convertToNative();
- $this->default = Amount::getDefaultCurrency();
+ $this->default = Amount::getNativeCurrency();
}
/**
@@ -72,7 +72,7 @@ class AccountTransformer extends AbstractTransformer
$convertToNative = Amount::convertToNative();
// get account role (will only work if the type is asset).
- $default = Amount::getDefaultCurrency();
+ $default = Amount::getNativeCurrency();
$accountRole = $this->getAccountRole($account, $accountType);
$date = $this->getDate();
$date->endOfDay();
diff --git a/app/Transformers/AvailableBudgetTransformer.php b/app/Transformers/AvailableBudgetTransformer.php
index 1bf829494b..6d8881482e 100644
--- a/app/Transformers/AvailableBudgetTransformer.php
+++ b/app/Transformers/AvailableBudgetTransformer.php
@@ -50,7 +50,7 @@ class AvailableBudgetTransformer extends AbstractTransformer
$this->repository = app(BudgetRepositoryInterface::class);
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->noBudgetRepository = app(NoBudgetRepositoryInterface::class);
- $this->default = Amount::getDefaultCurrency();
+ $this->default = Amount::getNativeCurrency();
$this->convertToNative = Amount::convertToNative();
}
diff --git a/app/Transformers/BillTransformer.php b/app/Transformers/BillTransformer.php
index 3626bf9a5a..b19fd5615f 100644
--- a/app/Transformers/BillTransformer.php
+++ b/app/Transformers/BillTransformer.php
@@ -52,7 +52,7 @@ class BillTransformer extends AbstractTransformer
{
$this->repository = app(BillRepositoryInterface::class);
$this->calculator = app(BillDateCalculator::class);
- $this->default = Amount::getDefaultCurrency();
+ $this->default = Amount::getNativeCurrency();
$this->convertToNative = Amount::convertToNative();
}
diff --git a/app/Transformers/BudgetLimitTransformer.php b/app/Transformers/BudgetLimitTransformer.php
index 384bb31ffb..1a4eaa5d3f 100644
--- a/app/Transformers/BudgetLimitTransformer.php
+++ b/app/Transformers/BudgetLimitTransformer.php
@@ -47,7 +47,7 @@ class BudgetLimitTransformer extends AbstractTransformer
public function __construct()
{
- $this->default = Amount::getDefaultCurrency();
+ $this->default = Amount::getNativeCurrency();
$this->convertToNative = Amount::convertToNative();
}
diff --git a/app/Transformers/BudgetTransformer.php b/app/Transformers/BudgetTransformer.php
index 13dc9b5f8d..9f4e220563 100644
--- a/app/Transformers/BudgetTransformer.php
+++ b/app/Transformers/BudgetTransformer.php
@@ -51,7 +51,7 @@ class BudgetTransformer extends AbstractTransformer
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->repository = app(BudgetRepositoryInterface::class);
$this->parameters = new ParameterBag();
- $this->default = Amount::getDefaultCurrency();
+ $this->default = Amount::getNativeCurrency();
$this->convertToNative = Amount::convertToNative();
}
diff --git a/app/Transformers/CategoryTransformer.php b/app/Transformers/CategoryTransformer.php
index 9233354c7a..c60d80a3da 100644
--- a/app/Transformers/CategoryTransformer.php
+++ b/app/Transformers/CategoryTransformer.php
@@ -48,7 +48,7 @@ class CategoryTransformer extends AbstractTransformer
{
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->repository = app(CategoryRepositoryInterface::class);
- $this->default = Amount::getDefaultCurrency();
+ $this->default = Amount::getNativeCurrency();
$this->convertToNative = Amount::convertToNative();
}
diff --git a/app/Transformers/V2/AccountTransformer.php b/app/Transformers/V2/AccountTransformer.php
index d6d627410a..564ee87ba7 100644
--- a/app/Transformers/V2/AccountTransformer.php
+++ b/app/Transformers/V2/AccountTransformer.php
@@ -135,7 +135,7 @@ class AccountTransformer extends AbstractTransformer
private function getDefaultCurrency(): void
{
- $this->default = app('amount')->getDefaultCurrency();
+ $this->default = app('amount')->getNativeCurrency();
}
private function collectAccountMetaData(Collection $accounts): void
diff --git a/app/Transformers/V2/BillTransformer.php b/app/Transformers/V2/BillTransformer.php
index ea022b5371..42f3cbc64d 100644
--- a/app/Transformers/V2/BillTransformer.php
+++ b/app/Transformers/V2/BillTransformer.php
@@ -97,7 +97,7 @@ class BillTransformer extends AbstractTransformer
];
}
Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));
- $this->default = app('amount')->getDefaultCurrency();
+ $this->default = app('amount')->getNativeCurrency();
$this->converter = new ExchangeRateConverter();
// grab all paid dates:
diff --git a/app/Transformers/V2/PiggyBankTransformer.php b/app/Transformers/V2/PiggyBankTransformer.php
index 87da0653f6..431181c696 100644
--- a/app/Transformers/V2/PiggyBankTransformer.php
+++ b/app/Transformers/V2/PiggyBankTransformer.php
@@ -156,7 +156,7 @@ class PiggyBankTransformer extends AbstractTransformer
// $this->piggyRepos->setUser($account->user);
// get currency from account, or use default.
- // $currency = $this->accountRepos->getAccountCurrency($account) ?? app('amount')->getDefaultCurrencyByUser($account->user);
+ // $currency = $this->accountRepos->getAccountCurrency($account) ?? app('amount')->getNativeCurrencyByUser($account->user);
// note
// $notes = $this->piggyRepos->getNoteText($piggyBank);
diff --git a/app/Transformers/V2/TransactionGroupTransformer.php b/app/Transformers/V2/TransactionGroupTransformer.php
index d4e4b3ba83..b4eba64da7 100644
--- a/app/Transformers/V2/TransactionGroupTransformer.php
+++ b/app/Transformers/V2/TransactionGroupTransformer.php
@@ -79,7 +79,7 @@ class TransactionGroupTransformer extends AbstractTransformer
}
}
- $this->default = app('amount')->getDefaultCurrency();
+ $this->default = app('amount')->getNativeCurrency();
$this->converter = new ExchangeRateConverter();
$this->collectAllMetaData();
diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.php
index 250ccd7c4f..763e66b53b 100644
--- a/app/Validation/TransactionValidation.php
+++ b/app/Validation/TransactionValidation.php
@@ -223,7 +223,7 @@ trait TransactionValidation
/** @var AccountRepository $accountRepository */
$accountRepository = app(AccountRepositoryInterface::class);
- $defaultCurrency = app('amount')->getDefaultCurrency();
+ $defaultCurrency = app('amount')->getNativeCurrency();
$sourceCurrency = $accountRepository->getAccountCurrency($source) ?? $defaultCurrency;
$destinationCurrency = $accountRepository->getAccountCurrency($destination) ?? $defaultCurrency;
// if both accounts have the same currency, continue.