Fix phpstan level 3!

This commit is contained in:
James Cole
2025-01-04 07:10:37 +01:00
parent cd296aa9ac
commit 2baac1a6d7
52 changed files with 113 additions and 113 deletions

View File

@@ -16,6 +16,8 @@ parameters:
- '#Dynamic call to static method#' # all the Laravel ORM things depend on this. - '#Dynamic call to static method#' # all the Laravel ORM things depend on this.
- identifier: varTag.nativeType - identifier: varTag.nativeType
- identifier: varTag.type - identifier: varTag.type
# phpstan can't handle this so we ignore them.
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Relations\\HasMany::before#' - '#Call to an undefined method Illuminate\\Database\\Eloquent\\Relations\\HasMany::before#'
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Relations\\HasMany::after#' - '#Call to an undefined method Illuminate\\Database\\Eloquent\\Relations\\HasMany::after#'
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Relations\\HasMany::withTrashed#' - '#Call to an undefined method Illuminate\\Database\\Eloquent\\Relations\\HasMany::withTrashed#'

View File

@@ -55,23 +55,9 @@ class ConvertsDatesToUTC extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
/**
* The console command description.
*
* @var string
*/
protected $description = 'Convert stored dates to UTC.'; protected $description = 'Convert stored dates to UTC.';
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'correction:convert-to-utc'; protected $signature = 'correction:convert-to-utc';
/**
* Execute the console command.
*/
public function handle(): int public function handle(): int
{ {
$this->friendlyWarning('Please do not use this command right now.'); $this->friendlyWarning('Please do not use this command right now.');

View File

@@ -67,7 +67,7 @@ class CorrectsOpeningBalanceCurrencies extends Command
private function getJournals(): Collection private function getJournals(): Collection
{ {
// @var Collection /** @var Collection */
return TransactionJournal::leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id') return TransactionJournal::leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
->whereNull('transaction_journals.deleted_at') ->whereNull('transaction_journals.deleted_at')
->where('transaction_types.type', TransactionTypeEnum::OPENING_BALANCE->value)->get(['transaction_journals.*']) ->where('transaction_types.type', TransactionTypeEnum::OPENING_BALANCE->value)->get(['transaction_journals.*'])

View File

@@ -81,18 +81,7 @@ class CorrectsTimezoneInformation extends Command
TransactionJournal::class => ['date'], TransactionJournal::class => ['date'],
]; ];
/**
* The console command description.
*
* @var string
*/
protected $description = 'Make sure all dates have a timezone.'; protected $description = 'Make sure all dates have a timezone.';
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'correction:timezones'; protected $signature = 'correction:timezones';
/** /**

View File

@@ -138,11 +138,13 @@ class UpgradesLiabilities extends Command
private function getSourceTransaction(TransactionJournal $journal): ?Transaction private function getSourceTransaction(TransactionJournal $journal): ?Transaction
{ {
/** @var Transaction|null */
return $journal->transactions()->where('amount', '<', 0)->first(); return $journal->transactions()->where('amount', '<', 0)->first();
} }
private function getDestinationTransaction(TransactionJournal $journal): ?Transaction private function getDestinationTransaction(TransactionJournal $journal): ?Transaction
{ {
/** @var Transaction|null */
return $journal->transactions()->where('amount', '>', 0)->first(); return $journal->transactions()->where('amount', '>', 0)->first();
} }

View File

@@ -208,6 +208,7 @@ class UpgradesTransferCurrencies extends Command
private function getSourceTransaction(TransactionJournal $transfer): ?Transaction private function getSourceTransaction(TransactionJournal $transfer): ?Transaction
{ {
/** @var Transaction|null */
return $transfer->transactions()->where('amount', '<', 0)->first(); return $transfer->transactions()->where('amount', '<', 0)->first();
} }
@@ -243,6 +244,7 @@ class UpgradesTransferCurrencies extends Command
private function getDestinationTransaction(TransactionJournal $transfer): ?Transaction private function getDestinationTransaction(TransactionJournal $transfer): ?Transaction
{ {
/** @var Transaction|null */
return $transfer->transactions()->where('amount', '>', 0)->first(); return $transfer->transactions()->where('amount', '>', 0)->first();
} }

View File

