Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix various level 4 issues [skip ci]
James Coled4942efd8e35
diff --git a/app/Api/V1/Controllers/Controller.php b/app/Api/V1/Controllers/Controller.phpindex a4fa915739..bf046a8fc5 100644--- a/app/Api/V1/Controllers/Controller.php+++ b/app/Api/V1/Controllers/Controller.php@@ -116,7 +116,7 @@ abstract class Controller extends BaseControllerif (null !== $date) {try {$obj = Carbon::parse((string) $date);- } catch (InvalidDateException|InvalidFormatException $e) {+ } catch (InvalidFormatException $e) {// don't careapp('log')->warning(sprintf(diff --git a/app/Console/Commands/Correction/ConvertsDatesToUTC.php b/app/Console/Commands/Correction/ConvertsDatesToUTC.phpindex 368d238120..4609f98475 100644--- a/app/Console/Commands/Correction/ConvertsDatesToUTC.php+++ b/app/Console/Commands/Correction/ConvertsDatesToUTC.php@@ -62,7 +62,11 @@ class ConvertsDatesToUTC extends Command{$this->friendlyWarning('Please do not use this command right now.');- return 0;+ // this variable is ALWAYS en_US.+ // stops phpstan complaining about dead code.+ if (config('app.fallback_locale') === 'en_US') {+ return Command::SUCCESS;+ }/*** @var string $model@@ -108,10 +112,10 @@ 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-line+ $item->{$timezoneField} = 'UTC'; // @phpstan-ignore-line$item->save();});diff --git a/app/Console/Commands/Integrity/ReportsSums.php b/app/Console/Commands/Integrity/ReportsSums.phpindex f08c942d3a..819754f819 100644--- a/app/Console/Commands/Integrity/ReportsSums.php+++ b/app/Console/Commands/Integrity/ReportsSums.php@@ -61,12 +61,7 @@ class ReportsSums extends Command$sum = '' === $sum ? '0' : $sum;$foreign = '' === $foreign ? '0' : $foreign;$total = bcadd($sum, $foreign);- if (!is_numeric($total)) {- $message = sprintf('Error: Transactions for user #%d (%s) have an invalid sum ("%s").', $user->id, $user->email, $total);- $this->friendlyError($message);- continue;- }if (0 !== bccomp($total, '0')) {$message = sprintf('Error: Transactions for user #%d (%s) are off by %s!', $user->id, $user->email, $total);$this->friendlyError($message);diff --git a/app/Console/Commands/Upgrade/UpgradesVariousCurrencyInformation.php b/app/Console/Commands/Upgrade/UpgradesVariousCurrencyInformation.phpindex ee4ba67ada..0283e00d7c 100644--- a/app/Console/Commands/Upgrade/UpgradesVariousCurrencyInformation.php+++ b/app/Console/Commands/Upgrade/UpgradesVariousCurrencyInformation.php@@ -240,7 +240,7 @@ class UpgradesVariousCurrencyInformation extends Commandprivate function isMultiCurrency(Account $account): bool{$value = $this->accountRepos->getMetaValue($account, 'is_multi_currency');- if (false === $value || null === $value) {+ if (null === $value) {return false;}diff --git a/app/Factory/PiggyBankFactory.php b/app/Factory/PiggyBankFactory.phpindex 6755df9559..199f324b75 100644--- a/app/Factory/PiggyBankFactory.php+++ b/app/Factory/PiggyBankFactory.php@@ -230,8 +230,8 @@ class PiggyBankFactoryforeach ($accounts as $info) {if ($account->id === $info['account_id']) {if (array_key_exists($account->id, $accounts)) {- $toBeLinked[$account->id] = ['current_amount' => $account->pivot?->current_amount ?? '0'];- Log::debug(sprintf('Prefilled for account #%d with amount %s', $account->id, $account->pivot?->current_amount ?? '0'));+ $toBeLinked[$account->id] = ['current_amount' => $account->pivot->current_amount ?? '0'];+ Log::debug(sprintf('Prefilled for account #%d with amount %s', $account->id, $account->pivot->current_amount ?? '0'));}}}@@ -246,7 +246,7 @@ class PiggyBankFactory}if (array_key_exists('current_amount', $info)) {$toBeLinked[$account->id] = ['current_amount' => $info['current_amount']];- Log::debug(sprintf('Will link account #%d with amount %s', $account->id, $account->pivot?->current_amount ?? '0'));+ Log::debug(sprintf('Will link account #%d with amount %s', $account->id, $account->pivot->current_amount ?? '0'));}if (!array_key_exists('current_amount', $info)) {$toBeLinked[$account->id] ??= [];diff --git a/app/Handlers/Events/Model/PiggyBankEventHandler.php b/app/Handlers/Events/Model/PiggyBankEventHandler.phpindex dfa4762fcb..21764cf508 100644--- a/app/Handlers/Events/Model/PiggyBankEventHandler.php+++ b/app/Handlers/Events/Model/PiggyBankEventHandler.php@@ -39,7 +39,7 @@ class PiggyBankEventHandlerif (null !== $event->transactionGroup) {$journal = $event->transactionGroup->transactionJournals()->first();}- $date = $journal?->date ?? today(config('app.timezone'));+ $date = $journal->date ?? today(config('app.timezone'));// sanity check: event must not already exist for this journal and piggy bank.if (null !== $journal) {$exists = PiggyBankEvent::where('piggy_bank_id', $event->piggyBank->id)diff --git a/app/Handlers/Observer/AccountObserver.php b/app/Handlers/Observer/AccountObserver.phpindex fc839ec78b..1360ca9656 100644--- a/app/Handlers/Observer/AccountObserver.php+++ b/app/Handlers/Observer/AccountObserver.php@@ -56,7 +56,7 @@ class AccountObserver$account->native_virtual_balance = $converter->convert($currency, $userCurrency, today(), $account->virtual_balance);}- if ('' === (string) $account->virtual_balance || ('' !== (string) $account->virtual_balance && 0 === bccomp($account->virtual_balance, '0'))) {+ if ('' === (string) $account->virtual_balance || (0 === bccomp($account->virtual_balance, '0'))) {$account->virtual_balance = null;$account->native_virtual_balance = null;}diff --git a/app/Handlers/Observer/PiggyBankObserver.php b/app/Handlers/Observer/PiggyBankObserver.phpindex cd8acc327d..824ef86621 100644--- a/app/Handlers/Observer/PiggyBankObserver.php+++ b/app/Handlers/Observer/PiggyBankObserver.php@@ -71,9 +71,6 @@ class PiggyBankObserverreturn;}$userCurrency = app('amount')->getDefaultCurrencyByUserGroup($group);- if (null === $userCurrency) {- return;- }$piggyBank->native_target_amount = null;if ($piggyBank->transactionCurrency->id !== $userCurrency->id) {$converter = new ExchangeRateConverter();diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.phpindex ae65970791..11599e1a09 100644--- a/app/Http/Controllers/DebugController.php+++ b/app/Http/Controllers/DebugController.php@@ -121,9 +121,7 @@ class DebugController extends Controllerecho sprintf('<h2>%s</h2>', $count);}}-exit;- var_dump($return);}/**diff --git a/app/Http/Controllers/PiggyBank/AmountController.php b/app/Http/Controllers/PiggyBank/AmountController.phpindex b9d4bc29a8..49962722bf 100644--- a/app/Http/Controllers/PiggyBank/AmountController.php+++ b/app/Http/Controllers/PiggyBank/AmountController.php@@ -41,7 +41,6 @@ use Illuminate\View\View;*/class AmountController extends Controller{- private AccountRepositoryInterface $accountRepos;private PiggyBankRepositoryInterface $piggyRepos;/**@@ -57,7 +56,6 @@ class AmountController extends Controllerapp('view')->share('mainTitleIcon', 'fa-bullseye');$this->piggyRepos = app(PiggyBankRepositoryInterface::class);- $this->accountRepos = app(AccountRepositoryInterface::class);return $next($request);}diff --git a/app/Http/Controllers/PiggyBank/EditController.php b/app/Http/Controllers/PiggyBank/EditController.phpindex f7574e59d9..b8d0b6d6bb 100644--- a/app/Http/Controllers/PiggyBank/EditController.php+++ b/app/Http/Controllers/PiggyBank/EditController.php@@ -41,7 +41,6 @@ use Illuminate\View\View;*/class EditController extends Controller{- private AccountRepositoryInterface $accountRepository;private AttachmentHelperInterface $attachments;private PiggyBankRepositoryInterface $piggyRepos;@@ -59,7 +58,6 @@ class EditController extends Controller$this->attachments = app(AttachmentHelperInterface::class);$this->piggyRepos = app(PiggyBankRepositoryInterface::class);- $this->accountRepository = app(AccountRepositoryInterface::class);return $next($request);}diff --git a/app/Jobs/CreateRecurringTransactions.php b/app/Jobs/CreateRecurringTransactions.phpindex 540eff0ba9..bf392a3462 100644--- a/app/Jobs/CreateRecurringTransactions.php+++ b/app/Jobs/CreateRecurringTransactions.php@@ -396,7 +396,7 @@ class CreateRecurringTransactions implements ShouldQueue// update recurring thing:$recurrence->latest_date = $date;- $recurrence->latest_date_tz = $date?->format('e');+ $recurrence->latest_date_tz = $date->format('e');$recurrence->save();return $group;@@ -419,7 +419,7 @@ class CreateRecurringTransactions implements ShouldQueue/** @var RecurrenceTransaction $transaction */foreach ($transactions as $index => $transaction) {$single = [- 'type' => null === $transaction?->transactionType?->type ? strtolower($recurrence->transactionType->type) : strtolower($transaction->transactionType->type),+ 'type' => null === $transaction->transactionType->type ? strtolower($recurrence->transactionType->type) : strtolower($transaction->transactionType->type),'date' => $date,'user' => $recurrence->user_id,'currency_id' => $transaction->transaction_currency_id,diff --git a/app/Validation/RecurrenceValidation.php b/app/Validation/RecurrenceValidation.phpindex ebb910bd0e..7c87c20b32 100644--- a/app/Validation/RecurrenceValidation.php+++ b/app/Validation/RecurrenceValidation.php@@ -265,8 +265,8 @@ trait RecurrenceValidationreturn;}- $nthDay = (int) ($parameters[0] ?? 0.0);- $dayOfWeek = (int) ($parameters[1] ?? 0.0);+ $nthDay = (int) $parameters[0];+ $dayOfWeek = (int) $parameters[1];if ($nthDay < 1 || $nthDay > 5) {$validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string) trans('validation.valid_recurrence_rep_moment'));