Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix phpstan level 3!
James Cole2baac1a6d7de
diff --git a/.ci/phpstan.neon b/.ci/phpstan.neonindex e9308c084c..a622c37e28 100644--- a/.ci/phpstan.neon+++ b/.ci/phpstan.neon@@ -16,6 +16,8 @@ parameters:- '#Dynamic call to static method#' # all the Laravel ORM things depend on this.- identifier: varTag.nativeType- identifier: varTag.type++ # phpstan can't handle this so we ignore them.- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Relations\\HasMany::before#'- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Relations\\HasMany::after#'- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Relations\\HasMany::withTrashed#'diff --git a/app/Console/Commands/Correction/ConvertsDatesToUTC.php b/app/Console/Commands/Correction/ConvertsDatesToUTC.phpindex b9d03027b1..368d238120 100644--- a/app/Console/Commands/Correction/ConvertsDatesToUTC.php+++ b/app/Console/Commands/Correction/ConvertsDatesToUTC.php@@ -55,23 +55,9 @@ class ConvertsDatesToUTC extends Command{use ShowsFriendlyMessages;- /**- * The console command description.- *- * @var string- */protected $description = 'Convert stored dates to UTC.';-- /**- * The name and signature of the console command.- *- * @var string- */protected $signature = 'correction:convert-to-utc';- /**- * Execute the console command.- */public function handle(): int{$this->friendlyWarning('Please do not use this command right now.');diff --git a/app/Console/Commands/Correction/CorrectsOpeningBalanceCurrencies.php b/app/Console/Commands/Correction/CorrectsOpeningBalanceCurrencies.phpindex 0b5b8f8ffe..f147160361 100644--- a/app/Console/Commands/Correction/CorrectsOpeningBalanceCurrencies.php+++ b/app/Console/Commands/Correction/CorrectsOpeningBalanceCurrencies.php@@ -67,7 +67,7 @@ class CorrectsOpeningBalanceCurrencies extends Commandprivate function getJournals(): Collection{- // @var Collection+ /** @var Collection */return TransactionJournal::leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')->whereNull('transaction_journals.deleted_at')->where('transaction_types.type', TransactionTypeEnum::OPENING_BALANCE->value)->get(['transaction_journals.*'])diff --git a/app/Console/Commands/Correction/CorrectsTimezoneInformation.php b/app/Console/Commands/Correction/CorrectsTimezoneInformation.phpindex 5b3b110bc6..ff514c0cdf 100644--- a/app/Console/Commands/Correction/CorrectsTimezoneInformation.php+++ b/app/Console/Commands/Correction/CorrectsTimezoneInformation.php@@ -81,18 +81,7 @@ class CorrectsTimezoneInformation extends CommandTransactionJournal::class => ['date'],];- /**- * The console command description.- *- * @var string- */protected $description = 'Make sure all dates have a timezone.';-- /**- * The name and signature of the console command.- *- * @var string- */protected $signature = 'correction:timezones';/**diff --git a/app/Console/Commands/Upgrade/UpgradesLiabilities.php b/app/Console/Commands/Upgrade/UpgradesLiabilities.phpindex c75ccc6a99..b9214069e6 100644--- a/app/Console/Commands/Upgrade/UpgradesLiabilities.php+++ b/app/Console/Commands/Upgrade/UpgradesLiabilities.php@@ -138,11 +138,13 @@ class UpgradesLiabilities extends Commandprivate function getSourceTransaction(TransactionJournal $journal): ?Transaction{+ /** @var Transaction|null */return $journal->transactions()->where('amount', '<', 0)->first();}private function getDestinationTransaction(TransactionJournal $journal): ?Transaction{+ /** @var Transaction|null */return $journal->transactions()->where('amount', '>', 0)->first();}diff --git a/app/Console/Commands/Upgrade/UpgradesTransferCurrencies.php b/app/Console/Commands/Upgrade/UpgradesTransferCurrencies.phpindex a48bad8c89..89258d3e77 100644--- a/app/Console/Commands/Upgrade/UpgradesTransferCurrencies.php+++ b/app/Console/Commands/Upgrade/UpgradesTransferCurrencies.php@@ -208,6 +208,7 @@ class UpgradesTransferCurrencies extends Commandprivate function getSourceTransaction(TransactionJournal $transfer): ?Transaction{+ /** @var Transaction|null */return $transfer->transactions()->where('amount', '<', 0)->first();}@@ -243,6 +244,7 @@ class UpgradesTransferCurrencies extends Commandprivate function getDestinationTransaction(TransactionJournal $transfer): ?Transaction{+ /** @var Transaction|null */return $transfer->transactions()->where('amount', '>', 0)->first();}diff --git a/app/Console/Commands/Upgrade/UpgradesVariousCurrencyInformation.php b/app/Console/Commands/Upgrade/UpgradesVariousCurrencyInformation.phpindex 0156ff186e..7a5002c3e6 100644--- a/app/Console/Commands/Upgrade/UpgradesVariousCurrencyInformation.php+++ b/app/Console/Commands/Upgrade/UpgradesVariousCurrencyInformation.php@@ -175,7 +175,7 @@ class UpgradesVariousCurrencyInformation extends Command*/private function getLeadTransaction(TransactionJournal $journal): ?Transaction{- /** @var Transaction $lead */+ /** @var Transaction|null $lead */$lead = null;switch ($journal->transactionType->type) {@@ -214,7 +214,7 @@ class UpgradesVariousCurrencyInformation extends Commandbreak;}-+ /** @var Transaction|null */return $lead;}diff --git a/app/Factory/AccountFactory.php b/app/Factory/AccountFactory.phpindex 4148e7da13..a2d2c4f881 100644--- a/app/Factory/AccountFactory.php+++ b/app/Factory/AccountFactory.php@@ -160,7 +160,7 @@ class AccountFactoryapp('log')->debug(sprintf('Now in AccountFactory::find("%s", "%s")', $accountName, $accountType));$type = AccountType::whereType($accountType)->first();- // @var Account|null+ /** @var Account|null */return $this->user->accounts()->where('account_type_id', $type->id)->where('name', $accountName)->first();}diff --git a/app/Factory/BillFactory.php b/app/Factory/BillFactory.phpindex ae120c4fdb..18a2889fbe 100644--- a/app/Factory/BillFactory.php+++ b/app/Factory/BillFactory.php@@ -129,6 +129,7 @@ class BillFactorypublic function findByName(string $name): ?Bill{+ /** @var Bill|null */return $this->user->bills()->whereLike('name', sprintf('%%%s%%', $name))->first();}diff --git a/app/Factory/BudgetFactory.php b/app/Factory/BudgetFactory.phpindex 48d424d27d..76cbc66a7d 100644--- a/app/Factory/BudgetFactory.php+++ b/app/Factory/BudgetFactory.php@@ -63,6 +63,7 @@ class BudgetFactorypublic function findByName(string $name): ?Budget{+ /** @var Budget|null */return $this->user->budgets()->where('name', $name)->first();}diff --git a/app/Factory/CategoryFactory.php b/app/Factory/CategoryFactory.phpindex 91e419d23e..caf095471e 100644--- a/app/Factory/CategoryFactory.php+++ b/app/Factory/CategoryFactory.php@@ -84,6 +84,7 @@ class CategoryFactorypublic function findByName(string $name): ?Category{+ /** @var Category|null */return $this->user->categories()->where('name', $name)->first();}diff --git a/app/Factory/PiggyBankFactory.php b/app/Factory/PiggyBankFactory.phpindex 831f24b8b8..5835757ce5 100644--- a/app/Factory/PiggyBankFactory.php+++ b/app/Factory/PiggyBankFactory.php@@ -41,14 +41,7 @@ class PiggyBankFactory{use CreatesObjectGroups;- public User $user {- set(User $value) {- $this->user = $value;- $this->currencyRepository->setUser($value);- $this->accountRepository->setUser($value);- $this->piggyBankRepository->setUser($value);- }- }+ public User $user;private AccountRepositoryInterface $accountRepository;private CurrencyRepositoryInterface $currencyRepository;private PiggyBankRepositoryInterface $piggyBankRepository;@@ -60,13 +53,21 @@ class PiggyBankFactory$this->piggyBankRepository = app(PiggyBankRepositoryInterface::class);}+ public function setUser(User $user): void+ {+ $this->user = $user;+ $this->currencyRepository->setUser($user);+ $this->accountRepository->setUser($user);+ $this->piggyBankRepository->setUser($user);+ }+/*** Store a piggy bank or come back with an exception.*/public function store(array $data): PiggyBank{- $piggyBankData = $data;+ $piggyBankData = $data;// unset some fieldsunset($piggyBankData['object_group_title'], $piggyBankData['transaction_currency_code'], $piggyBankData['transaction_currency_id'], $piggyBankData['accounts'], $piggyBankData['object_group_id'], $piggyBankData['notes']);@@ -90,11 +91,11 @@ class PiggyBankFactorythrow new FireflyException('400005: Could not store new piggy bank.', 0, $e);}- $piggyBank = $this->setOrder($piggyBank, $data);+ $piggyBank = $this->setOrder($piggyBank, $data);$this->linkToAccountIds($piggyBank, $data['accounts']);$this->piggyBankRepository->updateNote($piggyBank, $data['notes']);- $objectGroupTitle = $data['object_group_title'] ?? '';+ $objectGroupTitle = $data['object_group_title'] ?? '';if ('' !== $objectGroupTitle) {$objectGroup = $this->findOrCreateObjectGroup($objectGroupTitle);if (null !== $objectGroup) {@@ -102,7 +103,7 @@ class PiggyBankFactory}}// try also with ID- $objectGroupId = (int) ($data['object_group_id'] ?? 0);+ $objectGroupId = (int) ($data['object_group_id'] ?? 0);if (0 !== $objectGroupId) {$objectGroup = $this->findObjectGroupById($objectGroupId);if (null !== $objectGroup) {@@ -110,7 +111,7 @@ class PiggyBankFactory}}Log::debug('Touch piggy bank');- $piggyBank->encrypted = false;+ $piggyBank->encrypted = false;$piggyBank->save();$piggyBank->touch();@@ -143,11 +144,10 @@ class PiggyBankFactory// first find by ID:if ($piggyBankId > 0) {$piggyBank = PiggyBank::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')- ->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')- ->where('accounts.user_id', $this->user->id)- ->where('piggy_banks.id', $piggyBankId)- ->first(['piggy_banks.*'])- ;+ ->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')+ ->where('accounts.user_id', $this->user->id)+ ->where('piggy_banks.id', $piggyBankId)+ ->first(['piggy_banks.*']);if (null !== $piggyBank) {return $piggyBank;}@@ -168,17 +168,16 @@ class PiggyBankFactorypublic function findByName(string $name): ?PiggyBank{return PiggyBank::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')- ->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')- ->where('accounts.user_id', $this->user->id)- ->where('piggy_banks.name', $name)- ->first(['piggy_banks.*'])- ;+ ->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')+ ->where('accounts.user_id', $this->user->id)+ ->where('piggy_banks.name', $name)+ ->first(['piggy_banks.*']);}private function setOrder(PiggyBank $piggyBank, array $data): PiggyBank{$this->resetOrder();- $order = $this->getMaxOrder() + 1;+ $order = $this->getMaxOrder() + 1;if (array_key_exists('order', $data)) {$order = $data['order'];}@@ -193,15 +192,14 @@ class PiggyBankFactory{// TODO duplicate code$set = PiggyBank::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')- ->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')- ->where('accounts.user_id', $this->user->id)- ->with(- [- 'objectGroups',- ]- )- ->orderBy('piggy_banks.order', 'ASC')->get(['piggy_banks.*'])- ;+ ->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')+ ->where('accounts.user_id', $this->user->id)+ ->with(+ [+ 'objectGroups',+ ]+ )+ ->orderBy('piggy_banks.order', 'ASC')->get(['piggy_banks.*']);$current = 1;foreach ($set as $piggyBank) {if ($piggyBank->order !== $current) {diff --git a/app/Generator/Webhook/StandardMessageGenerator.php b/app/Generator/Webhook/StandardMessageGenerator.phpindex 929988f5e7..2d8770e99d 100644--- a/app/Generator/Webhook/StandardMessageGenerator.php+++ b/app/Generator/Webhook/StandardMessageGenerator.php@@ -132,7 +132,7 @@ class StandardMessageGenerator implements MessageGeneratorInterfacereturn;case TransactionGroup::class:- // @var TransactionGroup $model+ /** @var TransactionGroup $model */$basicMessage['user_id'] = $model->user->id;break;diff --git a/app/Http/Controllers/Account/ShowController.php b/app/Http/Controllers/Account/ShowController.phpindex badc25693d..1360a462d5 100644--- a/app/Http/Controllers/Account/ShowController.php+++ b/app/Http/Controllers/Account/ShowController.php@@ -85,11 +85,13 @@ class ShowController extends Controllerreturn $this->redirectAccountToAccount($account);}- // @var Carbon $start$start ??= session('start');- // @var Carbon $end$end ??= session('end');+ /** @var Carbon $start */+ /** @var Carbon $end */++if ($end->lt($start)) {[$start, $end] = [$end, $start];}diff --git a/app/Http/Controllers/Budget/ShowController.php b/app/Http/Controllers/Budget/ShowController.phpindex b3ec508d43..27137aa543 100644--- a/app/Http/Controllers/Budget/ShowController.php+++ b/app/Http/Controllers/Budget/ShowController.php@@ -79,10 +79,12 @@ class ShowController extends Controller*/public function noBudget(Request $request, ?Carbon $start = null, ?Carbon $end = null){- // @var Carbon $start$start ??= session('start');- // @var Carbon $end$end ??= session('end');++ /** @var Carbon $start */+ /** @var Carbon $end */+$subTitle = trans('firefly.without_budget_between',['start' => $start->isoFormat($this->monthAndDayFormat), 'end' => $end->isoFormat($this->monthAndDayFormat)]diff --git a/app/Http/Controllers/Category/NoCategoryController.php b/app/Http/Controllers/Category/NoCategoryController.phpindex cf19fcc3ab..323b309f4e 100644--- a/app/Http/Controllers/Category/NoCategoryController.php+++ b/app/Http/Controllers/Category/NoCategoryController.php@@ -75,10 +75,12 @@ class NoCategoryController extends Controllerpublic function show(Request $request, ?Carbon $start = null, ?Carbon $end = null){app('log')->debug('Start of noCategory()');- // @var Carbon $start$start ??= session('start');- // @var Carbon $end$end ??= session('end');++ /** @var Carbon $start */+ /** @var Carbon $end */+$page = (int) $request->get('page');$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;$subTitle = trans(diff --git a/app/Http/Controllers/Category/ShowController.php b/app/Http/Controllers/Category/ShowController.phpindex 00d6305868..c99370b6cb 100644--- a/app/Http/Controllers/Category/ShowController.php+++ b/app/Http/Controllers/Category/ShowController.php@@ -74,10 +74,12 @@ class ShowController extends Controller*/public function show(Request $request, Category $category, ?Carbon $start = null, ?Carbon $end = null){- // @var Carbon $start$start ??= session('start', today(config('app.timezone'))->startOfMonth());- // @var Carbon $end$end ??= session('end', today(config('app.timezone'))->endOfMonth());++ /** @var Carbon $start */+ /** @var Carbon $end */+$subTitleIcon = 'fa-bookmark';$page = (int) $request->get('page');$attachments = $this->repository->getAttachments($category);diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.phpindex 4f868317c0..d7c06b02af 100644--- a/app/Http/Controllers/DebugController.php+++ b/app/Http/Controllers/DebugController.php@@ -67,6 +67,7 @@ class DebugController extends Controllerif (!auth()->user()->hasRole('owner')) {throw new NotFoundHttpException();}+ /** @var iterable $routes */$routes = Route::getRoutes();$return = [];diff --git a/app/Http/Controllers/PiggyBank/IndexController.php b/app/Http/Controllers/PiggyBank/IndexController.phpindex d461ec49b5..5f54ed2940 100644--- a/app/Http/Controllers/PiggyBank/IndexController.php+++ b/app/Http/Controllers/PiggyBank/IndexController.php@@ -179,8 +179,9 @@ class IndexController extends Controllerprivate function mergeAccountsAndPiggies(array $piggyBanks, array $accounts): array{- // @var array $piggyBank+ /** @var array $group */foreach ($piggyBanks as $group) {+ /** @var array $piggyBank */foreach ($group['piggy_banks'] as $piggyBank) {// loop all accounts in this piggy bank subtract the current amount from "left to save" in the $accounts array./** @var array $piggyAccount */diff --git a/app/Jobs/CreateAutoBudgetLimits.php b/app/Jobs/CreateAutoBudgetLimits.phpindex c8a9e7e9b9..8c228a2f1b 100644--- a/app/Jobs/CreateAutoBudgetLimits.php+++ b/app/Jobs/CreateAutoBudgetLimits.php@@ -203,6 +203,7 @@ class CreateAutoBudgetLimits implements ShouldQueue));+ /** @var BudgetLimit|null */return $budget->budgetlimits()->where('start_date', $start->format('Y-m-d'))->where('end_date', $end->format('Y-m-d'))->first()diff --git a/app/Models/AccountMeta.php b/app/Models/AccountMeta.phpindex 782503ae8c..7aacf17970 100644--- a/app/Models/AccountMeta.php+++ b/app/Models/AccountMeta.php@@ -40,8 +40,6 @@ class AccountMeta extends Model];protected $fillable = ['account_id', 'name', 'data'];-- /** @var string The table to store the data in */protected $table = 'account_meta';public function account(): BelongsTodiff --git a/app/Models/Configuration.php b/app/Models/Configuration.phpindex 6f00839247..5028d26ba3 100644--- a/app/Models/Configuration.php+++ b/app/Models/Configuration.php@@ -41,7 +41,6 @@ class Configuration extends Model'deleted_at' => 'datetime',];- /** @var string The table to store the data in */protected $table = 'configuration';/**diff --git a/app/Models/Preference.php b/app/Models/Preference.phpindex 2f5343ed9a..af9d6d4a78 100644--- a/app/Models/Preference.php+++ b/app/Models/Preference.php@@ -79,6 +79,7 @@ class Preference extends Model$preference = $user->preferences()->where('id', (int) $value)->first();}if (null !== $preference) {+ /** @var Preference $preference */return $preference;}$default = config('firefly.default_preferences');@@ -89,7 +90,6 @@ class Preference extends Model$preference->user_id = (int) $user->id;$preference->user_group_id = in_array($value, $items, true) ? $userGroupId : null;$preference->save();-return $preference;}}diff --git a/app/Models/Recurrence.php b/app/Models/Recurrence.phpindex 6c8d4ea497..52e77b7979 100644--- a/app/Models/Recurrence.php+++ b/app/Models/Recurrence.php@@ -63,7 +63,6 @@ class Recurrence extends Modelprotected $fillable= ['user_id', 'transaction_type_id', 'title', 'description', 'first_date', 'first_date_tz', 'repeat_until', 'repeat_until_tz', 'latest_date', 'latest_date_tz', 'repetitions', 'apply_rules', 'active'];- /** @var string The table to store the data in */protected $table = 'recurrences';/**diff --git a/app/Models/RecurrenceMeta.php b/app/Models/RecurrenceMeta.phpindex d2ea3e8b0c..bfbea2ba84 100644--- a/app/Models/RecurrenceMeta.php+++ b/app/Models/RecurrenceMeta.php@@ -48,7 +48,6 @@ class RecurrenceMeta extends Modelprotected $fillable = ['recurrence_id', 'name', 'value'];- /** @var string The table to store the data in */protected $table = 'recurrences_meta';public function recurrence(): BelongsTodiff --git a/app/Models/RecurrenceRepetition.php b/app/Models/RecurrenceRepetition.phpindex 5f657bf4b6..6261a44952 100644--- a/app/Models/RecurrenceRepetition.php+++ b/app/Models/RecurrenceRepetition.php@@ -62,7 +62,6 @@ class RecurrenceRepetition extends Modelprotected $fillable = ['recurrence_id', 'weekend', 'repetition_type', 'repetition_moment', 'repetition_skip'];- /** @var string The table to store the data in */protected $table = 'recurrences_repetitions';public function recurrence(): BelongsTodiff --git a/app/Models/RecurrenceTransaction.php b/app/Models/RecurrenceTransaction.phpindex 85d8d37c45..40c9b2008f 100644--- a/app/Models/RecurrenceTransaction.php+++ b/app/Models/RecurrenceTransaction.php@@ -60,7 +60,6 @@ class RecurrenceTransaction extends Model'description',];- /** @var string The table to store the data in */protected $table = 'recurrences_transactions';public function destinationAccount(): BelongsTodiff --git a/app/Models/RecurrenceTransactionMeta.php b/app/Models/RecurrenceTransactionMeta.phpindex bc59ee520a..6899a36cd0 100644--- a/app/Models/RecurrenceTransactionMeta.php+++ b/app/Models/RecurrenceTransactionMeta.php@@ -48,7 +48,6 @@ class RecurrenceTransactionMeta extends Modelprotected $fillable = ['rt_id', 'name', 'value'];- /** @var string The table to store the data in */protected $table = 'rt_meta';public function recurrenceTransaction(): BelongsTodiff --git a/app/Models/TransactionJournalLink.php b/app/Models/TransactionJournalLink.phpindex a5f47481b2..bc0d79314b 100644--- a/app/Models/TransactionJournalLink.php+++ b/app/Models/TransactionJournalLink.php@@ -42,7 +42,6 @@ class TransactionJournalLink extends Model'updated_at' => 'datetime',];- /** @var string The table to store the data in */protected $table = 'journal_links';/**diff --git a/app/Models/TransactionJournalMeta.php b/app/Models/TransactionJournalMeta.phpindex 1ea70797cc..ca65121061 100644--- a/app/Models/TransactionJournalMeta.php+++ b/app/Models/TransactionJournalMeta.php@@ -45,7 +45,6 @@ class TransactionJournalMeta extends Modelprotected $fillable = ['transaction_journal_id', 'name', 'data', 'hash'];- /** @var string The table to store the data in */protected $table = 'journal_meta';/**diff --git a/app/Policies/AccountPolicy.php b/app/Policies/AccountPolicy.phpindex 6f6044fa1a..02a0d920c3 100644--- a/app/Policies/AccountPolicy.php+++ b/app/Policies/AccountPolicy.php@@ -42,8 +42,6 @@ class AccountPolicy/*** Everybody can do this, but selection should limit to user.- *- * @return true*/public function viewAny(): bool{@@ -54,8 +52,6 @@ class AccountPolicy/*** Everybody can do this, but selection should limit to user.- *- * @return true*/public function viewUser(User $user, Account $account): bool{diff --git a/app/Policies/BalancePolicy.php b/app/Policies/BalancePolicy.phpindex 6bcd56f673..665536a906 100644--- a/app/Policies/BalancePolicy.php+++ b/app/Policies/BalancePolicy.php@@ -39,8 +39,6 @@ class BalancePolicy/*** Everybody can do this, but selection should limit to user.- *- * @return true*/public function viewAny(): bool{diff --git a/app/Providers/CurrencyServiceProvider.php b/app/Providers/CurrencyServiceProvider.phpindex 601ea77f43..545dfef856 100644--- a/app/Providers/CurrencyServiceProvider.php+++ b/app/Providers/CurrencyServiceProvider.php@@ -77,7 +77,7 @@ class CurrencyServiceProvider extends ServiceProvider$this->app->bind(ExchangeRateRepositoryInterface::class,static function (Application $app) {- // @var ExchangeRateRepository $repository+ /** @var ExchangeRateRepository */return app(ExchangeRateRepository::class);});diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.phpindex 05267d6b5b..0913d75650 100644--- a/app/Repositories/Account/AccountRepository.php+++ b/app/Repositories/Account/AccountRepository.php@@ -120,7 +120,7 @@ class AccountRepository implements AccountRepositoryInterface$dbQuery->whereIn('account_types.type', $types);}- // @var Account|null+ /** @var Account|null */return $dbQuery->first(['accounts.*']);}@@ -134,7 +134,7 @@ class AccountRepository implements AccountRepositoryInterface$query->whereIn('account_types.type', $types);}- // @var Account|null+ /** @var Account|null */return $query->where('iban', $iban)->first(['accounts.*']);}@@ -278,7 +278,7 @@ class AccountRepository implements AccountRepositoryInterfacepublic function getLocation(Account $account): ?Location{- // @var Location|null+ /** @var Location|null */return $account->locations()->first();}@@ -428,6 +428,7 @@ class AccountRepository implements AccountRepositoryInterfacepublic function find(int $accountId): ?Account{+ /** @var Account|null */return $this->user->accounts()->find($accountId);}diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.phpindex 8c35166830..b8bdbf7213 100644--- a/app/Repositories/Bill/BillRepository.php+++ b/app/Repositories/Bill/BillRepository.php@@ -142,6 +142,7 @@ class BillRepository implements BillRepositoryInterface*/public function find(int $billId): ?Bill{+ /** @var Bill|null */return $this->user->bills()->find($billId);}@@ -150,6 +151,7 @@ class BillRepository implements BillRepositoryInterface*/public function findByName(string $name): ?Bill{+ /** @var Bill|null */return $this->user->bills()->where('name', $name)->first(['bills.*']);}diff --git a/app/Repositories/Budget/AvailableBudgetRepository.php b/app/Repositories/Budget/AvailableBudgetRepository.phpindex 45a8d4daba..40b74a7e4d 100644--- a/app/Repositories/Budget/AvailableBudgetRepository.php+++ b/app/Repositories/Budget/AvailableBudgetRepository.php@@ -103,6 +103,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface*/public function find(TransactionCurrency $currency, Carbon $start, Carbon $end): ?AvailableBudget{+ /** @var AvailableBudget|null */return $this->user->availableBudgets()->where('transaction_currency_id', $currency->id)->where('start_date', $start->format('Y-m-d'))@@ -194,6 +195,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterfacepublic function getByCurrencyDate(Carbon $start, Carbon $end, TransactionCurrency $currency): ?AvailableBudget{+ /** @var AvailableBudget|null */return $this->user->availableBudgets()->where('transaction_currency_id', $currency->id)@@ -207,6 +209,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface*/public function setAvailableBudget(TransactionCurrency $currency, Carbon $start, Carbon $end, string $amount): AvailableBudget{+ /** @var AvailableBudget */$availableBudget = $this->user->availableBudgets()->where('transaction_currency_id', $currency->id)->where('start_date', $start->format('Y-m-d'))@@ -223,7 +226,6 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface}$availableBudget->amount = $amount;$availableBudget->save();-return $availableBudget;}diff --git a/app/Repositories/Budget/BudgetLimitRepository.php b/app/Repositories/Budget/BudgetLimitRepository.phpindex 1ffc36abb5..203fe91e02 100644--- a/app/Repositories/Budget/BudgetLimitRepository.php+++ b/app/Repositories/Budget/BudgetLimitRepository.php@@ -324,6 +324,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterfacepublic function find(Budget $budget, TransactionCurrency $currency, Carbon $start, Carbon $end): ?BudgetLimit{+ /** @var BudgetLimit|null */return $budget->budgetlimits()->where('transaction_currency_id', $currency->id)->where('start_date', $start->format('Y-m-d'))diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.phpindex 096ffc32fd..7d41044d3b 100644--- a/app/Repositories/Budget/BudgetRepository.php+++ b/app/Repositories/Budget/BudgetRepository.php@@ -384,6 +384,7 @@ class BudgetRepository implements BudgetRepositoryInterfacepublic function getAutoBudget(Budget $budget): ?AutoBudget{+ /** @var AutoBudget|null */return $budget->autoBudgets()->first();}@@ -442,6 +443,7 @@ class BudgetRepository implements BudgetRepositoryInterface*/public function find(?int $budgetId = null): ?Budget{+ /** @var Budget|null */return $this->user->budgets()->find($budgetId);}@@ -513,7 +515,7 @@ class BudgetRepository implements BudgetRepositoryInterfacereturn null;}$query = sprintf('%%%s%%', $name);-+ /** @var Budget|null */return $this->user->budgets()->whereLike('name', $query)->first();}diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.phpindex 7501fcbdde..b9aed75534 100644--- a/app/Repositories/Category/CategoryRepository.php+++ b/app/Repositories/Category/CategoryRepository.php@@ -129,6 +129,7 @@ class CategoryRepository implements CategoryRepositoryInterface*/public function find(int $categoryId): ?Category{+ /** @var Category|null */return $this->user->categories()->find($categoryId);}@@ -137,6 +138,7 @@ class CategoryRepository implements CategoryRepositoryInterface*/public function findByName(string $name): ?Category{+ /** @var Category|null */return $this->user->categories()->where('name', $name)->first(['categories.*']);}diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.phpindex cac96ff771..d55668c352 100644--- a/app/Repositories/Journal/JournalRepository.php+++ b/app/Repositories/Journal/JournalRepository.php@@ -185,6 +185,7 @@ class JournalRepository implements JournalRepositoryInterface*/public function find(int $journalId): ?TransactionJournal{+ /** @var TransactionJournal|null */return $this->user->transactionJournals()->find($journalId);}diff --git a/app/Repositories/ObjectGroup/CreatesObjectGroups.php b/app/Repositories/ObjectGroup/CreatesObjectGroups.phpindex 767416456a..1710ca6405 100644--- a/app/Repositories/ObjectGroup/CreatesObjectGroups.php+++ b/app/Repositories/ObjectGroup/CreatesObjectGroups.php@@ -33,6 +33,7 @@ trait CreatesObjectGroups{protected function findObjectGroupById(int $groupId): ?ObjectGroup{+ /** @var ObjectGroup|null */return $this->user->objectGroups()->where('id', $groupId)->first();}@@ -66,6 +67,7 @@ trait CreatesObjectGroupsprotected function findObjectGroup(string $title): ?ObjectGroup{+ /** @var ObjectGroup|null */return $this->user->objectGroups()->where('title', $title)->first();}}diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.phpindex 3f5d987fdb..31bb7c8cdb 100644--- a/app/Repositories/PiggyBank/PiggyBankRepository.php+++ b/app/Repositories/PiggyBank/PiggyBankRepository.php@@ -313,7 +313,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterfacethrow new FireflyException('[b] Piggy bank repetitions are EOL.');}Log::warning('Piggy bank repetitions are EOL.');-+ /** @var PiggyBankRepetition|null */return $piggyBank->piggyBankRepetitions()->first();}diff --git a/app/Repositories/Rule/RuleRepository.php b/app/Repositories/Rule/RuleRepository.phpindex 05758578a7..9b0323bd00 100644--- a/app/Repositories/Rule/RuleRepository.php+++ b/app/Repositories/Rule/RuleRepository.php@@ -96,6 +96,7 @@ class RuleRepository implements RuleRepositoryInterface*/public function getFirstRuleGroup(): RuleGroup{+ /** @var RuleGroup|null */return $this->user->ruleGroups()->first();}@@ -276,6 +277,7 @@ class RuleRepository implements RuleRepositoryInterfacepublic function find(int $ruleId): ?Rule{+ /** @var Rule|null */return $this->user->rules()->find($ruleId);}diff --git a/app/Repositories/RuleGroup/RuleGroupRepository.php b/app/Repositories/RuleGroup/RuleGroupRepository.phpindex a5d6b57b78..830fe2d018 100644--- a/app/Repositories/RuleGroup/RuleGroupRepository.php+++ b/app/Repositories/RuleGroup/RuleGroupRepository.php@@ -208,11 +208,13 @@ class RuleGroupRepository implements RuleGroupRepositoryInterfacepublic function find(int $ruleGroupId): ?RuleGroup{+ /** @var RuleGroup|null */return $this->user->ruleGroups()->find($ruleGroupId);}public function findByTitle(string $title): ?RuleGroup{+ /** @var RuleGroup|null */return $this->user->ruleGroups()->where('title', $title)->first();}diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.phpindex 712dca3eba..ca945090d0 100644--- a/app/Repositories/Tag/TagRepository.php+++ b/app/Repositories/Tag/TagRepository.php@@ -101,18 +101,19 @@ class TagRepository implements TagRepositoryInterfacepublic function find(int $tagId): ?Tag{+ /** @var Tag|null */return $this->user->tags()->find($tagId);}public function findByTag(string $tag): ?Tag{- // @var Tag|null+ /** @var Tag|null */return $this->user->tags()->where('tag', $tag)->first();}public function firstUseDate(Tag $tag): ?Carbon{- // @var Carbon|null+ /** @var Carbon|null */return $tag->transactionJournals()->orderBy('date', 'ASC')->first()?->date;}@@ -180,7 +181,7 @@ class TagRepository implements TagRepositoryInterfacepublic function lastUseDate(Tag $tag): ?Carbon{- // @var Carbon|null+ /** @var Carbon|null */return $tag->transactionJournals()->orderBy('date', 'DESC')->first()?->date;}@@ -189,13 +190,13 @@ class TagRepository implements TagRepositoryInterface*/public function newestTag(): ?Tag{- // @var Tag|null+ /** @var Tag|null */return $this->user->tags()->whereNotNull('date')->orderBy('date', 'DESC')->first();}public function oldestTag(): ?Tag{- // @var Tag|null+ /** @var Tag|null */return $this->user->tags()->whereNotNull('date')->orderBy('date', 'ASC')->first();}@@ -380,7 +381,7 @@ class TagRepository implements TagRepositoryInterfacepublic function getLocation(Tag $tag): ?Location{- // @var Location|null+ /** @var Location|null */return $tag->locations()->first();}}diff --git a/app/Repositories/TransactionGroup/TransactionGroupRepository.php b/app/Repositories/TransactionGroup/TransactionGroupRepository.phpindex 349209cd9a..0e3fffa009 100644--- a/app/Repositories/TransactionGroup/TransactionGroupRepository.php+++ b/app/Repositories/TransactionGroup/TransactionGroupRepository.php@@ -69,6 +69,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface*/public function find(int $groupId): ?TransactionGroup{+ /** @var TransactionGroup|null */return $this->user->transactionGroups()->find($groupId);}@@ -290,6 +291,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface/** @var TransactionJournal $journal */$journal = $this->user->transactionJournals()->find($journalId);+ /** @var Location|null */return $journal->locations()->first();}diff --git a/app/Repositories/UserGroups/Account/AccountRepository.php b/app/Repositories/UserGroups/Account/AccountRepository.phpindex 7035f82b24..58ac999d95 100644--- a/app/Repositories/UserGroups/Account/AccountRepository.php+++ b/app/Repositories/UserGroups/Account/AccountRepository.php@@ -76,7 +76,7 @@ class AccountRepository implements AccountRepositoryInterface$dbQuery->whereIn('account_types.type', $types);}- // @var Account|null+ /** @var Account|null */return $dbQuery->first(['accounts.*']);}@@ -90,7 +90,7 @@ class AccountRepository implements AccountRepositoryInterface$query->whereIn('account_types.type', $types);}- // @var Account|null+ /** @var Account|null */return $query->where('iban', $iban)->first(['accounts.*']);}@@ -167,7 +167,7 @@ class AccountRepository implements AccountRepositoryInterfaceif (null === $account) {$account = $this->userGroup->accounts()->find($accountId);}-+ /** @var Account|null */return $account;}diff --git a/app/Repositories/UserGroups/Currency/CurrencyRepository.php b/app/Repositories/UserGroups/Currency/CurrencyRepository.phpindex 147e6599da..1d1a5a4bef 100644--- a/app/Repositories/UserGroups/Currency/CurrencyRepository.php+++ b/app/Repositories/UserGroups/Currency/CurrencyRepository.php@@ -199,7 +199,7 @@ class CurrencyRepository implements CurrencyRepositoryInterfacereturn $current;});-+ /** @var Collection */return $all;}diff --git a/app/Repositories/UserGroups/ExchangeRate/ExchangeRateRepository.php b/app/Repositories/UserGroups/ExchangeRate/ExchangeRateRepository.phpindex 6c8f789670..713b07f3e4 100644--- a/app/Repositories/UserGroups/ExchangeRate/ExchangeRateRepository.php+++ b/app/Repositories/UserGroups/ExchangeRate/ExchangeRateRepository.php@@ -61,6 +61,7 @@ class ExchangeRateRepository implements ExchangeRateRepositoryInterface#[\Override]public function getSpecificRateOnDate(TransactionCurrency $from, TransactionCurrency $to, Carbon $date): ?CurrencyExchangeRate{+ /** @var CurrencyExchangeRate|null */return$this->userGroup->currencyExchangeRates()->where('from_currency_id', $from->id)diff --git a/app/Rules/Account/IsUniqueAccount.php b/app/Rules/Account/IsUniqueAccount.phpindex 5a3fa3db9b..d60a1b3954 100644--- a/app/Rules/Account/IsUniqueAccount.php+++ b/app/Rules/Account/IsUniqueAccount.php@@ -39,9 +39,10 @@ class IsUniqueAccount implements ValidationRule, DataAwareRuleprotected \Closure $fail;#[\Override]- public function setData(array $data): void+ public function setData(array $data): self // @phpstan-ignore-line{$this->data = $data;+ return $this;}#[\Override]diff --git a/app/Services/Internal/Update/BillUpdateService.php b/app/Services/Internal/Update/BillUpdateService.phpindex e2f6044b87..a419499f5d 100644--- a/app/Services/Internal/Update/BillUpdateService.php+++ b/app/Services/Internal/Update/BillUpdateService.php@@ -250,6 +250,7 @@ class BillUpdateServiceprivate function getRuleTrigger(Rule $rule, string $key): ?RuleTrigger{+ /** @var RuleTrigger|null */return $rule->ruleTriggers()->where('trigger_type', $key)->first();}}diff --git a/app/Services/Internal/Update/JournalUpdateService.php b/app/Services/Internal/Update/JournalUpdateService.phpindex 5d498c52b7..66c970eda2 100644--- a/app/Services/Internal/Update/JournalUpdateService.php+++ b/app/Services/Internal/Update/JournalUpdateService.php@@ -238,11 +238,9 @@ class JournalUpdateServiceprivate function getSourceTransaction(): Transaction{if (null === $this->sourceTransaction) {- $this->sourceTransaction = $this->transactionJournal->transactions()->with(['account'])->where(- 'amount',- '<',- 0- )->first();+ /** @var Transaction|null $result */+ $result = $this->transactionJournal->transactions()->with(['account'])->where('amount', '<', 0)->first();+ $this->sourceTransaction = $result;}Log::debug(sprintf('getSourceTransaction: %s', $this->sourceTransaction->amount));@@ -321,7 +319,9 @@ class JournalUpdateServiceprivate function getDestinationTransaction(): Transaction{if (null === $this->destinationTransaction) {- $this->destinationTransaction = $this->transactionJournal->transactions()->where('amount', '>', 0)->first();+ /** @var Transaction|null $result */+ $result = $this->transactionJournal->transactions()->where('amount', '>', 0)->first();+ $this->destinationTransaction = $result;}return $this->destinationTransaction;