@@ -175,7 +175,7 @@ class UpgradesVariousCurrencyInformation extends Command
*/ */
private function getLeadTransaction(TransactionJournal $journal): ?Transaction private function getLeadTransaction(TransactionJournal $journal): ?Transaction
{ {
/** @var Transaction $lead */ /** @var Transaction|null $lead */
$lead = null; $lead = null;
switch ($journal->transactionType->type) { switch ($journal->transactionType->type) {
@@ -214,7 +214,7 @@ class UpgradesVariousCurrencyInformation extends Command
break; break;
} }
/** @var Transaction|null */
return $lead; return $lead;
} }

View File

@@ -160,7 +160,7 @@ class AccountFactory
app('log')->debug(sprintf('Now in AccountFactory::find("%s", "%s")', $accountName, $accountType)); app('log')->debug(sprintf('Now in AccountFactory::find("%s", "%s")', $accountName, $accountType));
$type = AccountType::whereType($accountType)->first(); $type = AccountType::whereType($accountType)->first();
// @var Account|null /** @var Account|null */
return $this->user->accounts()->where('account_type_id', $type->id)->where('name', $accountName)->first(); return $this->user->accounts()->where('account_type_id', $type->id)->where('name', $accountName)->first();
} }

View File

@@ -129,6 +129,7 @@ class BillFactory
public function findByName(string $name): ?Bill public function findByName(string $name): ?Bill
{ {
/** @var Bill|null */
return $this->user->bills()->whereLike('name', sprintf('%%%s%%', $name))->first(); return $this->user->bills()->whereLike('name', sprintf('%%%s%%', $name))->first();
} }

View File

@@ -63,6 +63,7 @@ class BudgetFactory
public function findByName(string $name): ?Budget public function findByName(string $name): ?Budget
{ {
/** @var Budget|null */
return $this->user->budgets()->where('name', $name)->first(); return $this->user->budgets()->where('name', $name)->first();
} }

View File

@@ -84,6 +84,7 @@ class CategoryFactory
public function findByName(string $name): ?Category public function findByName(string $name): ?Category
{ {
/** @var Category|null */
return $this->user->categories()->where('name', $name)->first(); return $this->user->categories()->where('name', $name)->first();
} }

View File

