mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Various PSR12 code cleanup
This commit is contained in:
@@ -27,7 +27,6 @@ namespace FireflyIII\Http\Middleware;
|
||||
use FireflyIII\Exceptions\BadHttpHeaderException;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Log;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
/**
|
||||
@@ -38,8 +37,8 @@ class AcceptHeaders
|
||||
/**
|
||||
* Handle the incoming requests.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param callable $next
|
||||
* @param Request $request
|
||||
* @param callable $next
|
||||
* @return Response
|
||||
* @throws BadHttpHeaderException
|
||||
*/
|
||||
@@ -50,7 +49,7 @@ class AcceptHeaders
|
||||
if ('GET' === $method && !$request->accepts(['application/json', 'application/vdn.api+json'])) {
|
||||
throw new BadHttpHeaderException('Your request must accept either application/json or application/vdn.api+json.');
|
||||
}
|
||||
$allowed = ['application/x-www-form-urlencoded','application/json'];
|
||||
$allowed = ['application/x-www-form-urlencoded', 'application/json'];
|
||||
$submitted = (string)$request->header('Content-Type');
|
||||
if (('POST' === $method || 'PUT' === $method) && !in_array($submitted, $allowed, true)) {
|
||||
$error = new BadHttpHeaderException(sprintf('Content-Type cannot be "%s"', $submitted));
|
||||
|
@@ -47,7 +47,7 @@ class Authenticate
|
||||
/**
|
||||
* Create a new middleware instance.
|
||||
*
|
||||
* @param Auth $auth
|
||||
* @param Auth $auth
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -59,9 +59,9 @@ class Authenticate
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @param string[] ...$guards
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @param string[] ...$guards
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
@@ -78,8 +78,8 @@ class Authenticate
|
||||
/**
|
||||
* Determine if the user is logged in to any of the given guards.
|
||||
*
|
||||
* @param mixed $request
|
||||
* @param array $guards
|
||||
* @param mixed $request
|
||||
* @param array $guards
|
||||
*
|
||||
* @return mixed
|
||||
* @throws FireflyException
|
||||
@@ -94,10 +94,10 @@ class Authenticate
|
||||
// do an extra check on user object.
|
||||
/** @var User $user */
|
||||
$user = $this->auth->authenticate();
|
||||
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('session')->flash('logoutMessage', $message);
|
||||
$this->auth->logout();
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Binder.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -49,7 +50,7 @@ class Binder
|
||||
/**
|
||||
* Binder constructor.
|
||||
*
|
||||
* @param Auth $auth
|
||||
* @param Auth $auth
|
||||
*/
|
||||
public function __construct(Auth $auth)
|
||||
{
|
||||
@@ -60,8 +61,8 @@ class Binder
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
@@ -81,9 +82,9 @@ class Binder
|
||||
/**
|
||||
* Do the binding.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
* @param Route $route
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
* @param Route $route
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* EncryptCookies.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
|
@@ -38,8 +38,8 @@ class InstallationId
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
|
@@ -43,8 +43,8 @@ class Installer
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
@@ -118,7 +118,7 @@ class Installer
|
||||
/**
|
||||
* Is access denied error.
|
||||
*
|
||||
* @param string $message
|
||||
* @param string $message
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -130,7 +130,7 @@ class Installer
|
||||
/**
|
||||
* Is no tables exist error.
|
||||
*
|
||||
* @param string $message
|
||||
* @param string $message
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -147,8 +147,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) {
|
||||
app('log')->warning(
|
||||
sprintf(
|
||||
@@ -174,8 +174,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 (1 === version_compare($configVersion, $dbVersion)) {
|
||||
app('log')->warning(
|
||||
sprintf(
|
||||
|
@@ -40,8 +40,8 @@ class InterestingMessage
|
||||
/**
|
||||
* Flashes the user an interesting message if the URL parameters warrant it.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
@@ -82,7 +82,7 @@ class InterestingMessage
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -96,7 +96,7 @@ class InterestingMessage
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*/
|
||||
private function handleGroupMessage(Request $request): void
|
||||
{
|
||||
@@ -106,7 +106,7 @@ class InterestingMessage
|
||||
|
||||
// send message about newly created transaction group.
|
||||
/** @var 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;
|
||||
@@ -122,22 +122,22 @@ 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]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -151,7 +151,7 @@ class InterestingMessage
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*/
|
||||
private function handleAccountMessage(Request $request): void
|
||||
{
|
||||
@@ -166,18 +166,18 @@ 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]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -189,22 +189,9 @@ class InterestingMessage
|
||||
|
||||
return null !== $billId && null !== $message;
|
||||
}
|
||||
/**
|
||||
* @param Request $request
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function webhookMessage(Request $request): bool
|
||||
{
|
||||
// get parameters from request.
|
||||
$billId = $request->get('webhook_id');
|
||||
$message = $request->get('message');
|
||||
|
||||
return null !== $billId && null !== $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*/
|
||||
private function handleBillMessage(Request $request): void
|
||||
{
|
||||
@@ -219,21 +206,35 @@ 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]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function webhookMessage(Request $request): bool
|
||||
{
|
||||
// get parameters from request.
|
||||
$billId = $request->get('webhook_id');
|
||||
$message = $request->get('message');
|
||||
|
||||
return null !== $billId && null !== $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
*/
|
||||
private function handleWebhookMessage(Request $request): void
|
||||
{
|
||||
// get parameters from request.
|
||||
$webhookId = $request->get('webhook_id');
|
||||
$message = $request->get('message');
|
||||
$webhookId = $request->get('webhook_id');
|
||||
$message = $request->get('message');
|
||||
|
||||
/** @var Webhook $webhook */
|
||||
$webhook = auth()->user()->webhooks()->withTrashed()->find($webhookId);
|
||||
@@ -242,13 +243,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]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* IsAdmin.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -36,9 +37,9 @@ class IsAdmin
|
||||
/**
|
||||
* Handle an incoming request. Must be admin.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @param string|null $guard
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @param string|null $guard
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* IsDemoUser.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -36,8 +37,8 @@ class IsDemoUser
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -53,7 +54,7 @@ class IsDemoUser
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
if ($repository->hasRole($user, 'demo')) {
|
||||
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) {
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Range.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -40,8 +41,8 @@ class Range
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -112,12 +113,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);
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* RedirectIfAuthenticated.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -36,9 +37,9 @@ class RedirectIfAuthenticated
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @param string|null $guard
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @param string|null $guard
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
|
@@ -36,8 +36,8 @@ class SecureHeaders
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
@@ -64,8 +64,8 @@ class SecureHeaders
|
||||
|
||||
$route = $request->route();
|
||||
$customUrl = '';
|
||||
$authGuard = (string) config('firefly.authentication_guard');
|
||||
$logoutUrl = (string) config('firefly.custom_logout_url');
|
||||
$authGuard = (string)config('firefly.authentication_guard');
|
||||
$logoutUrl = (string)config('firefly.custom_logout_url');
|
||||
if ('remote_user_guard' === $authGuard && '' !== $logoutUrl) {
|
||||
$customUrl = $logoutUrl;
|
||||
}
|
||||
@@ -115,8 +115,8 @@ class SecureHeaders
|
||||
*/
|
||||
private function getTrackingScriptSource(): string
|
||||
{
|
||||
if ('' !== (string) config('firefly.tracker_site_id') && '' !== (string) config('firefly.tracker_url')) {
|
||||
return (string) config('firefly.tracker_url');
|
||||
if ('' !== (string)config('firefly.tracker_site_id') && '' !== (string)config('firefly.tracker_url')) {
|
||||
return (string)config('firefly.tracker_url');
|
||||
}
|
||||
|
||||
return '';
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* StartFireflySession.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -36,8 +37,8 @@ class StartFireflySession extends StartSession
|
||||
/**
|
||||
* Store the current URL for the request if necessary.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Session $session
|
||||
* @param Request $request
|
||||
* @param Session $session
|
||||
*/
|
||||
protected function storeCurrentUrl(Request $request, $session): void
|
||||
{
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* TrimStrings.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* TrustProxies.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -45,6 +46,6 @@ class TrustProxies extends Middleware
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->proxies = (string) config('firefly.trusted_proxies');
|
||||
$this->proxies = (string)config('firefly.trusted_proxies');
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* VerifyCsrfToken.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
|
Reference in New Issue
Block a user