Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
run phpcs
James Colec3ffd3945071
diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.ymlindex 2f7ca3e532..8fdbe4897a 100644--- a/.github/workflows/sonarcloud.yml+++ b/.github/workflows/sonarcloud.yml@@ -8,7 +8,7 @@ on:- developenv:DB_CONNECTION: sqlite- APP_KEY: UfpBqqeXx7zpNodsC6yjYQcRfDdm4Bxh+ APP_KEY: TestTestTestTestTestTestTestTestjobs:sonarcloud:name: SonarCloud@@ -46,7 +46,9 @@ jobs:run: composer install --prefer-dist --no-interaction --no-progress --no-scripts- name: "Create database file"- run: touch storage/database/database.sqlite+ run: |+ touch storage/database/database.sqlite+ wget -q https://github.com/firefly-iii/test-fixtures/raw/refs/heads/main/test-database.sqlite -O storage/database/database.sqlite- name: "Upgrades the database to the latest version"run: php artisan firefly-iii:upgrade-databasediff --git a/app/Api/V1/Controllers/Controller.php b/app/Api/V1/Controllers/Controller.phpindex bf046a8fc5..57fa8f5268 100644--- a/app/Api/V1/Controllers/Controller.php+++ b/app/Api/V1/Controllers/Controller.php@@ -25,7 +25,6 @@ declare(strict_types=1);namespace FireflyIII\Api\V1\Controllers;use Carbon\Carbon;-use Carbon\Exceptions\InvalidDateException;use Carbon\Exceptions\InvalidFormatException;use FireflyIII\Models\Preference;use FireflyIII\Models\TransactionCurrency;diff --git a/app/Console/Commands/Correction/ConvertsDatesToUTC.php b/app/Console/Commands/Correction/ConvertsDatesToUTC.phpindex 4609f98475..62b7754f14 100644--- a/app/Console/Commands/Correction/ConvertsDatesToUTC.php+++ b/app/Console/Commands/Correction/ConvertsDatesToUTC.php@@ -64,7 +64,7 @@ class ConvertsDatesToUTC extends Command// this variable is ALWAYS en_US.// stops phpstan complaining about dead code.- if (config('app.fallback_locale') === 'en_US') {+ if ('en_US' === config('app.fallback_locale')) {return Command::SUCCESS;}@@ -112,7 +112,7 @@ class ConvertsDatesToUTC extends Command$items->each(function ($item) use ($field, $timezoneField): void {/** @var Carbon $date */- $date = Carbon::parse($item->{$field}, $item->{$timezoneField}); // @phpstan-ignore-line+ $date = Carbon::parse($item->{$field}, $item->{$timezoneField}); // @phpstan-ignore-line$date->setTimezone('UTC');$item->{$field} = $date->format('Y-m-d H:i:s'); // @phpstan-ignore-line$item->{$timezoneField} = 'UTC'; // @phpstan-ignore-linediff --git a/app/Console/Commands/Correction/CorrectsAccountTypes.php b/app/Console/Commands/Correction/CorrectsAccountTypes.phpindex dc3ae1927f..c56fc6f79a 100644--- a/app/Console/Commands/Correction/CorrectsAccountTypes.php+++ b/app/Console/Commands/Correction/CorrectsAccountTypes.php@@ -111,6 +111,7 @@ class CorrectsAccountTypes extends Command$this->friendlyLine(sprintf('Found %d journals that need to be fixed.', $resultSet->count()));foreach ($resultSet as $entry) {app('log')->debug(sprintf('Now fixing journal #%d', $entry->id));+/** @var null|TransactionJournal $journal */$journal = TransactionJournal::find($entry->id);if (null !== $journal) {diff --git a/app/Console/Commands/Correction/CorrectsNativeAmounts.php b/app/Console/Commands/Correction/CorrectsNativeAmounts.phpindex 12b9e96cfe..47afadcee0 100644--- a/app/Console/Commands/Correction/CorrectsNativeAmounts.php+++ b/app/Console/Commands/Correction/CorrectsNativeAmounts.php@@ -236,7 +236,7 @@ class CorrectsNativeAmounts extends CommandTransactionObserver::$recalculate = false;foreach ($set as $item) {// here we are.- /** @var Transaction|null $transaction */+ /** @var null|Transaction $transaction */$transaction = Transaction::find($item->id);$transaction?->touch();}diff --git a/app/Console/Commands/Correction/RemovesEmptyJournals.php b/app/Console/Commands/Correction/RemovesEmptyJournals.phpindex 7da374b89c..28ac1e8257 100644--- a/app/Console/Commands/Correction/RemovesEmptyJournals.php+++ b/app/Console/Commands/Correction/RemovesEmptyJournals.php@@ -36,7 +36,7 @@ class RemovesEmptyJournals extends Commandprotected $description = 'Delete empty and uneven transaction journals.';- protected $signature = 'correction:empty-journals';+ protected $signature = 'correction:empty-journals';/*** Execute the console command.@@ -55,8 +55,8 @@ class RemovesEmptyJournals extends Commandprivate function deleteUnevenJournals(): void{$set = Transaction::whereNull('deleted_at')- ->groupBy('transactions.transaction_journal_id')- ->get([\DB::raw('COUNT(transactions.transaction_journal_id) as the_count'), 'transaction_journal_id']) // @phpstan-ignore-line+ ->groupBy('transactions.transaction_journal_id')+ ->get([\DB::raw('COUNT(transactions.transaction_journal_id) as the_count'), 'transaction_journal_id']) // @phpstan-ignore-line;$total = 0;@@ -66,7 +66,7 @@ class RemovesEmptyJournals extends Commandif (1 === $count % 2) {// uneven number, delete journal and transactions:try {- /** @var TransactionJournal|null $journal */+ /** @var null|TransactionJournal $journal */$journal = TransactionJournal::find($row->transaction_journal_id);$journal?->delete();} catch (QueryException $e) {@@ -87,13 +87,14 @@ class RemovesEmptyJournals extends Command{$count = 0;$set = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')- ->groupBy('transaction_journals.id')- ->whereNull('transactions.transaction_journal_id')- ->get(['transaction_journals.id']);+ ->groupBy('transaction_journals.id')+ ->whereNull('transactions.transaction_journal_id')+ ->get(['transaction_journals.id'])+ ;foreach ($set as $entry) {try {- /** @var TransactionJournal|null $journal */+ /** @var null|TransactionJournal $journal */$journal = TransactionJournal::find($entry->id);$journal?->delete();} catch (QueryException $e) {diff --git a/app/Console/Commands/Correction/RemovesOrphanedTransactions.php b/app/Console/Commands/Correction/RemovesOrphanedTransactions.phpindex 9a94395192..2952fd133a 100644--- a/app/Console/Commands/Correction/RemovesOrphanedTransactions.php+++ b/app/Console/Commands/Correction/RemovesOrphanedTransactions.php@@ -69,7 +69,7 @@ class RemovesOrphanedTransactions extends Command}$this->friendlyInfo(sprintf('Found %d orphaned journal(s).', $count));foreach ($set as $entry) {- /** @var TransactionJournal|null $journal */+ /** @var null|TransactionJournal $journal */$journal = TransactionJournal::withTrashed()->find($entry->id);if (null !== $journal) {$journal->delete();@@ -131,7 +131,7 @@ class RemovesOrphanedTransactions extends Command/** @var Transaction $transaction */foreach ($set as $transaction) {// delete journals- /** @var TransactionJournal|null $journal */+ /** @var null|TransactionJournal $journal */$journal = TransactionJournal::find($transaction->transaction_journal_id);if (null !== $journal) {$journal->delete();diff --git a/app/Console/Commands/System/ForcesDecimalSize.php b/app/Console/Commands/System/ForcesDecimalSize.phpindex a774b5e8de..66340b4c6c 100644--- a/app/Console/Commands/System/ForcesDecimalSize.php+++ b/app/Console/Commands/System/ForcesDecimalSize.php@@ -256,15 +256,16 @@ class ForcesDecimalSize extends Commandforeach ($result as $account) {/** @var string $field */foreach ($fields as $field) {- $value = $account->{$field};+ $value = $account->{$field};if (null === $value) {continue;}// fix $field by rounding it down correctly.- $pow = 10 ** $currency->decimal_places;- $correct = bcdiv((string) round($value * $pow), (string) $pow, 12);+ $pow = 10 ** $currency->decimal_places;+ $correct = bcdiv((string) round($value * $pow), (string) $pow, 12);$this->friendlyInfo(sprintf('Account #%d has %s with value "%s", this has been corrected to "%s".', $account->id, $field, $value, $correct));- /** @var Account|null $updateAccount */++ /** @var null|Account $updateAccount */$updateAccount = Account::find($account->id);$updateAccount?->update([$field => $correct]);}@@ -315,8 +316,9 @@ class ForcesDecimalSize extends Command$pow = 10 ** $currency->decimal_places;$correct = bcdiv((string) round($value * $pow), (string) $pow, 12);$this->friendlyWarning(sprintf('%s #%d has %s with value "%s", this has been corrected to "%s".', $table, $item->id, $field, $value, $correct));- /** @var Model|null $model */- $model = $class::find($item->id);++ /** @var null|Model $model */+ $model = $class::find($item->id);$model?->update([$field => $correct]);}}@@ -369,8 +371,9 @@ class ForcesDecimalSize extends Command$this->friendlyWarning(sprintf('Piggy bank event #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct));- /** @var PiggyBankEvent|null $event */- $event = PiggyBankEvent::find($item->id);++ /** @var null|PiggyBankEvent $event */+ $event = PiggyBankEvent::find($item->id);$event?->update([$field => $correct]);}}@@ -414,17 +417,18 @@ class ForcesDecimalSize extends Commandforeach ($result as $item) {/** @var string $field */foreach ($fields as $field) {- $value = $item->{$field};+ $value = $item->{$field};if (null === $value) {continue;}// fix $field by rounding it down correctly.- $pow = 10 ** $currency->decimal_places;- $correct = bcdiv((string) round($value * $pow), (string) $pow, 12);+ $pow = 10 ** $currency->decimal_places;+ $correct = bcdiv((string) round($value * $pow), (string) $pow, 12);$this->friendlyWarning(sprintf('Piggy bank repetition #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct));- /** @var PiggyBankRepetition|null $repetition */++ /** @var null|PiggyBankRepetition $repetition */$repetition = PiggyBankRepetition::find($item->id);$repetition->update([$field => $correct]);}@@ -467,15 +471,16 @@ class ForcesDecimalSize extends Commandforeach ($result as $item) {/** @var string $field */foreach ($fields as $field) {- $value = $item->{$field};+ $value = $item->{$field};if (null === $value) {continue;}// fix $field by rounding it down correctly.- $pow = 10 ** $currency->decimal_places;- $correct = bcdiv((string) round($value * $pow), (string) $pow, 12);+ $pow = 10 ** $currency->decimal_places;+ $correct = bcdiv((string) round($value * $pow), (string) $pow, 12);$this->friendlyWarning(sprintf('Piggy bank #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct));- /** @var PiggyBank|null $piggyBank */++ /** @var null|PiggyBank $piggyBank */$piggyBank = PiggyBank::find($item->id);$piggyBank?->update([$field => $correct]);}@@ -502,15 +507,16 @@ class ForcesDecimalSize extends Command/** @var Transaction $item */foreach ($result as $item) {- $value = $item->amount;+ $value = $item->amount;if ('' === $value) {continue;}// fix $field by rounding it down correctly.- $pow = (float) 10 ** $currency->decimal_places;- $correct = bcdiv((string) round((float) $value * $pow), (string) $pow, 12);+ $pow = (float) 10 ** $currency->decimal_places;+ $correct = bcdiv((string) round((float) $value * $pow), (string) $pow, 12);$this->friendlyWarning(sprintf('Transaction #%d has amount with value "%s", this has been corrected to "%s".', $item->id, $value, $correct));- /** @var Transaction|null $transaction */++ /** @var null|Transaction $transaction */$transaction = Transaction::find($item->id);$transaction?->update(['amount' => $correct]);}@@ -532,17 +538,18 @@ class ForcesDecimalSize extends Command/** @var Transaction $item */foreach ($result as $item) {- $value = $item->foreign_amount;+ $value = $item->foreign_amount;if (null === $value) {continue;}// fix $field by rounding it down correctly.- $pow = (float) 10 ** $currency->decimal_places;- $correct = bcdiv((string) round((float) $value * $pow), (string) $pow, 12);+ $pow = (float) 10 ** $currency->decimal_places;+ $correct = bcdiv((string) round((float) $value * $pow), (string) $pow, 12);$this->friendlyWarning(sprintf('Transaction #%d has foreign amount with value "%s", this has been corrected to "%s".', $item->id, $value, $correct));- /** @var Transaction|null $transaction */++ /** @var null|Transaction $transaction */$transaction = Transaction::find($item->id);$transaction?->update(['foreign_amount' => $correct]);}diff --git a/app/Handlers/Events/Model/BudgetLimitHandler.php b/app/Handlers/Events/Model/BudgetLimitHandler.phpindex 952c8d70b6..1942c5459b 100644--- a/app/Handlers/Events/Model/BudgetLimitHandler.php+++ b/app/Handlers/Events/Model/BudgetLimitHandler.php@@ -53,11 +53,13 @@ class BudgetLimitHandlerprivate function updateAvailableBudget(BudgetLimit $budgetLimit): void{Log::debug(sprintf('Now in updateAvailableBudget(limit #%d)', $budgetLimit->id));- /** @var Budget|null $budget */++ /** @var null|Budget $budget */$budget = Budget::find($budgetLimit->budget_id);if (null === $budget) {Log::warning('Budget is null, probably deleted, find deleted version.');- /** @var Budget|null $budget */++ /** @var null|Budget $budget */$budget = Budget::withTrashed()->find($budgetLimit->budget_id);}if (null === $budget) {diff --git a/app/Helpers/Collector/Extensions/AccountCollection.php b/app/Helpers/Collector/Extensions/AccountCollection.phpindex ff45348a6f..d96a49f321 100644--- a/app/Helpers/Collector/Extensions/AccountCollection.php+++ b/app/Helpers/Collector/Extensions/AccountCollection.php@@ -251,10 +251,11 @@ trait AccountCollectionif (0 === $accountId) {return false;}+// in theory, this could lead to finding other users accounts.- /** @var Account|null $account */- $account = Account::find($accountId);- if(null === $account) {+ /** @var null|Account $account */+ $account = Account::find($accountId);+ if (null === $account) {continue;}$balance = Steam::finalAccountBalance($account, $transaction['date']);diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.phpindex 94053a0b95..0e405fa800 100644--- a/app/Http/Controllers/DebugController.php+++ b/app/Http/Controllers/DebugController.php@@ -121,6 +121,7 @@ class DebugController extends Controllerecho sprintf('<h2>%s</h2>', $count);}}+exit;}diff --git a/app/Http/Controllers/PiggyBank/AmountController.php b/app/Http/Controllers/PiggyBank/AmountController.phpindex 49962722bf..7ff8d63258 100644--- a/app/Http/Controllers/PiggyBank/AmountController.php+++ b/app/Http/Controllers/PiggyBank/AmountController.php@@ -28,7 +28,6 @@ use Carbon\Carbon;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Models\Account;use FireflyIII\Models\PiggyBank;-use FireflyIII\Repositories\Account\AccountRepositoryInterface;use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;use Illuminate\Contracts\View\Factory;use Illuminate\Http\RedirectResponse;@@ -55,7 +54,7 @@ class AmountController extends Controllerapp('view')->share('title', (string) trans('firefly.piggyBanks'));app('view')->share('mainTitleIcon', 'fa-bullseye');- $this->piggyRepos = app(PiggyBankRepositoryInterface::class);+ $this->piggyRepos = app(PiggyBankRepositoryInterface::class);return $next($request);}diff --git a/app/Http/Controllers/PiggyBank/EditController.php b/app/Http/Controllers/PiggyBank/EditController.phpindex b8d0b6d6bb..b46fea3ff0 100644--- a/app/Http/Controllers/PiggyBank/EditController.php+++ b/app/Http/Controllers/PiggyBank/EditController.php@@ -28,7 +28,6 @@ use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Http\Requests\PiggyBankUpdateRequest;use FireflyIII\Models\PiggyBank;-use FireflyIII\Repositories\Account\AccountRepositoryInterface;use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;use Illuminate\Contracts\View\Factory;use Illuminate\Http\RedirectResponse;@@ -56,8 +55,8 @@ class EditController extends Controllerapp('view')->share('title', (string) trans('firefly.piggyBanks'));app('view')->share('mainTitleIcon', 'fa-bullseye');- $this->attachments = app(AttachmentHelperInterface::class);- $this->piggyRepos = app(PiggyBankRepositoryInterface::class);+ $this->attachments = app(AttachmentHelperInterface::class);+ $this->piggyRepos = app(PiggyBankRepositoryInterface::class);return $next($request);}diff --git a/app/Http/Controllers/UserGroup/CreateController.php b/app/Http/Controllers/UserGroup/CreateController.phpindex 26b385a662..88ab1ec074 100644--- a/app/Http/Controllers/UserGroup/CreateController.php+++ b/app/Http/Controllers/UserGroup/CreateController.php@@ -42,6 +42,7 @@ class CreateController extends Controllerapp('log')->debug(sprintf('Now at %s', __METHOD__));return view('administrations.create') // @phpstan-ignore-line- ->with(compact('title', 'subTitle', 'mainTitleIcon'));+ ->with(compact('title', 'subTitle', 'mainTitleIcon'))+ ;}}diff --git a/app/Http/Controllers/UserGroup/EditController.php b/app/Http/Controllers/UserGroup/EditController.phpindex db784e2dbb..476b6ec9b1 100644--- a/app/Http/Controllers/UserGroup/EditController.php+++ b/app/Http/Controllers/UserGroup/EditController.php@@ -43,6 +43,7 @@ class EditController extends Controllerapp('log')->debug(sprintf('Now at %s', __METHOD__));return view('administrations.edit') // @phpstan-ignore-line- ->with(compact('title', 'subTitle', 'mainTitleIcon'));+ ->with(compact('title', 'subTitle', 'mainTitleIcon'))+ ;}}diff --git a/app/Notifications/Admin/UserRegistration.php b/app/Notifications/Admin/UserRegistration.phpindex 9fbd1ea148..ef51a2fb24 100644--- a/app/Notifications/Admin/UserRegistration.php+++ b/app/Notifications/Admin/UserRegistration.php@@ -47,9 +47,9 @@ class UserRegistration extends Notificationprivate User $user;- public function __construct( User $user)+ public function __construct(User $user){- $this->user = $user;+ $this->user = $user;}/**diff --git a/app/Policies/UserPolicy.php b/app/Policies/UserPolicy.phpindex 98ad47dfba..169efb8109 100644--- a/app/Policies/UserPolicy.php+++ b/app/Policies/UserPolicy.php@@ -34,13 +34,13 @@ class UserPolicypublic function view(User $user, User $user1): bool{return true;-// return auth()->check() && $user->id === $account->user_id;+ // return auth()->check() && $user->id === $account->user_id;}public function viewAccounts(User $user): bool{return true;-// return auth()->check();+ // return auth()->check();}/**@@ -51,6 +51,6 @@ class UserPolicypublic function viewAny(): bool{return true;-// return auth()->check();+ // return auth()->check();}}diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.phpindex 7566f3bdeb..6a97997004 100644--- a/app/Repositories/Account/AccountRepository.php+++ b/app/Repositories/Account/AccountRepository.php@@ -524,7 +524,7 @@ class AccountRepository implements AccountRepositoryInterface->first(['transaction_journals.id']);if (null !== $first) {- /** @var TransactionJournal|null */+ /** @var null|TransactionJournal */return TransactionJournal::find($first->id);}diff --git a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php b/app/Repositories/PiggyBank/ModifiesPiggyBanks.phpindex 0f5a75b7d1..001b4c34bb 100644--- a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php+++ b/app/Repositories/PiggyBank/ModifiesPiggyBanks.php@@ -68,9 +68,9 @@ trait ModifiesPiggyBanks$pivot->native_current_amount = null;// also update native_current_amount.- $userCurrency = app('amount')->getDefaultCurrencyByUserGroup($this->user->userGroup);+ $userCurrency = app('amount')->getDefaultCurrencyByUserGroup($this->user->userGroup);if ($userCurrency->id !== $piggyBank->transaction_currency_id) {- $converter = new ExchangeRateConverter();+ $converter = new ExchangeRateConverter();$converter->setIgnoreSettings(true);$pivot->native_current_amount = $converter->convert($piggyBank->transactionCurrency, $userCurrency, today(), $pivot->current_amount);}@@ -91,9 +91,9 @@ trait ModifiesPiggyBanks$pivot->native_current_amount = null;// also update native_current_amount.- $userCurrency = app('amount')->getDefaultCurrencyByUserGroup($this->user->userGroup);+ $userCurrency = app('amount')->getDefaultCurrencyByUserGroup($this->user->userGroup);if ($userCurrency->id !== $piggyBank->transaction_currency_id) {- $converter = new ExchangeRateConverter();+ $converter = new ExchangeRateConverter();$converter->setIgnoreSettings(true);$pivot->native_current_amount = $converter->convert($piggyBank->transactionCurrency, $userCurrency, today(), $pivot->current_amount);}@@ -125,8 +125,8 @@ trait ModifiesPiggyBanksLog::debug(sprintf('Maximum amount: %s', $maxAmount));}- $compare = bccomp($amount, $maxAmount);- $result = $compare <= 0;+ $compare = bccomp($amount, $maxAmount);+ $result = $compare <= 0;Log::debug(sprintf('Compare <= 0? %d, so canAddAmount is %s', $compare, var_export($result, true)));@@ -160,11 +160,11 @@ trait ModifiesPiggyBankspublic function setCurrentAmount(PiggyBank $piggyBank, string $amount): PiggyBank{- $repetition = $this->getRepetition($piggyBank);+ $repetition = $this->getRepetition($piggyBank);if (null === $repetition) {return $piggyBank;}- $max = $piggyBank->target_amount;+ $max = $piggyBank->target_amount;if (1 === bccomp($amount, $max) && 0 !== bccomp($piggyBank->target_amount, '0')) {$amount = $max;}@@ -207,14 +207,14 @@ trait ModifiesPiggyBankspublic function update(PiggyBank $piggyBank, array $data): PiggyBank{- $piggyBank = $this->updateProperties($piggyBank, $data);+ $piggyBank = $this->updateProperties($piggyBank, $data);if (array_key_exists('notes', $data)) {$this->updateNote($piggyBank, (string) $data['notes']);}// update the order of the piggy bank:- $oldOrder = $piggyBank->order;- $newOrder = (int) ($data['order'] ?? $oldOrder);+ $oldOrder = $piggyBank->order;+ $newOrder = (int) ($data['order'] ?? $oldOrder);if ($oldOrder !== $newOrder) {$this->setOrder($piggyBank, $newOrder);}@@ -306,7 +306,7 @@ trait ModifiesPiggyBanksreturn;}- $dbNote = $piggyBank->notes()->first();+ $dbNote = $piggyBank->notes()->first();if (null === $dbNote) {$dbNote = new Note();$dbNote->noteable()->associate($piggyBank);@@ -317,15 +317,16 @@ trait ModifiesPiggyBankspublic function setOrder(PiggyBank $piggyBank, int $newOrder): bool{- $oldOrder = $piggyBank->order;+ $oldOrder = $piggyBank->order;// Log::debug(sprintf('Will move piggy bank #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder));if ($newOrder > $oldOrder) {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.order', '<=', $newOrder)->where('piggy_banks.order', '>', $oldOrder)- ->where('piggy_banks.id', '!=', $piggyBank->id)- ->distinct()->decrement('piggy_banks.order');+ ->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')+ ->where('accounts.user_id', $this->user->id)+ ->where('piggy_banks.order', '<=', $newOrder)->where('piggy_banks.order', '>', $oldOrder)+ ->where('piggy_banks.id', '!=', $piggyBank->id)+ ->distinct()->decrement('piggy_banks.order')+ ;$piggyBank->order = $newOrder;Log::debug(sprintf('[1] Order of piggy #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder));@@ -334,11 +335,12 @@ trait ModifiesPiggyBanksreturn true;}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.order', '>=', $newOrder)->where('piggy_banks.order', '<', $oldOrder)- ->where('piggy_banks.id', '!=', $piggyBank->id)- ->distinct()->increment('piggy_banks.order');+ ->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')+ ->where('accounts.user_id', $this->user->id)+ ->where('piggy_banks.order', '>=', $newOrder)->where('piggy_banks.order', '<', $oldOrder)+ ->where('piggy_banks.id', '!=', $piggyBank->id)+ ->distinct()->increment('piggy_banks.order')+ ;$piggyBank->order = $newOrder;Log::debug(sprintf('[2] Order of piggy #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder));@@ -359,7 +361,7 @@ trait ModifiesPiggyBanks}// if this account contains less than the amount, remove the current amount, update the amount and continue.$this->removeAmount($piggyBank, $account, $current);- $amount = bcsub($amount, $current);+ $amount = bcsub($amount, $current);}}}diff --git a/app/Repositories/User/UserRepository.php b/app/Repositories/User/UserRepository.phpindex 7481e366d7..a811edd134 100644--- a/app/Repositories/User/UserRepository.php+++ b/app/Repositories/User/UserRepository.php@@ -268,7 +268,7 @@ class UserRepository implements UserRepositoryInterfacepublic function inviteUser(null|Authenticatable|User $user, string $email): InvitedUser{- if(!($user instanceof User)) {+ if (!$user instanceof User) {throw new FireflyException('User is not a User object.');}$now = today(config('app.timezone'));diff --git a/app/Services/Internal/Destroy/AccountDestroyService.php b/app/Services/Internal/Destroy/AccountDestroyService.phpindex cca5f50893..8f1c40c125 100644--- a/app/Services/Internal/Destroy/AccountDestroyService.php+++ b/app/Services/Internal/Destroy/AccountDestroyService.php@@ -91,7 +91,8 @@ class AccountDestroyService$transaction->delete();$ibAccount->delete();}- /** @var TransactionJournal|null $journal */++ /** @var null|TransactionJournal $journal */$journal = TransactionJournal::find($journalId);if (null !== $journal) {/** @var JournalDestroyService $service */diff --git a/app/Support/Amount.php b/app/Support/Amount.phpindex f3d618cc39..939a691670 100644--- a/app/Support/Amount.php+++ b/app/Support/Amount.php@@ -177,7 +177,7 @@ class Amountreturn $cache->get();}- /** @var TransactionCurrency|null $default */+ /** @var null|TransactionCurrency $default */$default = $userGroup->currencies()->where('group_default', true)->first();if (null === $default) {$default = $this->getSystemCurrency();diff --git a/app/Support/Form/CurrencyForm.php b/app/Support/Form/CurrencyForm.phpindex eb1ef9d8cb..b25e1fd541 100644--- a/app/Support/Form/CurrencyForm.php+++ b/app/Support/Form/CurrencyForm.php@@ -50,6 +50,7 @@ class CurrencyForm/*** @throws FireflyException+ ** @phpstan-param view-string $view*/protected function currencyField(string $name, string $view, mixed $value = null, ?array $options = null): stringdiff --git a/app/Support/Http/Api/ExchangeRateConverter.php b/app/Support/Http/Api/ExchangeRateConverter.phpindex ccc7ce5724..2588794911 100644--- a/app/Support/Http/Api/ExchangeRateConverter.php+++ b/app/Support/Http/Api/ExchangeRateConverter.php@@ -40,9 +40,9 @@ use Illuminate\Support\Facades\Log;class ExchangeRateConverter{// use ConvertsExchangeRates;- private bool $ignoreSettings = false;- private array $prepared = [];- private int $queryCount = 0;+ private bool $ignoreSettings = false;+ private array $prepared = [];+ private int $queryCount = 0;private UserGroup $userGroup;diff --git a/app/Support/Models/AccountBalanceCalculator.php b/app/Support/Models/AccountBalanceCalculator.phpindex c8e24d94f5..554936da51 100644--- a/app/Support/Models/AccountBalanceCalculator.php+++ b/app/Support/Models/AccountBalanceCalculator.php@@ -156,7 +156,7 @@ class AccountBalanceCalculator* @var array $currencies*/foreach ($balances as $accountId => $currencies) {- /** @var Account|null $account */+ /** @var null|Account $account */$account = Account::find($accountId);if (null === $account) {Log::error(sprintf('Could not find account #%d, will not save account balance.', $accountId));@@ -169,7 +169,7 @@ class AccountBalanceCalculator* @var array $balance*/foreach ($currencies as $currencyId => $balance) {- /** @var TransactionCurrency|null $currency */+ /** @var null|TransactionCurrency $currency */$currency = TransactionCurrency::find($currencyId);if (null === $currency) {Log::error(sprintf('Could not find currency #%d, will not save account balance.', $currencyId));@@ -207,5 +207,4 @@ class AccountBalanceCalculator}$object->optimizedCalculation($accounts, $transactionJournal->date);}-}diff --git a/app/Support/Steam.php b/app/Support/Steam.phpindex 7ff1750cb8..bf1d02e6ec 100644--- a/app/Support/Steam.php+++ b/app/Support/Steam.php@@ -129,6 +129,7 @@ class Steam// find currency of this entry.$currencies[$entry->transaction_currency_id] ??= TransactionCurrency::find($entry->transaction_currency_id);+/** @var TransactionCurrency $entryCurrency */$entryCurrency = $currencies[$entry->transaction_currency_id];diff --git a/app/Transformers/V2/AccountTransformer.php b/app/Transformers/V2/AccountTransformer.phpindex 28f6e96798..d6d627410a 100644--- a/app/Transformers/V2/AccountTransformer.php+++ b/app/Transformers/V2/AccountTransformer.php@@ -174,7 +174,7 @@ class AccountTransformer extends AbstractTransformerprivate function getBalanceDifference(Collection $accounts, Carbon $start, Carbon $end): void{- if (config('app.fallback_locale') === 'en_US') {+ if ('en_US' === config('app.fallback_locale')) {throw new FireflyException('Used deprecated method, rethink this.');}// collect balances, start and end for both native and converted.diff --git a/app/Transformers/V2/PiggyBankTransformer.php b/app/Transformers/V2/PiggyBankTransformer.phpindex 19bccfb266..54e599b1cd 100644--- a/app/Transformers/V2/PiggyBankTransformer.php+++ b/app/Transformers/V2/PiggyBankTransformer.php@@ -115,7 +115,7 @@ class PiggyBankTransformer extends AbstractTransformer// grab repetitions (for current amount):$repetitions = PiggyBankRepetition::whereIn('piggy_bank_id', $piggyBanks)->get();- if (config('app.fallback_locale') === 'en_US') {+ if ('en_US' === config('app.fallback_locale')) {throw new FireflyException('[d] Piggy bank repetitions are EOL.');}diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.phpindex 2dc360a134..59eda8067c 100644--- a/app/Validation/FireflyValidator.php+++ b/app/Validation/FireflyValidator.php@@ -102,7 +102,7 @@ class FireflyValidator extends Validator/*** @SuppressWarnings("PHPMD.UnusedFormalParameter")*/- public function validateBic(mixed $attribute,mixed $value): bool+ public function validateBic(mixed $attribute, mixed $value): bool{$regex = '/^[a-z]{6}[0-9a-z]{2}([0-9a-z]{3})?\z/i';$result = preg_match($regex, $value);