chore: reformat code.

This commit is contained in:
James Cole
2023-06-21 12:34:58 +02:00
parent 8d87abde64
commit 3dcb35710b
799 changed files with 23319 additions and 22173 deletions

View File

@@ -47,7 +47,7 @@ trait AugumentData
/**
* Searches for the opposing account.
*
* @param Collection $accounts
* @param Collection $accounts
*
* @return array
*/
@@ -74,7 +74,7 @@ trait AugumentData
/**
* Small helper function for the revenue and expense account charts.
*
* @param array $names
* @param array $names
*
* @return array
*/
@@ -91,7 +91,7 @@ trait AugumentData
/**
* Small helper function for the revenue and expense account charts.
*
* @param Collection $accounts
* @param Collection $accounts
*
* @return array
*/
@@ -109,7 +109,7 @@ trait AugumentData
/**
* Get the account names belonging to a bunch of account ID's.
*
* @param array $accountIds
* @param array $accountIds
*
* @return array
*/
@@ -135,7 +135,7 @@ trait AugumentData
/**
* Get the budget names from a set of budget ID's.
*
* @param array $budgetIds
* @param array $budgetIds
*
* @return array
*/
@@ -159,7 +159,7 @@ trait AugumentData
/**
* Get the category names from a set of category ID's. Small helper function for some of the charts.
*
* @param array $categoryIds
* @param array $categoryIds
*
* @return array
*/
@@ -185,9 +185,9 @@ trait AugumentData
/**
* Gets all budget limits for a budget.
*
* @param Budget $budget
* @param Carbon $start
* @param Carbon $end
* @param Budget $budget
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
@@ -233,7 +233,7 @@ trait AugumentData
/**
* Group set of transactions by name of opposing account.
*
* @param array $array
* @param array $array
*
* @return array
*/
@@ -261,10 +261,10 @@ trait AugumentData
/**
* Spent in a period.
*
* @param Collection $assets
* @param Collection $opposing
* @param Carbon $start
* @param Carbon $end
* @param Collection $assets
* @param Collection $opposing
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/

View File

@@ -34,8 +34,8 @@ trait BasicDataSupport
/**
* Find the ID in a given array. Return '0' if not there (amount).
*
* @param array $array
* @param int $entryId
* @param array $array
* @param int $entryId
*
* @return null|mixed
*/
@@ -47,8 +47,8 @@ trait BasicDataSupport
/**
* Find the ID in a given array. Return null if not there (amount).
*
* @param array $array
* @param int $entryId
* @param array $array
* @param int $entryId
*
* @return null|Carbon
*/

View File

@@ -42,9 +42,9 @@ trait ChartGeneration
/**
* Shows an overview of the account balances for a set of accounts.
*
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return array
* @throws FireflyException

View File

@@ -41,8 +41,8 @@ trait CreateStuff
/**
* Creates an asset account.
*
* @param NewUserFormRequest $request
* @param TransactionCurrency $currency
* @param NewUserFormRequest $request
* @param TransactionCurrency $currency
*
* @return bool
*/
@@ -71,8 +71,8 @@ trait CreateStuff
/**
* Creates a cash wallet.
*
* @param TransactionCurrency $currency
* @param string $language
* @param TransactionCurrency $currency
* @param string $language
*
* @return bool
*/
@@ -123,9 +123,9 @@ trait CreateStuff
/**
* Create a savings account.
*
* @param NewUserFormRequest $request
* @param TransactionCurrency $currency
* @param string $language
* @param NewUserFormRequest $request
* @param TransactionCurrency $currency
* @param string $language
*
* @return bool
*/
@@ -153,7 +153,7 @@ trait CreateStuff
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @param array $data
*
* @return User
*/

View File

