mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-12 01:42:32 +00:00
Fix various phpstan issues.
This commit is contained in:
@@ -48,7 +48,7 @@ trait LiabilityValidation
|
||||
// if the ID is not null the source account should be a dummy account of the type liability credit.
|
||||
// the ID of the destination must belong to a liability.
|
||||
if (null !== $accountId) {
|
||||
if (AccountType::LIABILITY_CREDIT !== $this?->source?->accountType?->type) {
|
||||
if (AccountType::LIABILITY_CREDIT !== $this->source?->accountType?->type) {
|
||||
app('log')->error('Source account is not a liability.');
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -58,8 +58,6 @@ class AccountValidator
|
||||
private array $combinations;
|
||||
private string $transactionType;
|
||||
private bool $useUserGroupRepository = false;
|
||||
private User $user;
|
||||
private UserGroup $userGroup;
|
||||
private UserGroupAccountRepositoryInterface $userGroupAccountRepository;
|
||||
|
||||
/**
|
||||
@@ -127,7 +125,6 @@ class AccountValidator
|
||||
*/
|
||||
public function setUser(User $user): void
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->accountRepository->setUser($user);
|
||||
$this->useUserGroupRepository = false;
|
||||
}
|
||||
@@ -139,7 +136,6 @@ class AccountValidator
|
||||
*/
|
||||
public function setUserGroup(UserGroup $userGroup): void
|
||||
{
|
||||
$this->userGroup = $userGroup;
|
||||
$this->userGroupAccountRepository->setUserGroup($userGroup);
|
||||
$this->useUserGroupRepository = true;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ trait ValidatesAutoBudgetRequest
|
||||
return;
|
||||
}
|
||||
|
||||
if ('' === $amount) {
|
||||
if ('' === (string) $amount) {
|
||||
$validator->errors()->add('auto_budget_amount', (string)trans('validation.amount_required_for_auto_budget'));
|
||||
}
|
||||
if (1 !== bccomp((string)$amount, '0')) {
|
||||
|
||||
@@ -226,7 +226,7 @@ class FireflyValidator extends Validator
|
||||
}
|
||||
try {
|
||||
$checksum = bcmod($iban, '97');
|
||||
} catch (ValueError $e) {
|
||||
} catch (ValueError $e) { // @phpstan-ignore-line
|
||||
$message = sprintf('Could not validate IBAN check value "%s" (IBAN "%s")', $iban, $value);
|
||||
app('log')->error($message);
|
||||
app('log')->error($e->getTraceAsString());
|
||||
|
||||
@@ -229,7 +229,7 @@ trait GroupValidation
|
||||
}
|
||||
$journalId = (int)$journalId;
|
||||
$count = $transactionGroup->transactionJournals()->where('transaction_journals.id', $journalId)->count();
|
||||
if (null === $journalId || 0 === $count) {
|
||||
if (0 === $journalId || 0 === $count) {
|
||||
app('log')->warning(sprintf('Transaction group #%d has %d journals with ID %d', $transactionGroup->id, $count, $journalId));
|
||||
app('log')->warning('Invalid submission: Each split must have transaction_journal_id (either valid ID or 0).');
|
||||
$validator->errors()->add(sprintf('transactions.%d.source_name', $index), (string)trans('validation.need_id_in_edit'));
|
||||
|
||||
@@ -212,7 +212,6 @@ trait RecurrenceValidation
|
||||
if (null === $repetition['moment']) {
|
||||
$repetition['moment'] = '';
|
||||
}
|
||||
$repetition['moment'] = $repetition['moment'] ?? 'invalid';
|
||||
|
||||
switch ($repetition['type'] ?? 'empty') {
|
||||
default:
|
||||
@@ -319,7 +318,7 @@ trait RecurrenceValidation
|
||||
{
|
||||
try {
|
||||
Carbon::createFromFormat('Y-m-d', $moment);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
} catch (InvalidArgumentException $e) { // @phpstan-ignore-line
|
||||
app('log')->debug(sprintf('Invalid argument for Carbon: %s', $e->getMessage()));
|
||||
$validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string)trans('validation.valid_recurrence_rep_moment'));
|
||||
}
|
||||
@@ -337,12 +336,6 @@ trait RecurrenceValidation
|
||||
$transactions = $this->getTransactionData();
|
||||
$submittedTrCount = count($transactions);
|
||||
|
||||
//$recurrence = $validator->get
|
||||
if (null === $transactions) {
|
||||
app('log')->warning('[a] User submitted no transactions.');
|
||||
$validator->errors()->add('transactions', (string)trans('validation.at_least_one_transaction'));
|
||||
return;
|
||||
}
|
||||
if (0 === $submittedTrCount) {
|
||||
app('log')->warning('[b] User submitted no transactions.');
|
||||
$validator->errors()->add('transactions', (string)trans('validation.at_least_one_transaction'));
|
||||
|
||||
Reference in New Issue
Block a user