@@ -41,14 +41,7 @@ class PiggyBankFactory
{ {
use CreatesObjectGroups; use CreatesObjectGroups;
public User $user { public User $user;
set(User $value) {
$this->user = $value;
$this->currencyRepository->setUser($value);
$this->accountRepository->setUser($value);
$this->piggyBankRepository->setUser($value);
}
}
private AccountRepositoryInterface $accountRepository; private AccountRepositoryInterface $accountRepository;
private CurrencyRepositoryInterface $currencyRepository; private CurrencyRepositoryInterface $currencyRepository;
private PiggyBankRepositoryInterface $piggyBankRepository; private PiggyBankRepositoryInterface $piggyBankRepository;
@@ -60,6 +53,14 @@ class PiggyBankFactory
$this->piggyBankRepository = app(PiggyBankRepositoryInterface::class); $this->piggyBankRepository = app(PiggyBankRepositoryInterface::class);
} }
public function setUser(User $user): void
{
$this->user = $user;
$this->currencyRepository->setUser($user);
$this->accountRepository->setUser($user);
$this->piggyBankRepository->setUser($user);
}
/** /**
* Store a piggy bank or come back with an exception. * Store a piggy bank or come back with an exception.
*/ */
@@ -146,8 +147,7 @@ class PiggyBankFactory
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id') ->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
->where('accounts.user_id', $this->user->id) ->where('accounts.user_id', $this->user->id)
->where('piggy_banks.id', $piggyBankId) ->where('piggy_banks.id', $piggyBankId)
->first(['piggy_banks.*']) ->first(['piggy_banks.*']);
;
if (null !== $piggyBank) { if (null !== $piggyBank) {
return $piggyBank; return $piggyBank;
} }
@@ -171,8 +171,7 @@ class PiggyBankFactory
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id') ->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
->where('accounts.user_id', $this->user->id) ->where('accounts.user_id', $this->user->id)
->where('piggy_banks.name', $name) ->where('piggy_banks.name', $name)
->first(['piggy_banks.*']) ->first(['piggy_banks.*']);
;
} }
private function setOrder(PiggyBank $piggyBank, array $data): PiggyBank private function setOrder(PiggyBank $piggyBank, array $data): PiggyBank
@@ -200,8 +199,7 @@ class PiggyBankFactory
'objectGroups', 'objectGroups',
] ]
) )
->orderBy('piggy_banks.order', 'ASC')->get(['piggy_banks.*']) ->orderBy('piggy_banks.order', 'ASC')->get(['piggy_banks.*']);
;
$current = 1; $current = 1;
foreach ($set as $piggyBank) { foreach ($set as $piggyBank) {
if ($piggyBank->order !== $current) { if ($piggyBank->order !== $current) {

View File

@@ -132,7 +132,7 @@ class StandardMessageGenerator implements MessageGeneratorInterface
return; return;
case TransactionGroup::class: case TransactionGroup::class:
// @var TransactionGroup $model /** @var TransactionGroup $model */
$basicMessage['user_id'] = $model->user->id; $basicMessage['user_id'] = $model->user->id;
break; break;

View File

@@ -85,11 +85,13 @@ class ShowController extends Controller
return $this->redirectAccountToAccount($account); return $this->redirectAccountToAccount($account);
} }
// @var Carbon $start
$start ??= session('start'); $start ??= session('start');
// @var Carbon $end
$end ??= session('end'); $end ??= session('end');
/** @var Carbon $start */
/** @var Carbon $end */
if ($end->lt($start)) { if ($end->lt($start)) {
[$start, $end] = [$end, $start]; [$start, $end] = [$end, $start];
} }

View File

@@ -79,10 +79,12 @@ class ShowController extends Controller
*/ */
public function noBudget(Request $request, ?Carbon $start = null, ?Carbon $end = null) public function noBudget(Request $request, ?Carbon $start = null, ?Carbon $end = null)
{ {
// @var Carbon $start
$start ??= session('start'); $start ??= session('start');
// @var Carbon $end
$end ??= session('end'); $end ??= session('end');
/** @var Carbon $start */
/** @var Carbon $end */
$subTitle = trans( $subTitle = trans(
'firefly.without_budget_between', 'firefly.without_budget_between',
['start' => $start->isoFormat($this->monthAndDayFormat), 'end' => $end->isoFormat($this->monthAndDayFormat)] ['start' => $start->isoFormat($this->monthAndDayFormat), 'end' => $end->isoFormat($this->monthAndDayFormat)]

View File

@@ -75,10 +75,12 @@ class NoCategoryController extends Controller
public function show(Request $request, ?Carbon $start = null, ?Carbon $end = null) public function show(Request $request, ?Carbon $start = null, ?Carbon $end = null)
{ {
app('log')->debug('Start of noCategory()'); app('log')->debug('Start of noCategory()');
// @var Carbon $start
$start ??= session('start'); $start ??= session('start');
// @var Carbon $end
$end ??= session('end'); $end ??= session('end');
/** @var Carbon $start */
/** @var Carbon $end */
$page = (int) $request->get('page'); $page = (int) $request->get('page');
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data; $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
$subTitle = trans( $subTitle = trans(

View File

@@ -74,10 +74,12 @@ class ShowController extends Controller
*/ */
public function show(Request $request, Category $category, ?Carbon $start = null, ?Carbon $end = null) public function show(Request $request, Category $category, ?Carbon $start = null, ?Carbon $end = null)
{ {
// @var Carbon $start
$start ??= session('start', today(config('app.timezone'))->startOfMonth()); $start ??= session('start', today(config('app.timezone'))->startOfMonth());
// @var Carbon $end
$end ??= session('end', today(config('app.timezone'))->endOfMonth()); $end ??= session('end', today(config('app.timezone'))->endOfMonth());
/** @var Carbon $start */
/** @var Carbon $end */
$subTitleIcon = 'fa-bookmark'; $subTitleIcon = 'fa-bookmark';
$page = (int) $request->get('page'); $page = (int) $request->get('page');
$attachments = $this->repository->getAttachments($category); $attachments = $this->repository->getAttachments($category);

View File

@@ -67,6 +67,7 @@ class DebugController extends Controller
if (!auth()->user()->hasRole('owner')) { if (!auth()->user()->hasRole('owner')) {
throw new NotFoundHttpException(); throw new NotFoundHttpException();
} }
/** @var iterable $routes */
$routes = Route::getRoutes(); $routes = Route::getRoutes();
$return = []; $return = [];

View File

@@ -179,8 +179,9 @@ class IndexController extends Controller
private function mergeAccountsAndPiggies(array $piggyBanks, array $accounts): array private function mergeAccountsAndPiggies(array $piggyBanks, array $accounts): array
{ {
// @var array $piggyBank /** @var array $group */
foreach ($piggyBanks as $group) { foreach ($piggyBanks as $group) {
/** @var array $piggyBank */
foreach ($group['piggy_banks'] as $piggyBank) { foreach ($group['piggy_banks'] as $piggyBank) {
// loop all accounts in this piggy bank subtract the current amount from "left to save" in the $accounts array. // loop all accounts in this piggy bank subtract the current amount from "left to save" in the $accounts array.
/** @var array $piggyAccount */ /** @var array $piggyAccount */

View File

@@ -203,6 +203,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
) )
); );
/** @var BudgetLimit|null */
return $budget->budgetlimits() return $budget->budgetlimits()
->where('start_date', $start->format('Y-m-d')) ->where('start_date', $start->format('Y-m-d'))
->where('end_date', $end->format('Y-m-d'))->first() ->where('end_date', $end->format('Y-m-d'))->first()

View File

@@ -40,8 +40,6 @@ class AccountMeta extends Model
]; ];
protected $fillable = ['account_id', 'name', 'data']; protected $fillable = ['account_id', 'name', 'data'];
/** @var string The table to store the data in */
protected $table = 'account_meta'; protected $table = 'account_meta';
public function account(): BelongsTo public function account(): BelongsTo

View File

@@ -41,7 +41,6 @@ class Configuration extends Model
'deleted_at' => 'datetime', 'deleted_at' => 'datetime',
]; ];
/** @var string The table to store the data in */
protected $table = 'configuration'; protected $table = 'configuration';
/** /**

View File

@@ -79,6 +79,7 @@ class Preference extends Model
$preference = $user->preferences()->where('id', (int) $value)->first(); $preference = $user->preferences()->where('id', (int) $value)->first();
} }
if (null !== $preference) { if (null !== $preference) {
/** @var Preference $preference */
return $preference; return $preference;
} }
$default = config('firefly.default_preferences'); $default = config('firefly.default_preferences');
@@ -89,7 +90,6 @@ class Preference extends Model
$preference->user_id = (int) $user->id; $preference->user_id = (int) $user->id;
$preference->user_group_id = in_array($value, $items, true) ? $userGroupId : null; $preference->user_group_id = in_array($value, $items, true) ? $userGroupId : null;
$preference->save(); $preference->save();
return $preference; return $preference;
} }
} }

View File

@@ -63,7 +63,6 @@ class Recurrence extends Model
protected $fillable protected $fillable
= ['user_id', 'transaction_type_id', 'title', 'description', 'first_date', 'first_date_tz', 'repeat_until', 'repeat_until_tz', 'latest_date', 'latest_date_tz', 'repetitions', 'apply_rules', 'active']; = ['user_id', 'transaction_type_id', 'title', 'description', 'first_date', 'first_date_tz', 'repeat_until', 'repeat_until_tz', 'latest_date', 'latest_date_tz', 'repetitions', 'apply_rules', 'active'];
/** @var string The table to store the data in */
protected $table = 'recurrences'; protected $table = 'recurrences';
/** /**

View File

@@ -48,7 +48,6 @@ class RecurrenceMeta extends Model
protected $fillable = ['recurrence_id', 'name', 'value']; protected $fillable = ['recurrence_id', 'name', 'value'];
/** @var string The table to store the data in */
protected $table = 'recurrences_meta'; protected $table = 'recurrences_meta';
public function recurrence(): BelongsTo public function recurrence(): BelongsTo

View File

@@ -62,7 +62,6 @@ class RecurrenceRepetition extends Model
protected $fillable = ['recurrence_id', 'weekend', 'repetition_type', 'repetition_moment', 'repetition_skip']; protected $fillable = ['recurrence_id', 'weekend', 'repetition_type', 'repetition_moment', 'repetition_skip'];
/** @var string The table to store the data in */
protected $table = 'recurrences_repetitions'; protected $table = 'recurrences_repetitions';
public function recurrence(): BelongsTo public function recurrence(): BelongsTo

View File

@@ -60,7 +60,6 @@ class RecurrenceTransaction extends Model
'description', 'description',
]; ];
/** @var string The table to store the data in */
protected $table = 'recurrences_transactions'; protected $table = 'recurrences_transactions';
public function destinationAccount(): BelongsTo public function destinationAccount(): BelongsTo

View File

@@ -48,7 +48,6 @@ class RecurrenceTransactionMeta extends Model
protected $fillable = ['rt_id', 'name', 'value']; protected $fillable = ['rt_id', 'name', 'value'];
/** @var string The table to store the data in */
protected $table = 'rt_meta'; protected $table = 'rt_meta';
public function recurrenceTransaction(): BelongsTo public function recurrenceTransaction(): BelongsTo

View File

@@ -42,7 +42,6 @@ class TransactionJournalLink extends Model
'updated_at' => 'datetime', 'updated_at' => 'datetime',
]; ];
/** @var string The table to store the data in */
protected $table = 'journal_links'; protected $table = 'journal_links';
/** /**

View File

@@ -45,7 +45,6 @@ class TransactionJournalMeta extends Model
protected $fillable = ['transaction_journal_id', 'name', 'data', 'hash']; protected $fillable = ['transaction_journal_id', 'name', 'data', 'hash'];
/** @var string The table to store the data in */
protected $table = 'journal_meta'; protected $table = 'journal_meta';
/** /**

View File

@@ -42,8 +42,6 @@ class AccountPolicy
/** /**
* Everybody can do this, but selection should limit to user. * Everybody can do this, but selection should limit to user.
*
* @return true
*/ */
public function viewAny(): bool public function viewAny(): bool
{ {
@@ -54,8 +52,6 @@ class AccountPolicy
/** /**
* Everybody can do this, but selection should limit to user. * Everybody can do this, but selection should limit to user.
*
* @return true
*/ */
public function viewUser(User $user, Account $account): bool public function viewUser(User $user, Account $account): bool
{ {

View File

@@ -39,8 +39,6 @@ class BalancePolicy
/** /**
* Everybody can do this, but selection should limit to user. * Everybody can do this, but selection should limit to user.
*
* @return true
*/ */
public function viewAny(): bool public function viewAny(): bool
{ {

View File

@@ -77,7 +77,7 @@ class CurrencyServiceProvider extends ServiceProvider
$this->app->bind( $this->app->bind(
ExchangeRateRepositoryInterface::class, ExchangeRateRepositoryInterface::class,
static function (Application $app) { static function (Application $app) {
// @var ExchangeRateRepository $repository /** @var ExchangeRateRepository */
return app(ExchangeRateRepository::class); return app(ExchangeRateRepository::class);
} }
); );

View File

@@ -120,7 +120,7 @@ class AccountRepository implements AccountRepositoryInterface
$dbQuery->whereIn('account_types.type', $types); $dbQuery->whereIn('account_types.type', $types);
} }
// @var Account|null /** @var Account|null */
return $dbQuery->first(['accounts.*']); return $dbQuery->first(['accounts.*']);
} }
@@ -134,7 +134,7 @@ class AccountRepository implements AccountRepositoryInterface
$query->whereIn('account_types.type', $types); $query->whereIn('account_types.type', $types);
} }
// @var Account|null /** @var Account|null */
return $query->where('iban', $iban)->first(['accounts.*']); return $query->where('iban', $iban)->first(['accounts.*']);
} }
@@ -278,7 +278,7 @@ class AccountRepository implements AccountRepositoryInterface
public function getLocation(Account $account): ?Location public function getLocation(Account $account): ?Location
{ {
// @var Location|null /** @var Location|null */
return $account->locations()->first(); return $account->locations()->first();
} }
@@ -428,6 +428,7 @@ class AccountRepository implements AccountRepositoryInterface
public function find(int $accountId): ?Account public function find(int $accountId): ?Account
{ {
/** @var Account|null */
return $this->user->accounts()->find($accountId); return $this->user->accounts()->find($accountId);
} }

