Skip to content

Firefly III: a personal finances manager

Fix phpstan issues.

James Colea0564751d62e
diff --git a/.ci/phpstan.neon b/.ci/phpstan.neon
index 199e3e3962..08d6b73f36 100644
--- a/.ci/phpstan.neon
+++ b/.ci/phpstan.neon
@@ -56,5 +56,5 @@ parameters:
# The level 8 is the highest level. original was 5
# TODO: slowly up the level and fix the issues found.
- level: 3
+ level: 4
diff --git a/app/Factory/BudgetFactory.php b/app/Factory/BudgetFactory.php
index 728f69c51f..9c284b91f6 100644
--- a/app/Factory/BudgetFactory.php
+++ b/app/Factory/BudgetFactory.php
@@ -50,7 +50,7 @@ class BudgetFactory
// first by ID:
if ($budgetId > 0) {
- /** @var Budget $budget */
+ /** @var Budget|null $budget */
$budget = $this->user->budgets()->find($budgetId);
if (null !== $budget) {
return $budget;
diff --git a/app/Factory/CategoryFactory.php b/app/Factory/CategoryFactory.php
index 84a3c7349f..799740b3a1 100644
--- a/app/Factory/CategoryFactory.php
+++ b/app/Factory/CategoryFactory.php
@@ -54,7 +54,7 @@ class CategoryFactory
}
// first by ID:
if ($categoryId > 0) {
- /** @var Category $category */
+ /** @var Category|null $category */
$category = $this->user->categories()->find($categoryId);
if (null !== $category) {
return $category;
diff --git a/app/Factory/PiggyBankFactory.php b/app/Factory/PiggyBankFactory.php
index 7d6d85fe2d..ec53f757b5 100644
--- a/app/Factory/PiggyBankFactory.php
+++ b/app/Factory/PiggyBankFactory.php
@@ -48,7 +48,7 @@ class PiggyBankFactory
}
// first find by ID:
if ($piggyBankId > 0) {
- /** @var PiggyBank $piggyBank */
+ /** @var PiggyBank|null $piggyBank */
$piggyBank = $this->user->piggyBanks()->find($piggyBankId);
if (null !== $piggyBank) {
return $piggyBank;
@@ -57,7 +57,7 @@ class PiggyBankFactory
// then find by name:
if ('' !== $piggyBankName) {
- /** @var PiggyBank $piggyBank */
+ /** @var PiggyBank|null $piggyBank */
$piggyBank = $this->findByName($piggyBankName);
if (null !== $piggyBank) {
return $piggyBank;
diff --git a/app/Factory/TagFactory.php b/app/Factory/TagFactory.php
index 1e77e66078..e029e4efc8 100644
--- a/app/Factory/TagFactory.php
+++ b/app/Factory/TagFactory.php
@@ -92,6 +92,7 @@ class TagFactory
'longitude' => null,
'zoomLevel' => null,
];
+ /** @var Tag|null $tag */
$tag = Tag::create($array);
if (null !== $tag && null !== $latitude && null !== $longitude) {
// create location object.
diff --git a/app/Factory/TransactionFactory.php b/app/Factory/TransactionFactory.php
index f6e3e3b318..eeb5cf830a 100644
--- a/app/Factory/TransactionFactory.php
+++ b/app/Factory/TransactionFactory.php
@@ -127,7 +127,9 @@ class TransactionFactory
);
// do foreign currency thing: add foreign currency info to $one and $two if necessary.
- if (null !== $this->foreignCurrency && null !== $foreignAmount && $this->foreignCurrency->id !== $this->currency->id && '' !== $foreignAmount) {
+ if (null !== $this->foreignCurrency &&
+ null !== $foreignAmount &&
+ $this->foreignCurrency->id !== $this->currency->id) {
$result->foreign_currency_id = $this->foreignCurrency->id;
$result->foreign_amount = $foreignAmount;
}
diff --git a/app/Handlers/Events/UserEventHandler.php b/app/Handlers/Events/UserEventHandler.php
index a7980f6862..2689d53840 100644
--- a/app/Handlers/Events/UserEventHandler.php
+++ b/app/Handlers/Events/UserEventHandler.php
@@ -131,7 +131,7 @@ class UserEventHandler
$group = null;
// create a new group.
- while (true === $groupExists) {
+ while (true === $groupExists) { /** @phpstan-ignore-line */
$groupExists = UserGroup::where('title', $groupTitle)->count() > 0;
if (false === $groupExists) {
$group = UserGroup::create(['title' => $groupTitle]);
diff --git a/app/Helpers/Attachments/AttachmentHelper.php b/app/Helpers/Attachments/AttachmentHelper.php
index 8dee4f8353..7167e21c1f 100644
--- a/app/Helpers/Attachments/AttachmentHelper.php
+++ b/app/Helpers/Attachments/AttachmentHelper.php
@@ -206,7 +206,7 @@ class AttachmentHelper implements AttachmentHelperInterface
Log::debug(sprintf('Now in saveAttachmentsForModel for model %s', get_class($model)));
if (is_array($files)) {
Log::debug('$files is an array.');
- /** @var UploadedFile $entry */
+ /** @var UploadedFile|null $entry */
foreach ($files as $entry) {
if (null !== $entry) {
$this->processFile($entry, $model);
diff --git a/app/Http/Controllers/Account/CreateController.php b/app/Http/Controllers/Account/CreateController.php
index ff88e40f5b..169df67b86 100644
--- a/app/Http/Controllers/Account/CreateController.php
+++ b/app/Http/Controllers/Account/CreateController.php
@@ -158,7 +158,7 @@ class CreateController extends Controller
}
// store attachment(s):
- /** @var array $files */
+ /** @var array|null $files */
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
if (null !== $files && !auth()->user()->hasRole('demo')) {
$this->attachments->saveAttachmentsForModel($account, $files);
diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php
index 927b37deb8..6149fd77ad 100644
--- a/app/Http/Controllers/Auth/ForgotPasswordController.php
+++ b/app/Http/Controllers/Auth/ForgotPasswordController.php
@@ -79,7 +79,7 @@ class ForgotPasswordController extends Controller
$this->validateEmail($request);
// verify if the user is not a demo user. If so, we give him back an error.
- /** @var User $user */
+ /** @var User|null $user */
$user = User::where('email', $request->get('email'))->first();
if (null !== $user && $repository->hasRole($user, 'demo')) {
diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php
index 4c5e82533d..b381b140ad 100644
--- a/app/Http/Controllers/Auth/LoginController.php
+++ b/app/Http/Controllers/Auth/LoginController.php
@@ -97,7 +97,7 @@ class LoginController extends Controller
// If the class is using the ThrottlesLogins trait, we can automatically throttle
// the login attempts for this application. We'll key this by the username and
// the IP address of the client making these requests into this application.
- if (method_exists($this, 'hasTooManyLoginAttempts') && $this->hasTooManyLoginAttempts($request)) {
+ if ($this->hasTooManyLoginAttempts($request)) {
Log::channel('audit')->info(sprintf('Login for user "%s" was locked out.', $request->get($this->username())));
app('log')->error(sprintf('Login for user "%s" was locked out.', $request->get($this->username())));
$this->fireLockoutEvent($request);
diff --git a/app/Http/Controllers/Bill/CreateController.php b/app/Http/Controllers/Bill/CreateController.php
index abc6f797dd..4976785400 100644
--- a/app/Http/Controllers/Bill/CreateController.php
+++ b/app/Http/Controllers/Bill/CreateController.php
@@ -114,7 +114,7 @@ class CreateController extends Controller
$request->session()->flash('success', (string)trans('firefly.stored_new_bill', ['name' => $bill->name]));
app('preferences')->mark();
- /** @var array $files */
+ /** @var array|null $files */
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
if (null !== $files && !auth()->user()->hasRole('demo')) {
$this->attachments->saveAttachmentsForModel($bill, $files);
diff --git a/app/Http/Controllers/Bill/EditController.php b/app/Http/Controllers/Bill/EditController.php
index d9b692e825..b6a8e89735 100644
--- a/app/Http/Controllers/Bill/EditController.php
+++ b/app/Http/Controllers/Bill/EditController.php
@@ -128,7 +128,7 @@ class EditController extends Controller
$request->session()->flash('success', (string)trans('firefly.updated_bill', ['name' => $bill->name]));
app('preferences')->mark();
- /** @var array $files */
+ /** @var array|null $files */
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
if (null !== $files && !auth()->user()->hasRole('demo')) {
$this->attachments->saveAttachmentsForModel($bill, $files);
diff --git a/app/Http/Controllers/Bill/ShowController.php b/app/Http/Controllers/Bill/ShowController.php
index 29861be314..70f53aadf2 100644
--- a/app/Http/Controllers/Bill/ShowController.php
+++ b/app/Http/Controllers/Bill/ShowController.php
@@ -90,11 +90,7 @@ class ShowController extends Controller
return redirect(route('bills.show', [$bill->id]));
}
- $set = new Collection();
- if (true === $bill->active) {
- $set = $this->repository->getRulesForBill($bill);
- $total = 0;
- }
+ $set = $this->repository->getRulesForBill($bill);
if (0 === $set->count()) {
$request->session()->flash('error', (string)trans('firefly.no_rules_for_bill'));
diff --git a/app/Http/Controllers/PiggyBank/CreateController.php b/app/Http/Controllers/PiggyBank/CreateController.php
index 66c3a8d518..4a3ec07f11 100644
--- a/app/Http/Controllers/PiggyBank/CreateController.php
+++ b/app/Http/Controllers/PiggyBank/CreateController.php
@@ -103,7 +103,7 @@ class CreateController extends Controller
app('preferences')->mark();
// store attachment(s):
- /** @var array $files */
+ /** @var array|null $files */
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
if (null !== $files && !auth()->user()->hasRole('demo')) {
$this->attachments->saveAttachmentsForModel($piggyBank, $files);
diff --git a/app/Http/Controllers/PiggyBank/EditController.php b/app/Http/Controllers/PiggyBank/EditController.php
index a8605716be..6824bb4ab2 100644
--- a/app/Http/Controllers/PiggyBank/EditController.php
+++ b/app/Http/Controllers/PiggyBank/EditController.php
@@ -127,7 +127,7 @@ class EditController extends Controller
app('preferences')->mark();
// store new attachment(s):
- /** @var array $files */
+ /** @var array|null $files */
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
if (null !== $files && !auth()->user()->hasRole('demo')) {
$this->attachments->saveAttachmentsForModel($piggyBank, $files);
diff --git a/app/Http/Controllers/Recurring/CreateController.php b/app/Http/Controllers/Recurring/CreateController.php
index 71fe0dd453..0fcd8bf211 100644
--- a/app/Http/Controllers/Recurring/CreateController.php
+++ b/app/Http/Controllers/Recurring/CreateController.php
@@ -241,7 +241,7 @@ class CreateController extends Controller
app('preferences')->mark();
// store attachment(s):
- /** @var array $files */
+ /** @var array|null $files */
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
if (null !== $files && !auth()->user()->hasRole('demo')) {
$this->attachments->saveAttachmentsForModel($recurrence, $files);
diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php
index 691b36446f..030fa74d3f 100644
--- a/app/Http/Controllers/TagController.php
+++ b/app/Http/Controllers/TagController.php
@@ -327,7 +327,7 @@ class TagController extends Controller
app('preferences')->mark();
// store attachment(s):
- /** @var array $files */
+ /** @var array|null $files */
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
if (null !== $files && !auth()->user()->hasRole('demo')) {
$this->attachmentsHelper->saveAttachmentsForModel($result, $files);
@@ -366,7 +366,7 @@ class TagController extends Controller
app('preferences')->mark();
// store new attachment(s):
- /** @var array $files */
+ /** @var array|null $files */
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
if (null !== $files && !auth()->user()->hasRole('demo')) {
$this->attachmentsHelper->saveAttachmentsForModel($tag, $files);
diff --git a/app/Http/Controllers/Transaction/MassController.php b/app/Http/Controllers/Transaction/MassController.php
index f641ee33a7..1268159611 100644
--- a/app/Http/Controllers/Transaction/MassController.php
+++ b/app/Http/Controllers/Transaction/MassController.php
@@ -106,7 +106,7 @@ class MassController extends Controller
/** @var string $journalId */
foreach ($ids as $journalId) {
app('log')->debug(sprintf('Searching for ID #%d', $journalId));
- /** @var TransactionJournal $journal */
+ /** @var TransactionJournal|null $journal */
$journal = $this->repository->find((int)$journalId);
if (null !== $journal && (int)$journalId === (int)$journal->id) {
$this->repository->destroyJournal($journal);
diff --git a/app/Http/Requests/AccountFormRequest.php b/app/Http/Requests/AccountFormRequest.php
index f39eb03e28..4796680562 100644
--- a/app/Http/Requests/AccountFormRequest.php
+++ b/app/Http/Requests/AccountFormRequest.php
@@ -122,7 +122,7 @@ class AccountFormRequest extends FormRequest
];
$rules = Location::requestRules($rules);
- /** @var Account $account */
+ /** @var Account|null $account */
$account = $this->route()->parameter('account');
if (null !== $account) {
// add rules:
diff --git a/app/Http/Requests/BudgetFormUpdateRequest.php b/app/Http/Requests/BudgetFormUpdateRequest.php
index 91d7d479aa..4cf7c48ce4 100644
--- a/app/Http/Requests/BudgetFormUpdateRequest.php
+++ b/app/Http/Requests/BudgetFormUpdateRequest.php
@@ -65,7 +65,7 @@ class BudgetFormUpdateRequest extends FormRequest
{
$nameRule = 'required|between:1,100|uniqueObjectForUser:budgets,name';
- /** @var Budget $budget */
+ /** @var Budget|null $budget */
$budget = $this->route()->parameter('budget');
if (null !== $budget) {
diff --git a/app/Http/Requests/CategoryFormRequest.php b/app/Http/Requests/CategoryFormRequest.php
index 79b3977eea..9be9ad514c 100644
--- a/app/Http/Requests/CategoryFormRequest.php
+++ b/app/Http/Requests/CategoryFormRequest.php
@@ -57,7 +57,7 @@ class CategoryFormRequest extends FormRequest
public function rules(): array
{
$nameRule = 'required|between:1,100|uniqueObjectForUser:categories,name';
- /** @var Category $category */
+ /** @var Category|null $category */
$category = $this->route()->parameter('category');
if (null !== $category) {
diff --git a/app/Http/Requests/CurrencyFormRequest.php b/app/Http/Requests/CurrencyFormRequest.php
index 228b0538ea..2b5c3a1eaf 100644
--- a/app/Http/Requests/CurrencyFormRequest.php
+++ b/app/Http/Requests/CurrencyFormRequest.php
@@ -68,7 +68,7 @@ class CurrencyFormRequest extends FormRequest
'enabled' => 'in:0,1',
];
- /** @var TransactionCurrency $currency */
+ /** @var TransactionCurrency|null $currency */
$currency = $this->route()->parameter('currency');
if (null !== $currency) {
diff --git a/app/Http/Requests/ObjectGroupFormRequest.php b/app/Http/Requests/ObjectGroupFormRequest.php
index cdf90b70e0..cf77969ebc 100644
--- a/app/Http/Requests/ObjectGroupFormRequest.php
+++ b/app/Http/Requests/ObjectGroupFormRequest.php
@@ -55,7 +55,7 @@ class ObjectGroupFormRequest extends FormRequest
*/
public function rules(): array
{
- /** @var ObjectGroup $objectGroup */
+ /** @var ObjectGroup|null $objectGroup */
$objectGroup = $this->route()->parameter('objectGroup');
$titleRule = 'required|between:1,255|uniqueObjectGroup';
diff --git a/app/Http/Requests/RecurrenceFormRequest.php b/app/Http/Requests/RecurrenceFormRequest.php
index 7c086d3f56..f8334b0c84 100644
--- a/app/Http/Requests/RecurrenceFormRequest.php
+++ b/app/Http/Requests/RecurrenceFormRequest.php
@@ -259,7 +259,7 @@ class RecurrenceFormRequest extends FormRequest
}
// update some rules in case the user is editing a post:
- /** @var Recurrence $recurrence */
+ /** @var Recurrence|null $recurrence */
$recurrence = $this->route()->parameter('recurrence');
if ($recurrence instanceof Recurrence) {
$rules['id'] = 'required|numeric|exists:recurrences,id';
diff --git a/app/Http/Requests/RuleFormRequest.php b/app/Http/Requests/RuleFormRequest.php
index ecd433cfaf..7a3fe63f29 100644
--- a/app/Http/Requests/RuleFormRequest.php
+++ b/app/Http/Requests/RuleFormRequest.php
@@ -164,7 +164,7 @@ class RuleFormRequest extends FormRequest
'strict' => 'in:0,1',
];
- /** @var Rule $rule */
+ /** @var Rule|null $rule */
$rule = $this->route()->parameter('rule');
if (null !== $rule) {
diff --git a/app/Http/Requests/RuleGroupFormRequest.php b/app/Http/Requests/RuleGroupFormRequest.php
index 635bac67b3..60fbaa41af 100644
--- a/app/Http/Requests/RuleGroupFormRequest.php
+++ b/app/Http/Requests/RuleGroupFormRequest.php
@@ -65,7 +65,7 @@ class RuleGroupFormRequest extends FormRequest
{
$titleRule = 'required|between:1,100|uniqueObjectForUser:rule_groups,title';
- /** @var RuleGroup $ruleGroup */
+ /** @var RuleGroup|null $ruleGroup */
$ruleGroup = $this->route()->parameter('ruleGroup');
if (null !== $ruleGroup) {
diff --git a/app/Http/Requests/TagFormRequest.php b/app/Http/Requests/TagFormRequest.php
index 8e04f69211..e631d35232 100644
--- a/app/Http/Requests/TagFormRequest.php
+++ b/app/Http/Requests/TagFormRequest.php
@@ -64,7 +64,7 @@ class TagFormRequest extends FormRequest
{
$idRule = '';
- /** @var Tag $tag */
+ /** @var Tag|null $tag */
$tag = $this->route()->parameter('tag');
$tagRule = 'required|max:1024|min:1|uniqueObjectForUser:tags,tag';
if (null !== $tag) {
diff --git a/app/Models/Account.php b/app/Models/Account.php
index bbc9e10721..4d0606c990 100644
--- a/app/Models/Account.php
+++ b/app/Models/Account.php
@@ -141,7 +141,7 @@ class Account extends Model
$accountId = (int)$value;
/** @var User $user */
$user = auth()->user();
- /** @var Account $account */
+ /** @var Account|null $account */
$account = $user->accounts()->with(['accountType'])->find($accountId);
if (null !== $account) {
return $account;
diff --git a/app/Models/Attachment.php b/app/Models/Attachment.php
index 668cad5914..de6bedd794 100644
--- a/app/Models/Attachment.php
+++ b/app/Models/Attachment.php
@@ -111,7 +111,7 @@ class Attachment extends Model
$attachmentId = (int)$value;
/** @var User $user */
$user = auth()->user();
- /** @var Attachment $attachment */
+ /** @var Attachment|null $attachment */
$attachment = $user->attachments()->find($attachmentId);
if (null !== $attachment) {
return $attachment;
diff --git a/app/Models/AvailableBudget.php b/app/Models/AvailableBudget.php
index 67a44254c7..64c930a5a5 100644
--- a/app/Models/AvailableBudget.php
+++ b/app/Models/AvailableBudget.php
@@ -97,7 +97,7 @@ class AvailableBudget extends Model
$availableBudgetId = (int)$value;
/** @var User $user */
$user = auth()->user();
- /** @var AvailableBudget $availableBudget */
+ /** @var AvailableBudget|null $availableBudget */
$availableBudget = $user->availableBudgets()->find($availableBudgetId);
if (null !== $availableBudget) {
return $availableBudget;
diff --git a/app/Models/Bill.php b/app/Models/Bill.php
index db02bd16b3..d8594599b4 100644
--- a/app/Models/Bill.php
+++ b/app/Models/Bill.php
@@ -156,7 +156,7 @@ class Bill extends Model
$billId = (int)$value;
/** @var User $user */
$user = auth()->user();
- /** @var Bill $bill */
+ /** @var Bill|null $bill */
$bill = $user->bills()->find($billId);
if (null !== $bill) {
return $bill;
diff --git a/app/Models/Budget.php b/app/Models/Budget.php
index 25a9cd98c9..878e4a74cb 100644
--- a/app/Models/Budget.php
+++ b/app/Models/Budget.php
@@ -113,7 +113,7 @@ class Budget extends Model
$budgetId = (int)$value;
/** @var User $user */
$user = auth()->user();
- /** @var Budget $budget */
+ /** @var Budget|null $budget */
$budget = $user->budgets()->find($budgetId);
if (null !== $budget) {
return $budget;
diff --git a/app/Models/Category.php b/app/Models/Category.php
index 4f9692f5af..b0080a04ed 100644
--- a/app/Models/Category.php
+++ b/app/Models/Category.php
@@ -103,7 +103,7 @@ class Category extends Model
$categoryId = (int)$value;
/** @var User $user */
$user = auth()->user();
- /** @var Category $category */
+ /** @var Category|null $category */
$category = $user->categories()->find($categoryId);
if (null !== $category) {
return $category;
diff --git a/app/Models/InvitedUser.php b/app/Models/InvitedUser.php
index 3825ec140a..aa753d8edd 100644
--- a/app/Models/InvitedUser.php
+++ b/app/Models/InvitedUser.php
@@ -77,7 +77,7 @@ class InvitedUser extends Model
{
if (auth()->check()) {
$attemptId = (int)$value;
- /** @var InvitedUser $attempt */
+ /** @var InvitedUser|null $attempt */
$attempt = self::find($attemptId);
if (null !== $attempt) {
return $attempt;
diff --git a/app/Models/ObjectGroup.php b/app/Models/ObjectGroup.php
index 57fa04e6d9..60e4ccfd5e 100644
--- a/app/Models/ObjectGroup.php
+++ b/app/Models/ObjectGroup.php
@@ -89,7 +89,7 @@ class ObjectGroup extends Model
{
if (auth()->check()) {
$objectGroupId = (int)$value;
- /** @var ObjectGroup $objectGroup */
+ /** @var ObjectGroup|null $objectGroup */
$objectGroup = self::where('object_groups.id', $objectGroupId)
->where('object_groups.user_id', auth()->user()->id)->first();
if (null !== $objectGroup) {
diff --git a/app/Models/Recurrence.php b/app/Models/Recurrence.php
index d74474af69..e0f75e5fd1 100644
--- a/app/Models/Recurrence.php
+++ b/app/Models/Recurrence.php
@@ -129,7 +129,7 @@ class Recurrence extends Model
$recurrenceId = (int)$value;
/** @var User $user */
$user = auth()->user();
- /** @var Recurrence $recurrence */
+ /** @var Recurrence|null $recurrence */
$recurrence = $user->recurrences()->find($recurrenceId);
if (null !== $recurrence) {
return $recurrence;
diff --git a/app/Models/Rule.php b/app/Models/Rule.php
index d5f0c251cd..37bacf10f9 100644
--- a/app/Models/Rule.php
+++ b/app/Models/Rule.php
@@ -112,7 +112,7 @@ class Rule extends Model
$ruleId = (int)$value;
/** @var User $user */
$user = auth()->user();
- /** @var Rule $rule */
+ /** @var Rule|null $rule */
$rule = $user->rules()->find($ruleId);
if (null !== $rule) {
return $rule;
diff --git a/app/Models/RuleGroup.php b/app/Models/RuleGroup.php
index 0a94ff166d..5d7dfcf1c3 100644
--- a/app/Models/RuleGroup.php
+++ b/app/Models/RuleGroup.php
@@ -102,7 +102,7 @@ class RuleGroup extends Model
$ruleGroupId = (int)$value;
/** @var User $user */
$user = auth()->user();
- /** @var RuleGroup $ruleGroup */
+ /** @var RuleGroup|null $ruleGroup */
$ruleGroup = $user->ruleGroups()->find($ruleGroupId);
if (null !== $ruleGroup) {
return $ruleGroup;
diff --git a/app/Models/Tag.php b/app/Models/Tag.php
index 1e94127209..d87f83e4eb 100644
--- a/app/Models/Tag.php
+++ b/app/Models/Tag.php
@@ -113,7 +113,7 @@ class Tag extends Model
$tagId = (int)$value;
/** @var User $user */
$user = auth()->user();
- /** @var Tag $tag */
+ /** @var Tag|null $tag */
$tag = $user->tags()->find($tagId);
if (null !== $tag) {
return $tag;
diff --git a/app/Models/TransactionGroup.php b/app/Models/TransactionGroup.php
index b5baeff384..68f2cc11f8 100644
--- a/app/Models/TransactionGroup.php
+++ b/app/Models/TransactionGroup.php
@@ -97,7 +97,7 @@ class TransactionGroup extends Model
/** @var User $user */
$user = auth()->user();
app('log')->debug(sprintf('User authenticated as %s', $user->email));
- /** @var TransactionGroup $group */
+ /** @var TransactionGroup|null $group */
$group = $user->transactionGroups()
->with(['transactionJournals', 'transactionJournals.transactions'])
->where('transaction_groups.id', $groupId)->first(['transaction_groups.*']);
diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php
index 0d00260a13..bbd0c78c3c 100644
--- a/app/Models/TransactionJournal.php
+++ b/app/Models/TransactionJournal.php
@@ -173,7 +173,7 @@ class TransactionJournal extends Model
$journalId = (int)$value;
/** @var User $user */
$user = auth()->user();
- /** @var TransactionJournal $journal */
+ /** @var TransactionJournal|null $journal */
$journal = $user->transactionJournals()->where('transaction_journals.id', $journalId)->first(['transaction_journals.*']);
if (null !== $journal) {
return $journal;
diff --git a/app/Models/Webhook.php b/app/Models/Webhook.php
index f7817b5c13..7632104812 100644
--- a/app/Models/Webhook.php
+++ b/app/Models/Webhook.php
@@ -185,7 +185,7 @@ class Webhook extends Model
$webhookId = (int)$value;
/** @var User $user */
$user = auth()->user();
- /** @var Webhook $webhook */
+ /** @var Webhook|null $webhook */
$webhook = $user->webhooks()->find($webhookId);
if (null !== $webhook) {
return $webhook;
diff --git a/app/Models/WebhookAttempt.php b/app/Models/WebhookAttempt.php
index 810a5a0094..cf7f943388 100644
--- a/app/Models/WebhookAttempt.php
+++ b/app/Models/WebhookAttempt.php
@@ -78,7 +78,7 @@ class WebhookAttempt extends Model
$attemptId = (int)$value;
/** @var User $user */
$user = auth()->user();
- /** @var WebhookAttempt $attempt */
+ /** @var WebhookAttempt|null $attempt */
$attempt = self::find($attemptId);
if (null !== $attempt && $attempt->webhookMessage->webhook->user_id === $user->id) {
return $attempt;
diff --git a/app/Models/WebhookMessage.php b/app/Models/WebhookMessage.php
index c2c18ed12b..d047b0ada3 100644
--- a/app/Models/WebhookMessage.php
+++ b/app/Models/WebhookMessage.php
@@ -92,7 +92,7 @@ class WebhookMessage extends Model
$messageId = (int)$value;
/** @var User $user */
$user = auth()->user();
- /** @var WebhookMessage $message */
+ /** @var WebhookMessage|null $message */
$message = self::find($messageId);
if (null !== $message && $message->webhook->user_id === $user->id) {
return $message;
diff --git a/app/Repositories/Budget/OperationsRepository.php b/app/Repositories/Budget/OperationsRepository.php
index ba03116cfd..6bb1fa70eb 100644
--- a/app/Repositories/Budget/OperationsRepository.php
+++ b/app/Repositories/Budget/OperationsRepository.php
@@ -146,7 +146,7 @@ class OperationsRepository implements OperationsRepositoryInterface
if (null !== $budgets && $budgets->count() > 0) {
$collector->setBudgets($budgets);
}
- if (null === $budgets || (null !== $budgets && 0 === $budgets->count())) {
+ if (null === $budgets || 0 === $budgets->count()) {
$collector->setBudgets($this->getBudgets());
}
$collector->withBudgetInformation()->withAccountInformation()->withCategoryInformation();
diff --git a/app/Repositories/Category/OperationsRepository.php b/app/Repositories/Category/OperationsRepository.php
index 220ffb87db..7a7887562b 100644
--- a/app/Repositories/Category/OperationsRepository.php
+++ b/app/Repositories/Category/OperationsRepository.php
@@ -63,7 +63,7 @@ class OperationsRepository implements OperationsRepositoryInterface
if (null !== $categories && $categories->count() > 0) {
$collector->setCategories($categories);
}
- if (null === $categories || (null !== $categories && 0 === $categories->count())) {
+ if (null === $categories || 0 === $categories->count()) {
$collector->setCategories($this->getCategories());
}
$collector->withCategoryInformation()->withAccountInformation()->withBudgetInformation();
@@ -159,7 +159,7 @@ class OperationsRepository implements OperationsRepositoryInterface
if (null !== $categories && $categories->count() > 0) {
$collector->setCategories($categories);
}
- if (null === $categories || (null !== $categories && 0 === $categories->count())) {
+ if (null === $categories || 0 === $categories->count()) {
$collector->setCategories($this->getCategories());
}
$collector->withCategoryInformation()->withAccountInformation();
@@ -223,7 +223,7 @@ class OperationsRepository implements OperationsRepositoryInterface
if (null !== $categories && $categories->count() > 0) {
$collector->setCategories($categories);
}
- if (null === $categories || (null !== $categories && 0 === $categories->count())) {
+ if (null === $categories || 0 === $categories->count()) {
$collector->setCategories($this->getCategories());
}
$collector->withCategoryInformation()->withAccountInformation()->withBudgetInformation();
@@ -288,7 +288,7 @@ class OperationsRepository implements OperationsRepositoryInterface
if (null !== $categories && $categories->count() > 0) {
$collector->setCategories($categories);
}
- if (null === $categories || (null !== $categories && 0 === $categories->count())) {
+ if (null === $categories || 0 === $categories->count()) {
$collector->setCategories($this->getCategories());
}
$collector->withCategoryInformation()->withAccountInformation()->withBudgetInformation();
@@ -361,7 +361,7 @@ class OperationsRepository implements OperationsRepositoryInterface
if (null !== $accounts && $accounts->count() > 0) {
$collector->setAccounts($accounts);
}
- if (null === $categories || (null !== $categories && 0 === $categories->count())) {
+ if (null === $categories || 0 === $categories->count()) {
$categories = $this->getCategories();
}
$collector->setCategories($categories);
@@ -405,7 +405,7 @@ class OperationsRepository implements OperationsRepositoryInterface
if (null !== $accounts && $accounts->count() > 0) {
$collector->setAccounts($accounts);
}
- if (null === $categories || (null !== $categories && 0 === $categories->count())) {
+ if (null === $categories || 0 === $categories->count()) {
$categories = $this->getCategories();
}
$collector->setCategories($categories);
@@ -448,7 +448,7 @@ class OperationsRepository implements OperationsRepositoryInterface
if (null !== $accounts && $accounts->count() > 0) {
$collector->setAccounts($accounts);
}
- if (null === $categories || (null !== $categories && 0 === $categories->count())) {
+ if (null === $categories || 0 === $categories->count()) {
$categories = $this->getCategories();
}
$collector->setCategories($categories);
diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php
index 3693dfff13..5f5abbdb8e 100644
--- a/app/Repositories/Journal/JournalRepository.php
+++ b/app/Repositories/Journal/JournalRepository.php
@@ -89,7 +89,7 @@ class JournalRepository implements JournalRepositoryInterface
*/
public function firstNull(): ?TransactionJournal
{
- /** @var TransactionJournal $entry */
+ /** @var TransactionJournal|null $entry */
$entry = $this->user->transactionJournals()->orderBy('date', 'ASC')->first(['transaction_journals.*']);
$result = null;
if (null !== $entry) {
diff --git a/app/Repositories/LinkType/LinkTypeRepository.php b/app/Repositories/LinkType/LinkTypeRepository.php
index 729dc4709b..cdb6dd0331 100644
--- a/app/Repositories/LinkType/LinkTypeRepository.php
+++ b/app/Repositories/LinkType/LinkTypeRepository.php
@@ -347,7 +347,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
*/
public function switchLinkById(int $linkId): bool
{
- /** @var TransactionJournalLink $link */
+ /** @var TransactionJournalLink|null $link */
$link = TransactionJournalLink::find($linkId);
if (null !== $link && $link->source->user->id === $this->user->id) {
$this->switchLink($link);
diff --git a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php b/app/Repositories/PiggyBank/ModifiesPiggyBanks.php
index c4f6843ed3..6205206882 100644
--- a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php
+++ b/app/Repositories/PiggyBank/ModifiesPiggyBanks.php
@@ -404,11 +404,8 @@ trait ModifiesPiggyBanks
return $piggyBank;
}
- // remove if name is empty. Should be overruled by ID.
- if ('' === $objectGroupTitle) {
- $piggyBank->objectGroups()->sync([]);
- $piggyBank->save();
- }
+ $piggyBank->objectGroups()->sync([]);
+ $piggyBank->save();
}
// try also with ID:
diff --git a/app/Repositories/Tag/OperationsRepository.php b/app/Repositories/Tag/OperationsRepository.php
index 0ea45c2fd0..4f1db0d665 100644
--- a/app/Repositories/Tag/OperationsRepository.php
+++ b/app/Repositories/Tag/OperationsRepository.php
@@ -67,7 +67,7 @@ class OperationsRepository implements OperationsRepositoryInterface
if (null !== $tags && $tags->count() > 0) {
$collector->setTags($tags);
}
- if (null === $tags || (null !== $tags && 0 === $tags->count())) {
+ if (null === $tags || 0 === $tags->count()) {
$collector->setTags($this->getTags());
}
$collector->withCategoryInformation()->withAccountInformation()->withBudgetInformation()->withTagInformation();
@@ -166,7 +166,7 @@ class OperationsRepository implements OperationsRepositoryInterface
if (null !== $tags && $tags->count() > 0) {
$collector->setTags($tags);
}
- if (null === $tags || (null !== $tags && 0 === $tags->count())) {
+ if (null === $tags || 0 === $tags->count()) {
$collector->setTags($this->getTags());
}
$collector->withCategoryInformation()->withAccountInformation()->withBudgetInformation()->withTagInformation();
diff --git a/app/Repositories/UserGroup/UserGroupRepository.php b/app/Repositories/UserGroup/UserGroupRepository.php
index 818a857b4a..3df3d341bf 100644
--- a/app/Repositories/UserGroup/UserGroupRepository.php
+++ b/app/Repositories/UserGroup/UserGroupRepository.php
@@ -104,7 +104,7 @@ class UserGroupRepository implements UserGroupRepositoryInterface
$memberships = $this->user->groupMemberships()->get();
/** @var GroupMembership $membership */
foreach ($memberships as $membership) {
- /** @var UserGroup $group */
+ /** @var UserGroup|null $group */
$group = $membership->userGroup()->first();
if (null !== $group) {
$collection->push($group);
@@ -131,6 +131,7 @@ class UserGroupRepository implements UserGroupRepositoryInterface
$existingGroup = $this->findByName($groupName);
if (null === $existingGroup) {
$exists = false;
+ /** @var UserGroup|null $existingGroup */
$existingGroup = $this->store(['user' => $user, 'title' => $groupName]);
}
if (null !== $existingGroup) {
diff --git a/app/Services/Internal/Destroy/AccountDestroyService.php b/app/Services/Internal/Destroy/AccountDestroyService.php
index 73ccc995e3..1cd34e6295 100644
--- a/app/Services/Internal/Destroy/AccountDestroyService.php
+++ b/app/Services/Internal/Destroy/AccountDestroyService.php
@@ -161,7 +161,7 @@ class AccountDestroyService
/** @var Transaction $transaction */
foreach ($account->transactions()->get() as $transaction) {
app('log')->debug('Now at transaction #' . $transaction->id);
- /** @var TransactionJournal $journal */
+ /** @var TransactionJournal|null $journal */
$journal = $transaction->transactionJournal()->first();
if (null !== $journal) {
app('log')->debug('Call for deletion of journal #' . $journal->id);
diff --git a/app/Services/Internal/Support/AccountServiceTrait.php b/app/Services/Internal/Support/AccountServiceTrait.php
index afefb43d4f..eeed7d1db6 100644
--- a/app/Services/Internal/Support/AccountServiceTrait.php
+++ b/app/Services/Internal/Support/AccountServiceTrait.php
@@ -137,7 +137,7 @@ trait AccountServiceTrait
$data['account_role'] = '';
}
- if ($account->accountType->type === AccountType::ASSET && array_key_exists('account_role', $data) && 'ccAsset' === $data['account_role']) {
+ if ($account->accountType->type === AccountType::ASSET && 'ccAsset' === $data['account_role']) {
$fields = $this->validCCFields;
}
/** @var AccountMetaFactory $factory */
diff --git a/app/Services/Internal/Support/JournalServiceTrait.php b/app/Services/Internal/Support/JournalServiceTrait.php
index 29627b49ed..dc9743d1da 100644
--- a/app/Services/Internal/Support/JournalServiceTrait.php
+++ b/app/Services/Internal/Support/JournalServiceTrait.php
@@ -461,10 +461,8 @@ trait JournalServiceTrait
return;
}
- if ('' === $notes && null !== $note) {
- // try to delete existing notes.
- $note->delete();
- }
+ // try to delete existing notes.
+ $note?->delete();
}
/**
diff --git a/app/Services/Internal/Update/BillUpdateService.php b/app/Services/Internal/Update/BillUpdateService.php
index d948548734..75a8ca4863 100644
--- a/app/Services/Internal/Update/BillUpdateService.php
+++ b/app/Services/Internal/Update/BillUpdateService.php
@@ -113,10 +113,8 @@ class BillUpdateService
return $bill;
}
// remove if name is empty. Should be overruled by ID.
- if ('' === $objectGroupTitle) {
- $bill->objectGroups()->sync([]);
- $bill->save();
- }
+ $bill->objectGroups()->sync([]);
+ $bill->save();
}
if (array_key_exists('object_group_id', $data)) {
// try also with ID:
@@ -130,10 +128,8 @@ class BillUpdateService
return $bill;
}
- if (0 === $objectGroupId) {
- $bill->objectGroups()->sync([]);
- $bill->save();
- }
+ $bill->objectGroups()->sync([]);
+ $bill->save();
}
return $bill;
diff --git a/app/Services/Internal/Update/GroupCloneService.php b/app/Services/Internal/Update/GroupCloneService.php
index 21a0e3bbc4..7c8f68b709 100644
--- a/app/Services/Internal/Update/GroupCloneService.php
+++ b/app/Services/Internal/Update/GroupCloneService.php
@@ -105,7 +105,7 @@ class GroupCloneService
// add relation.
// TODO clone ALL linked piggy banks
- /** @var PiggyBankEvent $event */
+ /** @var PiggyBankEvent|null $event */
$event = $journal->piggyBankEvents()->first();
if (null !== $event) {
$piggyBank = $event->piggyBank;
diff --git a/app/Services/Internal/Update/JournalUpdateService.php b/app/Services/Internal/Update/JournalUpdateService.php
index ce2e0984cb..5ab0375721 100644
--- a/app/Services/Internal/Update/JournalUpdateService.php
+++ b/app/Services/Internal/Update/JournalUpdateService.php
@@ -497,9 +497,9 @@ class JournalUpdateService
{
$type = $this->transactionJournal->transactionType->type;
if ((
- array_key_exists('bill_id', $this->data)
+ array_key_exists('bill_id', $this->data)
|| array_key_exists('bill_name', $this->data)
- )
+ )
&& TransactionType::WITHDRAWAL === $type
) {
$billId = (int)($this->data['bill_id'] ?? 0);
@@ -690,24 +690,22 @@ class JournalUpdateService
$currencyId = $this->data['currency_id'] ?? null;
$currencyCode = $this->data['currency_code'] ?? null;
$currency = $this->currencyRepository->findCurrency($currencyId, $currencyCode);
- if (null !== $currency) {
- // update currency everywhere.
- $this->transactionJournal->transaction_currency_id = $currency->id;
- $this->transactionJournal->save();
+ // update currency everywhere.
+ $this->transactionJournal->transaction_currency_id = $currency->id;
+ $this->transactionJournal->save();
- $source = $this->getSourceTransaction();
- $source->transaction_currency_id = $currency->id;
- $source->save();
+ $source = $this->getSourceTransaction();
+ $source->transaction_currency_id = $currency->id;
+ $source->save();
- $dest = $this->getDestinationTransaction();
- $dest->transaction_currency_id = $currency->id;
- $dest->save();
+ $dest = $this->getDestinationTransaction();
+ $dest->transaction_currency_id = $currency->id;
+ $dest->save();
- // refresh transactions.
- $this->sourceTransaction->refresh();
- $this->destinationTransaction->refresh();
- app('log')->debug(sprintf('Updated currency to #%d (%s)', $currency->id, $currency->code));
- }
+ // refresh transactions.
+ $this->sourceTransaction->refresh();
+ $this->destinationTransaction->refresh();
+ app('log')->debug(sprintf('Updated currency to #%d (%s)', $currency->id, $currency->code));
}
/**
diff --git a/app/Support/Cronjobs/AutoBudgetCronjob.php b/app/Support/Cronjobs/AutoBudgetCronjob.php
index 18f09d9481..6008e834c8 100644
--- a/app/Support/Cronjobs/AutoBudgetCronjob.php
+++ b/app/Support/Cronjobs/AutoBudgetCronjob.php
@@ -55,11 +55,7 @@ class AutoBudgetCronjob extends AbstractCronjob
return;
}
-
- // fire job regardless.
- if (true === $this->force) {
- app('log')->info('Execution of the auto budget cron-job has been FORCED.');
- }
+ app('log')->info('Execution of the auto budget cron-job has been FORCED.');
}
if ($lastTime > 0 && $diff > 43200) {
diff --git a/app/Support/Cronjobs/BillWarningCronjob.php b/app/Support/Cronjobs/BillWarningCronjob.php
index 55e7ba400c..2e290c18f7 100644
--- a/app/Support/Cronjobs/BillWarningCronjob.php
+++ b/app/Support/Cronjobs/BillWarningCronjob.php
@@ -65,10 +65,7 @@ class BillWarningCronjob extends AbstractCronjob
return;
}
- // fire job regardless.
- if (true === $this->force) {
- app('log')->info('Execution of the bill warning cron-job has been FORCED.');
- }
+ app('log')->info('Execution of the bill warning cron-job has been FORCED.');
}
if ($lastTime > 0 && $diff > 43200) {
diff --git a/app/Support/Cronjobs/ExchangeRatesCronjob.php b/app/Support/Cronjobs/ExchangeRatesCronjob.php
index 0705e2b207..9793078677 100644
--- a/app/Support/Cronjobs/ExchangeRatesCronjob.php
+++ b/app/Support/Cronjobs/ExchangeRatesCronjob.php
@@ -56,10 +56,7 @@ class ExchangeRatesCronjob extends AbstractCronjob
return;
}
- // fire job regardless.
- if (true === $this->force) {
- app('log')->info('Execution of the exchange rates cron-job has been FORCED.');
- }
+ app('log')->info('Execution of the exchange rates cron-job has been FORCED.');
}
if ($lastTime > 0 && $diff > 43200) {
diff --git a/app/Support/Cronjobs/RecurringCronjob.php b/app/Support/Cronjobs/RecurringCronjob.php
index 99dfa64250..3388398140 100644
--- a/app/Support/Cronjobs/RecurringCronjob.php
+++ b/app/Support/Cronjobs/RecurringCronjob.php
@@ -64,11 +64,7 @@ class RecurringCronjob extends AbstractCronjob
return;
}
-
- // fire job regardless.
- if (true === $this->force) {
- app('log')->info('Execution of the recurring transaction cron-job has been FORCED.');
- }
+ app('log')->info('Execution of the recurring transaction cron-job has been FORCED.');
}
if ($lastTime > 0 && $diff > 43200) {
diff --git a/app/Support/Form/FormSupport.php b/app/Support/Form/FormSupport.php
index 5867a2116f..3078bcf9ee 100644
--- a/app/Support/Form/FormSupport.php
+++ b/app/Support/Form/FormSupport.php
@@ -104,7 +104,7 @@ trait FormSupport
protected function getHolderClasses(string $name): string
{
// Get errors from session:
- /** @var MessageBag $errors */
+ /** @var MessageBag|null $errors */
$errors = session('errors');
$classes = 'form-group';
diff --git a/app/Support/Request/ChecksLogin.php b/app/Support/Request/ChecksLogin.php
index 49184c5d94..90ac3207ee 100644
--- a/app/Support/Request/ChecksLogin.php
+++ b/app/Support/Request/ChecksLogin.php
@@ -45,7 +45,7 @@ trait ChecksLogin
if (!$check) {
return false;
}
- if (!property_exists($this, 'acceptedRoles')) {
+ if (!property_exists($this, 'acceptedRoles')) { // @phpstan-ignore-line
app('log')->debug('Request class has no acceptedRoles array');
return true; // check for false already took place.
}
diff --git a/app/Support/Request/ConvertsDataTypes.php b/app/Support/Request/ConvertsDataTypes.php
index f94d25124f..00102adccc 100644
--- a/app/Support/Request/ConvertsDataTypes.php
+++ b/app/Support/Request/ConvertsDataTypes.php
@@ -166,7 +166,7 @@ trait ConvertsDataTypes
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
- if (method_exists($this, 'validateUserGroup')) {
+ if (method_exists($this, 'validateUserGroup')) { /** @phpstan-ignore-line */
$userGroup = $this->validateUserGroup($this);
if (null !== $userGroup) {
$repository->setUserGroup($userGroup);
diff --git a/app/Transformers/BillTransformer.php b/app/Transformers/BillTransformer.php
index a1ed960e7f..a22a798261 100644
--- a/app/Transformers/BillTransformer.php
+++ b/app/Transformers/BillTransformer.php
@@ -68,7 +68,7 @@ class BillTransformer extends AbstractTransformer
$objectGroupId = null;
$objectGroupOrder = null;
$objectGroupTitle = null;
- /** @var ObjectGroup $objectGroup */
+ /** @var ObjectGroup|null $objectGroup */
$objectGroup = $bill->objectGroups->first();
if (null !== $objectGroup) {
$objectGroupId = (int)$objectGroup->id;
diff --git a/app/Transformers/PiggyBankTransformer.php b/app/Transformers/PiggyBankTransformer.php
index 33eb503b19..65962cc2d7 100644
--- a/app/Transformers/PiggyBankTransformer.php
+++ b/app/Transformers/PiggyBankTransformer.php
@@ -76,7 +76,7 @@ class PiggyBankTransformer extends AbstractTransformer
$objectGroupId = null;
$objectGroupOrder = null;
$objectGroupTitle = null;
- /** @var ObjectGroup $objectGroup */
+ /** @var ObjectGroup|null $objectGroup */
$objectGroup = $piggyBank->objectGroups->first();
if (null !== $objectGroup) {
$objectGroupId = (int)$objectGroup->id;
diff --git a/app/Transformers/RecurrenceTransformer.php b/app/Transformers/RecurrenceTransformer.php
index a480c05d9d..9cb12f48bd 100644
--- a/app/Transformers/RecurrenceTransformer.php
+++ b/app/Transformers/RecurrenceTransformer.php
@@ -26,6 +26,7 @@ namespace FireflyIII\Transformers;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Factory\CategoryFactory;
+use FireflyIII\Models\Account;
use FireflyIII\Models\Recurrence;
use FireflyIII\Models\RecurrenceRepetition;
use FireflyIII\Models\RecurrenceTransaction;
@@ -161,7 +162,9 @@ class RecurrenceTransformer extends AbstractTransformer
// get all transactions:
/** @var RecurrenceTransaction $transaction */
foreach ($recurrence->recurrenceTransactions()->get() as $transaction) {
+ /** @var Account|null $sourceAccount */
$sourceAccount = $transaction->sourceAccount;
+ /** @var Account|null $destinationAccount */
$destinationAccount = $transaction->destinationAccount;
$foreignCurrencyCode = null;
$foreignCurrencySymbol = null;
diff --git a/app/Transformers/TagTransformer.php b/app/Transformers/TagTransformer.php
index 067a508cd2..873c66e885 100644
--- a/app/Transformers/TagTransformer.php
+++ b/app/Transformers/TagTransformer.php
@@ -43,7 +43,7 @@ class TagTransformer extends AbstractTransformer
public function transform(Tag $tag): array
{
$date = $tag->date?->format('Y-m-d');
- /** @var Location $location */
+ /** @var Location|null $location */
$location = $tag->locations()->first();
$latitude = null;
$longitude = null;
diff --git a/app/Validation/GroupValidation.php b/app/Validation/GroupValidation.php
index bdfe6c4e1c..4b5a2b2138 100644
--- a/app/Validation/GroupValidation.php
+++ b/app/Validation/GroupValidation.php
@@ -59,7 +59,7 @@ trait GroupValidation
'source_number',
'destination_number',
];
- /** @var array $transaction */
+ /** @var array|null $transaction */
foreach ($transactions as $index => $transaction) {
if (!is_array($transaction)) {
throw new FireflyException('Invalid data submitted: transaction is not array.');
diff --git a/app/Validation/RecurrenceValidation.php b/app/Validation/RecurrenceValidation.php
index 0c245d5c47..e19dc81013 100644
--- a/app/Validation/RecurrenceValidation.php
+++ b/app/Validation/RecurrenceValidation.php
@@ -53,7 +53,7 @@ trait RecurrenceValidation
// grab model from parameter and try to set the transaction type from it
if ('invalid' === $transactionType) {
app('log')->debug('Type is invalid but we will search for it.');
- /** @var Recurrence $recurrence */
+ /** @var Recurrence|null $recurrence */
$recurrence = $this->route()->parameter('recurrence');
if (null !== $recurrence) {
app('log')->debug('There is a recurrence in the route.');
diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.php
index d4db3effc8..eedc402612 100644
--- a/app/Validation/TransactionValidation.php
+++ b/app/Validation/TransactionValidation.php
@@ -61,7 +61,7 @@ trait TransactionValidation
app('log')->debug(sprintf('Going to loop %d transaction(s)', count($transactions)));
/**
- * @var int $index
+ * @var int|null $index
* @var array $transaction
*/
foreach ($transactions as $index => $transaction) {
@@ -84,19 +84,13 @@ trait TransactionValidation
app('log')->debug('Now in getTransactionsArray');
$data = $validator->getData();
$transactions = [];
- if (is_array($data) && array_key_exists('transactions', $data) && is_array($data['transactions'])) {
+ if (array_key_exists('transactions', $data) && is_array($data['transactions'])) {
app('log')->debug('Transactions key exists and is array.');
$transactions = $data['transactions'];
}
- if (is_array($data) && array_key_exists('transactions', $data) && !is_array($data['transactions'])) {
+ if (array_key_exists('transactions', $data) && !is_array($data['transactions'])) {
app('log')->debug(sprintf('Transactions key exists but is NOT array, its a %s', gettype($data['transactions'])));
}
- // should be impossible to hit this:
- if (!is_countable($transactions)) {
- app('log')->error(sprintf('Transactions array is not countable, because its a %s', gettype($transactions)));
- return [];
- }
- //app('log')->debug('Returning transactions.', $transactions);
return $transactions;
}
@@ -383,7 +377,7 @@ trait TransactionValidation
$transactions = $this->getTransactionsArray($validator);
/**
- * @var int $index
+ * @var int|null $index
* @var array $transaction
*/
foreach ($transactions as $index => $transaction) {
@@ -783,13 +777,13 @@ trait TransactionValidation
if (0 === $journalId) {
return $return;
}
- /** @var Transaction $source */
+ /** @var Transaction|null $source */
$source = Transaction::where('transaction_journal_id', $journalId)->where('amount', '<', 0)->with(['account'])->first();
if (null !== $source) {
$return['source_id'] = $source->account_id;
$return['source_name'] = $source->account->name;
}
- /** @var Transaction $destination */
+ /** @var Transaction|null $destination */
$destination = Transaction::where('transaction_journal_id', $journalId)->where('amount', '>', 0)->with(['account'])->first();
if (null !== $source) {
$return['destination_id'] = $destination->account_id;