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

@@ -70,7 +70,7 @@ trait GetConfigurationData
$steps[] = $currentStep;
}
}
app('log')->debug(sprintf('Total basic steps for %s is %d', $routeKey, count($steps)));
Log::debug(sprintf('Total basic steps for %s is %d', $routeKey, count($steps)));
return $steps;
}
@@ -199,7 +199,7 @@ trait GetConfigurationData
}
}
}
app('log')->debug(sprintf('Total specific steps for route "%s" and page "%s" (routeKey is "%s") is %d', $route, $specificPage, $routeKey, count($steps)));
Log::debug(sprintf('Total specific steps for route "%s" and page "%s" (routeKey is "%s") is %d', $route, $specificPage, $routeKey, count($steps)));
return $steps;
}
@@ -209,7 +209,7 @@ trait GetConfigurationData
$config = FireflyConfig::get('last_rt_job', 0);
$lastTime = (int)$config?->data;
$now = Carbon::now()->getTimestamp();
app('log')->debug(sprintf('verifyRecurringCronJob: last time is %d ("%s"), now is %d', $lastTime, $config?->data, $now));
Log::debug(sprintf('verifyRecurringCronJob: last time is %d ("%s"), now is %d', $lastTime, $config?->data, $now));
if (0 === $lastTime) {
request()->session()->flash('info', trans('firefly.recurring_never_cron'));

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Support\Http\Controllers;
use Illuminate\Support\Facades\Log;
use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\AccountType;
@@ -57,8 +58,8 @@ trait ModelInformation
]
)->render();
} catch (Throwable $e) {
app('log')->error(sprintf('Throwable was thrown in getActionsForBill(): %s', $e->getMessage()));
app('log')->error($e->getTraceAsString());
Log::error(sprintf('Throwable was thrown in getActionsForBill(): %s', $e->getMessage()));
Log::error($e->getTraceAsString());
$result = 'Could not render view. See log files.';
throw new FireflyException($result, 0, $e);
@@ -144,8 +145,8 @@ trait ModelInformation
]
)->render();
} catch (Throwable $e) {
app('log')->debug(sprintf('Throwable was thrown in getTriggersForBill(): %s', $e->getMessage()));
app('log')->debug($e->getTraceAsString());
Log::debug(sprintf('Throwable was thrown in getTriggersForBill(): %s', $e->getMessage()));
Log::debug($e->getTraceAsString());
throw new FireflyException(sprintf('Could not render trigger: %s', $e->getMessage()), 0, $e);
}
@@ -260,8 +261,8 @@ trait ModelInformation
];
$string = view('rules.partials.trigger', $renderInfo)->render();
} catch (Throwable $e) {
app('log')->debug(sprintf('Throwable was thrown in getTriggersForJournal(): %s', $e->getMessage()));
app('log')->debug($e->getTraceAsString());
Log::debug(sprintf('Throwable was thrown in getTriggersForJournal(): %s', $e->getMessage()));
Log::debug($e->getTraceAsString());
throw new FireflyException(sprintf('Could not render trigger: %s', $e->getMessage()), 0, $e);
}

View File

