Fix code quality with rector [skip ci]

This commit is contained in:
James Cole
2025-11-09 09:08:03 +01:00
parent d2610be790
commit 68183a0a0e
209 changed files with 1021 additions and 1248 deletions

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\TransactionRules\Actions;
use Illuminate\Support\Facades\Log;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;
use FireflyIII\Events\Model\Rule\RuleActionFailedOnObject;
@@ -59,14 +60,14 @@ class ConvertToTransfer implements ActionInterface
/** @var null|TransactionJournal $object */
$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
if (null === $object) {
app('log')->error(sprintf('Cannot find journal #%d, cannot convert to transfer.', $journal['transaction_journal_id']));
Log::error(sprintf('Cannot find journal #%d, cannot convert to transfer.', $journal['transaction_journal_id']));
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_not_found')));
return false;
}
$groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count();
if ($groupCount > 1) {
app('log')->error(sprintf('Group #%d has more than one transaction in it, cannot convert to transfer.', $journal['transaction_group_id']));
Log::error(sprintf('Group #%d has more than one transaction in it, cannot convert to transfer.', $journal['transaction_group_id']));
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.split_group')));
return false;
@@ -76,7 +77,7 @@ class ConvertToTransfer implements ActionInterface
$user = $object->user;
$journalId = $object->id;
if (TransactionTypeEnum::TRANSFER->value === $type) {
app('log')->error(
Log::error(
sprintf('Journal #%d is already a transfer so cannot be converted (rule #%d).', $object->id, $this->action->rule_id)
);
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.is_already_transfer')));
@@ -105,7 +106,7 @@ class ConvertToTransfer implements ActionInterface
$opposing = $repository->findByName($accountName, [$expectedType]);
if (null === $opposing) {
app('log')->error(
Log::error(
sprintf(
'Journal #%d cannot be converted because no valid %s account with name "%s" exists (rule #%d).',
$expectedType,
@@ -120,36 +121,36 @@ class ConvertToTransfer implements ActionInterface
}
if (TransactionTypeEnum::WITHDRAWAL->value === $type) {
app('log')->debug('Going to transform a withdrawal to a transfer.');
Log::debug('Going to transform a withdrawal to a transfer.');
try {
$res = $this->convertWithdrawalArray($object, $opposing);
} catch (FireflyException $e) {
app('log')->debug('Could not convert withdrawal to transfer.');
app('log')->error($e->getMessage());
Log::debug('Could not convert withdrawal to transfer.');
Log::error($e->getMessage());
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.complex_error')));
return false;
}
if (false !== $res) {
if ($res) {
event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::TRANSFER->value));
}
return $res;
}
// can only be a deposit at this point.
app('log')->debug('Going to transform a deposit to a transfer.');
Log::debug('Going to transform a deposit to a transfer.');
try {
$res = $this->convertDepositArray($object, $opposing);
} catch (FireflyException $e) {
app('log')->debug('Could not convert deposit to transfer.');
app('log')->error($e->getMessage());
Log::debug('Could not convert deposit to transfer.');
Log::error($e->getMessage());
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.complex_error')));
return false;
}
if (false !== $res) {
if ($res) {
event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionTypeEnum::DEPOSIT->value, TransactionTypeEnum::TRANSFER->value));
}
@@ -161,7 +162,7 @@ class ConvertToTransfer implements ActionInterface
/** @var null|TransactionJournal $journal */
$journal = TransactionJournal::find($journalId);
if (null === $journal) {
app('log')->error(sprintf('Journal #%d does not exist. Cannot convert to transfer.', $journalId));
Log::error(sprintf('Journal #%d does not exist. Cannot convert to transfer.', $journalId));
return '';
}
@@ -174,7 +175,7 @@ class ConvertToTransfer implements ActionInterface
/** @var null|TransactionJournal $journal */
$journal = TransactionJournal::find($journalId);
if (null === $journal) {
app('log')->error(sprintf('Journal #%d does not exist. Cannot convert to transfer.', $journalId));
Log::error(sprintf('Journal #%d does not exist. Cannot convert to transfer.', $journalId));
return '';
}
@@ -193,7 +194,7 @@ class ConvertToTransfer implements ActionInterface
{
$sourceAccount = $this->getSourceAccount($journal);
if ($sourceAccount->id === $opposing->id) {
app('log')->error(
Log::error(
vsprintf(
'Journal #%d has already has "%s" as a source asset. ConvertToTransfer failed. (rule #%d).',
[$journal->id, $opposing->name, $this->action->rule_id]
@@ -219,7 +220,7 @@ class ConvertToTransfer implements ActionInterface
->update(['transaction_type_id' => $newType->id, 'bill_id' => null])
;
app('log')->debug('Converted withdrawal to transfer.');
Log::debug('Converted withdrawal to transfer.');
return true;
}
@@ -248,7 +249,7 @@ class ConvertToTransfer implements ActionInterface
{
$destAccount = $this->getDestinationAccount($journal);
if ($destAccount->id === $opposing->id) {
app('log')->error(
Log::error(
vsprintf(
'Journal #%d has already has "%s" as a destination asset. ConvertToTransfer failed. (rule #%d).',
[$journal->id, $opposing->name, $this->action->rule_id]
@@ -274,7 +275,7 @@ class ConvertToTransfer implements ActionInterface
->update(['transaction_type_id' => $newType->id, 'bill_id' => null])
;
app('log')->debug('Converted deposit to transfer.');
Log::debug('Converted deposit to transfer.');
return true;
}