mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-12 01:42:32 +00:00
Fix code quality with rector [skip ci]
This commit is contained in:
@@ -27,7 +27,6 @@ namespace FireflyIII\Helpers\Collector\Extensions;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
@@ -55,7 +54,7 @@ trait AttachmentCollection
|
||||
strtolower((string) $attachment['title']),
|
||||
strtolower($name)
|
||||
);
|
||||
if (true === $result) {
|
||||
if ($result) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -135,7 +134,7 @@ trait AttachmentCollection
|
||||
strtolower((string) $attachment['title']),
|
||||
strtolower($name)
|
||||
);
|
||||
if (true === $result) {
|
||||
if ($result) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -169,7 +168,7 @@ trait AttachmentCollection
|
||||
strtolower((string) $attachment['title']),
|
||||
strtolower($name)
|
||||
);
|
||||
if (true === $result) {
|
||||
if ($result) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -203,7 +202,7 @@ trait AttachmentCollection
|
||||
strtolower((string) $attachment['title']),
|
||||
strtolower($name)
|
||||
);
|
||||
if (true === $result) {
|
||||
if ($result) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -229,7 +228,7 @@ trait AttachmentCollection
|
||||
strtolower((string) $attachment['title']),
|
||||
strtolower($name)
|
||||
);
|
||||
if (true === $result) {
|
||||
if ($result) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -252,7 +251,7 @@ trait AttachmentCollection
|
||||
/** @var array $attachment */
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
$result = $attachment['filename'] === $name || $attachment['title'] === $name;
|
||||
if (true === $result) {
|
||||
if ($result) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -275,7 +274,7 @@ trait AttachmentCollection
|
||||
/** @var array $attachment */
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
$result = $attachment['filename'] !== $name && $attachment['title'] !== $name;
|
||||
if (true === $result) {
|
||||
if ($result) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -301,7 +300,7 @@ trait AttachmentCollection
|
||||
strtolower((string) $attachment['title']),
|
||||
strtolower($name)
|
||||
);
|
||||
if (true === $result) {
|
||||
if ($result) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -514,10 +513,10 @@ trait AttachmentCollection
|
||||
Log::debug('Add filter on no attachments.');
|
||||
$this->joinAttachmentTables();
|
||||
|
||||
$this->query->where(static function (Builder $q1): void { // @phpstan-ignore-line
|
||||
$this->query->where(static function (EloquentBuilder $q1): void { // @phpstan-ignore-line
|
||||
$q1
|
||||
->whereNull('attachments.attachable_id')
|
||||
->orWhere(static function (Builder $q2): void {
|
||||
->orWhere(static function (EloquentBuilder $q2): void {
|
||||
$q2
|
||||
->whereNotNull('attachments.attachable_id')
|
||||
->whereNotNull('attachments.deleted_at')
|
||||
|
||||
@@ -31,7 +31,6 @@ use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -170,7 +169,7 @@ trait MetaCollection
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'external_id');
|
||||
$this->query->where('journal_meta.data', '!=', sprintf('%s', json_encode($externalId)));
|
||||
$this->query->where('journal_meta.data', '!=', json_encode($externalId));
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
@@ -214,7 +213,7 @@ trait MetaCollection
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'recurrence_id');
|
||||
$this->query->where('journal_meta.data', '!=', sprintf('%s', json_encode($recurringId)));
|
||||
$this->query->where('journal_meta.data', '!=', json_encode($recurringId));
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -511,7 +510,7 @@ trait MetaCollection
|
||||
public function notesDoNotContain(string $value): GroupCollectorInterface
|
||||
{
|
||||
$this->withNotes();
|
||||
$this->query->where(static function (Builder $q) use ($value): void { // @phpstan-ignore-line
|
||||
$this->query->where(static function (EloquentBuilder $q) use ($value): void { // @phpstan-ignore-line
|
||||
$q->whereNull('notes.text');
|
||||
$q->orWhereNotLike('notes.text', sprintf('%%%s%%', $value));
|
||||
});
|
||||
@@ -522,7 +521,7 @@ trait MetaCollection
|
||||
public function notesDontEndWith(string $value): GroupCollectorInterface
|
||||
{
|
||||
$this->withNotes();
|
||||
$this->query->where(static function (Builder $q) use ($value): void { // @phpstan-ignore-line
|
||||
$this->query->where(static function (EloquentBuilder $q) use ($value): void { // @phpstan-ignore-line
|
||||
$q->whereNull('notes.text');
|
||||
$q->orWhereNotLike('notes.text', sprintf('%%%s', $value));
|
||||
});
|
||||
@@ -533,7 +532,7 @@ trait MetaCollection
|
||||
public function notesDontStartWith(string $value): GroupCollectorInterface
|
||||
{
|
||||
$this->withNotes();
|
||||
$this->query->where(static function (Builder $q) use ($value): void { // @phpstan-ignore-line
|
||||
$this->query->where(static function (EloquentBuilder $q) use ($value): void { // @phpstan-ignore-line
|
||||
$q->whereNull('notes.text');
|
||||
$q->orWhereNotLike('notes.text', sprintf('%s%%', $value));
|
||||
});
|
||||
@@ -552,7 +551,7 @@ trait MetaCollection
|
||||
public function notesExactly(string $value): GroupCollectorInterface
|
||||
{
|
||||
$this->withNotes();
|
||||
$this->query->where('notes.text', '=', sprintf('%s', $value));
|
||||
$this->query->where('notes.text', '=', $value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -560,9 +559,9 @@ trait MetaCollection
|
||||
public function notesExactlyNot(string $value): GroupCollectorInterface
|
||||
{
|
||||
$this->withNotes();
|
||||
$this->query->where(static function (Builder $q) use ($value): void { // @phpstan-ignore-line
|
||||
$this->query->where(static function (EloquentBuilder $q) use ($value): void { // @phpstan-ignore-line
|
||||
$q->whereNull('notes.text');
|
||||
$q->orWhere('notes.text', '!=', sprintf('%s', $value));
|
||||
$q->orWhere('notes.text', '!=', $value);
|
||||
});
|
||||
|
||||
return $this;
|
||||
@@ -587,7 +586,7 @@ trait MetaCollection
|
||||
|
||||
// this method adds a "postFilter" to the collector.
|
||||
$list = $tags->pluck('tag')->toArray();
|
||||
$list = array_map('strtolower', $list);
|
||||
$list = array_map(strtolower(...), $list);
|
||||
$filter = static function (array $object) use ($list): bool|array {
|
||||
$includedJournals = [];
|
||||
$return = $object;
|
||||
@@ -622,7 +621,7 @@ trait MetaCollection
|
||||
|
||||
// found at least the expected tags.
|
||||
$result = $foundTagCount >= $expectedTagCount;
|
||||
if (true === $result) {
|
||||
if ($result) {
|
||||
return $return;
|
||||
}
|
||||
|
||||
@@ -707,7 +706,7 @@ trait MetaCollection
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'external_id');
|
||||
$this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($externalId)));
|
||||
$this->query->where('journal_meta.data', '=', json_encode($externalId));
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
@@ -730,7 +729,7 @@ trait MetaCollection
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'internal_reference');
|
||||
$this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($internalReference)));
|
||||
$this->query->where('journal_meta.data', '=', json_encode($internalReference));
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
@@ -740,7 +739,7 @@ trait MetaCollection
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'recurrence_id');
|
||||
$this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($recurringId)));
|
||||
$this->query->where('journal_meta.data', '=', json_encode($recurringId));
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
@@ -750,7 +749,7 @@ trait MetaCollection
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'sepa_ct_id');
|
||||
$this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($sepaCT)));
|
||||
$this->query->where('journal_meta.data', '=', json_encode($sepaCT));
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
@@ -781,7 +780,7 @@ trait MetaCollection
|
||||
|
||||
// this method adds a "postFilter" to the collector.
|
||||
$list = $tags->pluck('tag')->toArray();
|
||||
$list = array_map('strtolower', $list);
|
||||
$list = array_map(strtolower(...), $list);
|
||||
$filter = static function (array $object) use ($list): bool {
|
||||
Log::debug(sprintf('Now in setTags(%s) filter', implode(', ', $list)));
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
@@ -812,7 +811,7 @@ trait MetaCollection
|
||||
|
||||
// this method adds a "postFilter" to the collector.
|
||||
$list = $tags->pluck('tag')->toArray();
|
||||
$list = array_map('strtolower', $list);
|
||||
$list = array_map(strtolower(...), $list);
|
||||
$filter = static function (array $object) use ($list): bool {
|
||||
Log::debug(sprintf('Now in setWithoutSpecificTags(%s) filter', implode(', ', $list)));
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
@@ -933,15 +932,15 @@ trait MetaCollection
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
// TODO not sure if this will work properly.
|
||||
$this->query->where(static function (Builder $q1): void { // @phpstan-ignore-line
|
||||
$q1->where(static function (Builder $q2): void {
|
||||
$this->query->where(static function (EloquentBuilder $q1): void { // @phpstan-ignore-line
|
||||
$q1->where(static function (EloquentBuilder $q2): void {
|
||||
$q2->where('journal_meta.name', '=', 'external_id');
|
||||
$q2->whereNull('journal_meta.data');
|
||||
$q2->whereNull('journal_meta.deleted_at');
|
||||
})->orWhere(static function (Builder $q3): void {
|
||||
})->orWhere(static function (EloquentBuilder $q3): void {
|
||||
$q3->where('journal_meta.name', '!=', 'external_id');
|
||||
$q3->whereNull('journal_meta.deleted_at');
|
||||
})->orWhere(static function (Builder $q4): void {
|
||||
})->orWhere(static function (EloquentBuilder $q4): void {
|
||||
$q4->whereNull('journal_meta.name');
|
||||
$q4->whereNull('journal_meta.deleted_at');
|
||||
});
|
||||
@@ -954,15 +953,15 @@ trait MetaCollection
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
// TODO not sure if this will work properly.
|
||||
$this->query->where(static function (Builder $q1): void { // @phpstan-ignore-line
|
||||
$q1->where(static function (Builder $q2): void {
|
||||
$this->query->where(static function (EloquentBuilder $q1): void { // @phpstan-ignore-line
|
||||
$q1->where(static function (EloquentBuilder $q2): void {
|
||||
$q2->where('journal_meta.name', '=', 'external_url');
|
||||
$q2->whereNull('journal_meta.data');
|
||||
$q2->whereNull('journal_meta.deleted_at');
|
||||
})->orWhere(static function (Builder $q3): void {
|
||||
})->orWhere(static function (EloquentBuilder $q3): void {
|
||||
$q3->where('journal_meta.name', '!=', 'external_url');
|
||||
$q3->whereNull('journal_meta.deleted_at');
|
||||
})->orWhere(static function (Builder $q4): void {
|
||||
})->orWhere(static function (EloquentBuilder $q4): void {
|
||||
$q4->whereNull('journal_meta.name');
|
||||
$q4->whereNull('journal_meta.deleted_at');
|
||||
});
|
||||
@@ -974,7 +973,7 @@ trait MetaCollection
|
||||
public function withoutNotes(): GroupCollectorInterface
|
||||
{
|
||||
$this->withNotes();
|
||||
$this->query->where(static function (Builder $q): void { // @phpstan-ignore-line
|
||||
$this->query->where(static function (EloquentBuilder $q): void { // @phpstan-ignore-line
|
||||
$q->whereNull('notes.text');
|
||||
$q->orWhere('notes.text', '');
|
||||
});
|
||||
|
||||
@@ -371,7 +371,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
{
|
||||
if (0 !== count($journalIds)) {
|
||||
// make all integers.
|
||||
$integerIDs = array_map('intval', $journalIds);
|
||||
$integerIDs = array_map(intval(...), $journalIds);
|
||||
|
||||
$this->query->whereNotIn('transaction_journals.id', $integerIDs);
|
||||
}
|
||||
@@ -779,7 +779,6 @@ class GroupCollector implements GroupCollectorInterface
|
||||
{
|
||||
$currentCollection = $collection;
|
||||
$countFilters = count($this->postFilters);
|
||||
$countCollection = count($currentCollection);
|
||||
if (0 === $countFilters) {
|
||||
return $currentCollection;
|
||||
}
|
||||
@@ -947,7 +946,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
{
|
||||
if (0 !== count($journalIds)) {
|
||||
// make all integers.
|
||||
$integerIDs = array_map('intval', $journalIds);
|
||||
$integerIDs = array_map(intval(...), $journalIds);
|
||||
Log::debug(sprintf('GroupCollector: setJournalIds: %s', implode(', ', $integerIDs)));
|
||||
|
||||
$this->query->whereIn('transaction_journals.id', $integerIDs);
|
||||
|
||||
Reference in New Issue
Block a user