View File

@@ -142,6 +142,7 @@ class BillRepository implements BillRepositoryInterface
*/ */
public function find(int $billId): ?Bill public function find(int $billId): ?Bill
{ {
/** @var Bill|null */
return $this->user->bills()->find($billId); return $this->user->bills()->find($billId);
} }
@@ -150,6 +151,7 @@ class BillRepository implements BillRepositoryInterface
*/ */
public function findByName(string $name): ?Bill public function findByName(string $name): ?Bill
{ {
/** @var Bill|null */
return $this->user->bills()->where('name', $name)->first(['bills.*']); return $this->user->bills()->where('name', $name)->first(['bills.*']);
} }

View File

@@ -103,6 +103,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
*/ */
public function find(TransactionCurrency $currency, Carbon $start, Carbon $end): ?AvailableBudget public function find(TransactionCurrency $currency, Carbon $start, Carbon $end): ?AvailableBudget
{ {
/** @var AvailableBudget|null */
return $this->user->availableBudgets() return $this->user->availableBudgets()
->where('transaction_currency_id', $currency->id) ->where('transaction_currency_id', $currency->id)
->where('start_date', $start->format('Y-m-d')) ->where('start_date', $start->format('Y-m-d'))
@@ -194,6 +195,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
public function getByCurrencyDate(Carbon $start, Carbon $end, TransactionCurrency $currency): ?AvailableBudget public function getByCurrencyDate(Carbon $start, Carbon $end, TransactionCurrency $currency): ?AvailableBudget
{ {
/** @var AvailableBudget|null */
return $this->user return $this->user
->availableBudgets() ->availableBudgets()
->where('transaction_currency_id', $currency->id) ->where('transaction_currency_id', $currency->id)
@@ -207,6 +209,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
*/ */
public function setAvailableBudget(TransactionCurrency $currency, Carbon $start, Carbon $end, string $amount): AvailableBudget public function setAvailableBudget(TransactionCurrency $currency, Carbon $start, Carbon $end, string $amount): AvailableBudget
{ {
/** @var AvailableBudget */
$availableBudget = $this->user->availableBudgets() $availableBudget = $this->user->availableBudgets()
->where('transaction_currency_id', $currency->id) ->where('transaction_currency_id', $currency->id)
->where('start_date', $start->format('Y-m-d')) ->where('start_date', $start->format('Y-m-d'))
@@ -223,7 +226,6 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
} }
$availableBudget->amount = $amount; $availableBudget->amount = $amount;
$availableBudget->save(); $availableBudget->save();
return $availableBudget; return $availableBudget;
} }

View File

@@ -324,6 +324,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
public function find(Budget $budget, TransactionCurrency $currency, Carbon $start, Carbon $end): ?BudgetLimit public function find(Budget $budget, TransactionCurrency $currency, Carbon $start, Carbon $end): ?BudgetLimit
{ {
/** @var BudgetLimit|null */
return $budget->budgetlimits() return $budget->budgetlimits()
->where('transaction_currency_id', $currency->id) ->where('transaction_currency_id', $currency->id)
->where('start_date', $start->format('Y-m-d')) ->where('start_date', $start->format('Y-m-d'))

View File

@@ -384,6 +384,7 @@ class BudgetRepository implements BudgetRepositoryInterface
public function getAutoBudget(Budget $budget): ?AutoBudget public function getAutoBudget(Budget $budget): ?AutoBudget
{ {
/** @var AutoBudget|null */
return $budget->autoBudgets()->first(); return $budget->autoBudgets()->first();
} }
@@ -442,6 +443,7 @@ class BudgetRepository implements BudgetRepositoryInterface
*/ */
public function find(?int $budgetId = null): ?Budget public function find(?int $budgetId = null): ?Budget
{ {
/** @var Budget|null */
return $this->user->budgets()->find($budgetId); return $this->user->budgets()->find($budgetId);
} }
@@ -513,7 +515,7 @@ class BudgetRepository implements BudgetRepositoryInterface
return null; return null;
} }
$query = sprintf('%%%s%%', $name); $query = sprintf('%%%s%%', $name);
/** @var Budget|null */
return $this->user->budgets()->whereLike('name', $query)->first(); return $this->user->budgets()->whereLike('name', $query)->first();
} }

