Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fixed level 7!
James Cole1aa8ebe57fd5
diff --git a/.ci/phpstan.neon b/.ci/phpstan.neonindex 34b8841ce3..b98f1857f3 100644--- a/.ci/phpstan.neon+++ b/.ci/phpstan.neon@@ -18,6 +18,9 @@ parameters:- identifier: varTag.type- 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#"+ - '#expects view-string, string given#'+ - '#expects view-string\|null, string given#'# phpstan can't handle this so we ignore them.- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Relations\\HasMany::before#'@@ -71,5 +74,5 @@ parameters:# The level 8 is the highest level. original was 5# 7 is more than enough, higher just leaves NULL things.- level: 6+ level: 7diff --git a/app/Helpers/Collector/Extensions/AccountCollection.php b/app/Helpers/Collector/Extensions/AccountCollection.phpindex 32eb27d169..ff45348a6f 100644--- a/app/Helpers/Collector/Extensions/AccountCollection.php+++ b/app/Helpers/Collector/Extensions/AccountCollection.php@@ -252,7 +252,12 @@ trait AccountCollectionreturn false;}// in theory, this could lead to finding other users accounts.- $balance = Steam::finalAccountBalance(Account::find($accountId), $transaction['date']);+ /** @var Account|null $account */+ $account = Account::find($accountId);+ if(null === $account) {+ continue;+ }+ $balance = Steam::finalAccountBalance($account, $transaction['date']);$result = bccomp($balance['balance'], $value);Log::debug(sprintf('"%s" vs "%s" is %d', $balance['balance'], $value, $result));diff --git a/app/Http/Controllers/Recurring/ShowController.php b/app/Http/Controllers/Recurring/ShowController.phpindex ef4beccd79..2e5f6bd137 100644--- a/app/Http/Controllers/Recurring/ShowController.php+++ b/app/Http/Controllers/Recurring/ShowController.php@@ -118,7 +118,7 @@ class ShowController extends Controllerif (null !== $array['nr_of_repetitions']) {$left = $array['nr_of_repetitions'] - $array['journal_count'];- $left = max(0, $left);+ $left = (int) max(0, $left);// limit each repetition to X occurrences:foreach ($array['repetitions'] as $index => $repetition) {$array['repetitions'][$index]['occurrences'] = array_slice($repetition['occurrences'], 0, $left);diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.phpindex c68b83ba42..cfaf7463d5 100644--- a/app/Repositories/Account/AccountRepository.php+++ b/app/Repositories/Account/AccountRepository.php@@ -33,6 +33,7 @@ use FireflyIII\Models\AccountMeta;use FireflyIII\Models\AccountType;use FireflyIII\Models\Attachment;use FireflyIII\Models\Location;+use FireflyIII\Models\Transaction;use FireflyIII\Models\TransactionCurrency;use FireflyIII\Models\TransactionGroup;use FireflyIII\Models\TransactionJournal;@@ -523,6 +524,7 @@ class AccountRepository implements AccountRepositoryInterface->first(['transaction_journals.id']);if (null !== $first) {+ /** @var TransactionJournal|null */return TransactionJournal::find($first->id);}diff --git a/app/Services/Internal/Destroy/AccountDestroyService.php b/app/Services/Internal/Destroy/AccountDestroyService.phpindex 0eee97065e..cca5f50893 100644--- a/app/Services/Internal/Destroy/AccountDestroyService.php+++ b/app/Services/Internal/Destroy/AccountDestroyService.php@@ -91,6 +91,7 @@ class AccountDestroyService$transaction->delete();$ibAccount->delete();}+ /** @var TransactionJournal|null $journal */$journal = TransactionJournal::find($journalId);if (null !== $journal) {/** @var JournalDestroyService $service */diff --git a/app/Support/Form/CurrencyForm.php b/app/Support/Form/CurrencyForm.phpindex 7115f25fd3..eb1ef9d8cb 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): string{diff --git a/app/Support/Steam.php b/app/Support/Steam.phpindex 9f8d2118ca..7ff1750cb8 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];Log::debug(sprintf('Processing transaction(s) on date %s', $carbon->format('Y-m-d H:i:s')));diff --git a/app/Transformers/V2/BillTransformer.php b/app/Transformers/V2/BillTransformer.phpindex 04041785f6..ea022b5371 100644--- a/app/Transformers/V2/BillTransformer.php+++ b/app/Transformers/V2/BillTransformer.php@@ -57,6 +57,7 @@ class BillTransformer extends AbstractTransformer*/public function collectMetaData(Collection $objects): Collection{+ /** @var array<int, TransactionCurrency> $currencies */$currencies = [];$bills = [];$this->notes = [];@@ -140,25 +141,25 @@ class BillTransformer extends AbstractTransformerapp('log')->debug(sprintf('Foreign currency is #%d', $transaction['foreign_currency_id']));$foreignCurrencyId = (int) $transaction['foreign_currency_id'];$currencies[$foreignCurrencyId] ??= TransactionCurrency::find($foreignCurrencyId);- $foreignCurrencyCode = $currencies[$foreignCurrencyId]->code;- $foreignCurrencyName = $currencies[$foreignCurrencyId]->name;- $foreignCurrencySymbol = $currencies[$foreignCurrencyId]->symbol;- $foreignCurrencyDp = $currencies[$foreignCurrencyId]->decimal_places;+ $foreignCurrencyCode = $currencies[$foreignCurrencyId]->code; // @phpstan-ignore property.notFound+ $foreignCurrencyName = $currencies[$foreignCurrencyId]->name; // @phpstan-ignore property.notFound+ $foreignCurrencySymbol = $currencies[$foreignCurrencyId]->symbol; // @phpstan-ignore property.notFound+ $foreignCurrencyDp = $currencies[$foreignCurrencyId]->decimal_places; // @phpstan-ignore property.notFound}$this->paidDates[$billId][] = ['transaction_group_id' => (string) $journal->id,'transaction_journal_id' => (string) $journal->transaction_group_id,'date' => $journal->date->toAtomString(),- 'currency_id' => $currencies[$currencyId]->id,- 'currency_code' => $currencies[$currencyId]->code,- 'currency_name' => $currencies[$currencyId]->name,- 'currency_symbol' => $currencies[$currencyId]->symbol,- 'currency_decimal_places' => $currencies[$currencyId]->decimal_places,- 'native_currency_id' => $currencies[$currencyId]->id,- 'native_currency_code' => $currencies[$currencyId]->code,- 'native_currency_symbol' => $currencies[$currencyId]->symbol,- 'native_currency_decimal_places' => $currencies[$currencyId]->decimal_places,+ 'currency_id' => $currencies[$currencyId]->id, // @phpstan-ignore property.notFound+ 'currency_code' => $currencies[$currencyId]->code, // @phpstan-ignore property.notFound+ 'currency_name' => $currencies[$currencyId]->name, // @phpstan-ignore property.notFound+ 'currency_symbol' => $currencies[$currencyId]->symbol, // @phpstan-ignore property.notFound+ 'currency_decimal_places' => $currencies[$currencyId]->decimal_places, // @phpstan-ignore property.notFound+ 'native_currency_id' => $currencies[$currencyId]->id, // @phpstan-ignore property.notFound+ 'native_currency_code' => $currencies[$currencyId]->code, // @phpstan-ignore property.notFound+ 'native_currency_symbol' => $currencies[$currencyId]->symbol, // @phpstan-ignore property.notFound+ 'native_currency_decimal_places' => $currencies[$currencyId]->decimal_places, // @phpstan-ignore property.notFound'foreign_currency_id' => $foreignCurrencyId,'foreign_currency_code' => $foreignCurrencyCode,'foreign_currency_name' => $foreignCurrencyName,@@ -166,13 +167,8 @@ class BillTransformer extends AbstractTransformer'foreign_currency_decimal_places' => $foreignCurrencyDp,'amount' => $transaction['amount'],'foreign_amount' => $transaction['foreign_amount'],- 'native_amount' => $this->converter->convert($currencies[$currencyId], $this->default, $journal->date, $transaction['amount']),- 'foreign_native_amount' => '' === (string) $transaction['foreign_amount'] ? null : $this->converter->convert(- $currencies[$foreignCurrencyId],- $this->default,- $journal->date,- $transaction['foreign_amount']- ),+ 'native_amount' => null,+ 'foreign_native_amount' => null,];}}