Skip to content

Firefly III: a personal finances manager

Fix sloppy variable names

James Cole536e0549615a
diff --git a/app/TransactionRules/Actions/AddTag.php b/app/TransactionRules/Actions/AddTag.php
index 2f030a24bf..afdb267073 100644
--- a/app/TransactionRules/Actions/AddTag.php
+++ b/app/TransactionRules/Actions/AddTag.php
@@ -73,10 +73,10 @@ class AddTag implements ActionInterface
// add to journal:
DB::table('tag_transaction_journal')->insert(['tag_id' => $tag->id, 'transaction_journal_id' => $journal['transaction_journal_id']]);
Log::debug(sprintf('RuleAction AddTag. Added tag #%d ("%s") to journal %d.', $tag->id, $tag->tag, $journal['transaction_journal_id']));
- $journal = TransactionJournal::find($journal['transaction_journal_id']);
+ $object = TransactionJournal::find($journal['transaction_journal_id']);
// event for audit log entry
- event(new TriggeredAuditLog($this->action->rule, $journal, 'add_tag', null, $tag->tag));
+ event(new TriggeredAuditLog($this->action->rule, $object, 'add_tag', null, $tag->tag));
return true;
}
diff --git a/app/TransactionRules/Actions/AppendDescription.php b/app/TransactionRules/Actions/AppendDescription.php
index e2108cdcde..214baa761a 100644
--- a/app/TransactionRules/Actions/AppendDescription.php
+++ b/app/TransactionRules/Actions/AppendDescription.php
@@ -53,9 +53,9 @@ class AppendDescription implements ActionInterface
DB::table('transaction_journals')->where('id', $journal['transaction_journal_id'])->limit(1)->update(['description' => $description]);
// event for audit log entry
- /** @var TransactionJournal $journal */
- $journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
- event(new TriggeredAuditLog($this->action->rule, $journal, 'update_description', $journal['description'], $description));
+ /** @var TransactionJournal $object */
+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
+ event(new TriggeredAuditLog($this->action->rule, $object, 'update_description', $journal['description'], $description));
return true;
}
diff --git a/app/TransactionRules/Actions/AppendDescriptionToNotes.php b/app/TransactionRules/Actions/AppendDescriptionToNotes.php
index fbce57ca19..f69d677a54 100644
--- a/app/TransactionRules/Actions/AppendDescriptionToNotes.php
+++ b/app/TransactionRules/Actions/AppendDescriptionToNotes.php
@@ -48,28 +48,28 @@ class AppendDescriptionToNotes implements ActionInterface
public function actOnArray(array $journal): bool
{
/** @var TransactionJournal $journal */
- $journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
- if (null === $journal) {
+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
+ if (null === $object) {
Log::error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id']));
return false;
}
- $note = $journal->notes()->first();
+ $note = $object->notes()->first();
if (null === $note) {
$note = new Note;
- $note->noteable()->associate($journal);
+ $note->noteable()->associate($object);
$note->text = '';
}
$before = $note->text;
if ('' !== $note->text) {
- $note->text = trim(sprintf("%s \n%s", $note->text, $journal->description));
+ $note->text = trim(sprintf("%s \n%s", $note->text, $object->description));
}
if ('' === $note->text) {
- $note->text = (string) $journal->description;
+ $note->text = (string) $object->description;
}
$after = $note->text;
// event for audit log entry
- event(new TriggeredAuditLog($this->action->rule, $journal, 'update_notes', $before, $after));
+ event(new TriggeredAuditLog($this->action->rule, $object, 'update_notes', $before, $after));
$note->save();
return true;
diff --git a/app/TransactionRules/Actions/AppendNotes.php b/app/TransactionRules/Actions/AppendNotes.php
index 259b1ac8c5..bb88302fe6 100644
--- a/app/TransactionRules/Actions/AppendNotes.php
+++ b/app/TransactionRules/Actions/AppendNotes.php
@@ -67,10 +67,10 @@ class AppendNotes implements ActionInterface
$dbNote->text = $text;
$dbNote->save();
- /** @var TransactionJournal $journal */
- $journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
+ /** @var TransactionJournal $object */
+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
- event(new TriggeredAuditLog($this->action->rule, $journal, 'update_notes', $before, $text));
+ event(new TriggeredAuditLog($this->action->rule, $object, 'update_notes', $before, $text));
return true;
}
diff --git a/app/TransactionRules/Actions/AppendNotesToDescription.php b/app/TransactionRules/Actions/AppendNotesToDescription.php
index f628a06c89..4343d78c67 100644
--- a/app/TransactionRules/Actions/AppendNotesToDescription.php
+++ b/app/TransactionRules/Actions/AppendNotesToDescription.php
@@ -54,27 +54,27 @@ class AppendNotesToDescription implements ActionInterface
public function actOnArray(array $journal): bool
{
Log::debug('Now in AppendNotesToDescription');
- /** @var TransactionJournal $journal */
- $journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
- if (null === $journal) {
+ /** @var TransactionJournal $object */
+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
+ if (null === $object) {
Log::error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id']));
return false;
}
- $note = $journal->notes()->first();
+ $note = $object->notes()->first();
if (null === $note) {
Log::debug('Journal has no notes.');
$note = new Note;
- $note->noteable()->associate($journal);
+ $note->noteable()->associate($object);
$note->text = '';
}
// only append if there is something to append
if ('' !== $note->text) {
- $before = $journal->description;
- $journal->description = trim(sprintf("%s %s", $journal->description, (string) $this->clearString($note->text, false)));
- $journal->save();
- Log::debug(sprintf('Journal description is updated to "%s".', $journal->description));
+ $before = $object->description;
+ $object->description = trim(sprintf("%s %s", $object->description, (string) $this->clearString($note->text, false)));
+ $object->save();
+ Log::debug(sprintf('Journal description is updated to "%s".', $object->description));
- event(new TriggeredAuditLog($this->action->rule, $journal, 'update_description', $before, $journal->description));
+ event(new TriggeredAuditLog($this->action->rule, $object, 'update_description', $before, $object->description));
return true;
}
diff --git a/app/TransactionRules/Actions/ClearBudget.php b/app/TransactionRules/Actions/ClearBudget.php
index ac5219a7fb..8faa733584 100644
--- a/app/TransactionRules/Actions/ClearBudget.php
+++ b/app/TransactionRules/Actions/ClearBudget.php
@@ -51,9 +51,9 @@ class ClearBudget implements ActionInterface
*/
public function actOnArray(array $journal): bool
{
- /** @var TransactionJournal $journal */
- $journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
- $budget = $journal->budgets()->first();
+ /** @var TransactionJournal $object */
+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
+ $budget = $object->budgets()->first();
if (null === $budget) {
Log::debug(sprintf('RuleAction ClearBudget, no budget in journal #%d.', $journal['transaction_journal_id']));
return false;
@@ -61,7 +61,7 @@ class ClearBudget implements ActionInterface
DB::table('budget_transaction_journal')->where('transaction_journal_id', '=', $journal['transaction_journal_id'])->delete();
- event(new TriggeredAuditLog($this->action->rule, $journal, 'clear_budget', $budget->name, null));
+ event(new TriggeredAuditLog($this->action->rule, $object, 'clear_budget', $budget->name, null));
Log::debug(sprintf('RuleAction ClearBudget removed all budgets from journal #%d.', $journal['transaction_journal_id']));
diff --git a/app/TransactionRules/Actions/ClearCategory.php b/app/TransactionRules/Actions/ClearCategory.php
index 0c26840676..3e8719ee57 100644
--- a/app/TransactionRules/Actions/ClearCategory.php
+++ b/app/TransactionRules/Actions/ClearCategory.php
@@ -50,9 +50,9 @@ class ClearCategory implements ActionInterface
*/
public function actOnArray(array $journal): bool
{
- /** @var TransactionJournal $journal */
- $journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
- $category = $journal->categories()->first();
+ /** @var TransactionJournal $object */
+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
+ $category = $object->categories()->first();
if (null === $category) {
Log::debug(sprintf('RuleAction ClearCategory, no category in journal #%d.', $journal['transaction_journal_id']));
return false;
@@ -60,7 +60,7 @@ class ClearCategory implements ActionInterface
DB::table('category_transaction_journal')->where('transaction_journal_id', '=', $journal['transaction_journal_id'])->delete();
- event(new TriggeredAuditLog($this->action->rule, $journal, 'clear_category', $category->name, null));
+ event(new TriggeredAuditLog($this->action->rule, $object, 'clear_category', $category->name, null));
Log::debug(sprintf('RuleAction ClearCategory removed all categories from journal #%d.', $journal['transaction_journal_id']));
diff --git a/app/TransactionRules/Actions/ClearNotes.php b/app/TransactionRules/Actions/ClearNotes.php
index d64fee9c19..52ca3e24ca 100644
--- a/app/TransactionRules/Actions/ClearNotes.php
+++ b/app/TransactionRules/Actions/ClearNotes.php
@@ -50,8 +50,8 @@ class ClearNotes implements ActionInterface
*/
public function actOnArray(array $journal): bool
{
- $journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
- $notes = $journal->notes()->first();
+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
+ $notes = $object->notes()->first();
if (null === $notes) {
Log::debug(sprintf('RuleAction ClearNotes, journal #%d has no notes.', $journal['transaction_journal_id']));
return false;
@@ -64,7 +64,7 @@ class ClearNotes implements ActionInterface
->delete();
Log::debug(sprintf('RuleAction ClearNotes removed all notes from journal #%d.', $journal['transaction_journal_id']));
- event(new TriggeredAuditLog($this->action->rule, $journal, 'clear_notes', $before, null));
+ event(new TriggeredAuditLog($this->action->rule, $object, 'clear_notes', $before, null));
return true;
}
diff --git a/app/TransactionRules/Actions/DeleteTransaction.php b/app/TransactionRules/Actions/DeleteTransaction.php
index 5140ddbc1d..45ddb01011 100644
--- a/app/TransactionRules/Actions/DeleteTransaction.php
+++ b/app/TransactionRules/Actions/DeleteTransaction.php
@@ -75,12 +75,12 @@ class DeleteTransaction implements ActionInterface
);
// trigger delete factory:
- $journal = TransactionJournal::find($journal['transaction_group_id']);
- if (null !== $journal) {
+ $object = TransactionJournal::find($journal['transaction_group_id']);
+ if (null !== $object) {
/** @var JournalDestroyService $service */
$service = app(JournalDestroyService::class);
- $service->destroy($journal);
- event(new TriggeredAuditLog($this->action->rule, $journal, 'delete_journal', null, null));
+ $service->destroy($object);
+ event(new TriggeredAuditLog($this->action->rule, $object, 'delete_journal', null, null));
}
return true;
diff --git a/app/TransactionRules/Actions/LinkToBill.php b/app/TransactionRules/Actions/LinkToBill.php
index 76fe89c98e..96696ac89a 100644
--- a/app/TransactionRules/Actions/LinkToBill.php
+++ b/app/TransactionRules/Actions/LinkToBill.php
@@ -78,8 +78,8 @@ class LinkToBill implements ActionInterface
sprintf('RuleAction LinkToBill set the bill of journal #%d to bill #%d ("%s").', $journal['transaction_journal_id'], $bill->id, $bill->name)
);
- $journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
- event(new TriggeredAuditLog($this->action->rule, $journal, 'set_bill', null, $bill->name));
+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
+ event(new TriggeredAuditLog($this->action->rule, $object, 'set_bill', null, $bill->name));
return true;
}
diff --git a/app/TransactionRules/Actions/MoveDescriptionToNotes.php b/app/TransactionRules/Actions/MoveDescriptionToNotes.php
index 04b72883d6..c8d48d3ba9 100644
--- a/app/TransactionRules/Actions/MoveDescriptionToNotes.php
+++ b/app/TransactionRules/Actions/MoveDescriptionToNotes.php
@@ -52,35 +52,35 @@ class MoveDescriptionToNotes implements ActionInterface
*/
public function actOnArray(array $journal): bool
{
- /** @var TransactionJournal $journal */
- $journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
- if (null === $journal) {
+ /** @var TransactionJournal $object */
+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
+ if (null === $object) {
Log::error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id']));
return false;
}
- $note = $journal->notes()->first();
+ $note = $object->notes()->first();
if (null === $note) {
$note = new Note;
- $note->noteable()->associate($journal);
+ $note->noteable()->associate($object);
$note->text = '';
}
$before = $note->text;
- $beforeDescription = $journal->description;
+ $beforeDescription = $object->description;
if ('' !== $note->text) {
- $note->text = trim(sprintf("%s \n%s", $note->text, $journal->description));
- $journal->description = '(no description)';
+ $note->text = trim(sprintf("%s \n%s", $note->text, $object->description));
+ $object->description = '(no description)';
}
if ('' === $note->text) {
- $note->text = (string) $journal->description;
- $journal->description = '(no description)';
+ $note->text = (string) $object->description;
+ $object->description = '(no description)';
}
$after = $note->text;
- event(new TriggeredAuditLog($this->action->rule, $journal, 'update_description', $beforeDescription, $journal->description));
- event(new TriggeredAuditLog($this->action->rule, $journal, 'update_notes', $before, $after));
+ event(new TriggeredAuditLog($this->action->rule, $object, 'update_description', $beforeDescription, $object->description));
+ event(new TriggeredAuditLog($this->action->rule, $object, 'update_notes', $before, $after));
$note->save();
- $journal->save();
+ $object->save();
return true;
}
}
diff --git a/app/TransactionRules/Actions/MoveNotesToDescription.php b/app/TransactionRules/Actions/MoveNotesToDescription.php
index 9ffb20e3de..0c3c6a28e7 100644
--- a/app/TransactionRules/Actions/MoveNotesToDescription.php
+++ b/app/TransactionRules/Actions/MoveNotesToDescription.php
@@ -51,13 +51,13 @@ class MoveNotesToDescription implements ActionInterface
*/
public function actOnArray(array $journal): bool
{
- /** @var TransactionJournal $journal */
- $journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
- if (null === $journal) {
+ /** @var TransactionJournal $object */
+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
+ if (null === $object) {
Log::error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id']));
return false;
}
- $note = $journal->notes()->first();
+ $note = $object->notes()->first();
if (null === $note) {
// nothing to move, return null
return false;
@@ -67,14 +67,14 @@ class MoveNotesToDescription implements ActionInterface
$note->delete();
return false;
}
- $before = $journal->description;
+ $before = $object->description;
$beforeNote = $note->text;
- $journal->description = (string) $this->clearString($note->text, false);
- $journal->save();
+ $object->description = (string) $this->clearString($note->text, false);
+ $object->save();
$note->delete();
- event(new TriggeredAuditLog($this->action->rule, $journal, 'update_description', $before, $journal->description));
- event(new TriggeredAuditLog($this->action->rule, $journal, 'clear_notes', $beforeNote, null));
+ event(new TriggeredAuditLog($this->action->rule, $object, 'update_description', $before, $object->description));
+ event(new TriggeredAuditLog($this->action->rule, $object, 'clear_notes', $beforeNote, null));
return true;
}
diff --git a/app/TransactionRules/Actions/PrependDescription.php b/app/TransactionRules/Actions/PrependDescription.php
index cab6bf60d6..824a015768 100644
--- a/app/TransactionRules/Actions/PrependDescription.php
+++ b/app/TransactionRules/Actions/PrependDescription.php
@@ -54,11 +54,11 @@ class PrependDescription implements ActionInterface
DB::table('transaction_journals')->where('id', $journal['transaction_journal_id'])->limit(1)->update(['description' => $after]);
// journal
- /** @var TransactionJournal $journal */
- $journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
+ /** @var TransactionJournal $object */
+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
// audit log
- event(new TriggeredAuditLog($this->action->rule, $journal, 'update_description', $before, $after));
+ event(new TriggeredAuditLog($this->action->rule, $object, 'update_description', $before, $after));
return true;
}
diff --git a/app/TransactionRules/Actions/PrependNotes.php b/app/TransactionRules/Actions/PrependNotes.php
index 2fea0c6f1e..6856af40e1 100644
--- a/app/TransactionRules/Actions/PrependNotes.php
+++ b/app/TransactionRules/Actions/PrependNotes.php
@@ -68,11 +68,11 @@ class PrependNotes implements ActionInterface
$dbNote->save();
// journal
- /** @var TransactionJournal $journal */
- $journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
+ /** @var TransactionJournal $object */
+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
// audit log
- event(new TriggeredAuditLog($this->action->rule, $journal, 'update_notes', $before, $text));
+ event(new TriggeredAuditLog($this->action->rule, $object, 'update_notes', $before, $text));
return true;
}
diff --git a/app/TransactionRules/Actions/RemoveAllTags.php b/app/TransactionRules/Actions/RemoveAllTags.php
index 395a8fe180..0d446cc499 100644
--- a/app/TransactionRules/Actions/RemoveAllTags.php
+++ b/app/TransactionRules/Actions/RemoveAllTags.php
@@ -58,11 +58,11 @@ class RemoveAllTags implements ActionInterface
}
Log::debug(sprintf('RuleAction RemoveAllTags removed all tags from journal %d.', $journal['transaction_journal_id']));
- /** @var TransactionJournal $journal */
- $journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
+ /** @var TransactionJournal $object */
+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
// audit log
- event(new TriggeredAuditLog($this->action->rule, $journal, 'clear_all_tags', null, null));
+ event(new TriggeredAuditLog($this->action->rule, $object, 'clear_all_tags', null, null));
return true;
}
diff --git a/app/TransactionRules/Actions/RemoveTag.php b/app/TransactionRules/Actions/RemoveTag.php
index 6594fa171d..916f8af499 100644
--- a/app/TransactionRules/Actions/RemoveTag.php
+++ b/app/TransactionRules/Actions/RemoveTag.php
@@ -74,9 +74,9 @@ class RemoveTag implements ActionInterface
->where('tag_id', $tag->id)
->delete();
- /** @var TransactionJournal $journal */
- $journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
- event(new TriggeredAuditLog($this->action->rule, $journal, 'clear_tag', $tag->tag, null));
+ /** @var TransactionJournal $object */
+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
+ event(new TriggeredAuditLog($this->action->rule, $object, 'clear_tag', $tag->tag, null));
return true;
}
diff --git a/app/TransactionRules/Actions/SetBudget.php b/app/TransactionRules/Actions/SetBudget.php
index a90fb3a888..77c8d9b030 100644
--- a/app/TransactionRules/Actions/SetBudget.php
+++ b/app/TransactionRules/Actions/SetBudget.php
@@ -87,9 +87,9 @@ class SetBudget implements ActionInterface
DB::table('budget_transaction_journal')->where('transaction_journal_id', '=', $journal['transaction_journal_id'])->delete();
DB::table('budget_transaction_journal')->insert(['transaction_journal_id' => $journal['transaction_journal_id'], 'budget_id' => $budget->id]);
- /** @var TransactionJournal $journal */
- $journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
- event(new TriggeredAuditLog($this->action->rule, $journal, 'set_budget', null, $budget->name));
+ /** @var TransactionJournal $object */
+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
+ event(new TriggeredAuditLog($this->action->rule, $object, 'set_budget', null, $budget->name));
return true;
}
diff --git a/app/TransactionRules/Actions/SetCategory.php b/app/TransactionRules/Actions/SetCategory.php
index ecef7ed818..f69a913225 100644
--- a/app/TransactionRules/Actions/SetCategory.php
+++ b/app/TransactionRules/Actions/SetCategory.php
@@ -85,9 +85,9 @@ class SetCategory implements ActionInterface
DB::table('category_transaction_journal')->where('transaction_journal_id', '=', $journal['transaction_journal_id'])->delete();
DB::table('category_transaction_journal')->insert(['transaction_journal_id' => $journal['transaction_journal_id'], 'category_id' => $category->id]);
- /** @var TransactionJournal $journal */
- $journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
- event(new TriggeredAuditLog($this->action->rule, $journal, 'set_category', null, $category->name));
+ /** @var TransactionJournal $object */
+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
+ event(new TriggeredAuditLog($this->action->rule, $object, 'set_category', null, $category->name));
return true;
}
diff --git a/app/TransactionRules/Actions/SetNotes.php b/app/TransactionRules/Actions/SetNotes.php
index 362a00f257..1cd1147b6d 100644
--- a/app/TransactionRules/Actions/SetNotes.php
+++ b/app/TransactionRules/Actions/SetNotes.php
@@ -69,10 +69,10 @@ class SetNotes implements ActionInterface
)
);
- /** @var TransactionJournal $journal */
- $journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
+ /** @var TransactionJournal $object */
+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
- event(new TriggeredAuditLog($this->action->rule, $journal, 'update_notes', $oldNotes, $this->action->action_value));
+ event(new TriggeredAuditLog($this->action->rule, $object, 'update_notes', $oldNotes, $this->action->action_value));
return true;
}