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

@@ -103,7 +103,7 @@ trait AccountCollection
if ($accounts->count() > 0) {
$accountIds = $accounts->pluck('id')->toArray();
$this->query->where(
static function (EloquentBuilder $query) use ($accountIds) {
static function (EloquentBuilder $query) use ($accountIds) { // @phpstan-ignore-line
$query->whereIn('source.account_id', $accountIds);
$query->orWhereIn('destination.account_id', $accountIds);
}
@@ -126,7 +126,7 @@ trait AccountCollection
if ($accounts->count() > 0) {
$accountIds = $accounts->pluck('id')->toArray();
$this->query->where(
static function (EloquentBuilder $query) use ($accountIds) {
static function (EloquentBuilder $query) use ($accountIds) { // @phpstan-ignore-line
$query->whereIn('source.account_id', $accountIds);
$query->whereIn('destination.account_id', $accountIds);
}
@@ -168,7 +168,7 @@ trait AccountCollection
if ($accounts->count() > 0) {
$accountIds = $accounts->pluck('id')->toArray();
$this->query->where(
static function (EloquentBuilder $query) use ($accountIds) {
static function (EloquentBuilder $query) use ($accountIds) { // @phpstan-ignore-line
$query->whereNotIn('source.account_id', $accountIds);
$query->whereNotIn('destination.account_id', $accountIds);
}
@@ -210,7 +210,7 @@ trait AccountCollection
if ($accounts->count() > 0) {
$accountIds = $accounts->pluck('id')->toArray();
$this->query->where(
static function (EloquentBuilder $q1) use ($accountIds) {
static function (EloquentBuilder $q1) use ($accountIds) { // @phpstan-ignore-line
// sourceAccount is in the set, and destination is NOT.
$q1->where(

View File

@@ -42,7 +42,7 @@ trait AmountCollection
public function amountIs(string $amount): GroupCollectorInterface
{
$this->query->where(
static function (EloquentBuilder $q) use ($amount) {
static function (EloquentBuilder $q) use ($amount) { // @phpstan-ignore-line
$q->where('source.amount', app('steam')->negative($amount));
}
);
@@ -56,7 +56,7 @@ trait AmountCollection
public function amountIsNot(string $amount): GroupCollectorInterface
{
$this->query->where(
static function (EloquentBuilder $q) use ($amount) {
static function (EloquentBuilder $q) use ($amount) { // @phpstan-ignore-line
$q->where('source.amount', '!=', app('steam')->negative($amount));
}
);
@@ -74,7 +74,7 @@ trait AmountCollection
public function amountLess(string $amount): GroupCollectorInterface
{
$this->query->where(
function (EloquentBuilder $q) use ($amount) {
function (EloquentBuilder $q) use ($amount) { // @phpstan-ignore-line
$q->where('destination.amount', '<=', app('steam')->positive($amount));
}
);
@@ -92,7 +92,7 @@ trait AmountCollection
public function amountMore(string $amount): GroupCollectorInterface
{
$this->query->where(
function (EloquentBuilder $q) use ($amount) {
function (EloquentBuilder $q) use ($amount) { // @phpstan-ignore-line
$q->where('destination.amount', '>=', app('steam')->positive($amount));
}
);
@@ -110,7 +110,7 @@ trait AmountCollection
public function foreignAmountIs(string $amount): GroupCollectorInterface
{
$this->query->where(
static function (EloquentBuilder $q) use ($amount) {
static function (EloquentBuilder $q) use ($amount) { // @phpstan-ignore-line
$q->whereNotNull('source.foreign_amount');
$q->where('source.foreign_amount', app('steam')->negative($amount));
}
@@ -129,7 +129,7 @@ trait AmountCollection
public function foreignAmountIsNot(string $amount): GroupCollectorInterface
{
$this->query->where(
static function (EloquentBuilder $q) use ($amount) {
static function (EloquentBuilder $q) use ($amount) { // @phpstan-ignore-line
$q->whereNull('source.foreign_amount');
$q->orWhere('source.foreign_amount', '!=', app('steam')->negative($amount));
}
@@ -148,7 +148,7 @@ trait AmountCollection
public function foreignAmountLess(string $amount): GroupCollectorInterface
{
$this->query->where(
function (EloquentBuilder $q) use ($amount) {
function (EloquentBuilder $q) use ($amount) { // @phpstan-ignore-line
$q->whereNotNull('destination.foreign_amount');
$q->where('destination.foreign_amount', '<=', app('steam')->positive($amount));
}
@@ -167,7 +167,7 @@ trait AmountCollection
public function foreignAmountMore(string $amount): GroupCollectorInterface
{
$this->query->where(
function (EloquentBuilder $q) use ($amount) {
function (EloquentBuilder $q) use ($amount) { // @phpstan-ignore-line
$q->whereNotNull('destination.foreign_amount');
$q->where('destination.foreign_amount', '>=', app('steam')->positive($amount));
}

View File

@@ -90,7 +90,7 @@ trait AttachmentCollection
$this->hasJoinedAttTables = true;
$this->query->leftJoin('attachments', 'attachments.attachable_id', '=', 'transaction_journals.id')
->where(
static function (EloquentBuilder $q1) {
static function (EloquentBuilder $q1) { // @phpstan-ignore-line
$q1->where('attachments.attachable_type', TransactionJournal::class);
$q1->where('attachments.uploaded', true);
$q1->whereNull('attachments.deleted_at');
@@ -544,7 +544,7 @@ trait AttachmentCollection
app('log')->debug('Add filter on no attachments.');
$this->joinAttachmentTables();
$this->query->where(function (Builder $q1) {
$this->query->where(function (Builder $q1) { // @phpstan-ignore-line
$q1
->whereNull('attachments.attachable_id')
->orWhere(function (Builder $q2) {

View File

@@ -45,7 +45,7 @@ trait MetaCollection
public function excludeBills(Collection $bills): GroupCollectorInterface
{
$this->withBillInformation();
$this->query->where(static function (EloquentBuilder $q1) use ($bills) {
$this->query->where(static function (EloquentBuilder $q1) use ($bills) { // @phpstan-ignore-line
$q1->whereNotIn('transaction_journals.bill_id', $bills->pluck('id')->toArray());
$q1->orWhereNull('transaction_journals.bill_id');
});
@@ -83,7 +83,7 @@ trait MetaCollection
{
$this->withBudgetInformation();
$this->query->where(static function (EloquentBuilder $q2) use ($budget) {
$this->query->where(static function (EloquentBuilder $q2) use ($budget) { // @phpstan-ignore-line
$q2->where('budgets.id', '!=', $budget->id);
$q2->orWhereNull('budgets.id');
});
@@ -119,7 +119,7 @@ trait MetaCollection
{
if ($budgets->count() > 0) {
$this->withBudgetInformation();
$this->query->where(static function (EloquentBuilder $q1) use ($budgets) {
$this->query->where(static function (EloquentBuilder $q1) use ($budgets) { // @phpstan-ignore-line
$q1->whereNotIn('budgets.id', $budgets->pluck('id')->toArray());
$q1->orWhereNull('budgets.id');
});
@@ -135,7 +135,7 @@ trait MetaCollection
{
if ($categories->count() > 0) {
$this->withCategoryInformation();
$this->query->where(static function (EloquentBuilder $q1) use ($categories) {
$this->query->where(static function (EloquentBuilder $q1) use ($categories) { // @phpstan-ignore-line
$q1->whereNotIn('categories.id', $categories->pluck('id')->toArray());
$q1->orWhereNull('categories.id');
});
@@ -176,7 +176,7 @@ trait MetaCollection
{
$this->withCategoryInformation();
$this->query->where(static function (EloquentBuilder $q2) use ($category) {
$this->query->where(static function (EloquentBuilder $q2) use ($category) { // @phpstan-ignore-line
$q2->where('categories.id', '!=', $category->id);
$q2->orWhereNull('categories.id');
});
@@ -618,7 +618,7 @@ trait MetaCollection
public function notesDoNotContain(string $value): GroupCollectorInterface
{
$this->withNotes();
$this->query->where(static function (Builder $q) use ($value) {
$this->query->where(static function (Builder $q) use ($value) { // @phpstan-ignore-line
$q->whereNull('notes.text');
$q->orWhere('notes.text', 'NOT LIKE', sprintf('%%%s%%', $value));
});
@@ -634,7 +634,7 @@ trait MetaCollection
public function notesDontEndWith(string $value): GroupCollectorInterface
{
$this->withNotes();
$this->query->where(static function (Builder $q) use ($value) {
$this->query->where(static function (Builder $q) use ($value) { // @phpstan-ignore-line
$q->whereNull('notes.text');
$q->orWhere('notes.text', 'NOT LIKE', sprintf('%%%s', $value));
});
@@ -650,7 +650,7 @@ trait MetaCollection
public function notesDontStartWith(string $value): GroupCollectorInterface
{
$this->withNotes();
$this->query->where(static function (Builder $q) use ($value) {
$this->query->where(static function (Builder $q) use ($value) { // @phpstan-ignore-line
$q->whereNull('notes.text');
$q->orWhere('notes.text', 'NOT LIKE', sprintf('%s%%', $value));
});
@@ -692,7 +692,7 @@ trait MetaCollection
public function notesExactlyNot(string $value): GroupCollectorInterface
{
$this->withNotes();
$this->query->where(static function (Builder $q) use ($value) {
$this->query->where(static function (Builder $q) use ($value) { // @phpstan-ignore-line
$q->whereNull('notes.text');
$q->orWhere('notes.text', '!=', sprintf('%s', $value));
});
@@ -1050,7 +1050,7 @@ trait MetaCollection
{
$this->joinMetaDataTables();
// TODO not sure if this will work properly.
$this->query->where(function (Builder $q1) {
$this->query->where(function (Builder $q1) { // @phpstan-ignore-line
$q1->where(function (Builder $q2) {
$q2->where('journal_meta.name', '=', 'external_id');
$q2->whereNull('journal_meta.data');
@@ -1071,7 +1071,7 @@ trait MetaCollection
{
$this->joinMetaDataTables();
// TODO not sure if this will work properly.
$this->query->where(function (Builder $q1) {
$this->query->where(function (Builder $q1) { // @phpstan-ignore-line
$q1->where(function (Builder $q2) {
$q2->where('journal_meta.name', '=', 'external_url');
$q2->whereNull('journal_meta.data');
@@ -1091,7 +1091,7 @@ trait MetaCollection
public function withoutNotes(): GroupCollectorInterface
{
$this->withNotes();
$this->query->where(function (Builder $q) {
$this->query->where(function (Builder $q) { // @phpstan-ignore-line
$q->whereNull('notes.text');
$q->orWhere('notes.text', '');
});