View File

@@ -129,6 +129,7 @@ class CategoryRepository implements CategoryRepositoryInterface
*/ */
public function find(int $categoryId): ?Category public function find(int $categoryId): ?Category
{ {
/** @var Category|null */
return $this->user->categories()->find($categoryId); return $this->user->categories()->find($categoryId);
} }
@@ -137,6 +138,7 @@ class CategoryRepository implements CategoryRepositoryInterface
*/ */
public function findByName(string $name): ?Category public function findByName(string $name): ?Category
{ {
/** @var Category|null */
return $this->user->categories()->where('name', $name)->first(['categories.*']); return $this->user->categories()->where('name', $name)->first(['categories.*']);
} }

View File

@@ -185,6 +185,7 @@ class JournalRepository implements JournalRepositoryInterface
*/ */
public function find(int $journalId): ?TransactionJournal public function find(int $journalId): ?TransactionJournal
{ {
/** @var TransactionJournal|null */
return $this->user->transactionJournals()->find($journalId); return $this->user->transactionJournals()->find($journalId);
} }

View File

@@ -33,6 +33,7 @@ trait CreatesObjectGroups
{ {
protected function findObjectGroupById(int $groupId): ?ObjectGroup protected function findObjectGroupById(int $groupId): ?ObjectGroup
{ {
/** @var ObjectGroup|null */
return $this->user->objectGroups()->where('id', $groupId)->first(); return $this->user->objectGroups()->where('id', $groupId)->first();
} }
@@ -66,6 +67,7 @@ trait CreatesObjectGroups
protected function findObjectGroup(string $title): ?ObjectGroup protected function findObjectGroup(string $title): ?ObjectGroup
{ {
/** @var ObjectGroup|null */
return $this->user->objectGroups()->where('title', $title)->first(); return $this->user->objectGroups()->where('title', $title)->first();
} }
} }

