Run phpcs locally to make sure phpstan stays fixed. [skip ci]

This commit is contained in:
James Cole
2025-01-04 07:39:16 +01:00
parent 1b97d8fd48
commit 7eaa0e16b3
164 changed files with 171 additions and 357 deletions

View File

@@ -36,7 +36,6 @@ use FireflyIII\Models\Location;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use FireflyIII\Services\Internal\Destroy\AccountDestroyService;
use FireflyIII\Services\Internal\Update\AccountUpdateService;
use FireflyIII\Support\Facades\Steam;
@@ -120,7 +119,7 @@ class AccountRepository implements AccountRepositoryInterface
$dbQuery->whereIn('account_types.type', $types);
}
/** @var Account|null */
/** @var null|Account */
return $dbQuery->first(['accounts.*']);
}
@@ -134,7 +133,7 @@ class AccountRepository implements AccountRepositoryInterface
$query->whereIn('account_types.type', $types);
}
/** @var Account|null */
/** @var null|Account */
return $query->where('iban', $iban)->first(['accounts.*']);
}
@@ -278,7 +277,7 @@ class AccountRepository implements AccountRepositoryInterface
public function getLocation(Account $account): ?Location
{
/** @var Location|null */
/** @var null|Location */
return $account->locations()->first();
}
@@ -428,7 +427,7 @@ class AccountRepository implements AccountRepositoryInterface
public function find(int $accountId): ?Account
{
/** @var Account|null */
/** @var null|Account */
return $this->user->accounts()->find($accountId);
}

View File

@@ -28,7 +28,6 @@ use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\Account;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
use FireflyIII\User;
use Illuminate\Contracts\Auth\Authenticatable;

View File

@@ -142,7 +142,7 @@ class BillRepository implements BillRepositoryInterface
*/
public function find(int $billId): ?Bill
{
/** @var Bill|null */
/** @var null|Bill */
return $this->user->bills()->find($billId);
}
@@ -151,7 +151,7 @@ class BillRepository implements BillRepositoryInterface
*/
public function findByName(string $name): ?Bill
{
/** @var Bill|null */
/** @var null|Bill */
return $this->user->bills()->where('name', $name)->first(['bills.*']);
}

View File

@@ -103,7 +103,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
*/
public function find(TransactionCurrency $currency, Carbon $start, Carbon $end): ?AvailableBudget
{
/** @var AvailableBudget|null */
/** @var null|AvailableBudget */
return $this->user->availableBudgets()
->where('transaction_currency_id', $currency->id)
->where('start_date', $start->format('Y-m-d'))
@@ -195,7 +195,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
public function getByCurrencyDate(Carbon $start, Carbon $end, TransactionCurrency $currency): ?AvailableBudget
{
/** @var AvailableBudget|null */
/** @var null|AvailableBudget */
return $this->user
->availableBudgets()
->where('transaction_currency_id', $currency->id)
@@ -226,6 +226,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
}
$availableBudget->amount = $amount;
$availableBudget->save();
return $availableBudget;
}

View File

@@ -285,7 +285,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
$currency->save();
// find the budget:
/** @var Budget|null $budget */
/** @var null|Budget $budget */
$budget = $this->user->budgets()->find((int) $data['budget_id']);
if (null === $budget) {
throw new FireflyException('200004: Budget does not exist.');
@@ -324,7 +324,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
public function find(Budget $budget, TransactionCurrency $currency, Carbon $start, Carbon $end): ?BudgetLimit
{
/** @var BudgetLimit|null */
/** @var null|BudgetLimit */
return $budget->budgetlimits()
->where('transaction_currency_id', $currency->id)
->where('start_date', $start->format('Y-m-d'))

View File

@@ -37,7 +37,6 @@ use FireflyIII\Models\Note;
use FireflyIII\Models\RecurrenceTransactionMeta;
use FireflyIII\Models\RuleAction;
use FireflyIII\Models\RuleTrigger;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
use FireflyIII\Services\Internal\Destroy\BudgetDestroyService;
@@ -384,7 +383,7 @@ class BudgetRepository implements BudgetRepositoryInterface
public function getAutoBudget(Budget $budget): ?AutoBudget
{
/** @var AutoBudget|null */
/** @var null|AutoBudget */
return $budget->autoBudgets()->first();
}
@@ -443,7 +442,7 @@ class BudgetRepository implements BudgetRepositoryInterface
*/
public function find(?int $budgetId = null): ?Budget
{
/** @var Budget|null */
/** @var null|Budget */
return $this->user->budgets()->find($budgetId);
}
@@ -515,7 +514,8 @@ class BudgetRepository implements BudgetRepositoryInterface
return null;
}
$query = sprintf('%%%s%%', $name);
/** @var Budget|null */
/** @var null|Budget */
return $this->user->budgets()->whereLike('name', $query)->first();
}

