Various PSR12 code cleanup

This commit is contained in:
James Cole
2022-12-29 19:41:57 +01:00
parent 0022009dd5
commit dbf3e76ecc
340 changed files with 4079 additions and 3816 deletions

View File

@@ -32,8 +32,8 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use FireflyIII\User;
use Illuminate\Support\Collection;
use JsonException;
use Illuminate\Support\Facades\Log;
use JsonException;
/**
*
@@ -44,7 +44,7 @@ class NetWorth implements NetWorthInterface
private AccountRepositoryInterface $accountRepository;
private CurrencyRepositoryInterface $currencyRepos;
private User $user;
private User $user;
/**
* Returns the user's net worth in an array with the following layout:
@@ -57,8 +57,8 @@ class NetWorth implements NetWorthInterface
* This repeats for each currency the user has transactions in.
* Result of this method is cached.
*
* @param Collection $accounts
* @param Carbon $date
* @param Collection $accounts
* @param Carbon $date
*
* @return array
* @throws JsonException
@@ -89,7 +89,7 @@ class NetWorth implements NetWorthInterface
/** @var Account $account */
foreach ($accounts as $account) {
Log::debug(sprintf('Now at account #%d: "%s"', $account->id, $account->name));
$currencyId = (int) $this->accountRepository->getMetaValue($account, 'currency_id');
$currencyId = (int)$this->accountRepository->getMetaValue($account, 'currency_id');
$currencyId = 0 === $currencyId ? $default->id : $currencyId;
Log::debug(sprintf('Currency ID is #%d', $currencyId));
@@ -100,7 +100,7 @@ class NetWorth implements NetWorthInterface
Log::debug(sprintf('Balance for %s is %s', $date->format('Y-m-d'), $balance));
// always subtract virtual balance.
$virtualBalance = (string) $account->virtual_balance;
$virtualBalance = (string)$account->virtual_balance;
if ('' !== $virtualBalance) {
$balance = bcsub($balance, $virtualBalance);
}
@@ -129,7 +129,7 @@ class NetWorth implements NetWorthInterface
}
/**
* @param User $user
* @param User $user
*/
public function setUser(User $user): void
{
@@ -159,19 +159,19 @@ class NetWorth implements NetWorthInterface
$balance = $balances[$account->id] ?? '0';
// always subtract virtual balance.
$virtualBalance = (string) $account->virtual_balance;
$virtualBalance = (string)$account->virtual_balance;
if ('' !== $virtualBalance) {
$balance = bcsub($balance, $virtualBalance);
}
$return[$currency->id] = $return[$currency->id] ?? [
'id' => (string) $currency->id,
'name' => $currency->name,
'symbol' => $currency->symbol,
'code' => $currency->code,
'decimal_places' => $currency->decimal_places,
'sum' => '0',
];
'id' => (string)$currency->id,
'name' => $currency->name,
'symbol' => $currency->symbol,
'code' => $currency->code,
'decimal_places' => $currency->decimal_places,
'sum' => '0',
];
$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $balance);
}
@@ -187,7 +187,7 @@ class NetWorth implements NetWorthInterface
$filtered = new Collection();
/** @var Account $account */
foreach ($accounts as $account) {
if (1 === (int) $this->accountRepository->getMetaValue($account, 'include_net_worth')) {
if (1 === (int)$this->accountRepository->getMetaValue($account, 'include_net_worth')) {
$filtered->push($account);
}
}

View File

@@ -44,15 +44,15 @@ interface NetWorthInterface
* This repeats for each currency the user has transactions in.
* Result of this method is cached.
*
* @param Collection $accounts
* @param Carbon $date
* @param Collection $accounts
* @param Carbon $date
* @return array
* @deprecated
*/
public function getNetWorthByCurrency(Collection $accounts, Carbon $date): array;
/**
* @param User $user
* @param User $user
*/
public function setUser(User $user): void;
@@ -61,7 +61,7 @@ interface NetWorthInterface
*
* Same as above but cleaner function with less dependencies.
*
* @param Carbon $date
* @param Carbon $date
*
* @return array
*/

View File

@@ -1,4 +1,5 @@
<?php
/**
* PopupReport.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -42,9 +43,9 @@ class PopupReport implements PopupReportInterface
/**
* Collect the transactions for one account and one budget.
*
* @param Budget $budget
* @param Account $account
* @param array $attributes
* @param Budget $budget
* @param Account $account
* @param array $attributes
*
* @return array
*/
@@ -64,8 +65,8 @@ class PopupReport implements PopupReportInterface
/**
* Collect the transactions for one account and no budget.
*
* @param Account $account
* @param array $attributes
* @param Account $account
* @param array $attributes
*
* @return array
*/
@@ -77,7 +78,7 @@ class PopupReport implements PopupReportInterface
if (null !== $currencyId) {
/** @var CurrencyRepositoryInterface $repos */
$repos = app(CurrencyRepositoryInterface::class);
$currency = $repos->find((int) $currencyId);
$currency = $repos->find((int)$currencyId);
}
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
@@ -99,8 +100,8 @@ class PopupReport implements PopupReportInterface
/**
* Collect the transactions for a budget.
*
* @param Budget $budget
* @param array $attributes
* @param Budget $budget
* @param array $attributes
*
* @return array
*/
@@ -112,7 +113,7 @@ class PopupReport implements PopupReportInterface
if (null !== $currencyId) {
/** @var CurrencyRepositoryInterface $repos */
$repos = app(CurrencyRepositoryInterface::class);
$currency = $repos->find((int) $currencyId);
$currency = $repos->find((int)$currencyId);
}
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
@@ -139,8 +140,8 @@ class PopupReport implements PopupReportInterface
/**
* Collect journals by a category.
*
* @param Category|null $category
* @param array $attributes
* @param Category|null $category
* @param array $attributes
*
* @return array
*/
@@ -152,7 +153,7 @@ class PopupReport implements PopupReportInterface
if (null !== $currencyId) {
/** @var CurrencyRepositoryInterface $repos */
$repos = app(CurrencyRepositoryInterface::class);
$currency = $repos->find((int) $currencyId);
$currency = $repos->find((int)$currencyId);
}
/** @var GroupCollectorInterface $collector */
@@ -182,8 +183,8 @@ class PopupReport implements PopupReportInterface
/**
* Group transactions by expense.
*
* @param Account $account
* @param array $attributes
* @param Account $account
* @param array $attributes
*
* @return array
*/
@@ -195,7 +196,7 @@ class PopupReport implements PopupReportInterface
if (null !== $currencyId) {
/** @var CurrencyRepositoryInterface $repos */
$repos = app(CurrencyRepositoryInterface::class);
$currency = $repos->find((int) $currencyId);
$currency = $repos->find((int)$currencyId);
}
/** @var JournalRepositoryInterface $repository */
@@ -228,8 +229,8 @@ class PopupReport implements PopupReportInterface
/**
* Collect transactions by income.
*
* @param Account $account
* @param array $attributes
* @param Account $account
* @param array $attributes
*
* @return array
*/

View File

@@ -1,4 +1,5 @@
<?php
/**
* PopupReportInterface.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -34,9 +35,9 @@ interface PopupReportInterface
/**
* Get balances for budget.
*
* @param Budget $budget
* @param Account $account
* @param array $attributes
* @param Budget $budget
* @param Account $account
* @param array $attributes
*
* @return array
*/
@@ -45,8 +46,8 @@ interface PopupReportInterface
/**
* Get balances for transactions without a budget.
*
* @param Account $account
* @param array $attributes
* @param Account $account
* @param array $attributes
*
* @return array
*/
@@ -55,8 +56,8 @@ interface PopupReportInterface
/**
* Group by budget.
*
* @param Budget $budget
* @param array $attributes
* @param Budget $budget
* @param array $attributes
*
* @return array
*/
@@ -65,8 +66,8 @@ interface PopupReportInterface
/**
* Group by category.
*
* @param Category|null $category
* @param array $attributes
* @param Category|null $category
* @param array $attributes
*
* @return array
*/
@@ -75,8 +76,8 @@ interface PopupReportInterface
/**
* Do something with expense. Sorry, I am not very inspirational here.
*
* @param Account $account
* @param array $attributes
* @param Account $account
* @param array $attributes
*
* @return array
*/
@@ -85,8 +86,8 @@ interface PopupReportInterface
/**
* Do something with income. Sorry, I am not very inspirational here.
*
* @param Account $account
* @param array $attributes
* @param Account $account
* @param array $attributes
*
* @return array
*/

View File

@@ -1,4 +1,5 @@
<?php
/**
* ReportHelper.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -43,7 +44,7 @@ class ReportHelper implements ReportHelperInterface
/**
* ReportHelper constructor.
*
* @param BudgetRepositoryInterface $budgetRepository
* @param BudgetRepositoryInterface $budgetRepository
*/
public function __construct(BudgetRepositoryInterface $budgetRepository)
{
@@ -56,9 +57,9 @@ class ReportHelper implements ReportHelperInterface
*
* Excludes bills which have not had a payment on the mentioned accounts.
*
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
*
* @return array
*/
@@ -112,7 +113,7 @@ class ReportHelper implements ReportHelperInterface
/**
* Generate a list of months for the report.
*
* @param Carbon $date
* @param Carbon $date
*
* @return array
*/
@@ -141,7 +142,7 @@ class ReportHelper implements ReportHelperInterface
$currentEnd = clone $start;
$currentEnd->endOfMonth();
$months[$year]['months'][] = [
'formatted' => $start->isoFormat((string) trans('config.month_js')),
'formatted' => $start->isoFormat((string)trans('config.month_js')),
'start' => $start->format('Y-m-d'),
'end' => $currentEnd->format('Y-m-d'),
'month' => $start->month,

View File

@@ -1,4 +1,5 @@
<?php
/**
* ReportHelperInterface.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -36,9 +37,9 @@ interface ReportHelperInterface
*
* Excludes bills which have not had a payment on the mentioned accounts.
*
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
*
* @return array
*/
@@ -47,7 +48,7 @@ interface ReportHelperInterface
/**
* Generate a list of months.
*
* @param Carbon $date
* @param Carbon $date
*
* @return array
*/