View File

@@ -313,7 +313,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
throw new FireflyException('[b] Piggy bank repetitions are EOL.'); throw new FireflyException('[b] Piggy bank repetitions are EOL.');
} }
Log::warning('Piggy bank repetitions are EOL.'); Log::warning('Piggy bank repetitions are EOL.');
/** @var PiggyBankRepetition|null */
return $piggyBank->piggyBankRepetitions()->first(); return $piggyBank->piggyBankRepetitions()->first();
} }

View File

@@ -96,6 +96,7 @@ class RuleRepository implements RuleRepositoryInterface
*/ */
public function getFirstRuleGroup(): RuleGroup public function getFirstRuleGroup(): RuleGroup
{ {
/** @var RuleGroup|null */
return $this->user->ruleGroups()->first(); return $this->user->ruleGroups()->first();
} }
@@ -276,6 +277,7 @@ class RuleRepository implements RuleRepositoryInterface
public function find(int $ruleId): ?Rule public function find(int $ruleId): ?Rule
{ {
/** @var Rule|null */
return $this->user->rules()->find($ruleId); return $this->user->rules()->find($ruleId);
} }

View File

@@ -208,11 +208,13 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
public function find(int $ruleGroupId): ?RuleGroup public function find(int $ruleGroupId): ?RuleGroup
{ {
/** @var RuleGroup|null */
return $this->user->ruleGroups()->find($ruleGroupId); return $this->user->ruleGroups()->find($ruleGroupId);
} }
public function findByTitle(string $title): ?RuleGroup public function findByTitle(string $title): ?RuleGroup
{ {
/** @var RuleGroup|null */
return $this->user->ruleGroups()->where('title', $title)->first(); return $this->user->ruleGroups()->where('title', $title)->first();
} }