@@ -38,8 +38,8 @@ use Psr\Container\NotFoundExceptionInterface;
trait CronRunner
{
/**
* @param bool $force
* @param Carbon $date
* @param bool $force
* @param Carbon $date
*
* @return array
* @throws ContainerExceptionInterface
@@ -71,8 +71,8 @@ trait CronRunner
}
/**
* @param bool $force
* @param Carbon $date
* @param bool $force
* @param Carbon $date
*
* @return array
*/
@@ -102,8 +102,8 @@ trait CronRunner
}
/**
* @param bool $force
* @param Carbon $date
* @param bool $force
* @param Carbon $date
*
* @return array
*/
@@ -133,8 +133,8 @@ trait CronRunner
}
/**
* @param bool $force
* @param Carbon $date
* @param bool $force
* @param Carbon $date
*
* @return array
* @throws ContainerExceptionInterface

View File

@@ -35,10 +35,11 @@ trait DateCalculation
* Calculate the number of days passed left until end date, as seen from start date.
* If today is between start and end, today will be used instead of end.
*
* If both are in the past OR both are in the future, simply return the number of days in the period with a minimum of 1
* If both are in the past OR both are in the future, simply return the number of days in the period with a minimum
* of 1
*
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return int
*/
@@ -59,8 +60,8 @@ trait DateCalculation
*
* If both are in the past OR both are in the future, simply return the period between them with a minimum of 1
*
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return int
*/
@@ -77,8 +78,8 @@ trait DateCalculation
}
/**
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
@@ -103,8 +104,8 @@ trait DateCalculation
* Get a list of the periods that will occur after this date. For example,
* March 2018, April 2018, etc.
*
* @param Carbon $date
* @param string $range
* @param Carbon $date
* @param string $range
*
* @return array
*/
@@ -139,8 +140,8 @@ trait DateCalculation
* Get a list of the periods that occurred before the start date. For example,
* March 2018, February 2018, etc.
*
* @param Carbon $date
* @param string $range
* @param Carbon $date
* @param string $range
*
* @return array
*/

View File

