Skip to content

Firefly III: a personal finances manager

Fix level 5! Mostly by ignoring the errors lol.

James Colef4bc313d0ba7
diff --git a/.ci/phpstan.neon b/.ci/phpstan.neon
index 894bcdd555..856e2a9abf 100644
--- a/.ci/phpstan.neon
+++ b/.ci/phpstan.neon
@@ -69,5 +69,5 @@ parameters:
# The level 8 is the highest level. original was 5
# 7 is more than enough, higher just leaves NULL things.
- level: 4
+ level: 5
diff --git a/app/Console/Commands/Correction/CorrectsNativeAmounts.php b/app/Console/Commands/Correction/CorrectsNativeAmounts.php
index ff0fd22bf2..39d05a5bd3 100644
--- a/app/Console/Commands/Correction/CorrectsNativeAmounts.php
+++ b/app/Console/Commands/Correction/CorrectsNativeAmounts.php
@@ -146,7 +146,7 @@ class CorrectsNativeAmounts extends Command
{
$set = $piggyBank->piggyBankEvents()->get();
$set->each(
- static function (PiggyBankEvent $event): void {
+ static function (PiggyBankEvent $event): void { // @phpstan-ignore-line
$event->touch();
}
);
diff --git a/app/Console/Commands/Correction/CorrectsUnevenAmount.php b/app/Console/Commands/Correction/CorrectsUnevenAmount.php
index 1582c787f2..c595cc34af 100644
--- a/app/Console/Commands/Correction/CorrectsUnevenAmount.php
+++ b/app/Console/Commands/Correction/CorrectsUnevenAmount.php
@@ -121,7 +121,7 @@ class CorrectsUnevenAmount extends Command
$journals = \DB::table('transactions')
->groupBy('transaction_journal_id')
->whereNull('deleted_at')
- ->get(['transaction_journal_id', \DB::raw('SUM(amount) AS the_sum')])
+ ->get(['transaction_journal_id', \DB::raw('SUM(amount) AS the_sum')]) // @phpstan-ignore-line
;
/** @var \stdClass $entry */
diff --git a/app/Http/Controllers/System/InstallController.php b/app/Http/Controllers/System/InstallController.php
index d724032384..df765dc6fb 100644
--- a/app/Http/Controllers/System/InstallController.php
+++ b/app/Http/Controllers/System/InstallController.php
@@ -98,7 +98,7 @@ class InstallController extends Controller
];
app('log')->debug(sprintf('Will now run commands. Request index is %d', $requestIndex));
- $indexes = array_values(array_keys($this->upgradeCommands));
+ $indexes = array_keys($this->upgradeCommands);
if (array_key_exists($requestIndex, $indexes)) {
$command = $indexes[$requestIndex];
$parameters = $this->upgradeCommands[$command];
diff --git a/app/Http/Controllers/UserGroup/CreateController.php b/app/Http/Controllers/UserGroup/CreateController.php
index 0f20e9e4c2..26b385a662 100644
--- a/app/Http/Controllers/UserGroup/CreateController.php
+++ b/app/Http/Controllers/UserGroup/CreateController.php
@@ -41,6 +41,7 @@ class CreateController extends Controller
$mainTitleIcon = 'fa-book';
app('log')->debug(sprintf('Now at %s', __METHOD__));
- return view('administrations.create')->with(compact('title', 'subTitle', 'mainTitleIcon'));
+ return view('administrations.create') // @phpstan-ignore-line
+ ->with(compact('title', 'subTitle', 'mainTitleIcon'));
}
}
diff --git a/app/Http/Controllers/UserGroup/EditController.php b/app/Http/Controllers/UserGroup/EditController.php
index c8d68e991d..db784e2dbb 100644
--- a/app/Http/Controllers/UserGroup/EditController.php
+++ b/app/Http/Controllers/UserGroup/EditController.php
@@ -42,6 +42,7 @@ class EditController extends Controller
$mainTitleIcon = 'fa-book';
app('log')->debug(sprintf('Now at %s', __METHOD__));
- return view('administrations.edit')->with(compact('title', 'subTitle', 'mainTitleIcon'));
+ return view('administrations.edit') // @phpstan-ignore-line
+ ->with(compact('title', 'subTitle', 'mainTitleIcon'));
}
}
diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php
index 6e0bba192f..c68b83ba42 100644
--- a/app/Repositories/Account/AccountRepository.php
+++ b/app/Repositories/Account/AccountRepository.php
@@ -186,8 +186,8 @@ class AccountRepository implements AccountRepositoryInterface
public function getActiveAccountsByType(array $types): Collection
{
$query = $this->user->accounts()->with(
- [
- 'accountmeta' => static function (HasMany $query): void {
+ [ // @phpstan-ignore-line
+ 'accountmeta' => static function (HasMany $query): void { // @phpstan-ignore-line
$query->where('name', 'account_role');
},
'attachments',
@@ -212,7 +212,7 @@ class AccountRepository implements AccountRepositoryInterface
$disk = \Storage::disk('upload');
return $set->each(
- static function (Attachment $attachment) use ($disk) {
+ static function (Attachment $attachment) use ($disk) { // @phpstan-ignore-line
$notes = $attachment->notes()->first();
$attachment->file_exists = $disk->exists($attachment->fileName());
$attachment->notes_text = null !== $notes ? $notes->text : '';
@@ -258,8 +258,8 @@ class AccountRepository implements AccountRepositoryInterface
public function getInactiveAccountsByType(array $types): Collection
{
$query = $this->user->accounts()->with(
- [
- 'accountmeta' => static function (HasMany $query): void {
+ [ // @phpstan-ignore-line
+ 'accountmeta' => static function (HasMany $query): void { // @phpstan-ignore-line
$query->where('name', 'account_role');
},
]
diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php
index c6d666271c..35f58db12e 100644
--- a/app/Repositories/Bill/BillRepository.php
+++ b/app/Repositories/Bill/BillRepository.php
@@ -166,7 +166,7 @@ class BillRepository implements BillRepositoryInterface
$disk = \Storage::disk('upload');
return $set->each(
- static function (Attachment $attachment) use ($disk) {
+ static function (Attachment $attachment) use ($disk) { // @phpstan-ignore-line
$notes = $attachment->notes()->first();
$attachment->file_exists = $disk->exists($attachment->fileName());
$attachment->notes_text = null !== $notes ? $notes->text : '';
diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php
index e35ae55ae8..49ac568e48 100644
--- a/app/Repositories/Budget/BudgetRepository.php
+++ b/app/Repositories/Budget/BudgetRepository.php
@@ -541,7 +541,7 @@ class BudgetRepository implements BudgetRepositoryInterface
$disk = \Storage::disk('upload');
return $set->each(
- static function (Attachment $attachment) use ($disk) {
+ static function (Attachment $attachment) use ($disk) { // @phpstan-ignore-line
$notes = $attachment->notes()->first();
$attachment->file_exists = $disk->exists($attachment->fileName());
$attachment->notes_text = null !== $notes ? $notes->text : '';
diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.php
index d8ad866c45..91fe6a6cce 100644
--- a/app/Repositories/Category/CategoryRepository.php
+++ b/app/Repositories/Category/CategoryRepository.php
@@ -248,7 +248,7 @@ class CategoryRepository implements CategoryRepositoryInterface
$disk = \Storage::disk('upload');
return $set->each(
- static function (Attachment $attachment) use ($disk) {
+ static function (Attachment $attachment) use ($disk) { // @phpstan-ignore-line
$notes = $attachment->notes()->first();
$attachment->file_exists = $disk->exists($attachment->fileName());
$attachment->notes_text = null !== $notes ? $notes->text : '';
diff --git a/app/Repositories/Journal/JournalAPIRepository.php b/app/Repositories/Journal/JournalAPIRepository.php
index f612970d52..71ba154860 100644
--- a/app/Repositories/Journal/JournalAPIRepository.php
+++ b/app/Repositories/Journal/JournalAPIRepository.php
@@ -89,7 +89,7 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface
{
$events = $journal->piggyBankEvents()->get();
$events->each(
- static function (PiggyBankEvent $event): void {
+ static function (PiggyBankEvent $event): void { // @phpstan-ignore-line
$event->piggyBank = PiggyBank::withTrashed()->find($event->piggy_bank_id);
}
);
diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php
index 3458c52652..631670ec21 100644
--- a/app/Repositories/PiggyBank/PiggyBankRepository.php
+++ b/app/Repositories/PiggyBank/PiggyBankRepository.php
@@ -115,7 +115,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
$disk = \Storage::disk('upload');
return $set->each(
- static function (Attachment $attachment) use ($disk) {
+ static function (Attachment $attachment) use ($disk) { // @phpstan-ignore-line
$notes = $attachment->notes()->first();
$attachment->file_exists = $disk->exists($attachment->fileName());
$attachment->notes_text = null !== $notes ? $notes->text : '';
diff --git a/app/Repositories/Rule/RuleRepository.php b/app/Repositories/Rule/RuleRepository.php
index dc60b57122..0c43cdc0db 100644
--- a/app/Repositories/Rule/RuleRepository.php
+++ b/app/Repositories/Rule/RuleRepository.php
@@ -239,6 +239,8 @@ class RuleRepository implements RuleRepositoryInterface
throw new FireflyException('No such rule group.');
}
+ /** @var RuleGroup $ruleGroup */
+
// start by creating a new rule:
$rule = new Rule();
$rule->user()->associate($this->user);
diff --git a/app/Repositories/RuleGroup/RuleGroupRepository.php b/app/Repositories/RuleGroup/RuleGroupRepository.php
index 26c8096039..447151dbad 100644
--- a/app/Repositories/RuleGroup/RuleGroupRepository.php
+++ b/app/Repositories/RuleGroup/RuleGroupRepository.php
@@ -258,7 +258,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
$groups = $this->user->ruleGroups()
->orderBy('order', 'ASC')
->with(
- [
+ [ // @phpstan-ignore-line
'rules' => static function (HasMany $query): void {
$query->orderBy('order', 'ASC');
},
@@ -277,7 +277,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
app('log')->debug(sprintf('Will filter getRuleGroupsWithRules on "%s".', $filter));
return $groups->map(
- static function (RuleGroup $group) use ($filter) {
+ static function (RuleGroup $group) use ($filter) { // @phpstan-ignore-line
app('log')->debug(sprintf('Now filtering group #%d', $group->id));
// filter the rules in the rule group:
$group->rules = $group->rules->filter(
@@ -314,7 +314,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
->orderBy('order', 'ASC')
->where('active', true)
->with(
- [
+ [ // @phpstan-ignore-line
'rules' => static function (HasMany $query): void {
$query->orderBy('order', 'ASC');
},
@@ -333,7 +333,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
app('log')->debug(sprintf('Will filter getRuleGroupsWithRules on "%s".', $filter));
return $groups->map(
- static function (RuleGroup $group) use ($filter) {
+ static function (RuleGroup $group) use ($filter) { // @phpstan-ignore-line
app('log')->debug(sprintf('Now filtering group #%d', $group->id));
// filter the rules in the rule group:
$group->rules = $group->rules->filter(
diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php
index 8d8a9e2f97..3b1427af38 100644
--- a/app/Repositories/Tag/TagRepository.php
+++ b/app/Repositories/Tag/TagRepository.php
@@ -124,7 +124,7 @@ class TagRepository implements TagRepositoryInterface
$disk = \Storage::disk('upload');
return $set->each(
- static function (Attachment $attachment) use ($disk): void {
+ static function (Attachment $attachment) use ($disk): void { // @phpstan-ignore-line
/** @var null|Note $note */
$note = $attachment->notes()->first();
// only used in v1 view of tags
@@ -220,7 +220,7 @@ class TagRepository implements TagRepositoryInterface
$tags->whereLike('tag', $search);
}
- return $tags->take($limit)->get('tags.*');
+ return $tags->take($limit)->get(['tags.*']);
}
public function store(array $data): Tag
diff --git a/app/Repositories/User/UserRepository.php b/app/Repositories/User/UserRepository.php
index ef8b158831..7481e366d7 100644
--- a/app/Repositories/User/UserRepository.php
+++ b/app/Repositories/User/UserRepository.php
@@ -268,6 +268,9 @@ class UserRepository implements UserRepositoryInterface
public function inviteUser(null|Authenticatable|User $user, string $email): InvitedUser
{
+ if(!($user instanceof User)) {
+ throw new FireflyException('User is not a User object.');
+ }
$now = today(config('app.timezone'));
$now->addDays(2);
$invitee = new InvitedUser();
diff --git a/app/Repositories/UserGroups/Currency/CurrencyRepository.php b/app/Repositories/UserGroups/Currency/CurrencyRepository.php
index 96ecb4d4e7..86c116c4b6 100644
--- a/app/Repositories/UserGroups/Currency/CurrencyRepository.php
+++ b/app/Repositories/UserGroups/Currency/CurrencyRepository.php
@@ -193,7 +193,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
public function get(): Collection
{
$all = $this->userGroup->currencies()->orderBy('code', 'ASC')->withPivot(['group_default'])->get();
- $all->map(static function (TransactionCurrency $current) {
+ $all->map(static function (TransactionCurrency $current) { // @phpstan-ignore-line
$current->userGroupEnabled = true;
$current->userGroupDefault = 1 === (int) $current->pivot->group_default;
diff --git a/app/Repositories/Webhook/WebhookRepository.php b/app/Repositories/Webhook/WebhookRepository.php
index aeaeacc080..4c9fd15ca9 100644
--- a/app/Repositories/Webhook/WebhookRepository.php
+++ b/app/Repositories/Webhook/WebhookRepository.php
@@ -78,7 +78,7 @@ class WebhookRepository implements WebhookRepositoryInterface
->where('webhook_messages.errored', 0)
->get(['webhook_messages.*'])
->filter(
- static function (WebhookMessage $message) {
+ static function (WebhookMessage $message) { // @phpstan-ignore-line
return $message->webhookAttempts()->count() <= 2;
}
)->splice(0, 3)
diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php
index 03d531750b..ffe70c6ea4 100644
--- a/app/Validation/FireflyValidator.php
+++ b/app/Validation/FireflyValidator.php
@@ -823,7 +823,7 @@ class FireflyValidator extends Validator
}
$query->where('piggy_banks.name', $value);
- return 0 === $query->count(['piggy_banks.*']);
+ return 0 === $query->count('piggy_banks.*');
}
/**