View File

@@ -101,18 +101,19 @@ class TagRepository implements TagRepositoryInterface
public function find(int $tagId): ?Tag public function find(int $tagId): ?Tag
{ {
/** @var Tag|null */
return $this->user->tags()->find($tagId); return $this->user->tags()->find($tagId);
} }
public function findByTag(string $tag): ?Tag public function findByTag(string $tag): ?Tag
{ {
// @var Tag|null /** @var Tag|null */
return $this->user->tags()->where('tag', $tag)->first(); return $this->user->tags()->where('tag', $tag)->first();
} }
public function firstUseDate(Tag $tag): ?Carbon public function firstUseDate(Tag $tag): ?Carbon
{ {
// @var Carbon|null /** @var Carbon|null */
return $tag->transactionJournals()->orderBy('date', 'ASC')->first()?->date; return $tag->transactionJournals()->orderBy('date', 'ASC')->first()?->date;
} }
@@ -180,7 +181,7 @@ class TagRepository implements TagRepositoryInterface
public function lastUseDate(Tag $tag): ?Carbon public function lastUseDate(Tag $tag): ?Carbon
{ {
// @var Carbon|null /** @var Carbon|null */
return $tag->transactionJournals()->orderBy('date', 'DESC')->first()?->date; return $tag->transactionJournals()->orderBy('date', 'DESC')->first()?->date;
} }
@@ -189,13 +190,13 @@ class TagRepository implements TagRepositoryInterface
*/ */
public function newestTag(): ?Tag public function newestTag(): ?Tag
{ {
// @var Tag|null /** @var Tag|null */
return $this->user->tags()->whereNotNull('date')->orderBy('date', 'DESC')->first(); return $this->user->tags()->whereNotNull('date')->orderBy('date', 'DESC')->first();
} }
public function oldestTag(): ?Tag public function oldestTag(): ?Tag
{ {
// @var Tag|null /** @var Tag|null */
return $this->user->tags()->whereNotNull('date')->orderBy('date', 'ASC')->first(); return $this->user->tags()->whereNotNull('date')->orderBy('date', 'ASC')->first();
} }
@@ -380,7 +381,7 @@ class TagRepository implements TagRepositoryInterface
public function getLocation(Tag $tag): ?Location public function getLocation(Tag $tag): ?Location
{ {
// @var Location|null /** @var Location|null */
return $tag->locations()->first(); return $tag->locations()->first();
} }
} }

View File