@@ -38,7 +38,7 @@ trait GetConfigurationData
/**
* Some common combinations.
*
* @param int $value
* @param int $value
*
* @return string
*/
@@ -60,7 +60,7 @@ trait GetConfigurationData
/**
* Get the basic steps from config.
*
* @param string $route
* @param string $route
*
* @return array
*/
@@ -74,7 +74,7 @@ trait GetConfigurationData
$currentStep = $options;
// get the text:
$currentStep['intro'] = (string)trans('intro.'.$route.'_'.$key);
$currentStep['intro'] = (string)trans('intro.' . $route . '_' . $key);
// save in array:
$steps[] = $currentStep;
@@ -183,8 +183,8 @@ trait GetConfigurationData
/**
* Get specific info for special routes.
*
* @param string $route
* @param string $specificPage
* @param string $route
* @param string $specificPage
*
* @return array
*
@@ -197,13 +197,13 @@ trait GetConfigurationData
// user is on page with specific instructions:
if ('' !== $specificPage) {
$routeKey = str_replace('.', '_', $route);
$elements = config(sprintf('intro.%s', $routeKey.'_'.$specificPage));
$elements = config(sprintf('intro.%s', $routeKey . '_' . $specificPage));
if (is_array($elements) && count($elements) > 0) {
foreach ($elements as $key => $options) {
$currentStep = $options;
// get the text:
$currentStep['intro'] = (string)trans('intro.'.$route.'_'.$specificPage.'_'.$key);
$currentStep['intro'] = (string)trans('intro.' . $route . '_' . $specificPage . '_' . $key);
// save in array:
$steps[] = $currentStep;

View File

@@ -42,7 +42,7 @@ trait ModelInformation
/**
* Get actions based on a bill.
*
* @param Bill $bill
* @param Bill $bill
*
* @return array
* @throws FireflyException
@@ -109,7 +109,7 @@ trait ModelInformation
/**
* Create fake triggers to match the bill's properties
*
* @param Bill $bill
* @param Bill $bill
*
* @return array
* @throws FireflyException
@@ -161,7 +161,7 @@ trait ModelInformation
}
/**
* @param TransactionJournal $journal
* @param TransactionJournal $journal
*
* @return array
* @throws FireflyException

View File

@@ -74,9 +74,9 @@ trait PeriodOverview
* and for each period, the amount of money spent and earned. This is a complex operation which is cached for
* performance reasons.
*
* @param Account $account
* @param Carbon $start
* @param Carbon $end
* @param Account $account
* @param Carbon $start
* @param Carbon $end
*
* @return array
* @throws FireflyException
@@ -150,12 +150,122 @@ trait PeriodOverview
return $entries;
}
/**
* Filter a list of journals by a set of dates, and then group them by currency.
*
* @param array $array
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
private function filterJournalsByDate(array $array, Carbon $start, Carbon $end): array
{
$result = [];
/** @var array $journal */
foreach ($array as $journal) {
if ($journal['date'] <= $end && $journal['date'] >= $start) {
$result[] = $journal;
}
}
return $result;
}
/**
* Return only transactions where $account is the source.
*
* @param Account $account
* @param array $journals
*
* @return array
*/
private function filterTransferredAway(Account $account, array $journals): array
{
$return = [];
/** @var array $journal */
foreach ($journals as $journal) {
if ($account->id === (int)$journal['source_account_id']) {
$return[] = $journal;
}
}
return $return;
}
/**
* Return only transactions where $account is the source.
*
* @param Account $account
* @param array $journals
*
* @return array
*/
private function filterTransferredIn(Account $account, array $journals): array
{
$return = [];
/** @var array $journal */
foreach ($journals as $journal) {
if ($account->id === (int)$journal['destination_account_id']) {
$return[] = $journal;
}
}
return $return;
}
/**
* @param array $journals
*
* @return array
*/
private function groupByCurrency(array $journals): array
{
$return = [];
/** @var array $journal */
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$foreignCurrencyId = $journal['foreign_currency_id'];
if (!array_key_exists($currencyId, $return)) {
$return[$currencyId] = [
'amount' => '0',
'count' => 0,
'currency_id' => $currencyId,
'currency_name' => $journal['currency_name'],
'currency_code' => $journal['currency_code'],
'currency_symbol' => $journal['currency_symbol'],
'currency_decimal_places' => $journal['currency_decimal_places'],
];
}
$return[$currencyId]['amount'] = bcadd($return[$currencyId]['amount'], $journal['amount'] ?? '0');
$return[$currencyId]['count']++;
if (null !== $foreignCurrencyId && null !== $journal['foreign_amount']) {
if (!array_key_exists($foreignCurrencyId, $return)) {
$return[$foreignCurrencyId] = [
'amount' => '0',
'count' => 0,
'currency_id' => (int)$foreignCurrencyId,
'currency_name' => $journal['foreign_currency_name'],
'currency_code' => $journal['foreign_currency_code'],
'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;
}
/**
* Overview for single category. Has been refactored recently.
*
* @param Category $category
* @param Carbon $start
* @param Carbon $end
* @param Category $category
* @param Carbon $start
* @param Carbon $end
*
* @return array
* @throws FireflyException
@@ -234,8 +344,8 @@ trait PeriodOverview
*
* This method has been refactored recently.
*
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return array
* @throws FireflyException
@@ -290,7 +400,7 @@ trait PeriodOverview
*
* Show period overview for no category view.
*
* @param Carbon $theDate
* @param Carbon $theDate
*
* @return array
* @throws FireflyException
@@ -360,9 +470,9 @@ trait PeriodOverview
/**
* This shows a period overview for a tag. It goes back in time and lists all relevant transactions and sums.
*
* @param Tag $tag
* @param Carbon $start
* @param Carbon $end
* @param Tag $tag
* @param Carbon $start
* @param Carbon $end
*
* @return array
* @throws FireflyException
@@ -435,9 +545,9 @@ trait PeriodOverview
}
/**
* @param string $transactionType
* @param Carbon $start
* @param Carbon $end
* @param string $transactionType
* @param Carbon $start
* @param Carbon $end
*
* @return array
* @throws FireflyException
@@ -498,114 +608,4 @@ trait PeriodOverview
return $entries;
}
/**
* Filter a list of journals by a set of dates, and then group them by currency.
*
* @param array $array
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
private function filterJournalsByDate(array $array, Carbon $start, Carbon $end): array
{
$result = [];
/** @var array $journal */
foreach ($array as $journal) {
if ($journal['date'] <= $end && $journal['date'] >= $start) {
$result[] = $journal;
}
}
return $result;
}
/**
* Return only transactions where $account is the source.
*
* @param Account $account
* @param array $journals
*
* @return array
*/
private function filterTransferredAway(Account $account, array $journals): array
{
$return = [];
/** @var array $journal */
foreach ($journals as $journal) {
if ($account->id === (int)$journal['source_account_id']) {
$return[] = $journal;
}
}
return $return;
}
/**
* Return only transactions where $account is the source.
*
* @param Account $account
* @param array $journals
*
* @return array
*/
private function filterTransferredIn(Account $account, array $journals): array
{
$return = [];
/** @var array $journal */
foreach ($journals as $journal) {
if ($account->id === (int)$journal['destination_account_id']) {
$return[] = $journal;
}
}
return $return;
}
/**
* @param array $journals
*
* @return array
*/
private function groupByCurrency(array $journals): array
{
$return = [];
/** @var array $journal */
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$foreignCurrencyId = $journal['foreign_currency_id'];
if (!array_key_exists($currencyId, $return)) {
$return[$currencyId] = [
'amount' => '0',
'count' => 0,
'currency_id' => $currencyId,
'currency_name' => $journal['currency_name'],
'currency_code' => $journal['currency_code'],
'currency_symbol' => $journal['currency_symbol'],
'currency_decimal_places' => $journal['currency_decimal_places'],
];
}
$return[$currencyId]['amount'] = bcadd($return[$currencyId]['amount'], $journal['amount'] ?? '0');
$return[$currencyId]['count']++;
if (null !== $foreignCurrencyId && null !== $journal['foreign_amount']) {
if (!array_key_exists($foreignCurrencyId, $return)) {
$return[$foreignCurrencyId] = [
'amount' => '0',
'count' => 0,
'currency_id' => (int)$foreignCurrencyId,
'currency_name' => $journal['foreign_currency_name'],
'currency_code' => $journal['foreign_currency_code'],
'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;
}
}

View File

@@ -48,7 +48,7 @@ trait RenderPartialViews
/**
* View for transactions in a budget for an account.
*
* @param array $attributes
* @param array $attributes
*
* @return string
* @throws FireflyException
@@ -104,7 +104,7 @@ trait RenderPartialViews
/**
* View for spent in a single budget.
*
* @param array $attributes
* @param array $attributes
*
* @return string
* @throws FireflyException
@@ -137,7 +137,7 @@ trait RenderPartialViews
/**
* View for transactions in a category.
*
* @param array $attributes
* @param array $attributes
*
* @return string
* @throws FireflyException
@@ -232,7 +232,7 @@ trait RenderPartialViews
/**
* Returns all the expenses that went to the given expense account.
*
* @param array $attributes
* @param array $attributes
*
* @return string
* @throws FireflyException
@@ -267,7 +267,7 @@ trait RenderPartialViews
/**
* Get current (from system) rule actions.
*
* @param Rule $rule
* @param Rule $rule
*
* @return array
* @throws FireflyException
@@ -306,7 +306,7 @@ trait RenderPartialViews
/**
* Get current (from DB) rule triggers.
*
* @param Rule $rule
* @param Rule $rule
*
* @return array
* @throws FireflyException
@@ -362,7 +362,7 @@ trait RenderPartialViews
/**
* Returns all the incomes that went to the given asset account.
*
* @param array $attributes
* @param array $attributes
*
* @return string
* @throws FireflyException

View File

@@ -59,28 +59,10 @@ trait RequestInformation
return $parts['host'];
}
/**
* @return string
*/
final protected function getPageName(): string // get request info
{
return str_replace('.', '_', RouteFacade::currentRouteName());
}
/**
* Get the specific name of a page for intro.
*
* @return string
*/
final protected function getSpecificPageName(): string // get request info
{
return null === RouteFacade::current()->parameter('objectType') ? '' : '_'.RouteFacade::current()->parameter('objectType');
}
/**
* Get a list of triggers.
*
* @param TestRuleFormRequest $request
* @param TestRuleFormRequest $request
*
* @return array
*/
@@ -133,10 +115,28 @@ trait RequestInformation
return $shownDemo;
}
/**
* @return string
*/
final protected function getPageName(): string // get request info
{
return str_replace('.', '_', RouteFacade::currentRouteName());
}
/**
* Get the specific name of a page for intro.
*
* @return string
*/
final protected function getSpecificPageName(): string // get request info
{
return null === RouteFacade::current()->parameter('objectType') ? '' : '_' . RouteFacade::current()->parameter('objectType');
}
/**
* Check if date is outside session range.
*
* @param Carbon $date
* @param Carbon $date
*
* @return bool
*
@@ -162,7 +162,7 @@ trait RequestInformation
/**
* Parses attributes from URL
*
* @param array $attributes
* @param array $attributes
*
* @return array
*/
@@ -192,9 +192,9 @@ trait RequestInformation
/**
* Validate users new password.
*
* @param User $user
* @param string $current
* @param string $new
* @param User $user
* @param string $current
* @param string $new
*
* @return bool
*
@@ -216,7 +216,7 @@ trait RequestInformation
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @param array $data
*
* @return ValidatorContract
*/

View File

@@ -37,7 +37,7 @@ use Throwable;
trait RuleManagement
{
/**
* @param Request $request
* @param Request $request
*
* @return array
* @throws FireflyException
@@ -72,7 +72,7 @@ trait RuleManagement
}
/**
* @param Request $request
* @param Request $request
*
* @return array
* @throws FireflyException
@@ -119,7 +119,7 @@ trait RuleManagement
}
/**
* @param array $submittedOperators
* @param array $submittedOperators
*
* @return array
* @throws FireflyException

View File

@@ -37,10 +37,10 @@ trait TransactionCalculation
/**
* Get all expenses for a set of accounts.
*
* @param Collection $accounts
* @param Collection $opposing
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $opposing
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
@@ -61,10 +61,10 @@ trait TransactionCalculation
/**
* Get all expenses by tags.
*
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
*
* @return array
*
@@ -83,10 +83,10 @@ trait TransactionCalculation
/**
* Helper function that collects expenses for the given budgets.
*
* @param Collection $accounts
* @param Collection $budgets
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $budgets
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
@@ -103,10 +103,10 @@ trait TransactionCalculation
/**
* Get all expenses in a period for categories.
*
* @param Collection $accounts
* @param Collection $categories
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $categories
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
@@ -127,10 +127,10 @@ trait TransactionCalculation
/**
* Get all income for a period and a bunch of categories.
*
* @param Collection $accounts
* @param Collection $categories
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $categories
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
@@ -147,10 +147,10 @@ trait TransactionCalculation
/**
* Get the income for a set of accounts.
*
* @param Collection $accounts
* @param Collection $opposing
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $opposing
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
@@ -167,10 +167,10 @@ trait TransactionCalculation
/**
* Get all income by tag.
*
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/

View File

@@ -42,11 +42,12 @@ trait UserNavigation
/**
* Functionality:.
*
* - If the $identifier contains the word "delete" then a remembered url with the text "/show/" in it will not be returned but instead the index (/)
* will be returned.
* - If the remembered url contains "jscript/" the remembered url will not be returned but instead the index (/) will be returned.
* - If the $identifier contains the word "delete" then a remembered url with the text "/show/" in it will not be
* returned but instead the index (/) will be returned.
* - If the remembered url contains "jscript/" the remembered url will not be returned but instead the index (/)
* will be returned.
*
* @param string $identifier
* @param string $identifier
*
* @return string
*/
@@ -62,7 +63,7 @@ trait UserNavigation
/**
* Will return false if you cant edit this account type.
*
* @param Account $account
* @param Account $account
*
* @return bool
*/
@@ -75,7 +76,7 @@ trait UserNavigation
}
/**
* @param TransactionGroup $group
* @param TransactionGroup $group
*
* @return bool
*/
@@ -93,7 +94,7 @@ trait UserNavigation
}
/**
* @param Account $account
* @param Account $account
*
* @return RedirectResponse|Redirector
*/
@@ -128,7 +129,7 @@ trait UserNavigation
}
/**
* @param TransactionGroup $group
* @param TransactionGroup $group
*
* @return RedirectResponse|Redirector
*/
@@ -156,7 +157,7 @@ trait UserNavigation
}
/**
* @param string $identifier
* @param string $identifier
*
* @return string|null
*/