Fix various phpstan issues.

This commit is contained in:
James Cole
2023-11-04 11:31:14 +01:00
parent ef428a0226
commit 0220cf9784
64 changed files with 195 additions and 153 deletions

View File

@@ -116,7 +116,7 @@ class AccountRepository implements AccountRepositoryInterface
->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
->where('accounts.active', true)
->where(
function (EloquentBuilder $q1) use ($number) {
function (EloquentBuilder $q1) use ($number) { // @phpstan-ignore-line
$json = json_encode($number);
$q1->where('account_meta.name', '=', 'account_number');
$q1->where('account_meta.data', '=', $json);
@@ -728,7 +728,7 @@ class AccountRepository implements AccountRepositoryInterface
foreach ($parts as $part) {
$search = sprintf('%%%s%%', $part);
$dbQuery->where(
function (EloquentBuilder $q1) use ($search) {
function (EloquentBuilder $q1) use ($search) { // @phpstan-ignore-line
$q1->where('accounts.iban', 'LIKE', $search);
$q1->orWhere(
function (EloquentBuilder $q2) use ($search) {

View File

@@ -123,7 +123,7 @@ interface AccountRepositoryInterface
public function getAccountsById(array $accountIds): Collection;
/**
* @param array $types
* @param array<int, string> $types
* @param array|null $sort
*
* @return Collection

View File

@@ -72,7 +72,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
$query = $this->user->availableBudgets()->with(['transactionCurrency']);
if (null !== $start && null !== $end) {
$query->where(
static function (Builder $q1) use ($start, $end) {
static function (Builder $q1) use ($start, $end) { // @phpstan-ignore-line
$q1->where('start_date', '=', $start->format('Y-m-d'));
$q1->where('end_date', '=', $end->format('Y-m-d'));
}

View File

@@ -240,7 +240,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
// when both dates are set:
return $budget->budgetlimits()
->where(
static function (Builder $q5) use ($start, $end) {
static function (Builder $q5) use ($start, $end) { // @phpstan-ignore-line
$q5->where(
static function (Builder $q1) use ($start, $end) {
// budget limit ends within period
@@ -397,7 +397,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
$limits = $budget->budgetlimits()
->where('budget_limits.start_date', $start->format('Y-m-d 00:00:00'))
->where('budget_limits.end_date', $end->format('Y-m-d 00:00:00'))
->count(['budget_limits.*']);
->count('budget_limits.*');
app('log')->debug(sprintf('Found %d budget limits.', $limits));
// there might be a budget limit for these dates:

View File

@@ -238,7 +238,7 @@ class RecurringRepository implements RecurringRepositoryInterface
if (null !== $end) {
$query->where('transaction_journals.date', '<=', $end->format('Y-m-d 00:00:00'));
}
return $query->count(['transaction_journals.id']);
return $query->count('transaction_journals.id');
}
/**

View File

@@ -220,7 +220,7 @@ class UserGroupRepository implements UserGroupRepositoryInterface
return $userGroup;
}
// count the number of members in the group right now:
$membershipCount = $userGroup->groupMemberships()->distinct()->count(['group_memberships.user_id']);
$membershipCount = $userGroup->groupMemberships()->distinct()->count('group_memberships.user_id');
// if it's 1:
if (1 === $membershipCount) {