From c37a877f349231c3595d7a5fcbef726624b36d44 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 3 Dec 2023 08:28:50 +0100 Subject: [PATCH] Fix phpstan things --- app/Api/V2/Controllers/Chart/AccountController.php | 2 +- app/Factory/TransactionJournalFactory.php | 6 +++--- app/Support/Search/OperatorQuerySearch.php | 4 ++-- .../Actions/SetDestinationToCashAccount.php | 4 ++-- app/TransactionRules/Actions/SetSourceToCashAccount.php | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/Api/V2/Controllers/Chart/AccountController.php b/app/Api/V2/Controllers/Chart/AccountController.php index f02c58834a..4b4df31947 100644 --- a/app/Api/V2/Controllers/Chart/AccountController.php +++ b/app/Api/V2/Controllers/Chart/AccountController.php @@ -99,7 +99,7 @@ class AccountController extends Controller /** @var TransactionCurrency $default */ $default = app('amount')->getDefaultCurrency(); $params = $request->getAll(); - /** @var Collection $preSet */ + /** @var Collection $accounts */ $accounts = $params['accounts']; $chartData = []; diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.php index dd072ab721..2edf6feda3 100644 --- a/app/Factory/TransactionJournalFactory.php +++ b/app/Factory/TransactionJournalFactory.php @@ -426,20 +426,20 @@ class TransactionJournalFactory app('log')->debug('Both accounts exist, simply return them.'); return [$sourceAccount, $destinationAccount]; } - if (null !== $sourceAccount && null === $destinationAccount) { + if (null === $destinationAccount) { // @phpstan-ignore-line app('log')->debug('Destination account is NULL, source account is not.'); $account = $this->accountRepository->getReconciliation($sourceAccount); app('log')->debug(sprintf('Will return account #%d ("%s") of type "%s"', $account->id, $account->name, $account->accountType->type)); return [$sourceAccount, $account]; } - if (null === $sourceAccount && null !== $destinationAccount) { + if (null === $sourceAccount) { // @phpstan-ignore-line app('log')->debug('Source account is NULL, destination account is not.'); $account = $this->accountRepository->getReconciliation($destinationAccount); app('log')->debug(sprintf('Will return account #%d ("%s") of type "%s"', $account->id, $account->name, $account->accountType->type)); return [$account, $destinationAccount]; } - app('log')->debug('Unused fallback'); + app('log')->debug('Unused fallback'); // @phpstan-ignore-line return [$sourceAccount, $destinationAccount]; } diff --git a/app/Support/Search/OperatorQuerySearch.php b/app/Support/Search/OperatorQuerySearch.php index 5f4af55847..899e06690a 100644 --- a/app/Support/Search/OperatorQuerySearch.php +++ b/app/Support/Search/OperatorQuerySearch.php @@ -952,8 +952,8 @@ class OperatorQuerySearch implements SearchInterface break; case '-tag_is': case 'tag_is_not': - $result = $this->tagRepository->searchTag($value); - if ($result->count() > 0) { + $result = $this->tagRepository->findByTag($value); + if (null !== $result) { $this->excludeTags[] = $result->id; $this->excludeTags = array_unique($this->excludeTags); } diff --git a/app/TransactionRules/Actions/SetDestinationToCashAccount.php b/app/TransactionRules/Actions/SetDestinationToCashAccount.php index 554bfec7f8..af12a4241c 100644 --- a/app/TransactionRules/Actions/SetDestinationToCashAccount.php +++ b/app/TransactionRules/Actions/SetDestinationToCashAccount.php @@ -53,7 +53,7 @@ class SetDestinationToCashAccount implements ActionInterface /** * @inheritDoc */ - #[\Override] public function actOnArray(array $journal): bool + public function actOnArray(array $journal): bool { /** @var User $user */ $user = User::find($journal['user_id']); @@ -91,7 +91,7 @@ class SetDestinationToCashAccount implements ActionInterface event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_source_transaction_account'))); return false; } - if (null !== $cashAccount && $cashAccount->id === $source->account_id) { + if ($cashAccount->id === $source->account_id) { app('log')->error( sprintf( 'New destination account ID #%d and current source account ID #%d are the same. Do nothing.', diff --git a/app/TransactionRules/Actions/SetSourceToCashAccount.php b/app/TransactionRules/Actions/SetSourceToCashAccount.php index 982f1e9b17..1cc1a16085 100644 --- a/app/TransactionRules/Actions/SetSourceToCashAccount.php +++ b/app/TransactionRules/Actions/SetSourceToCashAccount.php @@ -52,7 +52,7 @@ class SetSourceToCashAccount implements ActionInterface /** * @inheritDoc */ - #[\Override] public function actOnArray(array $journal): bool + public function actOnArray(array $journal): bool { /** @var User $user */ $user = User::find($journal['user_id']); @@ -90,7 +90,7 @@ class SetSourceToCashAccount implements ActionInterface event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_destination_transaction_account'))); return false; } - if (null !== $cashAccount && $cashAccount->id === $destination->account_id) { + if ($cashAccount->id === $destination->account_id) { app('log')->error( sprintf( 'New source account ID #%d and current destination account ID #%d are the same. Do nothing.',