mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-20 19:42:02 +00:00
Fix phpstan level 3!
This commit is contained in:
@@ -120,7 +120,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$dbQuery->whereIn('account_types.type', $types);
|
||||
}
|
||||
|
||||
// @var Account|null
|
||||
/** @var Account|null */
|
||||
return $dbQuery->first(['accounts.*']);
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$query->whereIn('account_types.type', $types);
|
||||
}
|
||||
|
||||
// @var Account|null
|
||||
/** @var Account|null */
|
||||
return $query->where('iban', $iban)->first(['accounts.*']);
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
|
||||
public function getLocation(Account $account): ?Location
|
||||
{
|
||||
// @var Location|null
|
||||
/** @var Location|null */
|
||||
return $account->locations()->first();
|
||||
}
|
||||
|
||||
@@ -428,6 +428,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
|
||||
public function find(int $accountId): ?Account
|
||||
{
|
||||
/** @var Account|null */
|
||||
return $this->user->accounts()->find($accountId);
|
||||
}
|
||||
|
||||
|
||||
@@ -142,6 +142,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
*/
|
||||
public function find(int $billId): ?Bill
|
||||
{
|
||||
/** @var Bill|null */
|
||||
return $this->user->bills()->find($billId);
|
||||
}
|
||||
|
||||
@@ -150,6 +151,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
*/
|
||||
public function findByName(string $name): ?Bill
|
||||
{
|
||||
/** @var Bill|null */
|
||||
return $this->user->bills()->where('name', $name)->first(['bills.*']);
|
||||
}
|
||||
|
||||
|
||||
@@ -103,6 +103,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
|
||||
*/
|
||||
public function find(TransactionCurrency $currency, Carbon $start, Carbon $end): ?AvailableBudget
|
||||
{
|
||||
/** @var AvailableBudget|null */
|
||||
return $this->user->availableBudgets()
|
||||
->where('transaction_currency_id', $currency->id)
|
||||
->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
|
||||
{
|
||||
/** @var AvailableBudget|null */
|
||||
return $this->user
|
||||
->availableBudgets()
|
||||
->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
|
||||
{
|
||||
/** @var AvailableBudget */
|
||||
$availableBudget = $this->user->availableBudgets()
|
||||
->where('transaction_currency_id', $currency->id)
|
||||
->where('start_date', $start->format('Y-m-d'))
|
||||
@@ -223,7 +226,6 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
|
||||
}
|
||||
$availableBudget->amount = $amount;
|
||||
$availableBudget->save();
|
||||
|
||||
return $availableBudget;
|
||||
}
|
||||
|
||||
|
||||
@@ -324,6 +324,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
|
||||
|
||||
public function find(Budget $budget, TransactionCurrency $currency, Carbon $start, Carbon $end): ?BudgetLimit
|
||||
{
|
||||
/** @var BudgetLimit|null */
|
||||
return $budget->budgetlimits()
|
||||
->where('transaction_currency_id', $currency->id)
|
||||
->where('start_date', $start->format('Y-m-d'))
|
||||
|
||||
@@ -384,6 +384,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
|
||||
public function getAutoBudget(Budget $budget): ?AutoBudget
|
||||
{
|
||||
/** @var AutoBudget|null */
|
||||
return $budget->autoBudgets()->first();
|
||||
}
|
||||
|
||||
@@ -442,6 +443,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
*/
|
||||
public function find(?int $budgetId = null): ?Budget
|
||||
{
|
||||
/** @var Budget|null */
|
||||
return $this->user->budgets()->find($budgetId);
|
||||
}
|
||||
|
||||
@@ -513,7 +515,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
return null;
|
||||
}
|
||||
$query = sprintf('%%%s%%', $name);
|
||||
|
||||
/** @var Budget|null */
|
||||
return $this->user->budgets()->whereLike('name', $query)->first();
|
||||
}
|
||||
|
||||
|
||||
@@ -129,6 +129,7 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
*/
|
||||
public function find(int $categoryId): ?Category
|
||||
{
|
||||
/** @var Category|null */
|
||||
return $this->user->categories()->find($categoryId);
|
||||
}
|
||||
|
||||
@@ -137,6 +138,7 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
*/
|
||||
public function findByName(string $name): ?Category
|
||||
{
|
||||
/** @var Category|null */
|
||||
return $this->user->categories()->where('name', $name)->first(['categories.*']);
|
||||
}
|
||||
|
||||
|
||||
@@ -185,6 +185,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
*/
|
||||
public function find(int $journalId): ?TransactionJournal
|
||||
{
|
||||
/** @var TransactionJournal|null */
|
||||
return $this->user->transactionJournals()->find($journalId);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ trait CreatesObjectGroups
|
||||
{
|
||||
protected function findObjectGroupById(int $groupId): ?ObjectGroup
|
||||
{
|
||||
/** @var ObjectGroup|null */
|
||||
return $this->user->objectGroups()->where('id', $groupId)->first();
|
||||
}
|
||||
|
||||
@@ -66,6 +67,7 @@ trait CreatesObjectGroups
|
||||
|
||||
protected function findObjectGroup(string $title): ?ObjectGroup
|
||||
{
|
||||
/** @var ObjectGroup|null */
|
||||
return $this->user->objectGroups()->where('title', $title)->first();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
throw new FireflyException('[b] Piggy bank repetitions are EOL.');
|
||||
}
|
||||
Log::warning('Piggy bank repetitions are EOL.');
|
||||
|
||||
/** @var PiggyBankRepetition|null */
|
||||
return $piggyBank->piggyBankRepetitions()->first();
|
||||
}
|
||||
|
||||
|
||||
@@ -96,6 +96,7 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
*/
|
||||
public function getFirstRuleGroup(): RuleGroup
|
||||
{
|
||||
/** @var RuleGroup|null */
|
||||
return $this->user->ruleGroups()->first();
|
||||
}
|
||||
|
||||
@@ -276,6 +277,7 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
|
||||
public function find(int $ruleId): ?Rule
|
||||
{
|
||||
/** @var Rule|null */
|
||||
return $this->user->rules()->find($ruleId);
|
||||
}
|
||||
|
||||
|
||||
@@ -208,11 +208,13 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
|
||||
public function find(int $ruleGroupId): ?RuleGroup
|
||||
{
|
||||
/** @var RuleGroup|null */
|
||||
return $this->user->ruleGroups()->find($ruleGroupId);
|
||||
}
|
||||
|
||||
public function findByTitle(string $title): ?RuleGroup
|
||||
{
|
||||
/** @var RuleGroup|null */
|
||||
return $this->user->ruleGroups()->where('title', $title)->first();
|
||||
}
|
||||
|
||||
|
||||
@@ -101,18 +101,19 @@ class TagRepository implements TagRepositoryInterface
|
||||
|
||||
public function find(int $tagId): ?Tag
|
||||
{
|
||||
/** @var Tag|null */
|
||||
return $this->user->tags()->find($tagId);
|
||||
}
|
||||
|
||||
public function findByTag(string $tag): ?Tag
|
||||
{
|
||||
// @var Tag|null
|
||||
/** @var Tag|null */
|
||||
return $this->user->tags()->where('tag', $tag)->first();
|
||||
}
|
||||
|
||||
public function firstUseDate(Tag $tag): ?Carbon
|
||||
{
|
||||
// @var Carbon|null
|
||||
/** @var Carbon|null */
|
||||
return $tag->transactionJournals()->orderBy('date', 'ASC')->first()?->date;
|
||||
}
|
||||
|
||||
@@ -180,7 +181,7 @@ class TagRepository implements TagRepositoryInterface
|
||||
|
||||
public function lastUseDate(Tag $tag): ?Carbon
|
||||
{
|
||||
// @var Carbon|null
|
||||
/** @var Carbon|null */
|
||||
return $tag->transactionJournals()->orderBy('date', 'DESC')->first()?->date;
|
||||
}
|
||||
|
||||
@@ -189,13 +190,13 @@ class TagRepository implements TagRepositoryInterface
|
||||
*/
|
||||
public function newestTag(): ?Tag
|
||||
{
|
||||
// @var Tag|null
|
||||
/** @var Tag|null */
|
||||
return $this->user->tags()->whereNotNull('date')->orderBy('date', 'DESC')->first();
|
||||
}
|
||||
|
||||
public function oldestTag(): ?Tag
|
||||
{
|
||||
// @var Tag|null
|
||||
/** @var Tag|null */
|
||||
return $this->user->tags()->whereNotNull('date')->orderBy('date', 'ASC')->first();
|
||||
}
|
||||
|
||||
@@ -380,7 +381,7 @@ class TagRepository implements TagRepositoryInterface
|
||||
|
||||
public function getLocation(Tag $tag): ?Location
|
||||
{
|
||||
// @var Location|null
|
||||
/** @var Location|null */
|
||||
return $tag->locations()->first();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
|
||||
*/
|
||||
public function find(int $groupId): ?TransactionGroup
|
||||
{
|
||||
/** @var TransactionGroup|null */
|
||||
return $this->user->transactionGroups()->find($groupId);
|
||||
}
|
||||
|
||||
@@ -290,6 +291,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = $this->user->transactionJournals()->find($journalId);
|
||||
|
||||
/** @var Location|null */
|
||||
return $journal->locations()->first();
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$dbQuery->whereIn('account_types.type', $types);
|
||||
}
|
||||
|
||||
// @var Account|null
|
||||
/** @var Account|null */
|
||||
return $dbQuery->first(['accounts.*']);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$query->whereIn('account_types.type', $types);
|
||||
}
|
||||
|
||||
// @var Account|null
|
||||
/** @var Account|null */
|
||||
return $query->where('iban', $iban)->first(['accounts.*']);
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
if (null === $account) {
|
||||
$account = $this->userGroup->accounts()->find($accountId);
|
||||
}
|
||||
|
||||
/** @var Account|null */
|
||||
return $account;
|
||||
}
|
||||
|
||||
|
||||
@@ -199,7 +199,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
|
||||
return $current;
|
||||
});
|
||||
|
||||
/** @var Collection */
|
||||
return $all;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ class ExchangeRateRepository implements ExchangeRateRepositoryInterface
|
||||
#[\Override]
|
||||
public function getSpecificRateOnDate(TransactionCurrency $from, TransactionCurrency $to, Carbon $date): ?CurrencyExchangeRate
|
||||
{
|
||||
/** @var CurrencyExchangeRate|null */
|
||||
return
|
||||
$this->userGroup->currencyExchangeRates()
|
||||
->where('from_currency_id', $from->id)
|
||||
|
||||
Reference in New Issue
Block a user