@@ -69,6 +69,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
*/ */
public function find(int $groupId): ?TransactionGroup public function find(int $groupId): ?TransactionGroup
{ {
/** @var TransactionGroup|null */
return $this->user->transactionGroups()->find($groupId); return $this->user->transactionGroups()->find($groupId);
} }
@@ -290,6 +291,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
/** @var TransactionJournal $journal */ /** @var TransactionJournal $journal */
$journal = $this->user->transactionJournals()->find($journalId); $journal = $this->user->transactionJournals()->find($journalId);
/** @var Location|null */
return $journal->locations()->first(); return $journal->locations()->first();
} }

View File

@@ -76,7 +76,7 @@ class AccountRepository implements AccountRepositoryInterface
$dbQuery->whereIn('account_types.type', $types); $dbQuery->whereIn('account_types.type', $types);
} }
// @var Account|null /** @var Account|null */
return $dbQuery->first(['accounts.*']); return $dbQuery->first(['accounts.*']);
} }
@@ -90,7 +90,7 @@ class AccountRepository implements AccountRepositoryInterface
$query->whereIn('account_types.type', $types); $query->whereIn('account_types.type', $types);
} }
// @var Account|null /** @var Account|null */
return $query->where('iban', $iban)->first(['accounts.*']); return $query->where('iban', $iban)->first(['accounts.*']);
} }
@@ -167,7 +167,7 @@ class AccountRepository implements AccountRepositoryInterface
if (null === $account) { if (null === $account) {
$account = $this->userGroup->accounts()->find($accountId); $account = $this->userGroup->accounts()->find($accountId);
} }
/** @var Account|null */
return $account; return $account;
} }

View File

@@ -199,7 +199,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
return $current; return $current;
}); });
/** @var Collection */
return $all; return $all;
} }

View File

@@ -61,6 +61,7 @@ class ExchangeRateRepository implements ExchangeRateRepositoryInterface
#[\Override] #[\Override]
public function getSpecificRateOnDate(TransactionCurrency $from, TransactionCurrency $to, Carbon $date): ?CurrencyExchangeRate public function getSpecificRateOnDate(TransactionCurrency $from, TransactionCurrency $to, Carbon $date): ?CurrencyExchangeRate
{ {
/** @var CurrencyExchangeRate|null */
return return
$this->userGroup->currencyExchangeRates() $this->userGroup->currencyExchangeRates()
->where('from_currency_id', $from->id) ->where('from_currency_id', $from->id)

View File

@@ -39,9 +39,10 @@ class IsUniqueAccount implements ValidationRule, DataAwareRule
protected \Closure $fail; protected \Closure $fail;
#[\Override] #[\Override]
public function setData(array $data): void public function setData(array $data): self // @phpstan-ignore-line
{ {
$this->data = $data; $this->data = $data;
return $this;
} }
#[\Override] #[\Override]

View File

@@ -250,6 +250,7 @@ class BillUpdateService
private function getRuleTrigger(Rule $rule, string $key): ?RuleTrigger private function getRuleTrigger(Rule $rule, string $key): ?RuleTrigger
{ {
/** @var RuleTrigger|null */
return $rule->ruleTriggers()->where('trigger_type', $key)->first(); return $rule->ruleTriggers()->where('trigger_type', $key)->first();
} }
} }

View File

@@ -238,11 +238,9 @@ class JournalUpdateService
private function getSourceTransaction(): Transaction private function getSourceTransaction(): Transaction
{ {
if (null === $this->sourceTransaction) { if (null === $this->sourceTransaction) {
$this->sourceTransaction = $this->transactionJournal->transactions()->with(['account'])->where( /** @var Transaction|null $result */
'amount', $result = $this->transactionJournal->transactions()->with(['account'])->where('amount', '<', 0)->first();
'<', $this->sourceTransaction = $result;
0
)->first();
} }
Log::debug(sprintf('getSourceTransaction: %s', $this->sourceTransaction->amount)); Log::debug(sprintf('getSourceTransaction: %s', $this->sourceTransaction->amount));
@@ -321,7 +319,9 @@ class JournalUpdateService
private function getDestinationTransaction(): Transaction private function getDestinationTransaction(): Transaction
{ {
if (null === $this->destinationTransaction) { if (null === $this->destinationTransaction) {
$this->destinationTransaction = $this->transactionJournal->transactions()->where('amount', '>', 0)->first(); /** @var Transaction|null $result */
$result = $this->transactionJournal->transactions()->where('amount', '>', 0)->first();
$this->destinationTransaction = $result;
} }
return $this->destinationTransaction; return $this->destinationTransaction;