Reformat various code.

This commit is contained in:
James Cole
2022-03-29 15:01:48 +02:00
parent 452b6d0e1b
commit 60786461a9
7 changed files with 539 additions and 97 deletions

File diff suppressed because one or more lines are too long

View File

@@ -21,7 +21,6 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
use FireflyIII\Http\Middleware\IsAdmin;
/** /**
* Autocomplete controllers * Autocomplete controllers

View File

@@ -54,10 +54,10 @@ if (!function_exists('limitStringLength')) {
function limitStringLength(string $string): string function limitStringLength(string $string): string
{ {
$maxChars = 75; $maxChars = 75;
$length = \strlen($string); $length = strlen($string);
$result = $string; $result = $string;
if ($length > $maxChars) { if ($length > $maxChars) {
$result = substr_replace($string, ' ... ', (int)($maxChars / 2), $length - $maxChars); $result = substr_replace($string, ' ... ', (int) ($maxChars / 2), $length - $maxChars);
} }
return $result; return $result;
@@ -114,8 +114,8 @@ try {
if (null !== $start && null !== $end) { if (null !== $start && null !== $end) {
$title = trans( $title = trans(
'firefly.between_dates_breadcrumb', 'firefly.between_dates_breadcrumb',
['start' => $start->isoFormat((string)trans('config.month_and_day_js')), ['start' => $start->isoFormat((string) trans('config.month_and_day_js')),
'end' => $end->isoFormat((string)trans('config.month_and_day_js')),] 'end' => $end->isoFormat((string) trans('config.month_and_day_js')),]
); );
$breadcrumbs->push($title, route('accounts.show', $account)); $breadcrumbs->push($title, route('accounts.show', $account));
} }
@@ -443,8 +443,8 @@ try {
if (null !== $start && null !== $end) { if (null !== $start && null !== $end) {
$title = trans( $title = trans(
'firefly.between_dates_breadcrumb', 'firefly.between_dates_breadcrumb',
['start' => $start->isoFormat((string)trans('config.month_and_day_js')), ['start' => $start->isoFormat((string) trans('config.month_and_day_js')),
'end' => $end->isoFormat((string)trans('config.month_and_day_js')),] 'end' => $end->isoFormat((string) trans('config.month_and_day_js')),]
); );
$breadcrumbs->push($title, route('budgets.no-budget')); $breadcrumbs->push($title, route('budgets.no-budget'));
} }
@@ -477,8 +477,8 @@ try {
$title = trans( $title = trans(
'firefly.between_dates_breadcrumb', 'firefly.between_dates_breadcrumb',
['start' => $budgetLimit->start_date->isoFormat((string)trans('config.month_and_day_js')), ['start' => $budgetLimit->start_date->isoFormat((string) trans('config.month_and_day_js')),
'end' => $budgetLimit->end_date->isoFormat((string)trans('config.month_and_day_js')),] 'end' => $budgetLimit->end_date->isoFormat((string) trans('config.month_and_day_js')),]
); );
$breadcrumbs->push( $breadcrumbs->push(
@@ -527,8 +527,8 @@ try {
if (null !== $start && null !== $end) { if (null !== $start && null !== $end) {
$title = trans( $title = trans(
'firefly.between_dates_breadcrumb', 'firefly.between_dates_breadcrumb',
['start' => $start->isoFormat((string)trans('config.month_and_day_js')), ['start' => $start->isoFormat((string) trans('config.month_and_day_js')),
'end' => $end->isoFormat((string)trans('config.month_and_day_js')),] 'end' => $end->isoFormat((string) trans('config.month_and_day_js')),]
); );
$breadcrumbs->push($title, route('categories.show', [$category->id])); $breadcrumbs->push($title, route('categories.show', [$category->id]));
} }
@@ -552,8 +552,8 @@ try {
if (null !== $start && null !== $end) { if (null !== $start && null !== $end) {
$title = trans( $title = trans(
'firefly.between_dates_breadcrumb', 'firefly.between_dates_breadcrumb',
['start' => $start->isoFormat((string)trans('config.month_and_day_js')), ['start' => $start->isoFormat((string) trans('config.month_and_day_js')),
'end' => $end->isoFormat((string)trans('config.month_and_day_js')),] 'end' => $end->isoFormat((string) trans('config.month_and_day_js')),]
); );
$breadcrumbs->push($title, route('categories.no-category')); $breadcrumbs->push($title, route('categories.no-category'));
} }
@@ -747,10 +747,10 @@ try {
static function (Generator $breadcrumbs, string $accountIds, Carbon $start, Carbon $end) { static function (Generator $breadcrumbs, string $accountIds, Carbon $start, Carbon $end) {
$breadcrumbs->parent('reports.index'); $breadcrumbs->parent('reports.index');
$monthFormat = (string)trans('config.month_and_day_js'); $monthFormat = (string) trans('config.month_and_day_js');
$startString = $start->isoFormat($monthFormat); $startString = $start->isoFormat($monthFormat);
$endString = $end->isoFormat($monthFormat); $endString = $end->isoFormat($monthFormat);
$title = (string)trans('firefly.report_audit', ['start' => $startString, 'end' => $endString]); $title = (string) trans('firefly.report_audit', ['start' => $startString, 'end' => $endString]);
$breadcrumbs->push($title, route('reports.report.audit', [$accountIds, $start->format('Ymd'), $end->format('Ymd')])); $breadcrumbs->push($title, route('reports.report.audit', [$accountIds, $start->format('Ymd'), $end->format('Ymd')]));
} }
@@ -760,10 +760,10 @@ try {
static function (Generator $breadcrumbs, string $accountIds, string $budgetIds, Carbon $start, Carbon $end) { static function (Generator $breadcrumbs, string $accountIds, string $budgetIds, Carbon $start, Carbon $end) {
$breadcrumbs->parent('reports.index'); $breadcrumbs->parent('reports.index');
$monthFormat = (string)trans('config.month_and_day_js'); $monthFormat = (string) trans('config.month_and_day_js');
$startString = $start->isoFormat($monthFormat); $startString = $start->isoFormat($monthFormat);
$endString = $end->isoFormat($monthFormat); $endString = $end->isoFormat($monthFormat);
$title = (string)trans('firefly.report_budget', ['start' => $startString, 'end' => $endString]); $title = (string) trans('firefly.report_budget', ['start' => $startString, 'end' => $endString]);
$breadcrumbs->push($title, route('reports.report.budget', [$accountIds, $budgetIds, $start->format('Ymd'), $end->format('Ymd')])); $breadcrumbs->push($title, route('reports.report.budget', [$accountIds, $budgetIds, $start->format('Ymd'), $end->format('Ymd')]));
} }
@@ -774,10 +774,10 @@ try {
static function (Generator $breadcrumbs, string $accountIds, string $tagTags, Carbon $start, Carbon $end) { static function (Generator $breadcrumbs, string $accountIds, string $tagTags, Carbon $start, Carbon $end) {
$breadcrumbs->parent('reports.index'); $breadcrumbs->parent('reports.index');
$monthFormat = (string)trans('config.month_and_day_js'); $monthFormat = (string) trans('config.month_and_day_js');
$startString = $start->isoFormat($monthFormat); $startString = $start->isoFormat($monthFormat);
$endString = $end->isoFormat($monthFormat); $endString = $end->isoFormat($monthFormat);
$title = (string)trans('firefly.report_tag', ['start' => $startString, 'end' => $endString]); $title = (string) trans('firefly.report_tag', ['start' => $startString, 'end' => $endString]);
$breadcrumbs->push($title, route('reports.report.tag', [$accountIds, $tagTags, $start->format('Ymd'), $end->format('Ymd')])); $breadcrumbs->push($title, route('reports.report.tag', [$accountIds, $tagTags, $start->format('Ymd'), $end->format('Ymd')]));
} }
@@ -788,10 +788,10 @@ try {
static function (Generator $breadcrumbs, string $accountIds, string $categoryIds, Carbon $start, Carbon $end) { static function (Generator $breadcrumbs, string $accountIds, string $categoryIds, Carbon $start, Carbon $end) {
$breadcrumbs->parent('reports.index'); $breadcrumbs->parent('reports.index');
$monthFormat = (string)trans('config.month_and_day_js'); $monthFormat = (string) trans('config.month_and_day_js');
$startString = $start->isoFormat($monthFormat); $startString = $start->isoFormat($monthFormat);
$endString = $end->isoFormat($monthFormat); $endString = $end->isoFormat($monthFormat);
$title = (string)trans('firefly.report_category', ['start' => $startString, 'end' => $endString]); $title = (string) trans('firefly.report_category', ['start' => $startString, 'end' => $endString]);
$breadcrumbs->push($title, route('reports.report.category', [$accountIds, $categoryIds, $start->format('Ymd'), $end->format('Ymd')])); $breadcrumbs->push($title, route('reports.report.category', [$accountIds, $categoryIds, $start->format('Ymd'), $end->format('Ymd')]));
} }
@@ -802,10 +802,10 @@ try {
static function (Generator $breadcrumbs, string $accountIds, string $doubleIds, Carbon $start, Carbon $end) { static function (Generator $breadcrumbs, string $accountIds, string $doubleIds, Carbon $start, Carbon $end) {
$breadcrumbs->parent('reports.index'); $breadcrumbs->parent('reports.index');
$monthFormat = (string)trans('config.month_and_day_js'); $monthFormat = (string) trans('config.month_and_day_js');
$startString = $start->isoFormat($monthFormat); $startString = $start->isoFormat($monthFormat);
$endString = $end->isoFormat($monthFormat); $endString = $end->isoFormat($monthFormat);
$title = (string)trans('firefly.report_double', ['start' => $startString, 'end' => $endString]); $title = (string) trans('firefly.report_double', ['start' => $startString, 'end' => $endString]);
$breadcrumbs->push($title, route('reports.report.double', [$accountIds, $doubleIds, $start->format('Ymd'), $end->format('Ymd')])); $breadcrumbs->push($title, route('reports.report.double', [$accountIds, $doubleIds, $start->format('Ymd'), $end->format('Ymd')]));
} }
@@ -816,10 +816,10 @@ try {
static function (Generator $breadcrumbs, string $accountIds, Carbon $start, Carbon $end) { static function (Generator $breadcrumbs, string $accountIds, Carbon $start, Carbon $end) {
$breadcrumbs->parent('reports.index'); $breadcrumbs->parent('reports.index');
$monthFormat = (string)trans('config.month_and_day_js'); $monthFormat = (string) trans('config.month_and_day_js');
$startString = $start->isoFormat($monthFormat); $startString = $start->isoFormat($monthFormat);
$endString = $end->isoFormat($monthFormat); $endString = $end->isoFormat($monthFormat);
$title = (string)trans('firefly.report_default', ['start' => $startString, 'end' => $endString]); $title = (string) trans('firefly.report_default', ['start' => $startString, 'end' => $endString]);
$breadcrumbs->push($title, route('reports.report.default', [$accountIds, $start->format('Ymd'), $end->format('Ymd')])); $breadcrumbs->push($title, route('reports.report.default', [$accountIds, $start->format('Ymd'), $end->format('Ymd')]));
} }
@@ -1029,8 +1029,8 @@ try {
if (null !== $start && null !== $end) { if (null !== $start && null !== $end) {
$title = trans( $title = trans(
'firefly.between_dates_breadcrumb', 'firefly.between_dates_breadcrumb',
['start' => $start->isoFormat((string)trans('config.month_and_day_js')), ['start' => $start->isoFormat((string) trans('config.month_and_day_js')),
'end' => $end->isoFormat((string)trans('config.month_and_day_js')),] 'end' => $end->isoFormat((string) trans('config.month_and_day_js')),]
); );
$breadcrumbs->push($title, route('tags.show', [$tag->id, $start, $end])); $breadcrumbs->push($title, route('tags.show', [$tag->id, $start, $end]));
} }
@@ -1042,7 +1042,7 @@ try {
static function (Generator $breadcrumbs, Tag $tag) { static function (Generator $breadcrumbs, Tag $tag) {
$breadcrumbs->parent('tags.index'); $breadcrumbs->parent('tags.index');
$breadcrumbs->push($tag->tag, route('tags.show', [$tag->id])); $breadcrumbs->push($tag->tag, route('tags.show', [$tag->id]));
$title = (string)trans('firefly.all_journals_for_tag', ['tag' => $tag->tag]); $title = (string) trans('firefly.all_journals_for_tag', ['tag' => $tag->tag]);
$breadcrumbs->push($title, route('tags.show.all', $tag->id)); $breadcrumbs->push($title, route('tags.show.all', $tag->id));
} }
); );
@@ -1059,8 +1059,8 @@ try {
// add date range: // add date range:
$title = trans( $title = trans(
'firefly.between_dates_breadcrumb', 'firefly.between_dates_breadcrumb',
['start' => $start->isoFormat((string)trans('config.month_and_day_js')), ['start' => $start->isoFormat((string) trans('config.month_and_day_js')),
'end' => $end->isoFormat((string)trans('config.month_and_day_js')),] 'end' => $end->isoFormat((string) trans('config.month_and_day_js')),]
); );
$breadcrumbs->push($title, route('transactions.index', [$what, $start, $end])); $breadcrumbs->push($title, route('transactions.index', [$what, $start, $end]));
} }
@@ -1092,7 +1092,7 @@ try {
$first = $group->transactionJournals()->first(); $first = $group->transactionJournals()->first();
$breadcrumbs->push( $breadcrumbs->push(
trans('breadcrumbs.edit_journal', ['description' => limitStringLength((string)$first->description)]), trans('breadcrumbs.edit_journal', ['description' => limitStringLength((string) $first->description)]),
route('transactions.edit', [$group->id]) route('transactions.edit', [$group->id])
); );
} }
@@ -1131,7 +1131,7 @@ try {
$type = strtolower($first->transactionType->type); $type = strtolower($first->transactionType->type);
$title = limitStringLength($first->description); $title = limitStringLength($first->description);
if ($group->transactionJournals()->count() > 1) { if ($group->transactionJournals()->count() > 1) {
$title = limitStringLength((string)$group->title); $title = limitStringLength((string) $group->title);
} }
if ('opening balance' === $type) { if ('opening balance' === $type) {
// See reference nr. 1 // See reference nr. 1

View File

@@ -40,7 +40,7 @@ Route::group(
Route::group( Route::group(
['middleware' => 'binders-only', 'namespace' => 'FireflyIII\Http\Controllers\System'], ['middleware' => 'binders-only', 'namespace' => 'FireflyIII\Http\Controllers\System'],
static function () { static function () {
Route::get('offline', fn () => view('errors.offline')); Route::get('offline', fn() => view('errors.offline'));
Route::get('health', ['uses' => 'HealthcheckController@check', 'as' => 'healthcheck']); Route::get('health', ['uses' => 'HealthcheckController@check', 'as' => 'healthcheck']);
} }
); );