View File

@@ -28,7 +28,6 @@ use Carbon\Carbon;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionType;
use FireflyIII\Support\Report\Summarizer\TransactionSummarizer;
use FireflyIII\User;
use Illuminate\Contracts\Auth\Authenticatable;

View File

@@ -30,7 +30,6 @@ use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\Account;
use FireflyIII\Models\Budget;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Support\Facades\Amount;
use FireflyIII\Support\Report\Summarizer\TransactionSummarizer;

View File

@@ -129,7 +129,7 @@ class CategoryRepository implements CategoryRepositoryInterface
*/
public function find(int $categoryId): ?Category
{
/** @var Category|null */
/** @var null|Category */
return $this->user->categories()->find($categoryId);
}
@@ -138,7 +138,7 @@ class CategoryRepository implements CategoryRepositoryInterface
*/
public function findByName(string $name): ?Category
{
/** @var Category|null */
/** @var null|Category */
return $this->user->categories()->where('name', $name)->first(['categories.*']);
}

View File

@@ -27,7 +27,6 @@ namespace FireflyIII\Repositories\Category;
use Carbon\Carbon;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\TransactionType;
use FireflyIII\Support\Report\Summarizer\TransactionSummarizer;
use FireflyIII\User;
use Illuminate\Contracts\Auth\Authenticatable;

View File

@@ -27,7 +27,6 @@ namespace FireflyIII\Repositories\Category;
use Carbon\Carbon;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\TransactionType;
use FireflyIII\Support\Facades\Amount;
use FireflyIII\Support\Report\Summarizer\TransactionSummarizer;
use FireflyIII\User;

View File

@@ -54,13 +54,14 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
*/
public function getJournalBudgetId(TransactionJournal $journal): int
{
$budget = $journal->budgets()->first();
$budget = $journal->budgets()->first();
if (null !== $budget) {
return $budget->id;
}
/** @var Transaction|null $transaction */
/** @var null|Transaction $transaction */
$transaction = $journal->transactions()->first();
$budget = $transaction?->budgets()->first();
$budget = $transaction?->budgets()->first();
if (null !== $budget) {
return $budget->id;
}
@@ -73,13 +74,14 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
*/
public function getJournalCategoryId(TransactionJournal $journal): int
{
$category = $journal->categories()->first();
$category = $journal->categories()->first();
if (null !== $category) {
return $category->id;
}
/** @var Transaction|null $transaction */
/** @var null|Transaction $transaction */
$transaction = $journal->transactions()->first();
$category = $transaction?->categories()->first();
$category = $transaction?->categories()->first();
if (null !== $category) {
return $category->id;
}

View File

@@ -185,7 +185,7 @@ class JournalRepository implements JournalRepositoryInterface
*/
public function find(int $journalId): ?TransactionJournal
{
/** @var TransactionJournal|null */
/** @var null|TransactionJournal */
return $this->user->transactionJournals()->find($journalId);
}

View File

@@ -33,7 +33,7 @@ trait CreatesObjectGroups
{
protected function findObjectGroupById(int $groupId): ?ObjectGroup
{
/** @var ObjectGroup|null */
/** @var null|ObjectGroup */
return $this->user->objectGroups()->where('id', $groupId)->first();
}
@@ -67,7 +67,7 @@ trait CreatesObjectGroups
protected function findObjectGroup(string $title): ?ObjectGroup
{
/** @var ObjectGroup|null */
/** @var null|ObjectGroup */
return $this->user->objectGroups()->where('title', $title)->first();
}
}

View File

@@ -55,9 +55,10 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
Log::channel('audit')->info('Delete all piggy banks through destroyAll');
PiggyBank::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
->where('accounts.user_id', $this->user->id)
->delete();
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
->where('accounts.user_id', $this->user->id)
->delete()
;
}
public function findPiggyBank(?int $piggyBankId, ?string $piggyBankName): ?PiggyBank
@@ -313,7 +314,8 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
throw new FireflyException('[b] Piggy bank repetitions are EOL.');
}
Log::warning('Piggy bank repetitions are EOL.');
/** @var PiggyBankRepetition|null */
/** @var null|PiggyBankRepetition */
return $piggyBank->piggyBankRepetitions()->first();
}

