Code cleanup

This commit is contained in:
James Cole
2024-12-22 08:43:12 +01:00
parent 5751f7e5a3
commit 565bd87959
574 changed files with 4600 additions and 4604 deletions

View File

@@ -43,7 +43,7 @@ class AcceptHeaders
$method = $request->getMethod();
$accepts = ['application/x-www-form-urlencoded', 'application/json', 'application/vnd.api+json', 'application/octet-stream', '*/*'];
$contentTypes = ['application/x-www-form-urlencoded', 'application/json', 'application/vnd.api+json', 'application/octet-stream'];
$submitted = (string)$request->header('Content-Type');
$submitted = (string) $request->header('Content-Type');
// if bad Accept header, send error.
if (!$request->accepts($accepts)) {

View File

@@ -122,10 +122,10 @@ class Authenticate
}
if (null !== $user) {
// app('log')->debug(get_class($user));
if (1 === (int)$user->blocked) {
$message = (string)trans('firefly.block_account_logout');
if (1 === (int) $user->blocked) {
$message = (string) trans('firefly.block_account_logout');
if ('email_changed' === $user->blocked_code) {
$message = (string)trans('firefly.email_changed_logout');
$message = (string) trans('firefly.email_changed_logout');
}
app('log')->warning('User is blocked, cannot use authentication method.');
app('session')->flash('logoutMessage', $message);

View File

@@ -132,8 +132,8 @@ class Installer
private function oldDBVersion(): bool
{
// older version in config than database?
$configVersion = (int)config('firefly.db_version');
$dbVersion = (int)app('fireflyconfig')->getFresh('db_version', 1)->data;
$configVersion = (int) config('firefly.db_version');
$dbVersion = (int) app('fireflyconfig')->getFresh('db_version', 1)->data;
if ($configVersion > $dbVersion) {
Log::warning(
sprintf(
@@ -157,8 +157,8 @@ class Installer
private function oldVersion(): bool
{
// version compare thing.
$configVersion = (string)config('firefly.version');
$dbVersion = (string)app('fireflyconfig')->getFresh('ff3_version', '1.0')->data;
$configVersion = (string) config('firefly.version');
$dbVersion = (string) app('fireflyconfig')->getFresh('ff3_version', '1.0')->data;
if (str_starts_with($configVersion, 'develop')) {
Log::debug('Skipping version check for develop version.');

View File

@@ -95,7 +95,7 @@ class InterestingMessage
// send message about newly created transaction group.
/** @var null|TransactionGroup $group */
$group = auth()->user()->transactionGroups()->with(['transactionJournals', 'transactionJournals.transactionType'])->find((int)$transactionGroupId);
$group = auth()->user()->transactionGroups()->with(['transactionJournals', 'transactionJournals.transactionType'])->find((int) $transactionGroupId);
if (null === $group) {
return;
@@ -111,17 +111,17 @@ class InterestingMessage
$title = $count > 1 ? $group->title : $journal->description;
if ('created' === $message) {
session()->flash('success_url', route('transactions.show', [$transactionGroupId]));
session()->flash('success', (string)trans('firefly.stored_journal', ['description' => $title]));
session()->flash('success', (string) trans('firefly.stored_journal', ['description' => $title]));
}
if ('updated' === $message) {
$type = strtolower($journal->transactionType->type);
session()->flash('success_url', route('transactions.show', [$transactionGroupId]));
session()->flash('success', (string)trans(sprintf('firefly.updated_%s', $type), ['description' => $title]));
session()->flash('success', (string) trans(sprintf('firefly.updated_%s', $type), ['description' => $title]));
}
if ('no_change' === $message) {
$type = strtolower($journal->transactionType->type);
session()->flash('warning_url', route('transactions.show', [$transactionGroupId]));
session()->flash('warning', (string)trans(sprintf('firefly.no_changes_%s', $type), ['description' => $title]));
session()->flash('warning', (string) trans(sprintf('firefly.no_changes_%s', $type), ['description' => $title]));
}
}
@@ -147,13 +147,13 @@ class InterestingMessage
return;
}
if ('deleted' === $message) {
session()->flash('success', (string)trans('firefly.account_deleted', ['name' => $account->name]));
session()->flash('success', (string) trans('firefly.account_deleted', ['name' => $account->name]));
}
if ('created' === $message) {
session()->flash('success', (string)trans('firefly.stored_new_account', ['name' => $account->name]));
session()->flash('success', (string) trans('firefly.stored_new_account', ['name' => $account->name]));
}
if ('updated' === $message) {
session()->flash('success', (string)trans('firefly.updated_account', ['name' => $account->name]));
session()->flash('success', (string) trans('firefly.updated_account', ['name' => $account->name]));
}
}
@@ -179,10 +179,10 @@ class InterestingMessage
return;
}
if ('deleted' === $message) {
session()->flash('success', (string)trans('firefly.deleted_bill', ['name' => $bill->name]));
session()->flash('success', (string) trans('firefly.deleted_bill', ['name' => $bill->name]));
}
if ('created' === $message) {
session()->flash('success', (string)trans('firefly.stored_new_bill', ['name' => $bill->name]));
session()->flash('success', (string) trans('firefly.stored_new_bill', ['name' => $bill->name]));
}
}
@@ -208,13 +208,13 @@ class InterestingMessage
return;
}
if ('deleted' === $message) {
session()->flash('success', (string)trans('firefly.deleted_webhook', ['title' => $webhook->title]));
session()->flash('success', (string) trans('firefly.deleted_webhook', ['title' => $webhook->title]));
}
if ('updated' === $message) {
session()->flash('success', (string)trans('firefly.updated_webhook', ['title' => $webhook->title]));
session()->flash('success', (string) trans('firefly.updated_webhook', ['title' => $webhook->title]));
}
if ('created' === $message) {
session()->flash('success', (string)trans('firefly.stored_new_webhook', ['title' => $webhook->title]));
session()->flash('success', (string) trans('firefly.stored_new_webhook', ['title' => $webhook->title]));
}
}
@@ -241,22 +241,22 @@ class InterestingMessage
return;
}
if ('enabled' === $message) {
session()->flash('success', (string)trans('firefly.currency_is_now_enabled', ['name' => $currency->name]));
session()->flash('success', (string) trans('firefly.currency_is_now_enabled', ['name' => $currency->name]));
}
if ('enable_failed' === $message) {
session()->flash('error', (string)trans('firefly.could_not_enable_currency', ['name' => $currency->name]));
session()->flash('error', (string) trans('firefly.could_not_enable_currency', ['name' => $currency->name]));
}
if ('disabled' === $message) {
session()->flash('success', (string)trans('firefly.currency_is_now_disabled', ['name' => $currency->name]));
session()->flash('success', (string) trans('firefly.currency_is_now_disabled', ['name' => $currency->name]));
}
if ('disable_failed' === $message) {
session()->flash('error', (string)trans('firefly.could_not_disable_currency', ['name' => $currency->name]));
session()->flash('error', (string) trans('firefly.could_not_disable_currency', ['name' => $currency->name]));
}
if ('default' === $message) {
session()->flash('success', (string)trans('firefly.new_default_currency', ['name' => $currency->name]));
session()->flash('success', (string) trans('firefly.new_default_currency', ['name' => $currency->name]));
}
if ('default_failed' === $message) {
session()->flash('error', (string)trans('firefly.default_currency_failed', ['name' => $currency->name]));
session()->flash('error', (string) trans('firefly.default_currency_failed', ['name' => $currency->name]));
}
}
}

