Use PSR-12 code style

This commit is contained in:
James Cole
2022-10-30 14:24:37 +01:00
parent f53923f16c
commit f52675068b
151 changed files with 251 additions and 403 deletions

View File

@@ -87,7 +87,6 @@ trait ConvertsExchangeRates
$entry['native_decimal_places'] = $native->decimal_places;
}
$return[] = $entry;
}
return $return;
}
@@ -267,5 +266,4 @@ trait ConvertsExchangeRates
{
$this->enabled = true;
}
}

View File

@@ -59,7 +59,7 @@ trait AugumentData
$combined = [];
/** @var Account $expenseAccount */
foreach ($accounts as $expenseAccount) {
$collection = new Collection;
$collection = new Collection();
$collection->push($expenseAccount);
$revenue = $repository->findByName($expenseAccount->name, [AccountType::REVENUE]);
@@ -200,7 +200,7 @@ trait AugumentData
/** @var BudgetLimitRepositoryInterface $blRepository */
$blRepository = app(BudgetLimitRepositoryInterface::class);
// properties for cache
$cache = new CacheProperties;
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty($budget->id);
@@ -240,7 +240,6 @@ trait AugumentData
*/
protected function groupByName(array $array): array // filter + group data
{
// group by opposing account name.
$grouped = [];
/** @var array $journal */

View File

@@ -52,7 +52,6 @@ trait ChartGeneration
*/
protected function accountBalanceChart(Collection $accounts, Carbon $start, Carbon $end): array // chart helper method.
{
// chart properties for cache:
$cache = new CacheProperties();
$cache->addProperty($start);

View File

@@ -39,7 +39,6 @@ use phpseclib3\Crypt\RSA;
*/
trait CreateStuff
{
/**
* Creates an asset account.
*
@@ -61,7 +60,7 @@ trait CreateStuff
'active' => true,
'account_role' => 'defaultAsset',
'opening_balance' => $request->input('bank_balance'),
'opening_balance_date' => new Carbon,
'opening_balance_date' => new Carbon(),
'currency_id' => $currency->id,
];
@@ -120,7 +119,7 @@ trait CreateStuff
if (class_exists(LegacyRSA::class)) {
// PHP 7
Log::info('Will run PHP7 code.');
$keys = (new LegacyRSA)->createKey(4096);
$keys = (new LegacyRSA())->createKey(4096);
}
if (!class_exists(LegacyRSA::class)) {
@@ -158,7 +157,7 @@ trait CreateStuff
'active' => true,
'account_role' => 'savingAsset',
'opening_balance' => $request->input('savings_balance'),
'opening_balance_date' => new Carbon,
'opening_balance_date' => new Carbon(),
'currency_id' => $currency->id,
];
$repository->store($savingsAccount);
@@ -182,5 +181,4 @@ trait CreateStuff
]
);
}
}

View File

@@ -93,8 +93,5 @@ trait CronRunner
'job_errored' => $recurring->jobErrored,
'message' => $recurring->message,
];
}
}

View File

@@ -84,7 +84,6 @@ trait DateCalculation
*/
protected function calculateStep(Carbon $start, Carbon $end): string
{
$step = '1D';
$months = $start->diffInMonths($end);
if ($months > 3) {
@@ -167,5 +166,4 @@ trait DateCalculation
return $loop;
}
}

View File

@@ -140,26 +140,26 @@ trait GetConfigurationData
// last seven days:
$seven = Carbon::now()->subDays(7);
$index = (string) trans('firefly.last_seven_days');
$ranges[$index] = [$seven, new Carbon];
$ranges[$index] = [$seven, new Carbon()];
// last 30 days:
$thirty = Carbon::now()->subDays(30);
$index = (string) trans('firefly.last_thirty_days');
$ranges[$index] = [$thirty, new Carbon];
$ranges[$index] = [$thirty, new Carbon()];
// month to date:
$monthBegin = Carbon::now()->startOfMonth();
$index = (string) trans('firefly.month_to_date');
$ranges[$index] = [$monthBegin, new Carbon];
$ranges[$index] = [$monthBegin, new Carbon()];
// year to date:
$yearBegin = Carbon::now()->startOfYear();
$index = (string) trans('firefly.year_to_date');
$ranges[$index] = [$yearBegin, new Carbon];
$ranges[$index] = [$yearBegin, new Carbon()];
// everything
$index = (string) trans('firefly.everything');
$ranges[$index] = [$first, new Carbon];
$ranges[$index] = [$first, new Carbon()];
return [
'title' => $title,

View File

@@ -119,7 +119,6 @@ trait ModelInformation
$triggers = [];
foreach ($operators as $key => $operator) {
if ('user_action' !== $key && false === $operator['alias']) {
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
}
}
@@ -146,7 +145,6 @@ trait ModelInformation
]
)->render();
} catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Throwable was thrown in getTriggersForBill(): %s', $e->getMessage()));
Log::debug($e->getTraceAsString());
$string = '';
@@ -171,7 +169,6 @@ trait ModelInformation
$triggers = [];
foreach ($operators as $key => $operator) {
if ('user_action' !== $key && false === $operator['alias']) {
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
}
}
@@ -262,7 +259,6 @@ trait ModelInformation
]
)->render();
} catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Throwable was thrown in getTriggersForJournal(): %s', $e->getMessage()));
Log::debug($e->getTraceAsString());
$string = '';