View File

@@ -96,7 +96,7 @@ class RuleRepository implements RuleRepositoryInterface
*/
public function getFirstRuleGroup(): RuleGroup
{
/** @var RuleGroup|null */
/** @var null|RuleGroup */
return $this->user->ruleGroups()->first();
}
@@ -277,7 +277,7 @@ class RuleRepository implements RuleRepositoryInterface
public function find(int $ruleId): ?Rule
{
/** @var Rule|null */
/** @var null|Rule */
return $this->user->rules()->find($ruleId);
}

View File

@@ -208,13 +208,13 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
public function find(int $ruleGroupId): ?RuleGroup
{
/** @var RuleGroup|null */
/** @var null|RuleGroup */
return $this->user->ruleGroups()->find($ruleGroupId);
}
public function findByTitle(string $title): ?RuleGroup
{
/** @var RuleGroup|null */
/** @var null|RuleGroup */
return $this->user->ruleGroups()->where('title', $title)->first();
}

View File

@@ -28,7 +28,6 @@ use Carbon\Carbon;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\TransactionType;
use FireflyIII\User;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Support\Collection;

View File

@@ -31,7 +31,6 @@ use FireflyIII\Models\Attachment;
use FireflyIII\Models\Location;
use FireflyIII\Models\Note;
use FireflyIII\Models\Tag;
use FireflyIII\Models\TransactionType;
use FireflyIII\User;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Support\Collection;
@@ -101,19 +100,19 @@ class TagRepository implements TagRepositoryInterface
public function find(int $tagId): ?Tag
{
/** @var Tag|null */
/** @var null|Tag */
return $this->user->tags()->find($tagId);
}
public function findByTag(string $tag): ?Tag
{
/** @var Tag|null */
/** @var null|Tag */
return $this->user->tags()->where('tag', $tag)->first();
}
public function firstUseDate(Tag $tag): ?Carbon
{
/** @var Carbon|null */
/** @var null|Carbon */
return $tag->transactionJournals()->orderBy('date', 'ASC')->first()?->date;
}
@@ -181,7 +180,7 @@ class TagRepository implements TagRepositoryInterface
public function lastUseDate(Tag $tag): ?Carbon
{
/** @var Carbon|null */
/** @var null|Carbon */
return $tag->transactionJournals()->orderBy('date', 'DESC')->first()?->date;
}
@@ -190,13 +189,13 @@ class TagRepository implements TagRepositoryInterface
*/
public function newestTag(): ?Tag
{
/** @var Tag|null */
/** @var null|Tag */
return $this->user->tags()->whereNotNull('date')->orderBy('date', 'DESC')->first();
}
public function oldestTag(): ?Tag
{
/** @var Tag|null */
/** @var null|Tag */
return $this->user->tags()->whereNotNull('date')->orderBy('date', 'ASC')->first();
}
@@ -262,10 +261,10 @@ class TagRepository implements TagRepositoryInterface
}
$currencyId = (int) $journal['currency_id'];
$sums[$currencyId] ??= [
'currency_id' => $currencyId,
'currency_name' => $journal['currency_name'],
'currency_symbol' => $journal['currency_symbol'],
'currency_decimal_places' => $journal['currency_decimal_places'],
'currency_id' => $currencyId,
'currency_name' => $journal['currency_name'],
'currency_symbol' => $journal['currency_symbol'],
'currency_decimal_places' => $journal['currency_decimal_places'],
TransactionTypeEnum::WITHDRAWAL->value => '0',
TransactionTypeEnum::DEPOSIT->value => '0',
TransactionTypeEnum::TRANSFER->value => '0',
@@ -284,10 +283,10 @@ class TagRepository implements TagRepositoryInterface
$foreignCurrencyId = $journal['foreign_currency_id'];
if (null !== $foreignCurrencyId && 0 !== $foreignCurrencyId) {
$sums[$foreignCurrencyId] ??= [
'currency_id' => $foreignCurrencyId,
'currency_name' => $journal['foreign_currency_name'],
'currency_symbol' => $journal['foreign_currency_symbol'],
'currency_decimal_places' => $journal['foreign_currency_decimal_places'],
'currency_id' => $foreignCurrencyId,
'currency_name' => $journal['foreign_currency_name'],
'currency_symbol' => $journal['foreign_currency_symbol'],
'currency_decimal_places' => $journal['foreign_currency_decimal_places'],
TransactionTypeEnum::WITHDRAWAL->value => '0',
TransactionTypeEnum::DEPOSIT->value => '0',
TransactionTypeEnum::TRANSFER->value => '0',
@@ -381,7 +380,7 @@ class TagRepository implements TagRepositoryInterface
public function getLocation(Tag $tag): ?Location
{
/** @var Location|null */
/** @var null|Location */
return $tag->locations()->first();
}
}

View File

@@ -39,7 +39,6 @@ use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionJournalLink;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
use FireflyIII\Services\Internal\Destroy\TransactionGroupDestroyService;
use FireflyIII\Services\Internal\Update\GroupUpdateService;
@@ -69,7 +68,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
*/
public function find(int $groupId): ?TransactionGroup
{
/** @var TransactionGroup|null */
/** @var null|TransactionGroup */
return $this->user->transactionGroups()->find($groupId);
}
@@ -291,7 +290,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
/** @var TransactionJournal $journal */
$journal = $this->user->transactionJournals()->find($journalId);
/** @var Location|null */
/** @var null|Location */
return $journal->locations()->first();
}

View File

@@ -76,7 +76,7 @@ class AccountRepository implements AccountRepositoryInterface
$dbQuery->whereIn('account_types.type', $types);
}
/** @var Account|null */
/** @var null|Account */
return $dbQuery->first(['accounts.*']);
}
@@ -90,7 +90,7 @@ class AccountRepository implements AccountRepositoryInterface
$query->whereIn('account_types.type', $types);
}
/** @var Account|null */
/** @var null|Account */
return $query->where('iban', $iban)->first(['accounts.*']);
}
@@ -167,7 +167,8 @@ class AccountRepository implements AccountRepositoryInterface
if (null === $account) {
$account = $this->userGroup->accounts()->find($accountId);
}
/** @var Account|null */
/** @var null|Account */
return $account;
}

View File

@@ -28,7 +28,6 @@ use Carbon\Carbon;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\TransactionType;
use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
use Illuminate\Support\Collection;

View File

@@ -199,6 +199,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
return $current;
});
/** @var Collection */
return $all;
}

View File

@@ -61,7 +61,7 @@ class ExchangeRateRepository implements ExchangeRateRepositoryInterface
#[\Override]
public function getSpecificRateOnDate(TransactionCurrency $from, TransactionCurrency $to, Carbon $date): ?CurrencyExchangeRate
{
/** @var CurrencyExchangeRate|null */
/** @var null|CurrencyExchangeRate */
return
$this->userGroup->currencyExchangeRates()
->where('from_currency_id', $from->id)
@@ -105,10 +105,8 @@ class ExchangeRateRepository implements ExchangeRateRepositoryInterface
return $object;
}
/**
* @return Collection
*/
#[\Override] public function getAll(): Collection
#[\Override]
public function getAll(): Collection
{
return $this->userGroup->currencyExchangeRates()->get();
}