Clean up some code.

This commit is contained in:
James Cole
2021-04-27 06:42:07 +02:00
parent 366eca3173
commit 112a27dbd9
14 changed files with 28 additions and 25 deletions

View File

@@ -71,6 +71,7 @@ class DeleteEmptyJournals extends Command
->groupBy('transactions.transaction_journal_id')
->get([DB::raw('COUNT(transactions.transaction_journal_id) as the_count'), 'transaction_journal_id']);
$total = 0;
/** @var Transaction $row */
foreach ($set as $row) {
$count = (int)$row->the_count;
if (1 === $count % 2) {

View File

@@ -60,6 +60,7 @@ class FixGroupAccounts extends Command
$res = TransactionJournal
::groupBy('transaction_group_id')
->get(['transaction_group_id', DB::raw('COUNT(transaction_group_id) as the_count')]);
/** @var TransactionJournal $journal */
foreach ($res as $journal) {
if ((int)$journal->the_count > 1) {
$groups[] = (int)$journal->transaction_group_id;

View File

@@ -177,7 +177,7 @@ class DecryptDatabase extends Command
/**
* Tries to decrypt data. Will only throw an exception when the MAC is invalid.
*
* @param $value
* @param mixed $value
*
* @return string
* @throws FireflyException

View File

@@ -28,6 +28,7 @@ use Carbon\Carbon;
use Exception;
use FireflyIII\Console\Commands\VerifiesAccessToken;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
@@ -241,7 +242,7 @@ class ExportData extends Command
$accounts = $this->accountRepository->getAccountsByType($types);
}
// filter accounts,
/** @var AccountType $account */
/** @var Account $account */
foreach ($accounts as $account) {
if (in_array($account->accountType->type, $types, true)) {
$final->push($account);

View File

@@ -144,8 +144,7 @@ class BackToJournals extends Command
$chunks = array_chunk($transactions, 500);
foreach ($chunks as $chunk) {
$set = DB::table('transactions')->whereIn('transactions.id', $chunk)
->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray();
$set = DB::table('transactions')->whereIn('transactions.id', $chunk)->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray();
$array = array_merge($array, $set);
}

View File

@@ -414,7 +414,7 @@ class MigrateToGroups extends Command
if ($total > 0) {
Log::debug(sprintf('Going to convert %d transaction journals. Please hold..', $total));
$this->line(sprintf('Going to convert %d transaction journals. Please hold..', $total));
/** @var array $journal */
/** @var array $array */
foreach ($orphanedJournals as $array) {
$this->giveGroup($array);
}