View File

@@ -88,7 +88,7 @@ trait PeriodOverview
[$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
// properties for cache
$cache = new CacheProperties;
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('account-show-period-entries');
@@ -252,12 +252,10 @@ trait PeriodOverview
'currency_symbol' => $journal['foreign_currency_symbol'],
'currency_decimal_places' => $journal['foreign_currency_decimal_places'],
];
}
$return[$foreignCurrencyId]['count']++;
$return[$foreignCurrencyId]['amount'] = bcadd($return[$foreignCurrencyId]['amount'], $journal['foreign_amount']);
}
}
return $return;
@@ -361,7 +359,7 @@ trait PeriodOverview
[$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
$cache = new CacheProperties;
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('no-budget-period-entries');
@@ -415,7 +413,7 @@ trait PeriodOverview
Log::debug(sprintf('Now in getNoCategoryPeriodOverview(%s)', $theDate->format('Y-m-d')));
$range = app('preferences')->get('viewRange', '1M')->data;
$first = $this->journalRepos->firstNull();
$start = null === $first ? new Carbon : $first->date;
$start = null === $first ? new Carbon() : $first->date;
$end = $theDate ?? today(config('app.timezone'));
Log::debug(sprintf('Start for getNoCategoryPeriodOverview() is %s', $start->format('Y-m-d')));
@@ -484,12 +482,11 @@ trait PeriodOverview
*/
protected function getTagPeriodOverview(Tag $tag, Carbon $start, Carbon $end): array // period overview for tags.
{
$range = app('preferences')->get('viewRange', '1M')->data;
[$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
// properties for cache
$cache = new CacheProperties;
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('tag-period-entries');
@@ -565,7 +562,7 @@ trait PeriodOverview
[$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
// properties for cache
$cache = new CacheProperties;
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('transactions-period-entries');

View File

@@ -44,7 +44,6 @@ use Throwable;
*/
trait RenderPartialViews
{
/**
* View for transactions in a budget for an account.
*
@@ -114,7 +113,7 @@ trait RenderPartialViews
$budget = $budgetRepository->find((int) $attributes['budgetId']);
if (null === $budget) {
$budget = new Budget;
$budget = new Budget();
}
$journals = $popupHelper->byBudget($budget, $attributes);
@@ -276,7 +275,6 @@ trait RenderPartialViews
'count' => $count,
]
)->render();
} catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Throwable was thrown in getCurrentActions(): %s', $e->getMessage()));
Log::error($e->getTraceAsString());
@@ -303,7 +301,6 @@ trait RenderPartialViews
$triggers = [];
foreach ($operators as $key => $operator) {
if ('user_action' !== $key && false === $operator['alias']) {
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
}
}
@@ -318,7 +315,7 @@ trait RenderPartialViews
$count = ($index + 1);
try {
$rootOperator = OperatorQuerySearch::getRootOperator($entry->trigger_type);
if(str_starts_with($rootOperator, '-')) {
if (str_starts_with($rootOperator, '-')) {
$rootOperator = substr($rootOperator, 1);
}
$renderedEntries[] = view(
@@ -332,7 +329,6 @@ trait RenderPartialViews
'triggers' => $triggers,
]
)->render();
} catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Throwable was thrown in getCurrentTriggers(): %s', $e->getMessage()));
Log::error($e->getTraceAsString());
@@ -384,7 +380,6 @@ trait RenderPartialViews
*/
protected function noReportOptions(): string // render a view
{
try {
$result = view('reports.options.no-options')->render();
} catch (Throwable $e) { // @phpstan-ignore-line

View File

@@ -228,5 +228,4 @@ trait RequestInformation
]
);
}
}

View File

@@ -35,7 +35,6 @@ use Throwable;
*/
trait RuleManagement
{
/**
* @param Request $request
*
@@ -83,7 +82,6 @@ trait RuleManagement
$triggers = [];
foreach ($operators as $key => $operator) {
if ('user_action' !== $key && false === $operator['alias']) {
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
}
}
@@ -130,7 +128,6 @@ trait RuleManagement
$triggers = [];
foreach ($operators as $key => $operator) {
if ('user_action' !== $key && false === $operator['alias']) {
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
}
}

View File

@@ -183,5 +183,4 @@ trait TransactionCalculation
return $collector->getExtractedJournals();
}
}

View File

@@ -39,7 +39,6 @@ use Log;
*/
trait UserNavigation
{
/**
* Functionality:.
*