Various code cleanup and fixed alignments.

This commit is contained in:
James Cole
2024-01-01 14:43:56 +01:00
parent 1368aafe5f
commit f963ac63f1
443 changed files with 3668 additions and 3672 deletions

View File

@@ -64,7 +64,7 @@ class AcceptHeaders
}
// throw bad request if trace id is not a UUID
$uuid = $request->header('X-Trace-Id');
$uuid = $request->header('X-Trace-Id');
if (is_string($uuid) && '' !== trim($uuid) && (1 !== preg_match('/^[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}$/i', trim($uuid)))) {
throw new BadRequestHttpException('Bad X-Trace-Id header.');
}

View File

@@ -94,20 +94,20 @@ 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;
}
$count = $group->transactionJournals->count();
$count = $group->transactionJournals->count();
/** @var null|TransactionJournal $journal */
$journal = $group->transactionJournals->first();
$journal = $group->transactionJournals->first();
if (null === $journal) {
return;
}
$title = $count > 1 ? $group->title : $journal->description;
$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]));
@@ -140,7 +140,7 @@ class InterestingMessage
$message = $request->get('message');
/** @var null|Account $account */
$account = auth()->user()->accounts()->withTrashed()->find($accountId);
$account = auth()->user()->accounts()->withTrashed()->find($accountId);
if (null === $account) {
return;
@@ -172,7 +172,7 @@ class InterestingMessage
$message = $request->get('message');
/** @var null|Bill $bill */
$bill = auth()->user()->bills()->withTrashed()->find($billId);
$bill = auth()->user()->bills()->withTrashed()->find($billId);
if (null === $bill) {
return;
@@ -201,7 +201,7 @@ class InterestingMessage
$message = $request->get('message');
/** @var null|Webhook $webhook */
$webhook = auth()->user()->webhooks()->withTrashed()->find($webhookId);
$webhook = auth()->user()->webhooks()->withTrashed()->find($webhookId);
if (null === $webhook) {
return;
@@ -230,8 +230,8 @@ class InterestingMessage
{
// params:
// get parameters from request.
$code = $request->get('code');
$message = $request->get('message');
$code = $request->get('code');
$message = $request->get('message');
/** @var null|TransactionCurrency $currency */
$currency = TransactionCurrency::whereCode($code)->first();

View File

@@ -51,7 +51,7 @@ class IsAdmin
}
/** @var User $user */
$user = auth()->user();
$user = auth()->user();
/** @var UserRepositoryInterface $repository */
$repository = app(UserRepositoryInterface::class);

View File

@@ -40,7 +40,7 @@ class IsDemoUser
public function handle(Request $request, \Closure $next)
{
/** @var null|User $user */
$user = $request->user();
$user = $request->user();
if (null === $user) {
return $next($request);
}

View File

@@ -68,9 +68,9 @@ class Range
$viewRange = '1M';
}
$today = today(config('app.timezone'));
$start = app('navigation')->updateStartDate((string)$viewRange, $today);
$end = app('navigation')->updateEndDate((string)$viewRange, $start);
$today = today(config('app.timezone'));
$start = app('navigation')->updateStartDate((string)$viewRange, $today);
$end = app('navigation')->updateEndDate((string)$viewRange, $start);
app('session')->put('start', $start);
app('session')->put('end', $end);
@@ -94,15 +94,15 @@ class Range
private function configureView(): void
{
// get locale preference:
$language = app('steam')->getLanguage();
$locale = app('steam')->getLocale();
$language = app('steam')->getLanguage();
$locale = app('steam')->getLocale();
\App::setLocale($language);
Carbon::setLocale(substr($locale, 0, 2));
$localeArray = app('steam')->getLocaleArray($locale);
$localeArray = app('steam')->getLocaleArray($locale);
setlocale(LC_TIME, $localeArray);
$moneyResult = setlocale(LC_MONETARY, $localeArray);
$moneyResult = setlocale(LC_MONETARY, $localeArray);
// send error to view, if could not set money format
if (false === $moneyResult) {
@@ -116,7 +116,7 @@ class Range
$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

@@ -41,13 +41,13 @@ class SecureHeaders
public function handle(Request $request, \Closure $next)
{
// generate and share nonce.
$nonce = base64_encode(random_bytes(16));
$nonce = base64_encode(random_bytes(16));
Vite::useCspNonce($nonce);
app('view')->share('JS_NONCE', $nonce);
$response = $next($request);
$trackingScriptSrc = $this->getTrackingScriptSource();
$csp = [
$response = $next($request);
$trackingScriptSrc = $this->getTrackingScriptSource();
$csp = [
"default-src 'none'",
"object-src 'none'",
sprintf("script-src 'unsafe-eval' 'strict-dynamic' 'self' 'unsafe-inline' 'nonce-%1s' %2s", $nonce, $trackingScriptSrc),
@@ -59,10 +59,10 @@ class SecureHeaders
"manifest-src 'self'",
];
$route = $request->route();
$customUrl = '';
$authGuard = (string)config('firefly.authentication_guard');
$logoutUrl = (string)config('firefly.custom_logout_url');
$route = $request->route();
$customUrl = '';
$authGuard = (string)config('firefly.authentication_guard');
$logoutUrl = (string)config('firefly.custom_logout_url');
if ('remote_user_guard' === $authGuard && '' !== $logoutUrl) {
$customUrl = $logoutUrl;
}
@@ -71,7 +71,7 @@ class SecureHeaders
$csp[] = sprintf("form-action 'self' %s", $customUrl);
}
$featurePolicies = [
$featurePolicies = [
"geolocation 'none'",
"midi 'none'",
// "notifications 'none'",