View File

@@ -49,7 +49,7 @@ class IsDemoUser
$repository = app(UserRepositoryInterface::class);
if ($repository->hasRole($user, 'demo')) {
app('log')->info('User is a demo user.');
$request->session()->flash('info', (string)trans('firefly.not_available_demo_user'));
$request->session()->flash('info', (string) trans('firefly.not_available_demo_user'));
$current = $request->url();
$previous = $request->session()->previousUrl();
if ($current !== $previous) {

View File

@@ -71,8 +71,8 @@ class Range
}
$today = today(config('app.timezone'));
$start = app('navigation')->updateStartDate((string)$viewRange, $today);
$end = app('navigation')->updateEndDate((string)$viewRange, $start);
$start = app('navigation')->updateStartDate((string) $viewRange, $today);
$end = app('navigation')->updateEndDate((string) $viewRange, $start);
app('session')->put('start', $start);
app('session')->put('end', $end);
@@ -115,12 +115,12 @@ class Range
}
// save some formats:
$monthAndDayFormat = (string)trans('config.month_and_day_js', [], $locale);
$dateTimeFormat = (string)trans('config.date_time_js', [], $locale);
$monthAndDayFormat = (string) trans('config.month_and_day_js', [], $locale);
$dateTimeFormat = (string) trans('config.date_time_js', [], $locale);
$defaultCurrency = app('amount')->getDefaultCurrency();
// also format for moment JS:
$madMomentJS = (string)trans('config.month_and_day_moment_js', [], $locale);
$madMomentJS = (string) trans('config.month_and_day_moment_js', [], $locale);
app('view')->share('madMomentJS', $madMomentJS);
app('view')->share('monthAndDayFormat', $monthAndDayFormat);

View File

@@ -24,9 +24,9 @@ declare(strict_types=1);
namespace FireflyIII\Http\Middleware;
use Barryvdh\Debugbar\Facades\Debugbar;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Vite;
use Barryvdh\Debugbar\Facades\Debugbar;
/**
* Class SecureHeaders

View File

@@ -44,6 +44,6 @@ class TrustProxies extends Middleware
*/
public function __construct()
{
$this->proxies = (string)config('firefly.trusted_proxies');
$this->proxies = (string) config('firefly.trusted_proxies');
}
}

View File

@@ -30,7 +30,8 @@ use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
*/
class VerifyCsrfToken extends Middleware
{
protected $except = [
'oauth/token',
];
protected $except
= [
'oauth/token',
];
}