@@ -331,7 +331,7 @@ trait PeriodOverview
}
return $this->statistics->filter(
fn (PeriodStatistic $statistic) => $statistic->start->eq($start) && $statistic->end->eq($end) && $statistic->type === $type
fn (PeriodStatistic $statistic): bool => $statistic->start->eq($start) && $statistic->end->eq($end) && $statistic->type === $type
);
}
@@ -344,7 +344,7 @@ trait PeriodOverview
}
return $this->statistics->filter(
fn (PeriodStatistic $statistic) => $statistic->start->eq($start) && $statistic->end->eq($end) && str_starts_with($statistic->type, $prefix)
fn (PeriodStatistic $statistic): bool => $statistic->start->eq($start) && $statistic->end->eq($end) && str_starts_with($statistic->type, $prefix)
);
}
@@ -571,10 +571,6 @@ trait PeriodOverview
{
$result = [];
/**
* @var int $index
* @var array $item
*/
foreach ($this->transactions as $item) {
$date = Carbon::parse($item['date']);
$fits = $item['type'] === $type->value && $date >= $start && $date <= $end;
@@ -595,10 +591,6 @@ trait PeriodOverview
{
$result = [];
/**
* @var int $index
* @var array $item
*/
foreach ($this->transactions as $item) {
$date = Carbon::parse($item['date']);
if ($date >= $start && $date <= $end) {

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Support\Http\Controllers;
use Illuminate\Support\Facades\Log;
use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Report\PopupReportInterface;
@@ -68,9 +69,9 @@ trait RenderPartialViews
$journals = $popupHelper->balanceForBudget($budget, $account, $attributes);
try {
$view = view('popup.report.balance-amount', compact('journals', 'budget', 'account'))->render();
$view = view('popup.report.balance-amount', ['journals' => $journals, 'budget' => $budget, 'account' => $account])->render();
} catch (Throwable $e) {
app('log')->error(sprintf('Could not render: %s', $e->getMessage()));
Log::error(sprintf('Could not render: %s', $e->getMessage()));
$view = 'Firefly III could not render the view. Please see the log files.';
throw new FireflyException($view, 0, $e);
@@ -91,9 +92,9 @@ trait RenderPartialViews
$budgets = $repository->getActiveBudgets();
try {
$result = view('reports.options.budget', compact('budgets'))->render();
$result = view('reports.options.budget', ['budgets' => $budgets])->render();
} catch (Throwable $e) {
app('log')->error(sprintf('Cannot render reports.options.tag: %s', $e->getMessage()));
Log::error(sprintf('Cannot render reports.options.tag: %s', $e->getMessage()));
$result = 'Could not render view.';
throw new FireflyException($result, 0, $e);
@@ -123,9 +124,9 @@ trait RenderPartialViews
$journals = $popupHelper->byBudget($budget, $attributes);
try {
$view = view('popup.report.budget-spent-amount', compact('journals', 'budget'))->render();
$view = view('popup.report.budget-spent-amount', ['journals' => $journals, 'budget' => $budget])->render();
} catch (Throwable $e) {
app('log')->error(sprintf('Could not render: %s', $e->getMessage()));
Log::error(sprintf('Could not render: %s', $e->getMessage()));
$view = 'Firefly III could not render the view. Please see the log files.';
throw new FireflyException($view, 0, $e);
@@ -150,9 +151,9 @@ trait RenderPartialViews
$journals = $popupHelper->byCategory($category, $attributes);
try {
$view = view('popup.report.category-entry', compact('journals', 'category'))->render();
$view = view('popup.report.category-entry', ['journals' => $journals, 'category' => $category])->render();
} catch (Throwable $e) {
app('log')->error(sprintf('Could not render: %s', $e->getMessage()));
Log::error(sprintf('Could not render: %s', $e->getMessage()));
$view = 'Firefly III could not render the view. Please see the log files.';
throw new FireflyException($view, 0, $e);
@@ -173,9 +174,9 @@ trait RenderPartialViews
$categories = $repository->getCategories();
try {
$result = view('reports.options.category', compact('categories'))->render();
$result = view('reports.options.category', ['categories' => $categories])->render();
} catch (Throwable $e) {
app('log')->error(sprintf('Cannot render reports.options.category: %s', $e->getMessage()));
Log::error(sprintf('Cannot render reports.options.category: %s', $e->getMessage()));
$result = 'Could not render view.';
throw new FireflyException($result, 0, $e);
@@ -215,9 +216,9 @@ trait RenderPartialViews
}
try {
$result = view('reports.options.double', compact('set'))->render();
$result = view('reports.options.double', ['set' => $set])->render();
} catch (Throwable $e) {
app('log')->error(sprintf('Cannot render reports.options.tag: %s', $e->getMessage()));
Log::error(sprintf('Cannot render reports.options.tag: %s', $e->getMessage()));
$result = 'Could not render view.';
throw new FireflyException($result, 0, $e);
@@ -248,9 +249,9 @@ trait RenderPartialViews
$journals = $popupHelper->byExpenses($account, $attributes);
try {
$view = view('popup.report.expense-entry', compact('journals', 'account'))->render();
$view = view('popup.report.expense-entry', ['journals' => $journals, 'account' => $account])->render();
} catch (Throwable $e) {
app('log')->error(sprintf('Could not render: %s', $e->getMessage()));
Log::error(sprintf('Could not render: %s', $e->getMessage()));
$view = 'Firefly III could not render the view. Please see the log files.';
throw new FireflyException($view, 0, $e);
@@ -286,8 +287,8 @@ trait RenderPartialViews
]
)->render();
} catch (Throwable $e) {
app('log')->debug(sprintf('Throwable was thrown in getCurrentActions(): %s', $e->getMessage()));
app('log')->error($e->getTraceAsString());
Log::debug(sprintf('Throwable was thrown in getCurrentActions(): %s', $e->getMessage()));
Log::error($e->getTraceAsString());
throw new FireflyException(sprintf('Could not render: %s', $e->getMessage()), 0, $e);
}
@@ -341,8 +342,8 @@ trait RenderPartialViews
]
)->render();
} catch (Throwable $e) {
app('log')->debug(sprintf('Throwable was thrown in getCurrentTriggers(): %s', $e->getMessage()));
app('log')->error($e->getTraceAsString());
Log::debug(sprintf('Throwable was thrown in getCurrentTriggers(): %s', $e->getMessage()));
Log::error($e->getTraceAsString());
throw new FireflyException(sprintf('Could not render: %s', $e->getMessage()), 0, $e);
}
@@ -375,9 +376,9 @@ trait RenderPartialViews
$journals = $popupHelper->byIncome($account, $attributes);
try {
$view = view('popup.report.income-entry', compact('journals', 'account'))->render();
$view = view('popup.report.income-entry', ['journals' => $journals, 'account' => $account])->render();
} catch (Throwable $e) {
app('log')->error(sprintf('Could not render: %s', $e->getMessage()));
Log::error(sprintf('Could not render: %s', $e->getMessage()));
$view = 'Firefly III could not render the view. Please see the log files.';
throw new FireflyException($view, 0, $e);
@@ -396,7 +397,7 @@ trait RenderPartialViews
try {
$result = view('reports.options.no-options')->render();
} catch (Throwable $e) {
app('log')->error(sprintf('Cannot render reports.options.no-options: %s', $e->getMessage()));
Log::error(sprintf('Cannot render reports.options.no-options: %s', $e->getMessage()));
$result = 'Could not render view.';
throw new FireflyException($result, 0, $e);
@@ -417,9 +418,9 @@ trait RenderPartialViews
$tags = $repository->get();
try {
$result = view('reports.options.tag', compact('tags'))->render();
$result = view('reports.options.tag', ['tags' => $tags])->render();
} catch (Throwable $e) {
app('log')->error(sprintf('Cannot render reports.options.tag: %s', $e->getMessage()));
Log::error(sprintf('Cannot render reports.options.tag: %s', $e->getMessage()));
$result = 'Could not render view.';
throw new FireflyException($result, 0, $e);

View File

@@ -133,11 +133,7 @@ trait RequestInformation
return true;
}
// start and end in the past? use $end
if ($start->lessThanOrEqualTo($date) && $end->lessThanOrEqualTo($date)) {
return true;
}
return false;
return $start->lessThanOrEqualTo($date) && $end->lessThanOrEqualTo($date);
}
/**

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Support\Http\Controllers;
use Illuminate\Support\Facades\Log;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
use FireflyIII\Support\Search\OperatorQuerySearch;
@@ -56,8 +57,8 @@ trait RuleManagement
]
)->render();
} catch (Throwable $e) {
app('log')->error(sprintf('Throwable was thrown in getPreviousActions(): %s', $e->getMessage()));
app('log')->error($e->getTraceAsString());
Log::error(sprintf('Throwable was thrown in getPreviousActions(): %s', $e->getMessage()));
Log::error($e->getTraceAsString());
throw new FireflyException(sprintf('Could not render: %s', $e->getMessage()), 0, $e);
}
@@ -101,8 +102,8 @@ trait RuleManagement
]
)->render();
} catch (Throwable $e) {
app('log')->debug(sprintf('Throwable was thrown in getPreviousTriggers(): %s', $e->getMessage()));
app('log')->error($e->getTraceAsString());
Log::debug(sprintf('Throwable was thrown in getPreviousTriggers(): %s', $e->getMessage()));
Log::error($e->getTraceAsString());
throw new FireflyException(sprintf('Could not render: %s', $e->getMessage()), 0, $e);
}
@@ -147,8 +148,8 @@ trait RuleManagement
]
)->render();
} catch (Throwable $e) {
app('log')->debug(sprintf('Throwable was thrown in getPreviousTriggers(): %s', $e->getMessage()));
app('log')->error($e->getTraceAsString());
Log::debug(sprintf('Throwable was thrown in getPreviousTriggers(): %s', $e->getMessage()));
Log::error($e->getTraceAsString());
throw new FireflyException(sprintf('Could not render: %s', $e->getMessage()), 0, $e);
}

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Support\Http\Controllers;
use Illuminate\Support\Facades\Log;
use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Models\Account;
@@ -48,9 +49,9 @@ trait UserNavigation
*/
final protected function getPreviousUrl(string $identifier): string
{
app('log')->debug(sprintf('Trying to retrieve URL stored under "%s"', $identifier));
Log::debug(sprintf('Trying to retrieve URL stored under "%s"', $identifier));
$url = (string)session($identifier);
app('log')->debug(sprintf('The URL is %s', $url));
Log::debug(sprintf('The URL is %s', $url));
return app('steam')->getSafeUrl($url, route('index'));
}
@@ -79,10 +80,7 @@ trait UserNavigation
return in_array($type, $editable, true);
}
/**
* @return Redirector|RedirectResponse
*/
final protected function redirectAccountToAccount(Account $account)
final protected function redirectAccountToAccount(Account $account): Redirector|RedirectResponse
{
$type = $account->accountType->type;
if (AccountTypeEnum::RECONCILIATION->value === $type || AccountTypeEnum::INITIAL_BALANCE->value === $type || AccountTypeEnum::LIABILITY_CREDIT->value === $type) {
@@ -91,7 +89,7 @@ trait UserNavigation
/** @var null|Transaction $transaction */
$transaction = $account->transactions()->first();
if (null === $transaction) {
app('log')->error(sprintf('Account #%d has no transactions. Dont know where it belongs.', $account->id));
Log::error(sprintf('Account #%d has no transactions. Dont know where it belongs.', $account->id));
session()->flash('error', trans('firefly.cant_find_redirect_account'));
return redirect(route('index'));
@@ -101,7 +99,7 @@ trait UserNavigation
/** @var null|Transaction $other */
$other = $journal->transactions()->where('id', '!=', $transaction->id)->first();
if (null === $other) {
app('log')->error(sprintf('Account #%d has no valid journals. Dont know where it belongs.', $account->id));
Log::error(sprintf('Account #%d has no valid journals. Dont know where it belongs.', $account->id));
session()->flash('error', trans('firefly.cant_find_redirect_account'));
return redirect(route('index'));
@@ -113,15 +111,12 @@ trait UserNavigation
return redirect(route('index'));
}
/**
* @return Redirector|RedirectResponse
*/
final protected function redirectGroupToAccount(TransactionGroup $group)
final protected function redirectGroupToAccount(TransactionGroup $group): Redirector|RedirectResponse
{
/** @var null|TransactionJournal $journal */
$journal = $group->transactionJournals()->first();
if (null === $journal) {
app('log')->error(sprintf('No journals in group #%d', $group->id));
Log::error(sprintf('No journals in group #%d', $group->id));
return redirect(route('index'));
}
@@ -145,7 +140,7 @@ trait UserNavigation
$return = app('steam')->getSafePreviousUrl();
session()->put($identifier, $return);
app('log')->debug(sprintf('rememberPreviousUrl: %s: "%s"', $identifier, $return));
Log::debug(sprintf('rememberPreviousUrl: %s: "%s"', $identifier, $return));
return $return;
}