Fix phpstan issues.

This commit is contained in:
James Cole
2023-11-05 16:55:16 +01:00
parent 4edd9fe3da
commit a0564751d6
72 changed files with 110 additions and 138 deletions

View File

@@ -161,7 +161,7 @@ class AccountDestroyService
/** @var Transaction $transaction */
foreach ($account->transactions()->get() as $transaction) {
app('log')->debug('Now at transaction #' . $transaction->id);
/** @var TransactionJournal $journal */
/** @var TransactionJournal|null $journal */
$journal = $transaction->transactionJournal()->first();
if (null !== $journal) {
app('log')->debug('Call for deletion of journal #' . $journal->id);

View File

@@ -137,7 +137,7 @@ trait AccountServiceTrait
$data['account_role'] = '';
}
if ($account->accountType->type === AccountType::ASSET && array_key_exists('account_role', $data) && 'ccAsset' === $data['account_role']) {
if ($account->accountType->type === AccountType::ASSET && 'ccAsset' === $data['account_role']) {
$fields = $this->validCCFields;
}
/** @var AccountMetaFactory $factory */

View File

@@ -461,10 +461,8 @@ trait JournalServiceTrait
return;
}
if ('' === $notes && null !== $note) {
// try to delete existing notes.
$note->delete();
}
// try to delete existing notes.
$note?->delete();
}
/**

View File

@@ -113,10 +113,8 @@ class BillUpdateService
return $bill;
}
// remove if name is empty. Should be overruled by ID.
if ('' === $objectGroupTitle) {
$bill->objectGroups()->sync([]);
$bill->save();
}
$bill->objectGroups()->sync([]);
$bill->save();
}
if (array_key_exists('object_group_id', $data)) {
// try also with ID:
@@ -130,10 +128,8 @@ class BillUpdateService
return $bill;
}
if (0 === $objectGroupId) {
$bill->objectGroups()->sync([]);
$bill->save();
}
$bill->objectGroups()->sync([]);
$bill->save();
}
return $bill;

View File

@@ -105,7 +105,7 @@ class GroupCloneService
// add relation.
// TODO clone ALL linked piggy banks
/** @var PiggyBankEvent $event */
/** @var PiggyBankEvent|null $event */
$event = $journal->piggyBankEvents()->first();
if (null !== $event) {
$piggyBank = $event->piggyBank;

View File

@@ -497,9 +497,9 @@ class JournalUpdateService
{
$type = $this->transactionJournal->transactionType->type;
if ((
array_key_exists('bill_id', $this->data)
array_key_exists('bill_id', $this->data)
|| array_key_exists('bill_name', $this->data)
)
)
&& TransactionType::WITHDRAWAL === $type
) {
$billId = (int)($this->data['bill_id'] ?? 0);
@@ -690,24 +690,22 @@ class JournalUpdateService
$currencyId = $this->data['currency_id'] ?? null;
$currencyCode = $this->data['currency_code'] ?? null;
$currency = $this->currencyRepository->findCurrency($currencyId, $currencyCode);
if (null !== $currency) {
// update currency everywhere.
$this->transactionJournal->transaction_currency_id = $currency->id;
$this->transactionJournal->save();
// update currency everywhere.
$this->transactionJournal->transaction_currency_id = $currency->id;
$this->transactionJournal->save();
$source = $this->getSourceTransaction();
$source->transaction_currency_id = $currency->id;
$source->save();
$source = $this->getSourceTransaction();
$source->transaction_currency_id = $currency->id;
$source->save();
$dest = $this->getDestinationTransaction();
$dest->transaction_currency_id = $currency->id;
$dest->save();
$dest = $this->getDestinationTransaction();
$dest->transaction_currency_id = $currency->id;
$dest->save();
// refresh transactions.
$this->sourceTransaction->refresh();
$this->destinationTransaction->refresh();
app('log')->debug(sprintf('Updated currency to #%d (%s)', $currency->id, $currency->code));
}
// refresh transactions.
$this->sourceTransaction->refresh();
$this->destinationTransaction->refresh();
app('log')->debug(sprintf('Updated currency to #%d (%s)', $currency->id, $currency->code));
}
/**