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:
@@ -229,7 +229,7 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
Log::debug('Now in processFile()');
|
||||
$validation = $this->validateUpload($file, $model);
|
||||
$attachment = null;
|
||||
if (false !== $validation) {
|
||||
if ($validation) {
|
||||
$user = $model->user;
|
||||
// ignore lines about polymorphic calls.
|
||||
if ($model instanceof PiggyBank) {
|
||||
@@ -289,11 +289,11 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
}
|
||||
|
||||
// can't seem to reach this point.
|
||||
if (true === $result && !$this->validSize($file)) {
|
||||
if ($result && !$this->validSize($file)) {
|
||||
$result = false;
|
||||
}
|
||||
|
||||
if (true === $result && $this->hasFile($file, $model)) {
|
||||
if ($result && $this->hasFile($file, $model)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -27,15 +27,13 @@ use Carbon\Carbon;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class FiscalHelper.
|
||||
*/
|
||||
class FiscalHelper implements FiscalHelperInterface
|
||||
{
|
||||
/** @var bool */
|
||||
protected $useCustomFiscalYear;
|
||||
protected bool $useCustomFiscalYear;
|
||||
|
||||
/**
|
||||
* FiscalHelper constructor.
|
||||
@@ -52,7 +50,7 @@ class FiscalHelper implements FiscalHelperInterface
|
||||
{
|
||||
// Log::debug(sprintf('Now in endOfFiscalYear(%s).', $date->format('Y-m-d')));
|
||||
$endDate = $this->startOfFiscalYear($date);
|
||||
if (true === $this->useCustomFiscalYear) {
|
||||
if ($this->useCustomFiscalYear) {
|
||||
// add 1 year and sub 1 day
|
||||
$endDate->addYear();
|
||||
$endDate->subDay();
|
||||
@@ -75,7 +73,7 @@ class FiscalHelper implements FiscalHelperInterface
|
||||
{
|
||||
// get start mm-dd. Then create a start date in the year passed.
|
||||
$startDate = clone $date;
|
||||
if (true === $this->useCustomFiscalYear) {
|
||||
if ($this->useCustomFiscalYear) {
|
||||
$prefStartStr = Preferences::get('fiscalYearStart', '01-01')->data;
|
||||
if (is_array($prefStartStr)) {
|
||||
$prefStartStr = '01-01';
|
||||
|
||||
@@ -46,8 +46,6 @@ use Illuminate\Support\Facades\Log;
|
||||
class NetWorth implements NetWorthInterface
|
||||
{
|
||||
private AccountRepositoryInterface $accountRepository;
|
||||
private User $user; // @phpstan-ignore-line
|
||||
private ?UserGroup $userGroup = null;
|
||||
|
||||
/**
|
||||
* This method collects the user's net worth in ALL the user's currencies
|
||||
@@ -117,13 +115,11 @@ class NetWorth implements NetWorthInterface
|
||||
if (!$user instanceof User) {
|
||||
return;
|
||||
}
|
||||
$this->user = $user;
|
||||
$this->setUserGroup($user->userGroup);
|
||||
}
|
||||
|
||||
public function setUserGroup(UserGroup $userGroup): void
|
||||
{
|
||||
$this->userGroup = $userGroup;
|
||||
$this->accountRepository = app(AccountRepositoryInterface::class);
|
||||
$this->accountRepository->setUserGroup($userGroup);
|
||||
|
||||
|
||||
@@ -36,15 +36,14 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
class ReportHelper implements ReportHelperInterface
|
||||
{
|
||||
/** @var BudgetRepositoryInterface The budget repository */
|
||||
protected $budgetRepository;
|
||||
|
||||
/**
|
||||
* ReportHelper constructor.
|
||||
*/
|
||||
public function __construct(BudgetRepositoryInterface $budgetRepository)
|
||||
public function __construct(
|
||||
/** @var BudgetRepositoryInterface The budget repository */
|
||||
protected BudgetRepositoryInterface $budgetRepository
|
||||
)
|
||||
{
|
||||
$this->budgetRepository = $budgetRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user