diff --git a/.ci/php-cs-fixer/.php-cs-fixer.php b/.ci/php-cs-fixer/.php-cs-fixer.php index 56f3c0a050..b20dd1d8d0 100644 --- a/.ci/php-cs-fixer/.php-cs-fixer.php +++ b/.ci/php-cs-fixer/.php-cs-fixer.php @@ -19,7 +19,20 @@ * along with this program. If not, see . */ -$finder = PhpCsFixer\Finder::create(); +$current = __DIR__; + +$paths = [ + $current . '/../../app', + $current . '/../../config', + $current . '/../../database', + $current . '/../../routes', + $current . '/../../tests', + $current . '/../../resources/lang', +]; + +$finder = PhpCsFixer\Finder::create() + ->in($paths); + $config = new PhpCsFixer\Config(); return $config->setRules([ diff --git a/.ci/phpcs.sh b/.ci/phpcs.sh index 8479e000c8..fd0877199f 100755 --- a/.ci/phpcs.sh +++ b/.ci/phpcs.sh @@ -31,7 +31,7 @@ SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) # clean up php code cd $SCRIPT_DIR/php-cs-fixer composer update -./vendor/bin/php-cs-fixer fix $SCRIPT_DIR/../app --config $SCRIPT_DIR/php-cs-fixer/.php-cs-fixer.php --allow-risky=yes +./vendor/bin/php-cs-fixer fix --config $SCRIPT_DIR/php-cs-fixer/.php-cs-fixer.php --allow-risky=yes cd $SCRIPT_DIR/.. exit 0 diff --git a/app/Api/V1/Controllers/Autocomplete/AccountController.php b/app/Api/V1/Controllers/Autocomplete/AccountController.php index 999a6a39f3..1bb4f62100 100644 --- a/app/Api/V1/Controllers/Autocomplete/AccountController.php +++ b/app/Api/V1/Controllers/Autocomplete/AccountController.php @@ -67,7 +67,7 @@ class AccountController extends Controller * Documentation for this endpoint: * https://api-docs.firefly-iii.org/#/autocomplete/getAccountsAC * - * @param AutocompleteRequest $request + * @param AutocompleteRequest $request * * @return JsonResponse * @throws JsonException @@ -82,7 +82,7 @@ class AccountController extends Controller $date = $data['date'] ?? today(config('app.timezone')); $return = []; - $result = $this->repository->searchAccount((string) $query, $types, $data['limit']); + $result = $this->repository->searchAccount((string)$query, $types, $data['limit']); $defaultCurrency = app('amount')->getDefaultCurrency(); /** @var Account $account */ @@ -96,7 +96,7 @@ class AccountController extends Controller } $return[] = [ - 'id' => (string) $account->id, + 'id' => (string)$account->id, 'name' => $account->name, 'name_with_balance' => $nameWithBalance, 'type' => $account->accountType->type, diff --git a/app/Api/V1/Controllers/Autocomplete/BillController.php b/app/Api/V1/Controllers/Autocomplete/BillController.php index d8c4b706a9..7fe006aa67 100644 --- a/app/Api/V1/Controllers/Autocomplete/BillController.php +++ b/app/Api/V1/Controllers/Autocomplete/BillController.php @@ -59,7 +59,7 @@ class BillController extends Controller * Documentation for this endpoint is at: * https://api-docs.firefly-iii.org/#/autocomplete/getBillsAC * - * @param AutocompleteRequest $request + * @param AutocompleteRequest $request * * @return JsonResponse */ @@ -70,7 +70,7 @@ class BillController extends Controller $filtered = $result->map( static function (Bill $item) { return [ - 'id' => (string) $item->id, + 'id' => (string)$item->id, 'name' => $item->name, ]; } diff --git a/app/Api/V1/Controllers/Autocomplete/BudgetController.php b/app/Api/V1/Controllers/Autocomplete/BudgetController.php index 60d56f7fb0..48f6b69f2a 100644 --- a/app/Api/V1/Controllers/Autocomplete/BudgetController.php +++ b/app/Api/V1/Controllers/Autocomplete/BudgetController.php @@ -59,7 +59,7 @@ class BudgetController extends Controller * Documentation for this endpoint is at: * https://api-docs.firefly-iii.org/#/autocomplete/getBudgetsAC * - * @param AutocompleteRequest $request + * @param AutocompleteRequest $request * * @return JsonResponse */ @@ -70,7 +70,7 @@ class BudgetController extends Controller $filtered = $result->map( static function (Budget $item) { return [ - 'id' => (string) $item->id, + 'id' => (string)$item->id, 'name' => $item->name, ]; } diff --git a/app/Api/V1/Controllers/Autocomplete/CategoryController.php b/app/Api/V1/Controllers/Autocomplete/CategoryController.php index 3e29a7aa33..e98a20e4e1 100644 --- a/app/Api/V1/Controllers/Autocomplete/CategoryController.php +++ b/app/Api/V1/Controllers/Autocomplete/CategoryController.php @@ -59,7 +59,7 @@ class CategoryController extends Controller * Documentation for this endpoint is at: * https://api-docs.firefly-iii.org/#/autocomplete/getCategoriesAC * - * @param AutocompleteRequest $request + * @param AutocompleteRequest $request * * @return JsonResponse */ @@ -70,7 +70,7 @@ class CategoryController extends Controller $filtered = $result->map( static function (Category $item) { return [ - 'id' => (string) $item->id, + 'id' => (string)$item->id, 'name' => $item->name, ]; } diff --git a/app/Api/V1/Controllers/Autocomplete/CurrencyController.php b/app/Api/V1/Controllers/Autocomplete/CurrencyController.php index e0eef2e62a..50fd139f90 100644 --- a/app/Api/V1/Controllers/Autocomplete/CurrencyController.php +++ b/app/Api/V1/Controllers/Autocomplete/CurrencyController.php @@ -59,7 +59,7 @@ class CurrencyController extends Controller * Documentation for this endpoint is at: * https://api-docs.firefly-iii.org/#/autocomplete/getCurrenciesAC * - * @param AutocompleteRequest $request + * @param AutocompleteRequest $request * * @return JsonResponse */ @@ -72,7 +72,7 @@ class CurrencyController extends Controller /** @var TransactionCurrency $currency */ foreach ($collection as $currency) { $result[] = [ - 'id' => (string) $currency->id, + 'id' => (string)$currency->id, 'name' => $currency->name, 'code' => $currency->code, 'symbol' => $currency->symbol, @@ -87,7 +87,7 @@ class CurrencyController extends Controller * Documentation for this endpoint is at: * https://api-docs.firefly-iii.org/#/autocomplete/getCurrenciesCodeAC * - * @param AutocompleteRequest $request + * @param AutocompleteRequest $request * * @return JsonResponse * @deprecated @@ -101,7 +101,7 @@ class CurrencyController extends Controller /** @var TransactionCurrency $currency */ foreach ($collection as $currency) { $result[] = [ - 'id' => (string) $currency->id, + 'id' => (string)$currency->id, 'name' => sprintf('%s (%s)', $currency->name, $currency->code), 'code' => $currency->code, 'symbol' => $currency->symbol, diff --git a/app/Api/V1/Controllers/Autocomplete/ObjectGroupController.php b/app/Api/V1/Controllers/Autocomplete/ObjectGroupController.php index 80706c9369..10b119dd71 100644 --- a/app/Api/V1/Controllers/Autocomplete/ObjectGroupController.php +++ b/app/Api/V1/Controllers/Autocomplete/ObjectGroupController.php @@ -59,7 +59,7 @@ class ObjectGroupController extends Controller * Documentation for this endpoint is at: * https://api-docs.firefly-iii.org/#/autocomplete/getObjectGroupsAC * - * @param AutocompleteRequest $request + * @param AutocompleteRequest $request * * @return JsonResponse */ @@ -72,7 +72,7 @@ class ObjectGroupController extends Controller /** @var ObjectGroup $objectGroup */ foreach ($result as $objectGroup) { $return[] = [ - 'id' => (string) $objectGroup->id, + 'id' => (string)$objectGroup->id, 'name' => $objectGroup->title, 'title' => $objectGroup->title, ]; diff --git a/app/Api/V1/Controllers/Autocomplete/PiggyBankController.php b/app/Api/V1/Controllers/Autocomplete/PiggyBankController.php index 862f9c6cb0..65d784f501 100644 --- a/app/Api/V1/Controllers/Autocomplete/PiggyBankController.php +++ b/app/Api/V1/Controllers/Autocomplete/PiggyBankController.php @@ -63,7 +63,7 @@ class PiggyBankController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/autocomplete/getPiggiesAC * - * @param AutocompleteRequest $request + * @param AutocompleteRequest $request * * @return JsonResponse */ @@ -78,7 +78,7 @@ class PiggyBankController extends Controller foreach ($piggies as $piggy) { $currency = $this->accountRepository->getAccountCurrency($piggy->account) ?? $defaultCurrency; $response[] = [ - 'id' => (string) $piggy->id, + 'id' => (string)$piggy->id, 'name' => $piggy->name, 'currency_id' => $currency->id, 'currency_name' => $currency->name, @@ -95,7 +95,7 @@ class PiggyBankController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/autocomplete/getPiggiesBalanceAC * - * @param AutocompleteRequest $request + * @param AutocompleteRequest $request * * @return JsonResponse */ @@ -110,7 +110,7 @@ class PiggyBankController extends Controller $currency = $this->accountRepository->getAccountCurrency($piggy->account) ?? $defaultCurrency; $currentAmount = $this->piggyRepository->getRepetition($piggy)->currentamount ?? '0'; $response[] = [ - 'id' => (string) $piggy->id, + 'id' => (string)$piggy->id, 'name' => $piggy->name, 'name_with_balance' => sprintf( '%s (%s / %s)', diff --git a/app/Api/V1/Controllers/Autocomplete/RecurrenceController.php b/app/Api/V1/Controllers/Autocomplete/RecurrenceController.php index f5a45b00be..79a104ac91 100644 --- a/app/Api/V1/Controllers/Autocomplete/RecurrenceController.php +++ b/app/Api/V1/Controllers/Autocomplete/RecurrenceController.php @@ -56,7 +56,7 @@ class RecurrenceController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/autocomplete/getRecurringAC * - * @param AutocompleteRequest $request + * @param AutocompleteRequest $request * * @return JsonResponse */ @@ -69,7 +69,7 @@ class RecurrenceController extends Controller /** @var Recurrence $recurrence */ foreach ($recurrences as $recurrence) { $response[] = [ - 'id' => (string) $recurrence->id, + 'id' => (string)$recurrence->id, 'name' => $recurrence->title, 'description' => $recurrence->description, ]; diff --git a/app/Api/V1/Controllers/Autocomplete/RuleController.php b/app/Api/V1/Controllers/Autocomplete/RuleController.php index 9123b8f78c..1ab2cd1399 100644 --- a/app/Api/V1/Controllers/Autocomplete/RuleController.php +++ b/app/Api/V1/Controllers/Autocomplete/RuleController.php @@ -56,7 +56,7 @@ class RuleController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/autocomplete/getRulesAC * - * @param AutocompleteRequest $request + * @param AutocompleteRequest $request * * @return JsonResponse */ @@ -69,7 +69,7 @@ class RuleController extends Controller /** @var Rule $rule */ foreach ($rules as $rule) { $response[] = [ - 'id' => (string) $rule->id, + 'id' => (string)$rule->id, 'name' => $rule->title, 'description' => $rule->description, ]; diff --git a/app/Api/V1/Controllers/Autocomplete/RuleGroupController.php b/app/Api/V1/Controllers/Autocomplete/RuleGroupController.php index d5f88aa3cf..10e6fd3697 100644 --- a/app/Api/V1/Controllers/Autocomplete/RuleGroupController.php +++ b/app/Api/V1/Controllers/Autocomplete/RuleGroupController.php @@ -56,7 +56,7 @@ class RuleGroupController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/autocomplete/getRuleGroupsAC * - * @param AutocompleteRequest $request + * @param AutocompleteRequest $request * * @return JsonResponse */ @@ -69,7 +69,7 @@ class RuleGroupController extends Controller /** @var RuleGroup $group */ foreach ($groups as $group) { $response[] = [ - 'id' => (string) $group->id, + 'id' => (string)$group->id, 'name' => $group->title, 'description' => $group->description, ]; diff --git a/app/Api/V1/Controllers/Autocomplete/TagController.php b/app/Api/V1/Controllers/Autocomplete/TagController.php index 95e031ebf7..0175aa138c 100644 --- a/app/Api/V1/Controllers/Autocomplete/TagController.php +++ b/app/Api/V1/Controllers/Autocomplete/TagController.php @@ -59,7 +59,7 @@ class TagController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/autocomplete/getTagAC * - * @param AutocompleteRequest $request + * @param AutocompleteRequest $request * * @return JsonResponse */ @@ -72,7 +72,7 @@ class TagController extends Controller /** @var Tag $tag */ foreach ($result as $tag) { $array[] = [ - 'id' => (string) $tag->id, + 'id' => (string)$tag->id, 'name' => $tag->tag, 'tag' => $tag->tag, ]; diff --git a/app/Api/V1/Controllers/Autocomplete/TransactionController.php b/app/Api/V1/Controllers/Autocomplete/TransactionController.php index 89dbe0494b..dfb9f00f22 100644 --- a/app/Api/V1/Controllers/Autocomplete/TransactionController.php +++ b/app/Api/V1/Controllers/Autocomplete/TransactionController.php @@ -64,7 +64,7 @@ class TransactionController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/autocomplete/getTransactionsAC * - * @param AutocompleteRequest $request + * @param AutocompleteRequest $request * * @return JsonResponse */ @@ -80,8 +80,8 @@ class TransactionController extends Controller /** @var TransactionJournal $journal */ foreach ($filtered as $journal) { $array[] = [ - 'id' => (string) $journal->id, - 'transaction_group_id' => (string) $journal->transaction_group_id, + 'id' => (string)$journal->id, + 'transaction_group_id' => (string)$journal->transaction_group_id, 'name' => $journal->description, 'description' => $journal->description, ]; @@ -94,7 +94,7 @@ class TransactionController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/autocomplete/getTransactionsIDAC * - * @param AutocompleteRequest $request + * @param AutocompleteRequest $request * * @return JsonResponse */ @@ -104,7 +104,7 @@ class TransactionController extends Controller $result = new Collection(); if (is_numeric($data['query'])) { // search for group, not journal. - $firstResult = $this->groupRepository->find((int) $data['query']); + $firstResult = $this->groupRepository->find((int)$data['query']); if (null !== $firstResult) { // group may contain multiple journals, each a result: foreach ($firstResult->transactionJournals as $journal) { @@ -122,8 +122,8 @@ class TransactionController extends Controller /** @var TransactionJournal $journal */ foreach ($result as $journal) { $array[] = [ - 'id' => (string) $journal->id, - 'transaction_group_id' => (string) $journal->transaction_group_id, + 'id' => (string)$journal->id, + 'transaction_group_id' => (string)$journal->transaction_group_id, 'name' => sprintf('#%d: %s', $journal->transaction_group_id, $journal->description), 'description' => sprintf('#%d: %s', $journal->transaction_group_id, $journal->description), ]; diff --git a/app/Api/V1/Controllers/Autocomplete/TransactionTypeController.php b/app/Api/V1/Controllers/Autocomplete/TransactionTypeController.php index 24d09276f8..036b614cad 100644 --- a/app/Api/V1/Controllers/Autocomplete/TransactionTypeController.php +++ b/app/Api/V1/Controllers/Autocomplete/TransactionTypeController.php @@ -55,7 +55,7 @@ class TransactionTypeController extends Controller * This endpoint is documented at * https://api-docs.firefly-iii.org/#/autocomplete/getTransactionTypesAC * - * @param AutocompleteRequest $request + * @param AutocompleteRequest $request * * @return JsonResponse * @codeCoverageIgnore @@ -70,7 +70,7 @@ class TransactionTypeController extends Controller foreach ($types as $type) { // different key for consistency. $array[] = [ - 'id' => (string) $type->id, + 'id' => (string)$type->id, 'name' => $type->type, 'type' => $type->type, ]; diff --git a/app/Api/V1/Controllers/Chart/AccountController.php b/app/Api/V1/Controllers/Chart/AccountController.php index 32f55aacce..abbc314245 100644 --- a/app/Api/V1/Controllers/Chart/AccountController.php +++ b/app/Api/V1/Controllers/Chart/AccountController.php @@ -76,7 +76,7 @@ class AccountController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/charts/getChartAccountOverview * - * @param DateRequest $request + * @param DateRequest $request * * @return JsonResponse * @throws FireflyException @@ -115,7 +115,7 @@ class AccountController extends Controller } $currentSet = [ 'label' => $account->name, - 'currency_id' => (string) $currency->id, + 'currency_id' => (string)$currency->id, 'currency_code' => $currency->code, 'currency_symbol' => $currency->symbol, 'currency_decimal_places' => $currency->decimal_places, @@ -128,7 +128,7 @@ class AccountController extends Controller $currentStart = clone $start; $range = app('steam')->balanceInRange($account, $start, clone $end); // 2022-10-11 this method no longer converts to float. - $previous = array_values($range)[0]; + $previous = array_values($range)[0]; while ($currentStart <= $end) { $format = $currentStart->format('Y-m-d'); $label = $currentStart->toAtomString(); diff --git a/app/Api/V1/Controllers/Controller.php b/app/Api/V1/Controllers/Controller.php index 842d13ecc5..75a5f01407 100644 --- a/app/Api/V1/Controllers/Controller.php +++ b/app/Api/V1/Controllers/Controller.php @@ -33,7 +33,6 @@ use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Routing\Controller as BaseController; use League\Fractal\Manager; use League\Fractal\Serializer\JsonApiSerializer; -use Log; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; use Symfony\Component\HttpFoundation\ParameterBag; @@ -88,8 +87,8 @@ abstract class Controller extends BaseController if ($page < 1) { $page = 1; } - if ($page > (2^16)) { - $page = (2^16); + if ($page > (2 ^ 16)) { + $page = (2 ^ 16); } $bag->set('page', $page); @@ -101,7 +100,7 @@ abstract class Controller extends BaseController if (null !== $date) { try { $obj = Carbon::parse($date); - } catch (InvalidDateException | InvalidFormatException $e) { + } catch (InvalidDateException|InvalidFormatException $e) { // don't care app('log')->warning(sprintf('Ignored invalid date "%s" in API controller parameter check: %s', $date, $e->getMessage())); } @@ -123,7 +122,7 @@ abstract class Controller extends BaseController } /** - * @param ParameterBag $bag + * @param ParameterBag $bag * * @return ParameterBag */ @@ -172,7 +171,7 @@ abstract class Controller extends BaseController $params[$key] = $value; } - return $return . http_build_query($params); + return $return.http_build_query($params); } /** @@ -182,7 +181,7 @@ abstract class Controller extends BaseController { // create some objects: $manager = new Manager(); - $baseUrl = request()->getSchemeAndHttpHost() . '/api/v1'; + $baseUrl = request()->getSchemeAndHttpHost().'/api/v1'; $manager->setSerializer(new JsonApiSerializer($baseUrl)); return $manager; diff --git a/app/Api/V1/Controllers/Data/Bulk/AccountController.php b/app/Api/V1/Controllers/Data/Bulk/AccountController.php index caa9d2a4d5..defb3596c5 100644 --- a/app/Api/V1/Controllers/Data/Bulk/AccountController.php +++ b/app/Api/V1/Controllers/Data/Bulk/AccountController.php @@ -58,7 +58,7 @@ class AccountController extends Controller /** * This endpoint is deprecated and not documented. * - * @param MoveTransactionsRequest $request + * @param MoveTransactionsRequest $request * * @return JsonResponse * @deprecated diff --git a/app/Api/V1/Controllers/Data/Bulk/TransactionController.php b/app/Api/V1/Controllers/Data/Bulk/TransactionController.php index d36516f309..77e898306c 100644 --- a/app/Api/V1/Controllers/Data/Bulk/TransactionController.php +++ b/app/Api/V1/Controllers/Data/Bulk/TransactionController.php @@ -63,7 +63,7 @@ class TransactionController extends Controller /** * This endpoint is documented at: * - * @param TransactionRequest $request + * @param TransactionRequest $request * * @return JsonResponse */ @@ -76,8 +76,8 @@ class TransactionController extends Controller // to respond to what is in the $query. // this is OK because only one thing can be in the query at the moment. if ($this->updatesTransactionAccount($params)) { - $original = $this->repository->find((int) $params['where']['account_id']); - $destination = $this->repository->find((int) $params['update']['account_id']); + $original = $this->repository->find((int)$params['where']['account_id']); + $destination = $this->repository->find((int)$params['update']['account_id']); /** @var AccountDestroyService $service */ $service = app(AccountDestroyService::class); @@ -88,7 +88,7 @@ class TransactionController extends Controller } /** - * @param array $params + * @param array $params * * @return bool */ diff --git a/app/Api/V1/Controllers/Data/DestroyController.php b/app/Api/V1/Controllers/Data/DestroyController.php index f2e7004e8e..8154301663 100644 --- a/app/Api/V1/Controllers/Data/DestroyController.php +++ b/app/Api/V1/Controllers/Data/DestroyController.php @@ -58,7 +58,7 @@ class DestroyController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/data/destroyData * - * @param DestroyRequest $request + * @param DestroyRequest $request * * @return JsonResponse * @throws FireflyException @@ -97,24 +97,32 @@ class DestroyController extends Controller case 'accounts': $this->destroyAccounts( [ - AccountType::ASSET, AccountType::DEFAULT, - AccountType::BENEFICIARY, AccountType::EXPENSE, - AccountType::REVENUE, AccountType::INITIAL_BALANCE, - AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD, + AccountType::ASSET, + AccountType::DEFAULT, + AccountType::BENEFICIARY, + AccountType::EXPENSE, + AccountType::REVENUE, + AccountType::INITIAL_BALANCE, + AccountType::DEBT, + AccountType::LOAN, + AccountType::MORTGAGE, + AccountType::CREDITCARD, ] ); break; case 'asset_accounts': $this->destroyAccounts( [ - AccountType::ASSET, AccountType::DEFAULT, + AccountType::ASSET, + AccountType::DEFAULT, ] ); break; case 'expense_accounts': $this->destroyAccounts( [ - AccountType::BENEFICIARY, AccountType::EXPENSE, + AccountType::BENEFICIARY, + AccountType::EXPENSE, ] ); break; @@ -128,7 +136,10 @@ class DestroyController extends Controller case 'liabilities': $this->destroyAccounts( [ - AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD, + AccountType::DEBT, + AccountType::LOAN, + AccountType::MORTGAGE, + AccountType::CREDITCARD, ] ); break; @@ -256,7 +267,7 @@ class DestroyController extends Controller } /** - * @param array $types + * @param array $types */ private function destroyAccounts(array $types): void { @@ -281,7 +292,7 @@ class DestroyController extends Controller } /** - * @param array $types + * @param array $types */ private function destroyTransactions(array $types): void { diff --git a/app/Api/V1/Controllers/Data/Export/ExportController.php b/app/Api/V1/Controllers/Data/Export/ExportController.php index 38c97f9121..187ef28c4d 100644 --- a/app/Api/V1/Controllers/Data/Export/ExportController.php +++ b/app/Api/V1/Controllers/Data/Export/ExportController.php @@ -57,7 +57,7 @@ class ExportController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/data/exportAccounts * - * @param ExportRequest $request + * @param ExportRequest $request * * @return LaravelResponse * @throws FireflyException @@ -70,7 +70,7 @@ class ExportController extends Controller } /** - * @param string $key + * @param string $key * * @return LaravelResponse * @throws FireflyException @@ -86,13 +86,13 @@ class ExportController extends Controller $response ->header('Content-Description', 'File Transfer') ->header('Content-Type', 'application/octet-stream') - ->header('Content-Disposition', 'attachment; filename=' . $fileName) + ->header('Content-Disposition', 'attachment; filename='.$fileName) ->header('Content-Transfer-Encoding', 'binary') ->header('Connection', 'Keep-Alive') ->header('Expires', '0') ->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') ->header('Pragma', 'public') - ->header('Content-Length', (string) strlen($data[$key])); + ->header('Content-Length', (string)strlen($data[$key])); return $response; } @@ -101,7 +101,7 @@ class ExportController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/data/exportBills * - * @param ExportRequest $request + * @param ExportRequest $request * * @return LaravelResponse * @throws FireflyException @@ -117,7 +117,7 @@ class ExportController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/data/exportBudgets * - * @param ExportRequest $request + * @param ExportRequest $request * * @return LaravelResponse * @throws FireflyException @@ -133,7 +133,7 @@ class ExportController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/data/exportCategories * - * @param ExportRequest $request + * @param ExportRequest $request * * @return LaravelResponse * @throws FireflyException @@ -149,7 +149,7 @@ class ExportController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/data/exportPiggies * - * @param ExportRequest $request + * @param ExportRequest $request * * @return LaravelResponse * @throws FireflyException @@ -165,7 +165,7 @@ class ExportController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/data/exportRecurring * - * @param ExportRequest $request + * @param ExportRequest $request * * @return LaravelResponse * @throws FireflyException @@ -181,7 +181,7 @@ class ExportController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/data/exportRules * - * @param ExportRequest $request + * @param ExportRequest $request * * @return LaravelResponse * @throws FireflyException @@ -197,7 +197,7 @@ class ExportController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/data/exportTags * - * @param ExportRequest $request + * @param ExportRequest $request * * @return LaravelResponse * @throws FireflyException @@ -213,7 +213,7 @@ class ExportController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/data/exportTransactions * - * @param ExportRequest $request + * @param ExportRequest $request * * @return LaravelResponse * @throws FireflyException diff --git a/app/Api/V1/Controllers/Data/PurgeController.php b/app/Api/V1/Controllers/Data/PurgeController.php index c9d0fb37b1..b8db2215b6 100644 --- a/app/Api/V1/Controllers/Data/PurgeController.php +++ b/app/Api/V1/Controllers/Data/PurgeController.php @@ -28,7 +28,6 @@ use FireflyIII\Models\Account; use FireflyIII\Models\Bill; use FireflyIII\Models\Budget; use FireflyIII\Models\Category; -use FireflyIII\Models\ObjectGroup; use FireflyIII\Models\PiggyBank; use FireflyIII\Models\Recurrence; use FireflyIII\Models\Rule; @@ -58,7 +57,7 @@ class PurgeController extends Controller // piggies $set = PiggyBank::leftJoin('accounts', 'accounts.id', 'piggy_banks.account_id') - ->where('accounts.user_id', $user->id)->onlyTrashed()->get(['piggy_banks.*']); + ->where('accounts.user_id', $user->id)->onlyTrashed()->get(['piggy_banks.*']); /** @var PiggyBank $piggy */ foreach ($set as $piggy) { $piggy->forceDelete(); diff --git a/app/Api/V1/Controllers/Insight/Expense/AccountController.php b/app/Api/V1/Controllers/Insight/Expense/AccountController.php index a652b2eafb..1f9510e262 100644 --- a/app/Api/V1/Controllers/Insight/Expense/AccountController.php +++ b/app/Api/V1/Controllers/Insight/Expense/AccountController.php @@ -76,7 +76,7 @@ class AccountController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/insight/insightExpenseAsset * - * @param GenericRequest $request + * @param GenericRequest $request * * @return JsonResponse */ @@ -91,11 +91,11 @@ class AccountController extends Controller /** @var array $expense */ foreach ($expenses as $expense) { $result[] = [ - 'id' => (string) $expense['id'], + 'id' => (string)$expense['id'], 'name' => $expense['name'], 'difference' => $expense['sum'], - 'difference_float' => (float) $expense['sum'], // intentional float - 'currency_id' => (string) $expense['currency_id'], + 'difference_float' => (float)$expense['sum'], // intentional float + 'currency_id' => (string)$expense['currency_id'], 'currency_code' => $expense['currency_code'], ]; } @@ -107,7 +107,7 @@ class AccountController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/insight/insightExpenseExpense * - * @param GenericRequest $request + * @param GenericRequest $request * * @return JsonResponse */ @@ -123,11 +123,11 @@ class AccountController extends Controller /** @var array $expense */ foreach ($expenses as $expense) { $result[] = [ - 'id' => (string) $expense['id'], + 'id' => (string)$expense['id'], 'name' => $expense['name'], 'difference' => $expense['sum'], - 'difference_float' => (float) $expense['sum'], // intentional float - 'currency_id' => (string) $expense['currency_id'], + 'difference_float' => (float)$expense['sum'], // intentional float + 'currency_id' => (string)$expense['currency_id'], 'currency_code' => $expense['currency_code'], ]; } diff --git a/app/Api/V1/Controllers/Insight/Expense/BillController.php b/app/Api/V1/Controllers/Insight/Expense/BillController.php index 4d37805d34..84b40d3ba2 100644 --- a/app/Api/V1/Controllers/Insight/Expense/BillController.php +++ b/app/Api/V1/Controllers/Insight/Expense/BillController.php @@ -61,7 +61,7 @@ class BillController extends Controller * * Expenses per bill, possibly filtered by bill and account. * - * @param GenericRequest $request + * @param GenericRequest $request * * @return JsonResponse */ @@ -85,33 +85,33 @@ class BillController extends Controller $genericSet = $collector->getExtractedJournals(); foreach ($genericSet as $journal) { - $billId = (int) $journal['bill_id']; - $currencyId = (int) $journal['currency_id']; - $foreignCurrencyId = (int) $journal['foreign_currency_id']; + $billId = (int)$journal['bill_id']; + $currencyId = (int)$journal['currency_id']; + $foreignCurrencyId = (int)$journal['foreign_currency_id']; $key = sprintf('%d-%d', $billId, $currencyId); $foreignKey = sprintf('%d-%d', $billId, $foreignCurrencyId); if (0 !== $currencyId) { $response[$key] = $response[$key] ?? [ - 'id' => (string) $billId, - 'name' => $journal['bill_name'], - 'difference' => '0', - 'difference_float' => 0, - 'currency_id' => (string) $currencyId, - 'currency_code' => $journal['currency_code'], - ]; + 'id' => (string)$billId, + 'name' => $journal['bill_name'], + 'difference' => '0', + 'difference_float' => 0, + 'currency_id' => (string)$currencyId, + 'currency_code' => $journal['currency_code'], + ]; $response[$key]['difference'] = bcadd($response[$key]['difference'], $journal['amount']); - $response[$key]['difference_float'] = (float) $response[$key]['difference']; // intentional float + $response[$key]['difference_float'] = (float)$response[$key]['difference']; // intentional float } if (0 !== $foreignCurrencyId) { $response[$foreignKey] = $response[$foreignKey] ?? [ - 'difference' => '0', - 'difference_float' => 0, - 'currency_id' => (string) $foreignCurrencyId, - 'currency_code' => $journal['foreign_currency_code'], - ]; + 'difference' => '0', + 'difference_float' => 0, + 'currency_id' => (string)$foreignCurrencyId, + 'currency_code' => $journal['foreign_currency_code'], + ]; $response[$foreignKey]['difference'] = bcadd($response[$foreignKey]['difference'], $journal['foreign_amount']); - $response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference']; // intentional float + $response[$foreignKey]['difference_float'] = (float)$response[$foreignKey]['difference']; // intentional float } } @@ -124,7 +124,7 @@ class BillController extends Controller * * Expenses for no bill filtered by account. * - * @param GenericRequest $request + * @param GenericRequest $request * * @return JsonResponse */ @@ -143,28 +143,28 @@ class BillController extends Controller $genericSet = $collector->getExtractedJournals(); foreach ($genericSet as $journal) { - $currencyId = (int) $journal['currency_id']; - $foreignCurrencyId = (int) $journal['foreign_currency_id']; + $currencyId = (int)$journal['currency_id']; + $foreignCurrencyId = (int)$journal['foreign_currency_id']; if (0 !== $currencyId) { $response[$currencyId] = $response[$currencyId] ?? [ - 'difference' => '0', - 'difference_float' => 0, - 'currency_id' => (string) $currencyId, - 'currency_code' => $journal['currency_code'], - ]; + 'difference' => '0', + 'difference_float' => 0, + 'currency_id' => (string)$currencyId, + 'currency_code' => $journal['currency_code'], + ]; $response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $journal['amount']); - $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // intentional float + $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // intentional float } if (0 !== $foreignCurrencyId) { $response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [ - 'difference' => '0', - 'difference_float' => 0, - 'currency_id' => (string) $foreignCurrencyId, - 'currency_code' => $journal['foreign_currency_code'], - ]; + 'difference' => '0', + 'difference_float' => 0, + 'currency_id' => (string)$foreignCurrencyId, + 'currency_code' => $journal['foreign_currency_code'], + ]; $response[$foreignCurrencyId]['difference'] = bcadd($response[$foreignCurrencyId]['difference'], $journal['foreign_amount']); - $response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference']; // intentional float + $response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference']; // intentional float } } diff --git a/app/Api/V1/Controllers/Insight/Expense/BudgetController.php b/app/Api/V1/Controllers/Insight/Expense/BudgetController.php index 4947427c78..fc0578a002 100644 --- a/app/Api/V1/Controllers/Insight/Expense/BudgetController.php +++ b/app/Api/V1/Controllers/Insight/Expense/BudgetController.php @@ -68,7 +68,7 @@ class BudgetController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/insight/insightExpenseBudget * - * @param GenericRequest $request + * @param GenericRequest $request * * @return JsonResponse */ @@ -88,11 +88,11 @@ class BudgetController extends Controller /** @var array $expense */ foreach ($expenses as $expense) { $result[] = [ - 'id' => (string) $budget->id, + 'id' => (string)$budget->id, 'name' => $budget->name, 'difference' => $expense['sum'], - 'difference_float' => (float) $expense['sum'], // intentional float - 'currency_id' => (string) $expense['currency_id'], + 'difference_float' => (float)$expense['sum'], // intentional float + 'currency_id' => (string)$expense['currency_id'], 'currency_code' => $expense['currency_code'], ]; } @@ -105,7 +105,7 @@ class BudgetController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/insight/insightExpenseNoBudget * - * @param GenericRequest $request + * @param GenericRequest $request * * @return JsonResponse */ @@ -120,8 +120,8 @@ class BudgetController extends Controller foreach ($expenses as $expense) { $result[] = [ 'difference' => $expense['sum'], - 'difference_float' => (float) $expense['sum'], // intentional float - 'currency_id' => (string) $expense['currency_id'], + 'difference_float' => (float)$expense['sum'], // intentional float + 'currency_id' => (string)$expense['currency_id'], 'currency_code' => $expense['currency_code'], ]; } diff --git a/app/Api/V1/Controllers/Insight/Expense/CategoryController.php b/app/Api/V1/Controllers/Insight/Expense/CategoryController.php index 1923bdfdc8..32a60c321f 100644 --- a/app/Api/V1/Controllers/Insight/Expense/CategoryController.php +++ b/app/Api/V1/Controllers/Insight/Expense/CategoryController.php @@ -69,7 +69,7 @@ class CategoryController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/insight/insightTransferCategory * - * @param GenericRequest $request + * @param GenericRequest $request * * @return JsonResponse */ @@ -89,11 +89,11 @@ class CategoryController extends Controller /** @var array $expense */ foreach ($expenses as $expense) { $result[] = [ - 'id' => (string) $category->id, + 'id' => (string)$category->id, 'name' => $category->name, 'difference' => $expense['sum'], - 'difference_float' => (float) $expense['sum'], // intentional float - 'currency_id' => (string) $expense['currency_id'], + 'difference_float' => (float)$expense['sum'], // intentional float + 'currency_id' => (string)$expense['currency_id'], 'currency_code' => $expense['currency_code'], ]; } @@ -106,7 +106,7 @@ class CategoryController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/insight/insightTransferNoCategory * - * @param GenericRequest $request + * @param GenericRequest $request * * @return JsonResponse */ @@ -121,8 +121,8 @@ class CategoryController extends Controller foreach ($expenses as $expense) { $result[] = [ 'difference' => $expense['sum'], - 'difference_float' => (float) $expense['sum'], // intentional float - 'currency_id' => (string) $expense['currency_id'], + 'difference_float' => (float)$expense['sum'], // intentional float + 'currency_id' => (string)$expense['currency_id'], 'currency_code' => $expense['currency_code'], ]; } diff --git a/app/Api/V1/Controllers/Insight/Expense/PeriodController.php b/app/Api/V1/Controllers/Insight/Expense/PeriodController.php index 9bdb2a8d83..4a97dea7bb 100644 --- a/app/Api/V1/Controllers/Insight/Expense/PeriodController.php +++ b/app/Api/V1/Controllers/Insight/Expense/PeriodController.php @@ -38,7 +38,7 @@ class PeriodController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/insight/insightExpenseTotal * - * @param GenericRequest $request + * @param GenericRequest $request * * @return JsonResponse */ @@ -54,28 +54,28 @@ class PeriodController extends Controller $collector->setTypes([TransactionType::WITHDRAWAL])->setRange($start, $end)->setSourceAccounts($accounts); $genericSet = $collector->getExtractedJournals(); foreach ($genericSet as $journal) { - $currencyId = (int) $journal['currency_id']; - $foreignCurrencyId = (int) $journal['foreign_currency_id']; + $currencyId = (int)$journal['currency_id']; + $foreignCurrencyId = (int)$journal['foreign_currency_id']; if (0 !== $currencyId) { $response[$currencyId] = $response[$currencyId] ?? [ - 'difference' => '0', - 'difference_float' => 0, - 'currency_id' => (string) $currencyId, - 'currency_code' => $journal['currency_code'], - ]; + 'difference' => '0', + 'difference_float' => 0, + 'currency_id' => (string)$currencyId, + 'currency_code' => $journal['currency_code'], + ]; $response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $journal['amount']); - $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // intentional float + $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // intentional float } if (0 !== $foreignCurrencyId) { $response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [ - 'difference' => '0', - 'difference_float' => 0, - 'currency_id' => (string) $foreignCurrencyId, - 'currency_code' => $journal['foreign_currency_code'], - ]; + 'difference' => '0', + 'difference_float' => 0, + 'currency_id' => (string)$foreignCurrencyId, + 'currency_code' => $journal['foreign_currency_code'], + ]; $response[$foreignCurrencyId]['difference'] = bcadd($response[$foreignCurrencyId]['difference'], $journal['foreign_amount']); - $response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference']; // intentional float + $response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference']; // intentional float } } diff --git a/app/Api/V1/Controllers/Insight/Expense/TagController.php b/app/Api/V1/Controllers/Insight/Expense/TagController.php index 4de86ec2c0..76aa7bd795 100644 --- a/app/Api/V1/Controllers/Insight/Expense/TagController.php +++ b/app/Api/V1/Controllers/Insight/Expense/TagController.php @@ -60,7 +60,7 @@ class TagController extends Controller * * Expenses for no tag filtered by account. * - * @param GenericRequest $request + * @param GenericRequest $request * * @return JsonResponse */ @@ -79,28 +79,28 @@ class TagController extends Controller $genericSet = $collector->getExtractedJournals(); foreach ($genericSet as $journal) { - $currencyId = (int) $journal['currency_id']; - $foreignCurrencyId = (int) $journal['foreign_currency_id']; + $currencyId = (int)$journal['currency_id']; + $foreignCurrencyId = (int)$journal['foreign_currency_id']; if (0 !== $currencyId) { $response[$currencyId] = $response[$currencyId] ?? [ - 'difference' => '0', - 'difference_float' => 0, - 'currency_id' => (string) $currencyId, - 'currency_code' => $journal['currency_code'], - ]; + 'difference' => '0', + 'difference_float' => 0, + 'currency_id' => (string)$currencyId, + 'currency_code' => $journal['currency_code'], + ]; $response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $journal['amount']); - $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // float but on purpose. + $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // float but on purpose. } if (0 !== $foreignCurrencyId) { $response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [ - 'difference' => '0', - 'difference_float' => 0, - 'currency_id' => (string) $foreignCurrencyId, - 'currency_code' => $journal['foreign_currency_code'], - ]; + 'difference' => '0', + 'difference_float' => 0, + 'currency_id' => (string)$foreignCurrencyId, + 'currency_code' => $journal['foreign_currency_code'], + ]; $response[$foreignCurrencyId]['difference'] = bcadd($response[$foreignCurrencyId]['difference'], $journal['foreign_amount']); - $response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference']; // float but on purpose. + $response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference']; // float but on purpose. } } @@ -113,7 +113,7 @@ class TagController extends Controller * * Expenses per tag, possibly filtered by tag and account. * - * @param GenericRequest $request + * @param GenericRequest $request * * @return JsonResponse */ @@ -137,8 +137,8 @@ class TagController extends Controller $genericSet = $collector->getExtractedJournals(); /** @var array $journal */ foreach ($genericSet as $journal) { - $currencyId = (int) $journal['currency_id']; - $foreignCurrencyId = (int) $journal['foreign_currency_id']; + $currencyId = (int)$journal['currency_id']; + $foreignCurrencyId = (int)$journal['foreign_currency_id']; /** @var array $tag */ foreach ($journal['tags'] as $tag) { @@ -149,27 +149,27 @@ class TagController extends Controller // on currency ID if (0 !== $currencyId) { $response[$key] = $response[$key] ?? [ - 'id' => (string) $tagId, - 'name' => $tag['name'], - 'difference' => '0', - 'difference_float' => 0, - 'currency_id' => (string) $currencyId, - 'currency_code' => $journal['currency_code'], - ]; + 'id' => (string)$tagId, + 'name' => $tag['name'], + 'difference' => '0', + 'difference_float' => 0, + 'currency_id' => (string)$currencyId, + 'currency_code' => $journal['currency_code'], + ]; $response[$key]['difference'] = bcadd($response[$key]['difference'], $journal['amount']); - $response[$key]['difference_float'] = (float) $response[$key]['difference']; // float but on purpose. + $response[$key]['difference_float'] = (float)$response[$key]['difference']; // float but on purpose. } // on foreign ID if (0 !== $foreignCurrencyId) { $response[$foreignKey] = $journal[$foreignKey] ?? [ - 'difference' => '0', - 'difference_float' => 0, - 'currency_id' => (string) $foreignCurrencyId, - 'currency_code' => $journal['foreign_currency_code'], - ]; + 'difference' => '0', + 'difference_float' => 0, + 'currency_id' => (string)$foreignCurrencyId, + 'currency_code' => $journal['foreign_currency_code'], + ]; $response[$foreignKey]['difference'] = bcadd($response[$foreignKey]['difference'], $journal['foreign_amount']); - $response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference']; // float but on purpose. + $response[$foreignKey]['difference_float'] = (float)$response[$foreignKey]['difference']; // float but on purpose. } } } diff --git a/app/Api/V1/Controllers/Insight/Income/AccountController.php b/app/Api/V1/Controllers/Insight/Income/AccountController.php index 12b72e002e..4ea6a591cc 100644 --- a/app/Api/V1/Controllers/Insight/Income/AccountController.php +++ b/app/Api/V1/Controllers/Insight/Income/AccountController.php @@ -76,7 +76,7 @@ class AccountController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/insight/insightIncomeAsset * - * @param GenericRequest $request + * @param GenericRequest $request * * @return JsonResponse */ @@ -90,11 +90,11 @@ class AccountController extends Controller /** @var array $entry */ foreach ($income as $entry) { $result[] = [ - 'id' => (string) $entry['id'], + 'id' => (string)$entry['id'], 'name' => $entry['name'], 'difference' => $entry['sum'], - 'difference_float' => (float) $entry['sum'], // float but on purpose. - 'currency_id' => (string) $entry['currency_id'], + 'difference_float' => (float)$entry['sum'], // float but on purpose. + 'currency_id' => (string)$entry['currency_id'], 'currency_code' => $entry['currency_code'], ]; } @@ -106,7 +106,7 @@ class AccountController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/insight/insightIncomeRevenue * - * @param GenericRequest $request + * @param GenericRequest $request * * @return JsonResponse */ @@ -122,11 +122,11 @@ class AccountController extends Controller /** @var array $entry */ foreach ($income as $entry) { $result[] = [ - 'id' => (string) $entry['id'], + 'id' => (string)$entry['id'], 'name' => $entry['name'], 'difference' => $entry['sum'], - 'difference_float' => (float) $entry['sum'], // float but on purpose. - 'currency_id' => (string) $entry['currency_id'], + 'difference_float' => (float)$entry['sum'], // float but on purpose. + 'currency_id' => (string)$entry['currency_id'], 'currency_code' => $entry['currency_code'], ]; } diff --git a/app/Api/V1/Controllers/Insight/Income/CategoryController.php b/app/Api/V1/Controllers/Insight/Income/CategoryController.php index fec4a3c0b4..898bcac9c7 100644 --- a/app/Api/V1/Controllers/Insight/Income/CategoryController.php +++ b/app/Api/V1/Controllers/Insight/Income/CategoryController.php @@ -69,7 +69,7 @@ class CategoryController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/insight/insightIncomeCategory * - * @param GenericRequest $request + * @param GenericRequest $request * * @return JsonResponse */ @@ -89,11 +89,11 @@ class CategoryController extends Controller /** @var array $expense */ foreach ($expenses as $expense) { $result[] = [ - 'id' => (string) $category->id, + 'id' => (string)$category->id, 'name' => $category->name, 'difference' => $expense['sum'], - 'difference_float' => (float) $expense['sum'], // float but on purpose. - 'currency_id' => (string) $expense['currency_id'], + 'difference_float' => (float)$expense['sum'], // float but on purpose. + 'currency_id' => (string)$expense['currency_id'], 'currency_code' => $expense['currency_code'], ]; } @@ -106,7 +106,7 @@ class CategoryController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/insight/insightIncomeNoCategory * - * @param GenericRequest $request + * @param GenericRequest $request * * @return JsonResponse */ @@ -121,8 +121,8 @@ class CategoryController extends Controller foreach ($expenses as $expense) { $result[] = [ 'difference' => $expense['sum'], - 'difference_float' => (float) $expense['sum'], // float but on purpose. - 'currency_id' => (string) $expense['currency_id'], + 'difference_float' => (float)$expense['sum'], // float but on purpose. + 'currency_id' => (string)$expense['currency_id'], 'currency_code' => $expense['currency_code'], ]; } diff --git a/app/Api/V1/Controllers/Insight/Income/PeriodController.php b/app/Api/V1/Controllers/Insight/Income/PeriodController.php index ce611499ef..e748b4a5db 100644 --- a/app/Api/V1/Controllers/Insight/Income/PeriodController.php +++ b/app/Api/V1/Controllers/Insight/Income/PeriodController.php @@ -38,7 +38,7 @@ class PeriodController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/insight/insightIncomeTotal * - * @param GenericRequest $request + * @param GenericRequest $request * * @return JsonResponse */ @@ -54,31 +54,31 @@ class PeriodController extends Controller $collector->setTypes([TransactionType::DEPOSIT])->setRange($start, $end)->setDestinationAccounts($accounts); $genericSet = $collector->getExtractedJournals(); foreach ($genericSet as $journal) { - $currencyId = (int) $journal['currency_id']; - $foreignCurrencyId = (int) $journal['foreign_currency_id']; + $currencyId = (int)$journal['currency_id']; + $foreignCurrencyId = (int)$journal['foreign_currency_id']; if (0 !== $currencyId) { $response[$currencyId] = $response[$currencyId] ?? [ - 'difference' => '0', - 'difference_float' => 0, - 'currency_id' => (string) $currencyId, - 'currency_code' => $journal['currency_code'], - ]; + 'difference' => '0', + 'difference_float' => 0, + 'currency_id' => (string)$currencyId, + 'currency_code' => $journal['currency_code'], + ]; $response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal['amount'])); - $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // float but on purpose. + $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // float but on purpose. } if (0 !== $foreignCurrencyId) { $response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [ - 'difference' => '0', - 'difference_float' => 0, - 'currency_id' => (string) $foreignCurrencyId, - 'currency_code' => $journal['foreign_currency_code'], - ]; + 'difference' => '0', + 'difference_float' => 0, + 'currency_id' => (string)$foreignCurrencyId, + 'currency_code' => $journal['foreign_currency_code'], + ]; $response[$foreignCurrencyId]['difference'] = bcadd( $response[$foreignCurrencyId]['difference'], app('steam')->positive($journal['foreign_amount']) ); - $response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference']; // float but on purpose. + $response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference']; // float but on purpose. } } diff --git a/app/Api/V1/Controllers/Insight/Income/TagController.php b/app/Api/V1/Controllers/Insight/Income/TagController.php index cf38550e45..31e61ade91 100644 --- a/app/Api/V1/Controllers/Insight/Income/TagController.php +++ b/app/Api/V1/Controllers/Insight/Income/TagController.php @@ -61,7 +61,7 @@ class TagController extends Controller * * Expenses for no tag filtered by account. * - * @param GenericRequest $request + * @param GenericRequest $request * * @return JsonResponse */ @@ -80,31 +80,31 @@ class TagController extends Controller $genericSet = $collector->getExtractedJournals(); foreach ($genericSet as $journal) { - $currencyId = (int) $journal['currency_id']; - $foreignCurrencyId = (int) $journal['foreign_currency_id']; + $currencyId = (int)$journal['currency_id']; + $foreignCurrencyId = (int)$journal['foreign_currency_id']; if (0 !== $currencyId) { $response[$currencyId] = $response[$currencyId] ?? [ - 'difference' => '0', - 'difference_float' => 0, - 'currency_id' => (string) $currencyId, - 'currency_code' => $journal['currency_code'], - ]; + 'difference' => '0', + 'difference_float' => 0, + 'currency_id' => (string)$currencyId, + 'currency_code' => $journal['currency_code'], + ]; $response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal['amount'])); - $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; + $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; } if (0 !== $foreignCurrencyId) { $response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [ - 'difference' => '0', - 'difference_float' => 0, - 'currency_id' => (string) $foreignCurrencyId, - 'currency_code' => $journal['foreign_currency_code'], - ]; + 'difference' => '0', + 'difference_float' => 0, + 'currency_id' => (string)$foreignCurrencyId, + 'currency_code' => $journal['foreign_currency_code'], + ]; $response[$foreignCurrencyId]['difference'] = bcadd( $response[$foreignCurrencyId]['difference'], app('steam')->positive($journal['foreign_amount']) ); - $response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference']; + $response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference']; } } @@ -117,7 +117,7 @@ class TagController extends Controller * * Expenses per tag, possibly filtered by tag and account. * - * @param GenericRequest $request + * @param GenericRequest $request * * @return JsonResponse */ @@ -141,8 +141,8 @@ class TagController extends Controller $genericSet = $collector->getExtractedJournals(); /** @var array $journal */ foreach ($genericSet as $journal) { - $currencyId = (int) $journal['currency_id']; - $foreignCurrencyId = (int) $journal['foreign_currency_id']; + $currencyId = (int)$journal['currency_id']; + $foreignCurrencyId = (int)$journal['foreign_currency_id']; /** @var array $tag */ foreach ($journal['tags'] as $tag) { @@ -153,30 +153,30 @@ class TagController extends Controller // on currency ID if (0 !== $currencyId) { $response[$key] = $response[$key] ?? [ - 'id' => (string) $tagId, - 'name' => $tag['name'], - 'difference' => '0', - 'difference_float' => 0, - 'currency_id' => (string) $currencyId, - 'currency_code' => $journal['currency_code'], - ]; + 'id' => (string)$tagId, + 'name' => $tag['name'], + 'difference' => '0', + 'difference_float' => 0, + 'currency_id' => (string)$currencyId, + 'currency_code' => $journal['currency_code'], + ]; $response[$key]['difference'] = bcadd($response[$key]['difference'], app('steam')->positive($journal['amount'])); - $response[$key]['difference_float'] = (float) $response[$key]['difference']; + $response[$key]['difference_float'] = (float)$response[$key]['difference']; } // on foreign ID if (0 !== $foreignCurrencyId) { $response[$foreignKey] = $journal[$foreignKey] ?? [ - 'difference' => '0', - 'difference_float' => 0, - 'currency_id' => (string) $foreignCurrencyId, - 'currency_code' => $journal['foreign_currency_code'], - ]; + 'difference' => '0', + 'difference_float' => 0, + 'currency_id' => (string)$foreignCurrencyId, + 'currency_code' => $journal['foreign_currency_code'], + ]; $response[$foreignKey]['difference'] = bcadd( $response[$foreignKey]['difference'], app('steam')->positive($journal['foreign_amount']) ); - $response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference']; + $response[$foreignKey]['difference_float'] = (float)$response[$foreignKey]['difference']; } } } diff --git a/app/Api/V1/Controllers/Insight/Transfer/AccountController.php b/app/Api/V1/Controllers/Insight/Transfer/AccountController.php index 19dc00a0fc..451bc60c5a 100644 --- a/app/Api/V1/Controllers/Insight/Transfer/AccountController.php +++ b/app/Api/V1/Controllers/Insight/Transfer/AccountController.php @@ -61,7 +61,7 @@ class AccountController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/insight/insightTransfers * - * @param GenericRequest $request + * @param GenericRequest $request * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Insight/Transfer/CategoryController.php b/app/Api/V1/Controllers/Insight/Transfer/CategoryController.php index 966036eeb0..93e24ee0d0 100644 --- a/app/Api/V1/Controllers/Insight/Transfer/CategoryController.php +++ b/app/Api/V1/Controllers/Insight/Transfer/CategoryController.php @@ -68,7 +68,7 @@ class CategoryController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/insight/insightTransferCategory * - * @param GenericRequest $request + * @param GenericRequest $request * * @return JsonResponse */ @@ -88,11 +88,11 @@ class CategoryController extends Controller /** @var array $expense */ foreach ($expenses as $expense) { $result[] = [ - 'id' => (string) $category->id, + 'id' => (string)$category->id, 'name' => $category->name, 'difference' => $expense['sum'], - 'difference_float' => (float) $expense['sum'], - 'currency_id' => (string) $expense['currency_id'], + 'difference_float' => (float)$expense['sum'], + 'currency_id' => (string)$expense['currency_id'], 'currency_code' => $expense['currency_code'], ]; } @@ -105,7 +105,7 @@ class CategoryController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/insight/insightTransferNoCategory * - * @param GenericRequest $request + * @param GenericRequest $request * * @return JsonResponse */ @@ -120,8 +120,8 @@ class CategoryController extends Controller foreach ($expenses as $expense) { $result[] = [ 'difference' => $expense['sum'], - 'difference_float' => (float) $expense['sum'], - 'currency_id' => (string) $expense['currency_id'], + 'difference_float' => (float)$expense['sum'], + 'currency_id' => (string)$expense['currency_id'], 'currency_code' => $expense['currency_code'], ]; } diff --git a/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php b/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php index 7ece2103e6..7f57c15593 100644 --- a/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php +++ b/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php @@ -38,7 +38,7 @@ class PeriodController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/insight/insightTransferTotal * - * @param GenericRequest $request + * @param GenericRequest $request * * @return JsonResponse */ @@ -54,31 +54,31 @@ class PeriodController extends Controller $collector->setTypes([TransactionType::TRANSFER])->setRange($start, $end)->setDestinationAccounts($accounts); $genericSet = $collector->getExtractedJournals(); foreach ($genericSet as $journal) { - $currencyId = (int) $journal['currency_id']; - $foreignCurrencyId = (int) $journal['foreign_currency_id']; + $currencyId = (int)$journal['currency_id']; + $foreignCurrencyId = (int)$journal['foreign_currency_id']; if (0 !== $currencyId) { $response[$currencyId] = $response[$currencyId] ?? [ - 'difference' => '0', - 'difference_float' => 0, - 'currency_id' => (string) $currencyId, - 'currency_code' => $journal['currency_code'], - ]; + 'difference' => '0', + 'difference_float' => 0, + 'currency_id' => (string)$currencyId, + 'currency_code' => $journal['currency_code'], + ]; $response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal['amount'])); - $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; + $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; } if (0 !== $foreignCurrencyId) { $response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [ - 'difference' => '0', - 'difference_float' => 0, - 'currency_id' => (string) $foreignCurrencyId, - 'currency_code' => $journal['foreign_currency_code'], - ]; + 'difference' => '0', + 'difference_float' => 0, + 'currency_id' => (string)$foreignCurrencyId, + 'currency_code' => $journal['foreign_currency_code'], + ]; $response[$foreignCurrencyId]['difference'] = bcadd( $response[$foreignCurrencyId]['difference'], app('steam')->positive($journal['foreign_amount']) ); - $response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference']; + $response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference']; } } diff --git a/app/Api/V1/Controllers/Insight/Transfer/TagController.php b/app/Api/V1/Controllers/Insight/Transfer/TagController.php index 5346e51e43..78d5b5e282 100644 --- a/app/Api/V1/Controllers/Insight/Transfer/TagController.php +++ b/app/Api/V1/Controllers/Insight/Transfer/TagController.php @@ -58,7 +58,7 @@ class TagController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/insight/insightTransferNoTag * - * @param GenericRequest $request + * @param GenericRequest $request * * @return JsonResponse */ @@ -77,31 +77,31 @@ class TagController extends Controller $genericSet = $collector->getExtractedJournals(); foreach ($genericSet as $journal) { - $currencyId = (int) $journal['currency_id']; - $foreignCurrencyId = (int) $journal['foreign_currency_id']; + $currencyId = (int)$journal['currency_id']; + $foreignCurrencyId = (int)$journal['foreign_currency_id']; if (0 !== $currencyId) { $response[$currencyId] = $response[$currencyId] ?? [ - 'difference' => '0', - 'difference_float' => 0, - 'currency_id' => (string) $currencyId, - 'currency_code' => $journal['currency_code'], - ]; + 'difference' => '0', + 'difference_float' => 0, + 'currency_id' => (string)$currencyId, + 'currency_code' => $journal['currency_code'], + ]; $response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal['amount'])); - $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; + $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; } if (0 !== $foreignCurrencyId) { $response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [ - 'difference' => '0', - 'difference_float' => 0, - 'currency_id' => (string) $foreignCurrencyId, - 'currency_code' => $journal['foreign_currency_code'], - ]; + 'difference' => '0', + 'difference_float' => 0, + 'currency_id' => (string)$foreignCurrencyId, + 'currency_code' => $journal['foreign_currency_code'], + ]; $response[$foreignCurrencyId]['difference'] = bcadd( $response[$foreignCurrencyId]['difference'], app('steam')->positive($journal['foreign_amount']) ); - $response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference']; + $response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference']; } } @@ -114,7 +114,7 @@ class TagController extends Controller * * Transfers per tag, possibly filtered by tag and account. * - * @param GenericRequest $request + * @param GenericRequest $request * * @return JsonResponse */ @@ -138,8 +138,8 @@ class TagController extends Controller $genericSet = $collector->getExtractedJournals(); /** @var array $journal */ foreach ($genericSet as $journal) { - $currencyId = (int) $journal['currency_id']; - $foreignCurrencyId = (int) $journal['foreign_currency_id']; + $currencyId = (int)$journal['currency_id']; + $foreignCurrencyId = (int)$journal['foreign_currency_id']; /** @var array $tag */ foreach ($journal['tags'] as $tag) { @@ -150,30 +150,30 @@ class TagController extends Controller // on currency ID if (0 !== $currencyId) { $response[$key] = $response[$key] ?? [ - 'id' => (string) $tagId, - 'name' => $tag['name'], - 'difference' => '0', - 'difference_float' => 0, - 'currency_id' => (string) $currencyId, - 'currency_code' => $journal['currency_code'], - ]; + 'id' => (string)$tagId, + 'name' => $tag['name'], + 'difference' => '0', + 'difference_float' => 0, + 'currency_id' => (string)$currencyId, + 'currency_code' => $journal['currency_code'], + ]; $response[$key]['difference'] = bcadd($response[$key]['difference'], app('steam')->positive($journal['amount'])); - $response[$key]['difference_float'] = (float) $response[$key]['difference']; + $response[$key]['difference_float'] = (float)$response[$key]['difference']; } // on foreign ID if (0 !== $foreignCurrencyId) { $response[$foreignKey] = $journal[$foreignKey] ?? [ - 'difference' => '0', - 'difference_float' => 0, - 'currency_id' => (string) $foreignCurrencyId, - 'currency_code' => $journal['foreign_currency_code'], - ]; + 'difference' => '0', + 'difference_float' => 0, + 'currency_id' => (string)$foreignCurrencyId, + 'currency_code' => $journal['foreign_currency_code'], + ]; $response[$foreignKey]['difference'] = bcadd( $response[$foreignKey]['difference'], app('steam')->positive($journal['foreign_amount']) ); - $response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference']; // intentional float + $response[$foreignKey]['difference_float'] = (float)$response[$foreignKey]['difference']; // intentional float } } } diff --git a/app/Api/V1/Controllers/Models/Account/DestroyController.php b/app/Api/V1/Controllers/Models/Account/DestroyController.php index 739a65fec2..5430bd68df 100644 --- a/app/Api/V1/Controllers/Models/Account/DestroyController.php +++ b/app/Api/V1/Controllers/Models/Account/DestroyController.php @@ -61,7 +61,7 @@ class DestroyController extends Controller * * Remove the specified resource from storage. * - * @param Account $account + * @param Account $account * * @codeCoverageIgnore * @return JsonResponse diff --git a/app/Api/V1/Controllers/Models/Account/ListController.php b/app/Api/V1/Controllers/Models/Account/ListController.php index 24c5f6fe1a..866779725a 100644 --- a/app/Api/V1/Controllers/Models/Account/ListController.php +++ b/app/Api/V1/Controllers/Models/Account/ListController.php @@ -73,7 +73,7 @@ class ListController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/accounts/listAttachmentByAccount * - * @param Account $account + * @param Account $account * * @return JsonResponse * @codeCoverageIgnore @@ -82,7 +82,7 @@ class ListController extends Controller public function attachments(Account $account): JsonResponse { $manager = $this->getManager(); - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $collection = $this->repository->getAttachments($account); $count = $collection->count(); @@ -90,7 +90,7 @@ class ListController extends Controller // make paginator: $paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.accounts.attachments', [$account->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.accounts.attachments', [$account->id]).$this->buildParams()); /** @var AttachmentTransformer $transformer */ $transformer = app(AttachmentTransformer::class); @@ -106,7 +106,7 @@ class ListController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/accounts/listPiggyBankByAccount * - * @param Account $account + * @param Account $account * * @return JsonResponse * @throws FireflyException @@ -118,7 +118,7 @@ class ListController extends Controller $manager = $this->getManager(); // types to get, page size: - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; // get list of budgets. Count it and split it. $collection = $this->repository->getPiggyBanks($account); @@ -127,7 +127,7 @@ class ListController extends Controller // make paginator: $paginator = new LengthAwarePaginator($piggyBanks, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.accounts.piggy_banks', [$account->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.accounts.piggy_banks', [$account->id]).$this->buildParams()); /** @var PiggyBankTransformer $transformer */ $transformer = app(PiggyBankTransformer::class); @@ -147,15 +147,15 @@ class ListController extends Controller * * @codeCoverageIgnore * - * @param Request $request - * @param Account $account + * @param Request $request + * @param Account $account * * @return JsonResponse * @throws FireflyException */ public function transactions(Request $request, Account $account): JsonResponse { - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $type = $request->get('type') ?? 'default'; $this->parameters->set('type', $type); @@ -180,7 +180,7 @@ class ListController extends Controller } $paginator = $collector->getPaginatedGroups(); - $paginator->setPath(route('api.v1.accounts.transactions', [$account->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.accounts.transactions', [$account->id]).$this->buildParams()); $groups = $paginator->getCollection(); /** @var TransactionGroupTransformer $transformer */ diff --git a/app/Api/V1/Controllers/Models/Account/ShowController.php b/app/Api/V1/Controllers/Models/Account/ShowController.php index 2d7a8b5999..f251faaf4f 100644 --- a/app/Api/V1/Controllers/Models/Account/ShowController.php +++ b/app/Api/V1/Controllers/Models/Account/ShowController.php @@ -71,7 +71,7 @@ class ShowController extends Controller * * Display a listing of the resource. * - * @param Request $request + * @param Request $request * * @return JsonResponse * @throws FireflyException @@ -85,7 +85,7 @@ class ShowController extends Controller // types to get, page size: $types = $this->mapAccountTypes($this->parameters->get('type')); - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; // get list of accounts. Count it and split it. $this->repository->resetAccountOrder(); @@ -99,7 +99,7 @@ class ShowController extends Controller // make paginator: $paginator = new LengthAwarePaginator($accounts, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.accounts.index') . $this->buildParams()); + $paginator->setPath(route('api.v1.accounts.index').$this->buildParams()); /** @var AccountTransformer $transformer */ $transformer = app(AccountTransformer::class); @@ -117,7 +117,7 @@ class ShowController extends Controller * * Show single instance. * - * @param Account $account + * @param Account $account * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Models/Account/StoreController.php b/app/Api/V1/Controllers/Models/Account/StoreController.php index a05a0a66fd..0e4d530018 100644 --- a/app/Api/V1/Controllers/Models/Account/StoreController.php +++ b/app/Api/V1/Controllers/Models/Account/StoreController.php @@ -63,7 +63,7 @@ class StoreController extends Controller * * Store a new instance. * - * @param StoreRequest $request + * @param StoreRequest $request * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Models/Account/UpdateController.php b/app/Api/V1/Controllers/Models/Account/UpdateController.php index 65221bbeda..5c90221b79 100644 --- a/app/Api/V1/Controllers/Models/Account/UpdateController.php +++ b/app/Api/V1/Controllers/Models/Account/UpdateController.php @@ -66,8 +66,8 @@ class UpdateController extends Controller * * Update account. * - * @param UpdateRequest $request - * @param Account $account + * @param UpdateRequest $request + * @param Account $account * * @return JsonResponse */ @@ -75,7 +75,7 @@ class UpdateController extends Controller { Log::debug(sprintf('Now in %s', __METHOD__)); $data = $request->getUpdateData(); - $data['type'] = config('firefly.shortNamesByFullName.' . $account->accountType->type); + $data['type'] = config('firefly.shortNamesByFullName.'.$account->accountType->type); $account = $this->repository->update($account, $data); $manager = $this->getManager(); $account->refresh(); diff --git a/app/Api/V1/Controllers/Models/Attachment/DestroyController.php b/app/Api/V1/Controllers/Models/Attachment/DestroyController.php index 4150728688..287f621df8 100644 --- a/app/Api/V1/Controllers/Models/Attachment/DestroyController.php +++ b/app/Api/V1/Controllers/Models/Attachment/DestroyController.php @@ -66,7 +66,7 @@ class DestroyController extends Controller * * @codeCoverageIgnore * - * @param Attachment $attachment + * @param Attachment $attachment * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Models/Attachment/ShowController.php b/app/Api/V1/Controllers/Models/Attachment/ShowController.php index 55537851c8..aacb5b461f 100644 --- a/app/Api/V1/Controllers/Models/Attachment/ShowController.php +++ b/app/Api/V1/Controllers/Models/Attachment/ShowController.php @@ -71,7 +71,7 @@ class ShowController extends Controller * * Download an attachment. * - * @param Attachment $attachment + * @param Attachment $attachment * * @codeCoverageIgnore * @return LaravelResponse @@ -97,13 +97,13 @@ class ShowController extends Controller $response ->header('Content-Description', 'File Transfer') ->header('Content-Type', 'application/octet-stream') - ->header('Content-Disposition', 'attachment; filename=' . $quoted) + ->header('Content-Disposition', 'attachment; filename='.$quoted) ->header('Content-Transfer-Encoding', 'binary') ->header('Connection', 'Keep-Alive') ->header('Expires', '0') ->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') ->header('Pragma', 'public') - ->header('Content-Length', (string) strlen($content)); + ->header('Content-Length', (string)strlen($content)); return $response; } @@ -125,7 +125,7 @@ class ShowController extends Controller $manager = $this->getManager(); // types to get, page size: - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; // get list of attachments. Count it and split it. $collection = $this->repository->get(); @@ -134,7 +134,7 @@ class ShowController extends Controller // make paginator: $paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.attachments.index') . $this->buildParams()); + $paginator->setPath(route('api.v1.attachments.index').$this->buildParams()); /** @var AttachmentTransformer $transformer */ $transformer = app(AttachmentTransformer::class); @@ -152,7 +152,7 @@ class ShowController extends Controller * * Display the specified resource. * - * @param Attachment $attachment + * @param Attachment $attachment * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Models/Attachment/StoreController.php b/app/Api/V1/Controllers/Models/Attachment/StoreController.php index 2469b68938..8fd517f65c 100644 --- a/app/Api/V1/Controllers/Models/Attachment/StoreController.php +++ b/app/Api/V1/Controllers/Models/Attachment/StoreController.php @@ -71,7 +71,7 @@ class StoreController extends Controller * * Store a newly created resource in storage. * - * @param StoreRequest $request + * @param StoreRequest $request * * @return JsonResponse * @throws FireflyException @@ -97,8 +97,8 @@ class StoreController extends Controller * * @codeCoverageIgnore * - * @param Request $request - * @param Attachment $attachment + * @param Request $request + * @param Attachment $attachment * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Models/Attachment/UpdateController.php b/app/Api/V1/Controllers/Models/Attachment/UpdateController.php index f5d350b1e4..fc33e64d85 100644 --- a/app/Api/V1/Controllers/Models/Attachment/UpdateController.php +++ b/app/Api/V1/Controllers/Models/Attachment/UpdateController.php @@ -67,8 +67,8 @@ class UpdateController extends Controller * * Update the specified resource in storage. * - * @param UpdateRequest $request - * @param Attachment $attachment + * @param UpdateRequest $request + * @param Attachment $attachment * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Models/AvailableBudget/ShowController.php b/app/Api/V1/Controllers/Models/AvailableBudget/ShowController.php index b7d614b2cb..fef07373de 100644 --- a/app/Api/V1/Controllers/Models/AvailableBudget/ShowController.php +++ b/app/Api/V1/Controllers/Models/AvailableBudget/ShowController.php @@ -77,7 +77,7 @@ class ShowController extends Controller $manager = $this->getManager(); // types to get, page size: - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $start = $this->parameters->get('start'); $end = $this->parameters->get('end'); @@ -89,7 +89,7 @@ class ShowController extends Controller // make paginator: $paginator = new LengthAwarePaginator($availableBudgets, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.available_budgets.index') . $this->buildParams()); + $paginator->setPath(route('api.v1.available_budgets.index').$this->buildParams()); /** @var AvailableBudgetTransformer $transformer */ $transformer = app(AvailableBudgetTransformer::class); @@ -107,7 +107,7 @@ class ShowController extends Controller * * Display the specified resource. * - * @param AvailableBudget $availableBudget + * @param AvailableBudget $availableBudget * * @return JsonResponse * @codeCoverageIgnore diff --git a/app/Api/V1/Controllers/Models/Bill/DestroyController.php b/app/Api/V1/Controllers/Models/Bill/DestroyController.php index fa657ffd1b..bffce79962 100644 --- a/app/Api/V1/Controllers/Models/Bill/DestroyController.php +++ b/app/Api/V1/Controllers/Models/Bill/DestroyController.php @@ -59,7 +59,7 @@ class DestroyController extends Controller * * Remove the specified resource from storage. * - * @param Bill $bill + * @param Bill $bill * * @return JsonResponse * @codeCoverageIgnore diff --git a/app/Api/V1/Controllers/Models/Bill/ListController.php b/app/Api/V1/Controllers/Models/Bill/ListController.php index 5653c9fd1e..eb39fff345 100644 --- a/app/Api/V1/Controllers/Models/Bill/ListController.php +++ b/app/Api/V1/Controllers/Models/Bill/ListController.php @@ -72,7 +72,7 @@ class ListController extends Controller * * Display a listing of the resource. * - * @param Bill $bill + * @param Bill $bill * * @return JsonResponse * @throws FireflyException @@ -81,7 +81,7 @@ class ListController extends Controller public function attachments(Bill $bill): JsonResponse { $manager = $this->getManager(); - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $collection = $this->repository->getAttachments($bill); $count = $collection->count(); @@ -89,7 +89,7 @@ class ListController extends Controller // make paginator: $paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.bills.attachments', [$bill->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.bills.attachments', [$bill->id]).$this->buildParams()); /** @var AttachmentTransformer $transformer */ $transformer = app(AttachmentTransformer::class); @@ -107,7 +107,7 @@ class ListController extends Controller * * List all of them. * - * @param Bill $bill + * @param Bill $bill * * @return JsonResponse * @throws FireflyException @@ -118,7 +118,7 @@ class ListController extends Controller $manager = $this->getManager(); // types to get, page size: - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; // get list of budgets. Count it and split it. $collection = $this->repository->getRulesForBill($bill); @@ -127,7 +127,7 @@ class ListController extends Controller // make paginator: $paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.bills.rules', [$bill->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.bills.rules', [$bill->id]).$this->buildParams()); /** @var RuleTransformer $transformer */ $transformer = app(RuleTransformer::class); @@ -144,9 +144,9 @@ class ListController extends Controller * * Show all transactions. * - * @param Request $request + * @param Request $request * - * @param Bill $bill + * @param Bill $bill * * @return JsonResponse * @throws FireflyException @@ -154,7 +154,7 @@ class ListController extends Controller */ public function transactions(Request $request, Bill $bill): JsonResponse { - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $type = $request->get('type') ?? 'default'; $this->parameters->set('type', $type); @@ -187,7 +187,7 @@ class ListController extends Controller // get paginator. $paginator = $collector->getPaginatedGroups(); - $paginator->setPath(route('api.v1.bills.transactions', [$bill->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.bills.transactions', [$bill->id]).$this->buildParams()); $transactions = $paginator->getCollection(); /** @var TransactionGroupTransformer $transformer */ diff --git a/app/Api/V1/Controllers/Models/Bill/ShowController.php b/app/Api/V1/Controllers/Models/Bill/ShowController.php index 2fba6af816..43bd076f5a 100644 --- a/app/Api/V1/Controllers/Models/Bill/ShowController.php +++ b/app/Api/V1/Controllers/Models/Bill/ShowController.php @@ -74,7 +74,7 @@ class ShowController extends Controller $this->repository->correctOrder(); $bills = $this->repository->getBills(); $manager = $this->getManager(); - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $count = $bills->count(); $bills = $bills->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize); $paginator = new LengthAwarePaginator($bills, $count, $pageSize, $this->parameters->get('page')); @@ -95,7 +95,7 @@ class ShowController extends Controller * * Show the specified bill. * - * @param Bill $bill + * @param Bill $bill * * @return JsonResponse * @codeCoverageIgnore diff --git a/app/Api/V1/Controllers/Models/Bill/StoreController.php b/app/Api/V1/Controllers/Models/Bill/StoreController.php index 7c5cd8b3b5..1e05b2eccf 100644 --- a/app/Api/V1/Controllers/Models/Bill/StoreController.php +++ b/app/Api/V1/Controllers/Models/Bill/StoreController.php @@ -65,7 +65,7 @@ class StoreController extends Controller * * Store a bill. * - * @param StoreRequest $request + * @param StoreRequest $request * * @return JsonResponse * @throws FireflyException diff --git a/app/Api/V1/Controllers/Models/Bill/UpdateController.php b/app/Api/V1/Controllers/Models/Bill/UpdateController.php index 56420e2dcf..d02eba7979 100644 --- a/app/Api/V1/Controllers/Models/Bill/UpdateController.php +++ b/app/Api/V1/Controllers/Models/Bill/UpdateController.php @@ -62,8 +62,8 @@ class UpdateController extends Controller * * Update a bill. * - * @param UpdateRequest $request - * @param Bill $bill + * @param UpdateRequest $request + * @param Bill $bill * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Models/Budget/DestroyController.php b/app/Api/V1/Controllers/Models/Budget/DestroyController.php index 706ce3d82b..a8119c1e93 100644 --- a/app/Api/V1/Controllers/Models/Budget/DestroyController.php +++ b/app/Api/V1/Controllers/Models/Budget/DestroyController.php @@ -59,7 +59,7 @@ class DestroyController extends Controller * * Remove the specified resource from storage. * - * @param Budget $budget + * @param Budget $budget * * @return JsonResponse * @codeCoverageIgnore diff --git a/app/Api/V1/Controllers/Models/Budget/ListController.php b/app/Api/V1/Controllers/Models/Budget/ListController.php index 422b4d6df8..7f8911b7c7 100644 --- a/app/Api/V1/Controllers/Models/Budget/ListController.php +++ b/app/Api/V1/Controllers/Models/Budget/ListController.php @@ -74,7 +74,7 @@ class ListController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/budgets/listAttachmentByBudget * - * @param Budget $budget + * @param Budget $budget * * @return JsonResponse * @throws FireflyException @@ -83,7 +83,7 @@ class ListController extends Controller public function attachments(Budget $budget): JsonResponse { $manager = $this->getManager(); - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $collection = $this->repository->getAttachments($budget); $count = $collection->count(); @@ -91,7 +91,7 @@ class ListController extends Controller // make paginator: $paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.budgets.attachments', [$budget->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.budgets.attachments', [$budget->id]).$this->buildParams()); /** @var AttachmentTransformer $transformer */ $transformer = app(AttachmentTransformer::class); @@ -109,7 +109,7 @@ class ListController extends Controller * * Display a listing of the resource. * - * @param Budget $budget + * @param Budget $budget * * @return JsonResponse * @throws FireflyException @@ -118,13 +118,13 @@ class ListController extends Controller public function budgetLimits(Budget $budget): JsonResponse { $manager = $this->getManager(); - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $this->parameters->set('budget_id', $budget->id); $collection = $this->blRepository->getBudgetLimits($budget, $this->parameters->get('start'), $this->parameters->get('end')); $count = $collection->count(); $budgetLimits = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize); $paginator = new LengthAwarePaginator($budgetLimits, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.budgets.budget_limits', [$budget->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.budgets.budget_limits', [$budget->id]).$this->buildParams()); /** @var BudgetLimitTransformer $transformer */ $transformer = app(BudgetLimitTransformer::class); @@ -141,9 +141,9 @@ class ListController extends Controller * * Show all transactions. * - * @param Request $request + * @param Request $request * - * @param Budget $budget + * @param Budget $budget * * @return JsonResponse * @throws FireflyException @@ -151,7 +151,7 @@ class ListController extends Controller */ public function transactions(Request $request, Budget $budget): JsonResponse { - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; // user can overrule page size with limit parameter. $limit = $this->parameters->get('limit'); @@ -189,7 +189,7 @@ class ListController extends Controller } $paginator = $collector->getPaginatedGroups(); - $paginator->setPath(route('api.v1.budgets.transactions', [$budget->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.budgets.transactions', [$budget->id]).$this->buildParams()); $transactions = $paginator->getCollection(); /** @var TransactionGroupTransformer $transformer */ @@ -207,7 +207,7 @@ class ListController extends Controller * * Show all transactions. * - * @param Request $request + * @param Request $request * * @return JsonResponse * @throws FireflyException @@ -215,7 +215,7 @@ class ListController extends Controller */ public function withoutBudget(Request $request): JsonResponse { - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; // user can overrule page size with limit parameter. $limit = $this->parameters->get('limit'); @@ -253,7 +253,7 @@ class ListController extends Controller } $paginator = $collector->getPaginatedGroups(); - $paginator->setPath(route('api.v1.budgets.without-budget') . $this->buildParams()); + $paginator->setPath(route('api.v1.budgets.without-budget').$this->buildParams()); $transactions = $paginator->getCollection(); /** @var TransactionGroupTransformer $transformer */ diff --git a/app/Api/V1/Controllers/Models/Budget/ShowController.php b/app/Api/V1/Controllers/Models/Budget/ShowController.php index b011c5675d..80f413acf2 100644 --- a/app/Api/V1/Controllers/Models/Budget/ShowController.php +++ b/app/Api/V1/Controllers/Models/Budget/ShowController.php @@ -78,7 +78,7 @@ class ShowController extends Controller $manager = $this->getManager(); // types to get, page size: - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; // get list of budgets. Count it and split it. $collection = $this->repository->getBudgets(); @@ -87,7 +87,7 @@ class ShowController extends Controller // make paginator: $paginator = new LengthAwarePaginator($budgets, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.budgets.index') . $this->buildParams()); + $paginator->setPath(route('api.v1.budgets.index').$this->buildParams()); /** @var BudgetTransformer $transformer */ $transformer = app(BudgetTransformer::class); @@ -102,7 +102,7 @@ class ShowController extends Controller /** * Show a budget. * - * @param Budget $budget + * @param Budget $budget * * @return JsonResponse * @codeCoverageIgnore diff --git a/app/Api/V1/Controllers/Models/Budget/StoreController.php b/app/Api/V1/Controllers/Models/Budget/StoreController.php index af1d80251b..e8bc6269ca 100644 --- a/app/Api/V1/Controllers/Models/Budget/StoreController.php +++ b/app/Api/V1/Controllers/Models/Budget/StoreController.php @@ -62,7 +62,7 @@ class StoreController extends Controller * * Store a budget. * - * @param StoreRequest $request + * @param StoreRequest $request * * @return JsonResponse * @throws FireflyException diff --git a/app/Api/V1/Controllers/Models/Budget/UpdateController.php b/app/Api/V1/Controllers/Models/Budget/UpdateController.php index 29eba786b7..a8efcd80bb 100644 --- a/app/Api/V1/Controllers/Models/Budget/UpdateController.php +++ b/app/Api/V1/Controllers/Models/Budget/UpdateController.php @@ -62,8 +62,8 @@ class UpdateController extends Controller * * Update a budget. * - * @param UpdateRequest $request - * @param Budget $budget + * @param UpdateRequest $request + * @param Budget $budget * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Models/BudgetLimit/DestroyController.php b/app/Api/V1/Controllers/Models/BudgetLimit/DestroyController.php index 6bbd40c7bc..2f1b55e2c2 100644 --- a/app/Api/V1/Controllers/Models/BudgetLimit/DestroyController.php +++ b/app/Api/V1/Controllers/Models/BudgetLimit/DestroyController.php @@ -64,8 +64,8 @@ class DestroyController extends Controller * * Remove the specified resource from storage. * - * @param Budget $budget - * @param BudgetLimit $budgetLimit + * @param Budget $budget + * @param BudgetLimit $budgetLimit * * @return JsonResponse * @throws FireflyException diff --git a/app/Api/V1/Controllers/Models/BudgetLimit/ListController.php b/app/Api/V1/Controllers/Models/BudgetLimit/ListController.php index 8b2b2276e4..e4860564b2 100644 --- a/app/Api/V1/Controllers/Models/BudgetLimit/ListController.php +++ b/app/Api/V1/Controllers/Models/BudgetLimit/ListController.php @@ -71,9 +71,9 @@ class ListController extends Controller * https://api-docs.firefly-iii.org/#/budgets/listTransactionByBudgetLimit * Show all transactions. * - * @param Request $request - * @param Budget $budget - * @param BudgetLimit $budgetLimit + * @param Request $request + * @param Budget $budget + * @param BudgetLimit $budgetLimit * * @return JsonResponse * @throws FireflyException @@ -81,7 +81,7 @@ class ListController extends Controller */ public function transactions(Request $request, Budget $budget, BudgetLimit $budgetLimit): JsonResponse { - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $type = $request->get('type') ?? 'default'; $this->parameters->set('type', $type); @@ -110,7 +110,7 @@ class ListController extends Controller $collector->setRange($budgetLimit->start_date, $budgetLimit->end_date); $collector->setTypes($types); $paginator = $collector->getPaginatedGroups(); - $paginator->setPath(route('api.v1.budgets.limits.transactions', [$budget->id, $budgetLimit->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.budgets.limits.transactions', [$budget->id, $budgetLimit->id]).$this->buildParams()); $transactions = $paginator->getCollection(); /** @var TransactionGroupTransformer $transformer */ diff --git a/app/Api/V1/Controllers/Models/BudgetLimit/ShowController.php b/app/Api/V1/Controllers/Models/BudgetLimit/ShowController.php index 7856f6d428..a4e812fedd 100644 --- a/app/Api/V1/Controllers/Models/BudgetLimit/ShowController.php +++ b/app/Api/V1/Controllers/Models/BudgetLimit/ShowController.php @@ -75,8 +75,8 @@ class ShowController extends Controller * * Display a listing of the budget limits for this budget. * - * @param Request $request - * @param Budget $budget + * @param Request $request + * @param Budget $budget * * @return JsonResponse * @throws FireflyException @@ -86,12 +86,12 @@ class ShowController extends Controller { $manager = $this->getManager(); $manager->parseIncludes('budget'); - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $collection = $this->blRepository->getBudgetLimits($budget, $this->parameters->get('start'), $this->parameters->get('end')); $count = $collection->count(); $budgetLimits = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize); $paginator = new LengthAwarePaginator($budgetLimits, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.budgets.limits.index', [$budget->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.budgets.limits.index', [$budget->id]).$this->buildParams()); /** @var BudgetLimitTransformer $transformer */ $transformer = app(BudgetLimitTransformer::class); @@ -109,7 +109,7 @@ class ShowController extends Controller * * Display a listing of the budget limits for this budget. * - * @param DateRequest $request + * @param DateRequest $request * * @return JsonResponse * @throws FireflyException @@ -119,12 +119,12 @@ class ShowController extends Controller { $manager = $this->getManager(); $manager->parseIncludes('budget'); - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $collection = $this->blRepository->getAllBudgetLimits($this->parameters->get('start'), $this->parameters->get('end')); $count = $collection->count(); $budgetLimits = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize); $paginator = new LengthAwarePaginator($budgetLimits, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.budget-limits.index') . $this->buildParams()); + $paginator->setPath(route('api.v1.budget-limits.index').$this->buildParams()); /** @var BudgetLimitTransformer $transformer */ $transformer = app(BudgetLimitTransformer::class); @@ -140,16 +140,16 @@ class ShowController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/budgets/getBudgetLimit * - * @param Request $request - * @param Budget $budget - * @param BudgetLimit $budgetLimit + * @param Request $request + * @param Budget $budget + * @param BudgetLimit $budgetLimit * * @return JsonResponse * @throws FireflyException */ public function show(Request $request, Budget $budget, BudgetLimit $budgetLimit): JsonResponse { - if ((int) $budget->id !== (int) $budgetLimit->budget_id) { + if ((int)$budget->id !== (int)$budgetLimit->budget_id) { throw new FireflyException('20028: The budget limit does not belong to the budget.'); } // continue! diff --git a/app/Api/V1/Controllers/Models/BudgetLimit/StoreController.php b/app/Api/V1/Controllers/Models/BudgetLimit/StoreController.php index d5630273fd..d868777485 100644 --- a/app/Api/V1/Controllers/Models/BudgetLimit/StoreController.php +++ b/app/Api/V1/Controllers/Models/BudgetLimit/StoreController.php @@ -65,8 +65,8 @@ class StoreController extends Controller * * Store a newly created resource in storage. * - * @param StoreRequest $request - * @param Budget $budget + * @param StoreRequest $request + * @param Budget $budget * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Models/BudgetLimit/UpdateController.php b/app/Api/V1/Controllers/Models/BudgetLimit/UpdateController.php index 4706f68b0f..baa0217a80 100644 --- a/app/Api/V1/Controllers/Models/BudgetLimit/UpdateController.php +++ b/app/Api/V1/Controllers/Models/BudgetLimit/UpdateController.php @@ -67,16 +67,16 @@ class UpdateController extends Controller /** * Update the specified resource in storage. * - * @param UpdateRequest $request - * @param Budget $budget - * @param BudgetLimit $budgetLimit + * @param UpdateRequest $request + * @param Budget $budget + * @param BudgetLimit $budgetLimit * * @return JsonResponse * @throws FireflyException */ public function update(UpdateRequest $request, Budget $budget, BudgetLimit $budgetLimit): JsonResponse { - if ((int) $budget->id !== (int) $budgetLimit->budget_id) { + if ((int)$budget->id !== (int)$budgetLimit->budget_id) { throw new FireflyException('20028: The budget limit does not belong to the budget.'); } $data = $request->getAll(); diff --git a/app/Api/V1/Controllers/Models/Category/DestroyController.php b/app/Api/V1/Controllers/Models/Category/DestroyController.php index 1136bd2df8..c28e976324 100644 --- a/app/Api/V1/Controllers/Models/Category/DestroyController.php +++ b/app/Api/V1/Controllers/Models/Category/DestroyController.php @@ -59,7 +59,7 @@ class DestroyController extends Controller * * Remove the specified resource from storage. * - * @param Category $category + * @param Category $category * * @return JsonResponse * @codeCoverageIgnore diff --git a/app/Api/V1/Controllers/Models/Category/ListController.php b/app/Api/V1/Controllers/Models/Category/ListController.php index a3ebb136b4..4c0c8b2acd 100644 --- a/app/Api/V1/Controllers/Models/Category/ListController.php +++ b/app/Api/V1/Controllers/Models/Category/ListController.php @@ -69,7 +69,7 @@ class ListController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/categories/listAttachmentByCategory * - * @param Category $category + * @param Category $category * * @return JsonResponse * @throws FireflyException @@ -78,7 +78,7 @@ class ListController extends Controller public function attachments(Category $category): JsonResponse { $manager = $this->getManager(); - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $collection = $this->repository->getAttachments($category); $count = $collection->count(); @@ -86,7 +86,7 @@ class ListController extends Controller // make paginator: $paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.categories.attachments', [$category->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.categories.attachments', [$category->id]).$this->buildParams()); /** @var AttachmentTransformer $transformer */ $transformer = app(AttachmentTransformer::class); @@ -104,9 +104,9 @@ class ListController extends Controller * * Show all transactions. * - * @param Request $request + * @param Request $request * - * @param Category $category + * @param Category $category * * @return JsonResponse * @throws FireflyException @@ -114,7 +114,7 @@ class ListController extends Controller */ public function transactions(Request $request, Category $category): JsonResponse { - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $type = $request->get('type') ?? 'default'; $this->parameters->set('type', $type); @@ -145,7 +145,7 @@ class ListController extends Controller } $paginator = $collector->getPaginatedGroups(); - $paginator->setPath(route('api.v1.categories.transactions', [$category->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.categories.transactions', [$category->id]).$this->buildParams()); $transactions = $paginator->getCollection(); /** @var TransactionGroupTransformer $transformer */ diff --git a/app/Api/V1/Controllers/Models/Category/ShowController.php b/app/Api/V1/Controllers/Models/Category/ShowController.php index 0f18d8f831..009739d4a8 100644 --- a/app/Api/V1/Controllers/Models/Category/ShowController.php +++ b/app/Api/V1/Controllers/Models/Category/ShowController.php @@ -74,7 +74,7 @@ class ShowController extends Controller $manager = $this->getManager(); // types to get, page size: - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; // get list of budgets. Count it and split it. $collection = $this->repository->getCategories(); @@ -83,7 +83,7 @@ class ShowController extends Controller // make paginator: $paginator = new LengthAwarePaginator($categories, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.categories.index') . $this->buildParams()); + $paginator->setPath(route('api.v1.categories.index').$this->buildParams()); /** @var CategoryTransformer $transformer */ $transformer = app(CategoryTransformer::class); @@ -100,7 +100,7 @@ class ShowController extends Controller * * Show the category. * - * @param Category $category + * @param Category $category * * @return JsonResponse * @codeCoverageIgnore diff --git a/app/Api/V1/Controllers/Models/Category/StoreController.php b/app/Api/V1/Controllers/Models/Category/StoreController.php index d5f81a3dde..80918e0c54 100644 --- a/app/Api/V1/Controllers/Models/Category/StoreController.php +++ b/app/Api/V1/Controllers/Models/Category/StoreController.php @@ -62,7 +62,7 @@ class StoreController extends Controller * * Store new category. * - * @param StoreRequest $request + * @param StoreRequest $request * * @return JsonResponse * @throws FireflyException diff --git a/app/Api/V1/Controllers/Models/Category/UpdateController.php b/app/Api/V1/Controllers/Models/Category/UpdateController.php index 191a85f6e7..d72794be9a 100644 --- a/app/Api/V1/Controllers/Models/Category/UpdateController.php +++ b/app/Api/V1/Controllers/Models/Category/UpdateController.php @@ -62,8 +62,8 @@ class UpdateController extends Controller * * Update the category. * - * @param UpdateRequest $request - * @param Category $category + * @param UpdateRequest $request + * @param Category $category * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Models/ObjectGroup/DestroyController.php b/app/Api/V1/Controllers/Models/ObjectGroup/DestroyController.php index 1ba20dd668..72bbb5665b 100644 --- a/app/Api/V1/Controllers/Models/ObjectGroup/DestroyController.php +++ b/app/Api/V1/Controllers/Models/ObjectGroup/DestroyController.php @@ -62,7 +62,7 @@ class DestroyController extends Controller * * Remove the specified resource from storage. * - * @param ObjectGroup $objectGroup + * @param ObjectGroup $objectGroup * * @codeCoverageIgnore * @return JsonResponse diff --git a/app/Api/V1/Controllers/Models/ObjectGroup/ListController.php b/app/Api/V1/Controllers/Models/ObjectGroup/ListController.php index 2283526b1c..f82a2ad335 100644 --- a/app/Api/V1/Controllers/Models/ObjectGroup/ListController.php +++ b/app/Api/V1/Controllers/Models/ObjectGroup/ListController.php @@ -68,7 +68,7 @@ class ListController extends Controller * * List all bills in this object group * - * @param ObjectGroup $objectGroup + * @param ObjectGroup $objectGroup * * @return JsonResponse * @throws FireflyException @@ -78,7 +78,7 @@ class ListController extends Controller { $manager = $this->getManager(); - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; // get list of piggy banks. Count it and split it. $collection = $this->repository->getBills($objectGroup); $count = $collection->count(); @@ -86,7 +86,7 @@ class ListController extends Controller // make paginator: $paginator = new LengthAwarePaginator($bills, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.currencies.bills', [$objectGroup->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.currencies.bills', [$objectGroup->id]).$this->buildParams()); /** @var BillTransformer $transformer */ $transformer = app(BillTransformer::class); @@ -104,7 +104,7 @@ class ListController extends Controller * * List all piggies under the object group. * - * @param ObjectGroup $objectGroup + * @param ObjectGroup $objectGroup * * @return JsonResponse * @throws FireflyException @@ -116,7 +116,7 @@ class ListController extends Controller $manager = $this->getManager(); // types to get, page size: - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; // get list of piggy banks. Count it and split it. $collection = $this->repository->getPiggyBanks($objectGroup); @@ -125,7 +125,7 @@ class ListController extends Controller // make paginator: $paginator = new LengthAwarePaginator($piggyBanks, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.object-groups.piggy_banks', [$objectGroup->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.object-groups.piggy_banks', [$objectGroup->id]).$this->buildParams()); /** @var PiggyBankTransformer $transformer */ $transformer = app(PiggyBankTransformer::class); diff --git a/app/Api/V1/Controllers/Models/ObjectGroup/ShowController.php b/app/Api/V1/Controllers/Models/ObjectGroup/ShowController.php index bfc001fa93..3fe8b0b41a 100644 --- a/app/Api/V1/Controllers/Models/ObjectGroup/ShowController.php +++ b/app/Api/V1/Controllers/Models/ObjectGroup/ShowController.php @@ -69,7 +69,7 @@ class ShowController extends Controller * * Display a listing of the resource. * - * @param Request $request + * @param Request $request * * @return JsonResponse * @throws FireflyException @@ -80,7 +80,7 @@ class ShowController extends Controller $manager = $this->getManager(); // types to get, page size: - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $this->repository->resetOrder(); $collection = $this->repository->get(); @@ -89,7 +89,7 @@ class ShowController extends Controller // make paginator: $paginator = new LengthAwarePaginator($objectGroups, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.object-groups.index') . $this->buildParams()); + $paginator->setPath(route('api.v1.object-groups.index').$this->buildParams()); /** @var ObjectGroupTransformer $transformer */ $transformer = app(ObjectGroupTransformer::class); @@ -107,7 +107,7 @@ class ShowController extends Controller * * Show single instance. * - * @param ObjectGroup $objectGroup + * @param ObjectGroup $objectGroup * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Models/ObjectGroup/UpdateController.php b/app/Api/V1/Controllers/Models/ObjectGroup/UpdateController.php index ceb2e32dc9..a9d5ce11c8 100644 --- a/app/Api/V1/Controllers/Models/ObjectGroup/UpdateController.php +++ b/app/Api/V1/Controllers/Models/ObjectGroup/UpdateController.php @@ -63,8 +63,8 @@ class UpdateController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/object_groups/updateObjectGroup * - * @param UpdateRequest $request - * @param ObjectGroup $objectGroup + * @param UpdateRequest $request + * @param ObjectGroup $objectGroup * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Models/PiggyBank/DestroyController.php b/app/Api/V1/Controllers/Models/PiggyBank/DestroyController.php index 5ea137b509..87d78ebc8d 100644 --- a/app/Api/V1/Controllers/Models/PiggyBank/DestroyController.php +++ b/app/Api/V1/Controllers/Models/PiggyBank/DestroyController.php @@ -59,7 +59,7 @@ class DestroyController extends Controller * * Delete the resource. * - * @param PiggyBank $piggyBank + * @param PiggyBank $piggyBank * * @return JsonResponse * @codeCoverageIgnore diff --git a/app/Api/V1/Controllers/Models/PiggyBank/ListController.php b/app/Api/V1/Controllers/Models/PiggyBank/ListController.php index 5d8964746c..8ae793aba3 100644 --- a/app/Api/V1/Controllers/Models/PiggyBank/ListController.php +++ b/app/Api/V1/Controllers/Models/PiggyBank/ListController.php @@ -63,7 +63,7 @@ class ListController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/piggy_banks/listAttachmentByPiggyBank * - * @param PiggyBank $piggyBank + * @param PiggyBank $piggyBank * * @return JsonResponse * @throws FireflyException @@ -72,7 +72,7 @@ class ListController extends Controller public function attachments(PiggyBank $piggyBank): JsonResponse { $manager = $this->getManager(); - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $collection = $this->repository->getAttachments($piggyBank); $count = $collection->count(); @@ -80,7 +80,7 @@ class ListController extends Controller // make paginator: $paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.piggy_banks.attachments', [$piggyBank->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.piggy_banks.attachments', [$piggyBank->id]).$this->buildParams()); /** @var AttachmentTransformer $transformer */ $transformer = app(AttachmentTransformer::class); @@ -98,7 +98,7 @@ class ListController extends Controller * * List single resource. * - * @param PiggyBank $piggyBank + * @param PiggyBank $piggyBank * * @return JsonResponse * @throws FireflyException @@ -107,7 +107,7 @@ class ListController extends Controller public function piggyBankEvents(PiggyBank $piggyBank): JsonResponse { // types to get, page size: - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $manager = $this->getManager(); $collection = $this->repository->getEvents($piggyBank); @@ -116,7 +116,7 @@ class ListController extends Controller // make paginator: $paginator = new LengthAwarePaginator($events, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.piggy_banks.events', [$piggyBank->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.piggy_banks.events', [$piggyBank->id]).$this->buildParams()); /** @var PiggyBankEventTransformer $transformer */ $transformer = app(PiggyBankEventTransformer::class); diff --git a/app/Api/V1/Controllers/Models/PiggyBank/ShowController.php b/app/Api/V1/Controllers/Models/PiggyBank/ShowController.php index dd38e17401..748607cc51 100644 --- a/app/Api/V1/Controllers/Models/PiggyBank/ShowController.php +++ b/app/Api/V1/Controllers/Models/PiggyBank/ShowController.php @@ -73,7 +73,7 @@ class ShowController extends Controller { $manager = $this->getManager(); // types to get, page size: - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; // get list of budgets. Count it and split it. $collection = $this->repository->getPiggyBanks(); @@ -82,7 +82,7 @@ class ShowController extends Controller // make paginator: $paginator = new LengthAwarePaginator($piggyBanks, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.piggy_banks.index') . $this->buildParams()); + $paginator->setPath(route('api.v1.piggy_banks.index').$this->buildParams()); /** @var PiggyBankTransformer $transformer */ $transformer = app(PiggyBankTransformer::class); @@ -100,7 +100,7 @@ class ShowController extends Controller * * List single resource. * - * @param PiggyBank $piggyBank + * @param PiggyBank $piggyBank * * @return JsonResponse * @codeCoverageIgnore diff --git a/app/Api/V1/Controllers/Models/PiggyBank/StoreController.php b/app/Api/V1/Controllers/Models/PiggyBank/StoreController.php index a1bdd1dfc1..b24ce9c958 100644 --- a/app/Api/V1/Controllers/Models/PiggyBank/StoreController.php +++ b/app/Api/V1/Controllers/Models/PiggyBank/StoreController.php @@ -62,7 +62,7 @@ class StoreController extends Controller * * Store new object. * - * @param StoreRequest $request + * @param StoreRequest $request * * @return JsonResponse * @throws FireflyException diff --git a/app/Api/V1/Controllers/Models/PiggyBank/UpdateController.php b/app/Api/V1/Controllers/Models/PiggyBank/UpdateController.php index e156de2672..b4da94b7d1 100644 --- a/app/Api/V1/Controllers/Models/PiggyBank/UpdateController.php +++ b/app/Api/V1/Controllers/Models/PiggyBank/UpdateController.php @@ -62,8 +62,8 @@ class UpdateController extends Controller * * Update piggy bank. * - * @param UpdateRequest $request - * @param PiggyBank $piggyBank + * @param UpdateRequest $request + * @param PiggyBank $piggyBank * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Models/Recurrence/DestroyController.php b/app/Api/V1/Controllers/Models/Recurrence/DestroyController.php index 01d175eb1d..f623884984 100644 --- a/app/Api/V1/Controllers/Models/Recurrence/DestroyController.php +++ b/app/Api/V1/Controllers/Models/Recurrence/DestroyController.php @@ -59,7 +59,7 @@ class DestroyController extends Controller * * Delete the resource. * - * @param Recurrence $recurrence + * @param Recurrence $recurrence * * @return JsonResponse * @codeCoverageIgnore diff --git a/app/Api/V1/Controllers/Models/Recurrence/ListController.php b/app/Api/V1/Controllers/Models/Recurrence/ListController.php index 9b13fc88d7..04617cd30a 100644 --- a/app/Api/V1/Controllers/Models/Recurrence/ListController.php +++ b/app/Api/V1/Controllers/Models/Recurrence/ListController.php @@ -69,8 +69,8 @@ class ListController extends Controller * * Show transactions for this recurrence. * - * @param Request $request - * @param Recurrence $recurrence + * @param Request $request + * @param Recurrence $recurrence * * @return JsonResponse * @throws FireflyException @@ -78,7 +78,7 @@ class ListController extends Controller */ public function transactions(Request $request, Recurrence $recurrence): JsonResponse { - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $type = $request->get('type') ?? 'default'; $this->parameters->set('type', $type); @@ -110,7 +110,7 @@ class ListController extends Controller $collector->setRange($this->parameters->get('start'), $this->parameters->get('end')); } $paginator = $collector->getPaginatedGroups(); - $paginator->setPath(route('api.v1.transactions.index') . $this->buildParams()); + $paginator->setPath(route('api.v1.transactions.index').$this->buildParams()); $transactions = $paginator->getCollection(); /** @var TransactionGroupTransformer $transformer */ diff --git a/app/Api/V1/Controllers/Models/Recurrence/ShowController.php b/app/Api/V1/Controllers/Models/Recurrence/ShowController.php index 8d5bdfd0d0..fe42cb7374 100644 --- a/app/Api/V1/Controllers/Models/Recurrence/ShowController.php +++ b/app/Api/V1/Controllers/Models/Recurrence/ShowController.php @@ -74,7 +74,7 @@ class ShowController extends Controller $manager = $this->getManager(); // types to get, page size: - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; // get list of budgets. Count it and split it. $collection = $this->repository->get(); @@ -83,7 +83,7 @@ class ShowController extends Controller // make paginator: $paginator = new LengthAwarePaginator($piggyBanks, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.recurrences.index') . $this->buildParams()); + $paginator->setPath(route('api.v1.recurrences.index').$this->buildParams()); /** @var RecurrenceTransformer $transformer */ $transformer = app(RecurrenceTransformer::class); @@ -101,7 +101,7 @@ class ShowController extends Controller * * List single resource. * - * @param Recurrence $recurrence + * @param Recurrence $recurrence * * @return JsonResponse * @codeCoverageIgnore diff --git a/app/Api/V1/Controllers/Models/Recurrence/StoreController.php b/app/Api/V1/Controllers/Models/Recurrence/StoreController.php index 8ca5672b2a..f7a2f33a26 100644 --- a/app/Api/V1/Controllers/Models/Recurrence/StoreController.php +++ b/app/Api/V1/Controllers/Models/Recurrence/StoreController.php @@ -62,7 +62,7 @@ class StoreController extends Controller * * Store new object. * - * @param StoreRequest $request + * @param StoreRequest $request * * @return JsonResponse * @throws FireflyException diff --git a/app/Api/V1/Controllers/Models/Recurrence/UpdateController.php b/app/Api/V1/Controllers/Models/Recurrence/UpdateController.php index 4d569dbeec..d77aaa6928 100644 --- a/app/Api/V1/Controllers/Models/Recurrence/UpdateController.php +++ b/app/Api/V1/Controllers/Models/Recurrence/UpdateController.php @@ -62,8 +62,8 @@ class UpdateController extends Controller * * Update single recurrence. * - * @param UpdateRequest $request - * @param Recurrence $recurrence + * @param UpdateRequest $request + * @param Recurrence $recurrence * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Models/Rule/DestroyController.php b/app/Api/V1/Controllers/Models/Rule/DestroyController.php index 70e8f88dd0..a7ad885b96 100644 --- a/app/Api/V1/Controllers/Models/Rule/DestroyController.php +++ b/app/Api/V1/Controllers/Models/Rule/DestroyController.php @@ -63,7 +63,7 @@ class DestroyController extends Controller * * Delete the resource. * - * @param Rule $rule + * @param Rule $rule * * @return JsonResponse * @codeCoverageIgnore diff --git a/app/Api/V1/Controllers/Models/Rule/ShowController.php b/app/Api/V1/Controllers/Models/Rule/ShowController.php index e3ffd674fc..8b12d1c3f6 100644 --- a/app/Api/V1/Controllers/Models/Rule/ShowController.php +++ b/app/Api/V1/Controllers/Models/Rule/ShowController.php @@ -78,7 +78,7 @@ class ShowController extends Controller $manager = $this->getManager(); // types to get, page size: - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; // get list of budgets. Count it and split it. $collection = $this->ruleRepository->getAll(); @@ -87,7 +87,7 @@ class ShowController extends Controller // make paginator: $paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.rules.index') . $this->buildParams()); + $paginator->setPath(route('api.v1.rules.index').$this->buildParams()); /** @var RuleTransformer $transformer */ $transformer = app(RuleTransformer::class); @@ -105,7 +105,7 @@ class ShowController extends Controller * * List single resource. * - * @param Rule $rule + * @param Rule $rule * * @return JsonResponse * @codeCoverageIgnore diff --git a/app/Api/V1/Controllers/Models/Rule/StoreController.php b/app/Api/V1/Controllers/Models/Rule/StoreController.php index 322cf814d5..4cfe601f7f 100644 --- a/app/Api/V1/Controllers/Models/Rule/StoreController.php +++ b/app/Api/V1/Controllers/Models/Rule/StoreController.php @@ -65,7 +65,7 @@ class StoreController extends Controller * * Store new object. * - * @param StoreRequest $request + * @param StoreRequest $request * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Models/Rule/TriggerController.php b/app/Api/V1/Controllers/Models/Rule/TriggerController.php index 528f1e6755..f3eef085b5 100644 --- a/app/Api/V1/Controllers/Models/Rule/TriggerController.php +++ b/app/Api/V1/Controllers/Models/Rule/TriggerController.php @@ -69,8 +69,8 @@ class TriggerController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/rules/testRule * - * @param TestRequest $request - * @param Rule $rule + * @param TestRequest $request + * @param Rule $rule * * @return JsonResponse */ @@ -101,7 +101,7 @@ class TriggerController extends Controller $count = $transactions->count(); $paginator = new LengthAwarePaginator($transactions, $count, 31337, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.rules.test', [$rule->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.rules.test', [$rule->id]).$this->buildParams()); // resulting list is presented as JSON thing. $manager = $this->getManager(); @@ -121,8 +121,8 @@ class TriggerController extends Controller * * Execute the given rule group on a set of existing transactions. * - * @param TriggerRequest $request - * @param Rule $rule + * @param TriggerRequest $request + * @param Rule $rule * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Models/Rule/UpdateController.php b/app/Api/V1/Controllers/Models/Rule/UpdateController.php index b8e3996e8b..df81811814 100644 --- a/app/Api/V1/Controllers/Models/Rule/UpdateController.php +++ b/app/Api/V1/Controllers/Models/Rule/UpdateController.php @@ -66,8 +66,8 @@ class UpdateController extends Controller * * Update a rule. * - * @param UpdateRequest $request - * @param Rule $rule + * @param UpdateRequest $request + * @param Rule $rule * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Models/RuleGroup/DestroyController.php b/app/Api/V1/Controllers/Models/RuleGroup/DestroyController.php index b1e9e9610c..a137a56ac8 100644 --- a/app/Api/V1/Controllers/Models/RuleGroup/DestroyController.php +++ b/app/Api/V1/Controllers/Models/RuleGroup/DestroyController.php @@ -63,7 +63,7 @@ class DestroyController extends Controller * * Delete the resource. * - * @param RuleGroup $ruleGroup + * @param RuleGroup $ruleGroup * * @return JsonResponse * @codeCoverageIgnore diff --git a/app/Api/V1/Controllers/Models/RuleGroup/ListController.php b/app/Api/V1/Controllers/Models/RuleGroup/ListController.php index 26e1ca2767..73027a0e6e 100644 --- a/app/Api/V1/Controllers/Models/RuleGroup/ListController.php +++ b/app/Api/V1/Controllers/Models/RuleGroup/ListController.php @@ -66,7 +66,7 @@ class ListController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/rule_groups/listRuleByGroup * - * @param RuleGroup $group + * @param RuleGroup $group * * @return JsonResponse * @throws FireflyException @@ -76,7 +76,7 @@ class ListController extends Controller { $manager = $this->getManager(); // types to get, page size: - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; // get list of budgets. Count it and split it. $collection = $this->ruleGroupRepository->getRules($group); @@ -85,7 +85,7 @@ class ListController extends Controller // make paginator: $paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.rule_groups.rules', [$group->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.rule_groups.rules', [$group->id]).$this->buildParams()); /** @var RuleTransformer $transformer */ $transformer = app(RuleTransformer::class); diff --git a/app/Api/V1/Controllers/Models/RuleGroup/ShowController.php b/app/Api/V1/Controllers/Models/RuleGroup/ShowController.php index 7c72b09e38..ed525de037 100644 --- a/app/Api/V1/Controllers/Models/RuleGroup/ShowController.php +++ b/app/Api/V1/Controllers/Models/RuleGroup/ShowController.php @@ -76,7 +76,7 @@ class ShowController extends Controller { $manager = $this->getManager(); // types to get, page size: - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; // get list of rule groups. Count it and split it. $collection = $this->ruleGroupRepository->get(); @@ -85,7 +85,7 @@ class ShowController extends Controller // make paginator: $paginator = new LengthAwarePaginator($ruleGroups, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.rule_groups.index') . $this->buildParams()); + $paginator->setPath(route('api.v1.rule_groups.index').$this->buildParams()); /** @var RuleGroupTransformer $transformer */ $transformer = app(RuleGroupTransformer::class); @@ -103,7 +103,7 @@ class ShowController extends Controller * * List single resource. * - * @param RuleGroup $ruleGroup + * @param RuleGroup $ruleGroup * * @return JsonResponse * @codeCoverageIgnore diff --git a/app/Api/V1/Controllers/Models/RuleGroup/StoreController.php b/app/Api/V1/Controllers/Models/RuleGroup/StoreController.php index ce8d81141c..34455a4cf6 100644 --- a/app/Api/V1/Controllers/Models/RuleGroup/StoreController.php +++ b/app/Api/V1/Controllers/Models/RuleGroup/StoreController.php @@ -70,7 +70,7 @@ class StoreController extends Controller * * Store new object. * - * @param StoreRequest $request + * @param StoreRequest $request * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Models/RuleGroup/TriggerController.php b/app/Api/V1/Controllers/Models/RuleGroup/TriggerController.php index 33e83be30c..c909f736c0 100644 --- a/app/Api/V1/Controllers/Models/RuleGroup/TriggerController.php +++ b/app/Api/V1/Controllers/Models/RuleGroup/TriggerController.php @@ -70,8 +70,8 @@ class TriggerController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/rule_groups/testRuleGroup * - * @param TestRequest $request - * @param RuleGroup $group + * @param TestRequest $request + * @param RuleGroup $group * * @return JsonResponse * @throws FireflyException @@ -108,7 +108,7 @@ class TriggerController extends Controller $count = $transactions->count(); $paginator = new LengthAwarePaginator($transactions, $count, 31337, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.rule_groups.test', [$group->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.rule_groups.test', [$group->id]).$this->buildParams()); // resulting list is presented as JSON thing. $manager = $this->getManager(); @@ -128,8 +128,8 @@ class TriggerController extends Controller * * Execute the given rule group on a set of existing transactions. * - * @param TriggerRequest $request - * @param RuleGroup $group + * @param TriggerRequest $request + * @param RuleGroup $group * * @return JsonResponse * @throws Exception diff --git a/app/Api/V1/Controllers/Models/RuleGroup/UpdateController.php b/app/Api/V1/Controllers/Models/RuleGroup/UpdateController.php index 70f9c1a352..8a8115c991 100644 --- a/app/Api/V1/Controllers/Models/RuleGroup/UpdateController.php +++ b/app/Api/V1/Controllers/Models/RuleGroup/UpdateController.php @@ -66,8 +66,8 @@ class UpdateController extends Controller * * Update a rule group. * - * @param UpdateRequest $request - * @param RuleGroup $ruleGroup + * @param UpdateRequest $request + * @param RuleGroup $ruleGroup * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Models/Tag/DestroyController.php b/app/Api/V1/Controllers/Models/Tag/DestroyController.php index cbcecf0be9..ba83bae637 100644 --- a/app/Api/V1/Controllers/Models/Tag/DestroyController.php +++ b/app/Api/V1/Controllers/Models/Tag/DestroyController.php @@ -63,7 +63,7 @@ class DestroyController extends Controller * * Delete the resource. * - * @param Tag $tag + * @param Tag $tag * * @return JsonResponse * @codeCoverageIgnore diff --git a/app/Api/V1/Controllers/Models/Tag/ListController.php b/app/Api/V1/Controllers/Models/Tag/ListController.php index 855a7169f2..7f4196ea52 100644 --- a/app/Api/V1/Controllers/Models/Tag/ListController.php +++ b/app/Api/V1/Controllers/Models/Tag/ListController.php @@ -72,7 +72,7 @@ class ListController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/tags/listAttachmentByTag * - * @param Tag $tag + * @param Tag $tag * * @return JsonResponse * @throws FireflyException @@ -81,7 +81,7 @@ class ListController extends Controller public function attachments(Tag $tag): JsonResponse { $manager = $this->getManager(); - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $collection = $this->repository->getAttachments($tag); $count = $collection->count(); @@ -89,7 +89,7 @@ class ListController extends Controller // make paginator: $paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.tags.attachments', [$tag->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.tags.attachments', [$tag->id]).$this->buildParams()); /** @var AttachmentTransformer $transformer */ $transformer = app(AttachmentTransformer::class); @@ -107,8 +107,8 @@ class ListController extends Controller * * Show all transactions. * - * @param Request $request - * @param Tag $tag + * @param Request $request + * @param Tag $tag * * @return JsonResponse * @throws FireflyException @@ -116,7 +116,7 @@ class ListController extends Controller */ public function transactions(Request $request, Tag $tag): JsonResponse { - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $type = $request->get('type') ?? 'default'; $this->parameters->set('type', $type); @@ -145,7 +145,7 @@ class ListController extends Controller $collector->setRange($this->parameters->get('start'), $this->parameters->get('end')); } $paginator = $collector->getPaginatedGroups(); - $paginator->setPath(route('api.v1.tags.transactions', [$tag->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.tags.transactions', [$tag->id]).$this->buildParams()); $transactions = $paginator->getCollection(); /** @var TransactionGroupTransformer $transformer */ diff --git a/app/Api/V1/Controllers/Models/Tag/ShowController.php b/app/Api/V1/Controllers/Models/Tag/ShowController.php index 2400b9aab6..17620e0fcd 100644 --- a/app/Api/V1/Controllers/Models/Tag/ShowController.php +++ b/app/Api/V1/Controllers/Models/Tag/ShowController.php @@ -77,7 +77,7 @@ class ShowController extends Controller { $manager = $this->getManager(); // types to get, page size: - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; // get list of budgets. Count it and split it. $collection = $this->repository->get(); @@ -86,7 +86,7 @@ class ShowController extends Controller // make paginator: $paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.tags.index') . $this->buildParams()); + $paginator->setPath(route('api.v1.tags.index').$this->buildParams()); /** @var TagTransformer $transformer */ $transformer = app(TagTransformer::class); @@ -104,7 +104,7 @@ class ShowController extends Controller * * List single resource. * - * @param Tag $tag + * @param Tag $tag * * @return JsonResponse * @codeCoverageIgnore diff --git a/app/Api/V1/Controllers/Models/Tag/StoreController.php b/app/Api/V1/Controllers/Models/Tag/StoreController.php index 68df097bda..ab277913a9 100644 --- a/app/Api/V1/Controllers/Models/Tag/StoreController.php +++ b/app/Api/V1/Controllers/Models/Tag/StoreController.php @@ -65,7 +65,7 @@ class StoreController extends Controller * * Store new object. * - * @param StoreRequest $request + * @param StoreRequest $request * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Models/Tag/UpdateController.php b/app/Api/V1/Controllers/Models/Tag/UpdateController.php index 17dc165d29..952b2ac513 100644 --- a/app/Api/V1/Controllers/Models/Tag/UpdateController.php +++ b/app/Api/V1/Controllers/Models/Tag/UpdateController.php @@ -66,8 +66,8 @@ class UpdateController extends Controller * * Update a rule. * - * @param UpdateRequest $request - * @param Tag $tag + * @param UpdateRequest $request + * @param Tag $tag * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Models/Transaction/DestroyController.php b/app/Api/V1/Controllers/Models/Transaction/DestroyController.php index f2c81781ec..95de7b033b 100644 --- a/app/Api/V1/Controllers/Models/Transaction/DestroyController.php +++ b/app/Api/V1/Controllers/Models/Transaction/DestroyController.php @@ -24,7 +24,6 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Models\Transaction; use FireflyIII\Api\V1\Controllers\Controller; -use FireflyIII\Events\DestroyedTransactionGroup; use FireflyIII\Events\UpdatedAccount; use FireflyIII\Models\Account; use FireflyIII\Models\Transaction; @@ -41,8 +40,8 @@ use Log; */ class DestroyController extends Controller { - private JournalRepositoryInterface $repository; private TransactionGroupRepository $groupRepository; + private JournalRepositoryInterface $repository; /** * TransactionController constructor. @@ -74,7 +73,7 @@ class DestroyController extends Controller * * Remove the specified resource from storage. * - * @param TransactionGroup $transactionGroup + * @param TransactionGroup $transactionGroup * * @return JsonResponse * @codeCoverageIgnore @@ -114,7 +113,7 @@ class DestroyController extends Controller * * Remove the specified resource from storage. * - * @param TransactionJournal $transactionJournal + * @param TransactionJournal $transactionJournal * * @codeCoverageIgnore * @return JsonResponse diff --git a/app/Api/V1/Controllers/Models/Transaction/ListController.php b/app/Api/V1/Controllers/Models/Transaction/ListController.php index f08ffa918f..0da0a2b5b4 100644 --- a/app/Api/V1/Controllers/Models/Transaction/ListController.php +++ b/app/Api/V1/Controllers/Models/Transaction/ListController.php @@ -70,7 +70,7 @@ class ListController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/transactions/listAttachmentByTransaction * - * @param TransactionGroup $transactionGroup + * @param TransactionGroup $transactionGroup * * @return JsonResponse * @throws FireflyException @@ -79,7 +79,7 @@ class ListController extends Controller public function attachments(TransactionGroup $transactionGroup): JsonResponse { $manager = $this->getManager(); - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $collection = new Collection(); foreach ($transactionGroup->transactionJournals as $transactionJournal) { $collection = $this->journalAPIRepository->getAttachments($transactionJournal)->merge($collection); @@ -90,7 +90,7 @@ class ListController extends Controller // make paginator: $paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.transactions.attachments', [$transactionGroup->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.transactions.attachments', [$transactionGroup->id]).$this->buildParams()); /** @var AttachmentTransformer $transformer */ $transformer = app(AttachmentTransformer::class); @@ -106,7 +106,7 @@ class ListController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/transactions/listEventByTransaction * - * @param TransactionGroup $transactionGroup + * @param TransactionGroup $transactionGroup * * @return JsonResponse * @throws FireflyException @@ -116,7 +116,7 @@ class ListController extends Controller { $manager = $this->getManager(); $collection = new Collection(); - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; foreach ($transactionGroup->transactionJournals as $transactionJournal) { $collection = $this->journalAPIRepository->getPiggyBankEvents($transactionJournal)->merge($collection); } @@ -124,7 +124,7 @@ class ListController extends Controller $events = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize); // make paginator: $paginator = new LengthAwarePaginator($events, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.transactions.piggy_bank_events', [$transactionGroup->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.transactions.piggy_bank_events', [$transactionGroup->id]).$this->buildParams()); /** @var PiggyBankEventTransformer $transformer */ $transformer = app(PiggyBankEventTransformer::class); @@ -145,7 +145,7 @@ class ListController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/transactions/listLinksByJournal * - * @param TransactionJournal $transactionJournal + * @param TransactionJournal $transactionJournal * * @return JsonResponse * @throws FireflyException @@ -155,13 +155,13 @@ class ListController extends Controller { $manager = $this->getManager(); $collection = $this->journalAPIRepository->getJournalLinks($transactionJournal); - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $count = $collection->count(); $journalLinks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize); // make paginator: $paginator = new LengthAwarePaginator($journalLinks, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.transaction-journals.transaction_links', [$transactionJournal->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.transaction-journals.transaction_links', [$transactionJournal->id]).$this->buildParams()); /** @var TransactionLinkTransformer $transformer */ $transformer = app(TransactionLinkTransformer::class); diff --git a/app/Api/V1/Controllers/Models/Transaction/ShowController.php b/app/Api/V1/Controllers/Models/Transaction/ShowController.php index a200505818..383796dae2 100644 --- a/app/Api/V1/Controllers/Models/Transaction/ShowController.php +++ b/app/Api/V1/Controllers/Models/Transaction/ShowController.php @@ -51,7 +51,7 @@ class ShowController extends Controller * * Show all transactions. * - * @param Request $request + * @param Request $request * * @return JsonResponse * @throws FireflyException @@ -59,7 +59,7 @@ class ShowController extends Controller */ public function index(Request $request): JsonResponse { - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $type = $request->get('type') ?? 'default'; $this->parameters->set('type', $type); @@ -85,7 +85,7 @@ class ShowController extends Controller $collector->setRange($this->parameters->get('start'), $this->parameters->get('end')); } $paginator = $collector->getPaginatedGroups(); - $paginator->setPath(route('api.v1.transactions.index') . $this->buildParams()); + $paginator->setPath(route('api.v1.transactions.index').$this->buildParams()); $transactions = $paginator->getCollection(); /** @var TransactionGroupTransformer $transformer */ @@ -104,7 +104,7 @@ class ShowController extends Controller * * Show a single transaction, by transaction journal. * - * @param TransactionJournal $transactionJournal + * @param TransactionJournal $transactionJournal * * @return JsonResponse * @codeCoverageIgnore @@ -120,7 +120,7 @@ class ShowController extends Controller * * Show a single transaction. * - * @param TransactionGroup $transactionGroup + * @param TransactionGroup $transactionGroup * * @return JsonResponse * @codeCoverageIgnore diff --git a/app/Api/V1/Controllers/Models/Transaction/StoreController.php b/app/Api/V1/Controllers/Models/Transaction/StoreController.php index 24d9375b77..5f1bbcda96 100644 --- a/app/Api/V1/Controllers/Models/Transaction/StoreController.php +++ b/app/Api/V1/Controllers/Models/Transaction/StoreController.php @@ -76,7 +76,7 @@ class StoreController extends Controller * * Store a new transaction. * - * @param StoreRequest $request + * @param StoreRequest $request * * @return JsonResponse * @throws FireflyException|ValidationException diff --git a/app/Api/V1/Controllers/Models/Transaction/UpdateController.php b/app/Api/V1/Controllers/Models/Transaction/UpdateController.php index d2beda1960..9e5c8978a4 100644 --- a/app/Api/V1/Controllers/Models/Transaction/UpdateController.php +++ b/app/Api/V1/Controllers/Models/Transaction/UpdateController.php @@ -70,8 +70,8 @@ class UpdateController extends Controller * * Update a transaction. * - * @param UpdateRequest $request - * @param TransactionGroup $transactionGroup + * @param UpdateRequest $request + * @param TransactionGroup $transactionGroup * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Models/TransactionCurrency/DestroyController.php b/app/Api/V1/Controllers/Models/TransactionCurrency/DestroyController.php index b9a7396caf..f92e69d1cd 100644 --- a/app/Api/V1/Controllers/Models/TransactionCurrency/DestroyController.php +++ b/app/Api/V1/Controllers/Models/TransactionCurrency/DestroyController.php @@ -65,7 +65,7 @@ class DestroyController extends Controller * * Remove the specified resource from storage. * - * @param TransactionCurrency $currency + * @param TransactionCurrency $currency * * @return JsonResponse * @throws FireflyException diff --git a/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.php b/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.php index 2cafef38fb..3f9433022a 100644 --- a/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.php +++ b/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.php @@ -93,8 +93,8 @@ class ListController extends Controller * https://api-docs.firefly-iii.org/#/currencies/listAccountByCurrency * Display a list of accounts. * - * @param Request $request - * @param TransactionCurrency $currency + * @param Request $request + * @param TransactionCurrency $currency * * @return JsonResponse * @throws FireflyException @@ -110,7 +110,7 @@ class ListController extends Controller // types to get, page size: $types = $this->mapAccountTypes($this->parameters->get('type')); - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; // get list of accounts. Count it and split it. /** @var AccountRepositoryInterface $accountRepository */ @@ -120,7 +120,7 @@ class ListController extends Controller // filter list on currency preference: $collection = $unfiltered->filter( static function (Account $account) use ($currency, $accountRepository) { - $currencyId = (int) $accountRepository->getMetaValue($account, 'currency_id'); + $currencyId = (int)$accountRepository->getMetaValue($account, 'currency_id'); return $currencyId === $currency->id; } @@ -131,7 +131,7 @@ class ListController extends Controller // make paginator: $paginator = new LengthAwarePaginator($accounts, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.currencies.accounts', [$currency->code]) . $this->buildParams()); + $paginator->setPath(route('api.v1.currencies.accounts', [$currency->code]).$this->buildParams()); /** @var AccountTransformer $transformer */ $transformer = app(AccountTransformer::class); @@ -148,7 +148,7 @@ class ListController extends Controller * * Display a listing of the resource. * - * @param TransactionCurrency $currency + * @param TransactionCurrency $currency * * @return JsonResponse * @throws FireflyException @@ -158,7 +158,7 @@ class ListController extends Controller { $manager = $this->getManager(); // types to get, page size: - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; // get list of available budgets. Count it and split it. /** @var AvailableBudgetRepositoryInterface $abRepository */ @@ -169,7 +169,7 @@ class ListController extends Controller $availableBudgets = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize); // make paginator: $paginator = new LengthAwarePaginator($availableBudgets, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.currencies.available_budgets', [$currency->code]) . $this->buildParams()); + $paginator->setPath(route('api.v1.currencies.available_budgets', [$currency->code]).$this->buildParams()); /** @var AvailableBudgetTransformer $transformer */ $transformer = app(AvailableBudgetTransformer::class); @@ -187,7 +187,7 @@ class ListController extends Controller * * List all bills * - * @param TransactionCurrency $currency + * @param TransactionCurrency $currency * * @return JsonResponse * @throws FireflyException @@ -199,7 +199,7 @@ class ListController extends Controller /** @var BillRepositoryInterface $billRepos */ $billRepos = app(BillRepositoryInterface::class); - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $unfiltered = $billRepos->getBills(); // filter and paginate list: @@ -213,7 +213,7 @@ class ListController extends Controller // make paginator: $paginator = new LengthAwarePaginator($bills, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.currencies.bills', [$currency->code]) . $this->buildParams()); + $paginator->setPath(route('api.v1.currencies.bills', [$currency->code]).$this->buildParams()); /** @var BillTransformer $transformer */ $transformer = app(BillTransformer::class); @@ -231,7 +231,7 @@ class ListController extends Controller * * List all budget limits * - * @param TransactionCurrency $currency + * @param TransactionCurrency $currency * * @return JsonResponse * @throws FireflyException @@ -243,12 +243,12 @@ class ListController extends Controller $blRepository = app(BudgetLimitRepositoryInterface::class); $manager = $this->getManager(); - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $collection = $blRepository->getAllBudgetLimitsByCurrency($currency, $this->parameters->get('start'), $this->parameters->get('end')); $count = $collection->count(); $budgetLimits = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize); $paginator = new LengthAwarePaginator($budgetLimits, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.currencies.budget_limits', [$currency->code]) . $this->buildParams()); + $paginator->setPath(route('api.v1.currencies.budget_limits', [$currency->code]).$this->buildParams()); /** @var BudgetLimitTransformer $transformer */ $transformer = app(BudgetLimitTransformer::class); @@ -266,7 +266,7 @@ class ListController extends Controller * * List all recurring transactions. * - * @param TransactionCurrency $currency + * @param TransactionCurrency $currency * * @return JsonResponse * @throws FireflyException @@ -276,7 +276,7 @@ class ListController extends Controller { $manager = $this->getManager(); // types to get, page size: - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; // get list of budgets. Count it and split it. /** @var RecurringRepositoryInterface $recurringRepos */ @@ -301,7 +301,7 @@ class ListController extends Controller // make paginator: $paginator = new LengthAwarePaginator($piggyBanks, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.currencies.recurrences', [$currency->code]) . $this->buildParams()); + $paginator->setPath(route('api.v1.currencies.recurrences', [$currency->code]).$this->buildParams()); /** @var RecurrenceTransformer $transformer */ $transformer = app(RecurrenceTransformer::class); @@ -319,7 +319,7 @@ class ListController extends Controller * * List all of them. * - * @param TransactionCurrency $currency + * @param TransactionCurrency $currency * * @return JsonResponse * @throws FireflyException @@ -328,7 +328,7 @@ class ListController extends Controller public function rules(TransactionCurrency $currency): JsonResponse { $manager = $this->getManager(); - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; // get list of budgets. Count it and split it. /** @var RuleRepositoryInterface $ruleRepos */ @@ -353,7 +353,7 @@ class ListController extends Controller // make paginator: $paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.rules.index') . $this->buildParams()); + $paginator->setPath(route('api.v1.rules.index').$this->buildParams()); /** @var RuleTransformer $transformer */ $transformer = app(RuleTransformer::class); @@ -371,9 +371,9 @@ class ListController extends Controller * * Show all transactions. * - * @param Request $request + * @param Request $request * - * @param TransactionCurrency $currency + * @param TransactionCurrency $currency * * @return JsonResponse * @throws FireflyException @@ -381,7 +381,7 @@ class ListController extends Controller */ public function transactions(Request $request, TransactionCurrency $currency): JsonResponse { - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $type = $request->get('type') ?? 'default'; $this->parameters->set('type', $type); @@ -410,7 +410,7 @@ class ListController extends Controller $collector->setRange($this->parameters->get('start'), $this->parameters->get('end')); } $paginator = $collector->getPaginatedGroups(); - $paginator->setPath(route('api.v1.currencies.transactions', [$currency->code]) . $this->buildParams()); + $paginator->setPath(route('api.v1.currencies.transactions', [$currency->code]).$this->buildParams()); $transactions = $paginator->getCollection(); /** @var TransactionGroupTransformer $transformer */ diff --git a/app/Api/V1/Controllers/Models/TransactionCurrency/ShowController.php b/app/Api/V1/Controllers/Models/TransactionCurrency/ShowController.php index 2c3ac82a67..98dc10efef 100644 --- a/app/Api/V1/Controllers/Models/TransactionCurrency/ShowController.php +++ b/app/Api/V1/Controllers/Models/TransactionCurrency/ShowController.php @@ -79,13 +79,13 @@ class ShowController extends Controller */ public function index(): JsonResponse { - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $collection = $this->repository->getAll(); $count = $collection->count(); // slice them: $currencies = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize); $paginator = new LengthAwarePaginator($currencies, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.currencies.index') . $this->buildParams()); + $paginator->setPath(route('api.v1.currencies.index').$this->buildParams()); $manager = $this->getManager(); $defaultCurrency = app('amount')->getDefaultCurrencyByUser(auth()->user()); $this->parameters->set('defaultCurrency', $defaultCurrency); @@ -106,7 +106,7 @@ class ShowController extends Controller * * Show a currency. * - * @param TransactionCurrency $currency + * @param TransactionCurrency $currency * * @return JsonResponse * @throws FireflyException diff --git a/app/Api/V1/Controllers/Models/TransactionCurrency/StoreController.php b/app/Api/V1/Controllers/Models/TransactionCurrency/StoreController.php index cc4a6caa0f..ec9ab9fec4 100644 --- a/app/Api/V1/Controllers/Models/TransactionCurrency/StoreController.php +++ b/app/Api/V1/Controllers/Models/TransactionCurrency/StoreController.php @@ -72,7 +72,7 @@ class StoreController extends Controller * * Store new currency. * - * @param StoreRequest $request + * @param StoreRequest $request * * @return JsonResponse * @throws FireflyException diff --git a/app/Api/V1/Controllers/Models/TransactionCurrency/UpdateController.php b/app/Api/V1/Controllers/Models/TransactionCurrency/UpdateController.php index c69d4415a9..afef552d25 100644 --- a/app/Api/V1/Controllers/Models/TransactionCurrency/UpdateController.php +++ b/app/Api/V1/Controllers/Models/TransactionCurrency/UpdateController.php @@ -73,7 +73,7 @@ class UpdateController extends Controller * * Disable a currency. * - * @param TransactionCurrency $currency + * @param TransactionCurrency $currency * * @return JsonResponse * @throws FireflyException @@ -101,43 +101,13 @@ class UpdateController extends Controller return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE); } - /** - * This endpoint is documented at: - * https://api-docs.firefly-iii.org/#/currencies/enableCurrency - * - * Enable a currency. - * - * @param TransactionCurrency $currency - * - * @return JsonResponse - * @throws FireflyException - * @throws JsonException - * @codeCoverageIgnore - */ - public function enable(TransactionCurrency $currency): JsonResponse - { - $this->repository->enable($currency); - $manager = $this->getManager(); - - $defaultCurrency = app('amount')->getDefaultCurrencyByUser(auth()->user()); - $this->parameters->set('defaultCurrency', $defaultCurrency); - - /** @var CurrencyTransformer $transformer */ - $transformer = app(CurrencyTransformer::class); - $transformer->setParameters($this->parameters); - - $resource = new Item($currency, $transformer, 'currencies'); - - return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE); - } - /** * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/currencies/defaultCurrency * * Make the currency a default currency. * - * @param TransactionCurrency $currency + * @param TransactionCurrency $currency * * @return JsonResponse * @throws FireflyException @@ -163,14 +133,44 @@ class UpdateController extends Controller return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE); } + /** + * This endpoint is documented at: + * https://api-docs.firefly-iii.org/#/currencies/enableCurrency + * + * Enable a currency. + * + * @param TransactionCurrency $currency + * + * @return JsonResponse + * @throws FireflyException + * @throws JsonException + * @codeCoverageIgnore + */ + public function enable(TransactionCurrency $currency): JsonResponse + { + $this->repository->enable($currency); + $manager = $this->getManager(); + + $defaultCurrency = app('amount')->getDefaultCurrencyByUser(auth()->user()); + $this->parameters->set('defaultCurrency', $defaultCurrency); + + /** @var CurrencyTransformer $transformer */ + $transformer = app(CurrencyTransformer::class); + $transformer->setParameters($this->parameters); + + $resource = new Item($currency, $transformer, 'currencies'); + + return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE); + } + /** * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/currencies/updateCurrency * * Update a currency. * - * @param UpdateRequest $request - * @param TransactionCurrency $currency + * @param UpdateRequest $request + * @param TransactionCurrency $currency * * @return JsonResponse * @throws FireflyException diff --git a/app/Api/V1/Controllers/Models/TransactionLink/DestroyController.php b/app/Api/V1/Controllers/Models/TransactionLink/DestroyController.php index 533529c3c0..ff5b2cdb1e 100644 --- a/app/Api/V1/Controllers/Models/TransactionLink/DestroyController.php +++ b/app/Api/V1/Controllers/Models/TransactionLink/DestroyController.php @@ -62,7 +62,7 @@ class DestroyController extends Controller * * Delete the resource. * - * @param TransactionJournalLink $link + * @param TransactionJournalLink $link * * @return JsonResponse * @codeCoverageIgnore diff --git a/app/Api/V1/Controllers/Models/TransactionLink/ShowController.php b/app/Api/V1/Controllers/Models/TransactionLink/ShowController.php index 0f2ef4b6bb..aef868534f 100644 --- a/app/Api/V1/Controllers/Models/TransactionLink/ShowController.php +++ b/app/Api/V1/Controllers/Models/TransactionLink/ShowController.php @@ -69,7 +69,7 @@ class ShowController extends Controller * * List all transaction links there are. * - * @param Request $request + * @param Request $request * * @return JsonResponse * @throws FireflyException @@ -83,7 +83,7 @@ class ShowController extends Controller $name = $request->get('name'); // types to get, page size: - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $linkType = $this->repository->findByName($name); // get list of transaction links. Count it and split it. @@ -93,7 +93,7 @@ class ShowController extends Controller // make paginator: $paginator = new LengthAwarePaginator($journalLinks, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.transaction_links.index') . $this->buildParams()); + $paginator->setPath(route('api.v1.transaction_links.index').$this->buildParams()); /** @var TransactionLinkTransformer $transformer */ $transformer = app(TransactionLinkTransformer::class); @@ -111,7 +111,7 @@ class ShowController extends Controller * * List single resource. * - * @param TransactionJournalLink $journalLink + * @param TransactionJournalLink $journalLink * * @return JsonResponse * @codeCoverageIgnore diff --git a/app/Api/V1/Controllers/Models/TransactionLink/StoreController.php b/app/Api/V1/Controllers/Models/TransactionLink/StoreController.php index 08eaf6de80..6558cdd423 100644 --- a/app/Api/V1/Controllers/Models/TransactionLink/StoreController.php +++ b/app/Api/V1/Controllers/Models/TransactionLink/StoreController.php @@ -72,7 +72,7 @@ class StoreController extends Controller * * Store new object. * - * @param StoreRequest $request + * @param StoreRequest $request * * @return JsonResponse * @throws FireflyException diff --git a/app/Api/V1/Controllers/Models/TransactionLink/UpdateController.php b/app/Api/V1/Controllers/Models/TransactionLink/UpdateController.php index 7543587cfa..2db52ca859 100644 --- a/app/Api/V1/Controllers/Models/TransactionLink/UpdateController.php +++ b/app/Api/V1/Controllers/Models/TransactionLink/UpdateController.php @@ -69,8 +69,8 @@ class UpdateController extends Controller * * Update object. * - * @param UpdateRequest $request - * @param TransactionJournalLink $journalLink + * @param UpdateRequest $request + * @param TransactionJournalLink $journalLink * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Models/TransactionLinkType/DestroyController.php b/app/Api/V1/Controllers/Models/TransactionLinkType/DestroyController.php index 19230dd6c8..c734e31c66 100644 --- a/app/Api/V1/Controllers/Models/TransactionLinkType/DestroyController.php +++ b/app/Api/V1/Controllers/Models/TransactionLinkType/DestroyController.php @@ -70,7 +70,7 @@ class DestroyController extends Controller * * Delete the resource. * - * @param LinkType $linkType + * @param LinkType $linkType * * @return JsonResponse * @throws FireflyException diff --git a/app/Api/V1/Controllers/Models/TransactionLinkType/ListController.php b/app/Api/V1/Controllers/Models/TransactionLinkType/ListController.php index 236e1e354b..3a2a98e750 100644 --- a/app/Api/V1/Controllers/Models/TransactionLinkType/ListController.php +++ b/app/Api/V1/Controllers/Models/TransactionLinkType/ListController.php @@ -73,8 +73,8 @@ class ListController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/links/listTransactionByLinkType * - * @param Request $request - * @param LinkType $linkType + * @param Request $request + * @param LinkType $linkType * * @return JsonResponse * @throws FireflyException @@ -82,7 +82,7 @@ class ListController extends Controller */ public function transactions(Request $request, LinkType $linkType): JsonResponse { - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $type = $request->get('type') ?? 'default'; $this->parameters->set('type', $type); @@ -114,7 +114,7 @@ class ListController extends Controller $collector->setRange($this->parameters->get('start'), $this->parameters->get('end')); } $paginator = $collector->getPaginatedGroups(); - $paginator->setPath(route('api.v1.transactions.index') . $this->buildParams()); + $paginator->setPath(route('api.v1.transactions.index').$this->buildParams()); $transactions = $paginator->getCollection(); /** @var TransactionGroupTransformer $transformer */ diff --git a/app/Api/V1/Controllers/Models/TransactionLinkType/ShowController.php b/app/Api/V1/Controllers/Models/TransactionLinkType/ShowController.php index 70289e6e3c..f0020cce37 100644 --- a/app/Api/V1/Controllers/Models/TransactionLinkType/ShowController.php +++ b/app/Api/V1/Controllers/Models/TransactionLinkType/ShowController.php @@ -82,7 +82,7 @@ class ShowController extends Controller { // create some objects: $manager = $this->getManager(); - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; // get list of accounts. Count it and split it. $collection = $this->repository->get(); @@ -91,7 +91,7 @@ class ShowController extends Controller // make paginator: $paginator = new LengthAwarePaginator($linkTypes, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.link_types.index') . $this->buildParams()); + $paginator->setPath(route('api.v1.link_types.index').$this->buildParams()); /** @var LinkTypeTransformer $transformer */ $transformer = app(LinkTypeTransformer::class); @@ -109,7 +109,7 @@ class ShowController extends Controller * * List single resource. * - * @param LinkType $linkType + * @param LinkType $linkType * * @return JsonResponse * @codeCoverageIgnore diff --git a/app/Api/V1/Controllers/Models/TransactionLinkType/StoreController.php b/app/Api/V1/Controllers/Models/TransactionLinkType/StoreController.php index 1a839b2b83..abd1a748e7 100644 --- a/app/Api/V1/Controllers/Models/TransactionLinkType/StoreController.php +++ b/app/Api/V1/Controllers/Models/TransactionLinkType/StoreController.php @@ -72,7 +72,7 @@ class StoreController extends Controller * * Store new object. * - * @param StoreRequest $request + * @param StoreRequest $request * * @return JsonResponse * @throws FireflyException diff --git a/app/Api/V1/Controllers/Models/TransactionLinkType/UpdateController.php b/app/Api/V1/Controllers/Models/TransactionLinkType/UpdateController.php index 1b15727943..ddd55e6688 100644 --- a/app/Api/V1/Controllers/Models/TransactionLinkType/UpdateController.php +++ b/app/Api/V1/Controllers/Models/TransactionLinkType/UpdateController.php @@ -73,8 +73,8 @@ class UpdateController extends Controller * * Update object. * - * @param UpdateRequest $request - * @param LinkType $linkType + * @param UpdateRequest $request + * @param LinkType $linkType * * @return JsonResponse * @throws FireflyException diff --git a/app/Api/V1/Controllers/Search/AccountController.php b/app/Api/V1/Controllers/Search/AccountController.php index 2950b6cf17..e79ba13306 100644 --- a/app/Api/V1/Controllers/Search/AccountController.php +++ b/app/Api/V1/Controllers/Search/AccountController.php @@ -61,7 +61,7 @@ class AccountController extends Controller /** * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/search/searchAccounts - * @param Request $request + * @param Request $request * * @return JsonResponse|Response * @throws JsonException @@ -70,8 +70,8 @@ class AccountController extends Controller { Log::debug('Now in account search()'); $manager = $this->getManager(); - $query = trim((string) $request->get('query')); - $field = trim((string) $request->get('field')); + $query = trim((string)$request->get('query')); + $field = trim((string)$request->get('field')); $type = $request->get('type') ?? 'all'; if ('' === $query || !in_array($field, $this->validFields, true)) { return response(null, 422); diff --git a/app/Api/V1/Controllers/Search/TransactionController.php b/app/Api/V1/Controllers/Search/TransactionController.php index 016af96eda..9255da7713 100644 --- a/app/Api/V1/Controllers/Search/TransactionController.php +++ b/app/Api/V1/Controllers/Search/TransactionController.php @@ -42,8 +42,8 @@ class TransactionController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/search/searchTransactions * - * @param Request $request - * @param SearchInterface $searcher + * @param Request $request + * @param SearchInterface $searcher * * @return JsonResponse * @throws FireflyException @@ -51,16 +51,16 @@ class TransactionController extends Controller public function search(Request $request, SearchInterface $searcher): JsonResponse { $manager = $this->getManager(); - $fullQuery = (string) $request->get('query'); - $page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page'); - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; - $pageSize = 0 === (int) $request->get('limit') ? $pageSize : (int) $request->get('limit'); + $fullQuery = (string)$request->get('query'); + $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page'); + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = 0 === (int)$request->get('limit') ? $pageSize : (int)$request->get('limit'); $searcher->parseQuery($fullQuery); $searcher->setPage($page); $searcher->setLimit($pageSize); $groups = $searcher->searchTransactions(); $parameters = ['search' => $fullQuery]; - $url = route('api.v1.search.transactions') . '?' . http_build_query($parameters); + $url = route('api.v1.search.transactions').'?'.http_build_query($parameters); $groups->setPath($url); $transactions = $groups->getCollection(); diff --git a/app/Api/V1/Controllers/Summary/BasicController.php b/app/Api/V1/Controllers/Summary/BasicController.php index 5f56706121..1ea7ef2967 100644 --- a/app/Api/V1/Controllers/Summary/BasicController.php +++ b/app/Api/V1/Controllers/Summary/BasicController.php @@ -90,7 +90,7 @@ class BasicController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/summary/getBasicSummary * - * @param DateRequest $request + * @param DateRequest $request * * @return JsonResponse * @throws Exception @@ -122,8 +122,8 @@ class BasicController extends Controller } /** - * @param Carbon $start - * @param Carbon $end + * @param Carbon $start + * @param Carbon $end * * @return array */ @@ -148,7 +148,7 @@ class BasicController extends Controller $set = $collector->getExtractedJournals(); /** @var array $transactionJournal */ foreach ($set as $transactionJournal) { - $currencyId = (int) $transactionJournal['currency_id']; + $currencyId = (int)$transactionJournal['currency_id']; $incomes[$currencyId] = $incomes[$currencyId] ?? '0'; $incomes[$currencyId] = bcadd( $incomes[$currencyId], @@ -171,7 +171,7 @@ class BasicController extends Controller /** @var array $transactionJournal */ foreach ($set as $transactionJournal) { - $currencyId = (int) $transactionJournal['currency_id']; + $currencyId = (int)$transactionJournal['currency_id']; $expenses[$currencyId] = $expenses[$currencyId] ?? '0'; $expenses[$currencyId] = bcadd($expenses[$currencyId], $transactionJournal['amount']); $sums[$currencyId] = $sums[$currencyId] ?? '0'; @@ -189,15 +189,15 @@ class BasicController extends Controller $return[] = [ 'key' => sprintf('balance-in-%s', $currency->code), 'title' => trans('firefly.box_balance_in_currency', ['currency' => $currency->symbol]), - 'monetary_value' => $sums[$currencyId] ?? '0', + 'monetary_value' => $sums[$currencyId] ?? '0', 'currency_id' => $currency->id, 'currency_code' => $currency->code, 'currency_symbol' => $currency->symbol, 'currency_decimal_places' => $currency->decimal_places, 'value_parsed' => app('amount')->formatAnything($currency, $sums[$currencyId] ?? '0', false), 'local_icon' => 'balance-scale', - 'sub_title' => app('amount')->formatAnything($currency, $expenses[$currencyId] ?? '0', false) . - ' + ' . app('amount')->formatAnything($currency, $incomes[$currencyId] ?? '0', false), + 'sub_title' => app('amount')->formatAnything($currency, $expenses[$currencyId] ?? '0', false). + ' + '.app('amount')->formatAnything($currency, $incomes[$currencyId] ?? '0', false), ]; $return[] = [ 'key' => sprintf('spent-in-%s', $currency->code), @@ -229,8 +229,8 @@ class BasicController extends Controller } /** - * @param Carbon $start - * @param Carbon $end + * @param Carbon $start + * @param Carbon $end * * @return array */ @@ -245,14 +245,14 @@ class BasicController extends Controller $return = []; foreach ($paidAmount as $currencyId => $amount) { $amount = bcmul($amount, '-1'); - $currency = $this->currencyRepos->find((int) $currencyId); + $currency = $this->currencyRepos->find((int)$currencyId); if (null === $currency) { continue; } $return[] = [ 'key' => sprintf('bills-paid-in-%s', $currency->code), 'title' => trans('firefly.box_bill_paid_in_currency', ['currency' => $currency->symbol]), - 'monetary_value' => $amount, + 'monetary_value' => $amount, 'currency_id' => $currency->id, 'currency_code' => $currency->code, 'currency_symbol' => $currency->symbol, @@ -265,7 +265,7 @@ class BasicController extends Controller foreach ($unpaidAmount as $currencyId => $amount) { $amount = bcmul($amount, '-1'); - $currency = $this->currencyRepos->find((int) $currencyId); + $currency = $this->currencyRepos->find((int)$currencyId); if (null === $currency) { continue; } @@ -287,8 +287,8 @@ class BasicController extends Controller } /** - * @param Carbon $start - * @param Carbon $end + * @param Carbon $start + * @param Carbon $end * * @return array * @throws Exception @@ -310,27 +310,29 @@ class BasicController extends Controller $days = $today->diffInDays($end) + 1; $perDay = '0'; if (0 !== $days && bccomp($leftToSpend, '0') > -1) { - $perDay = bcdiv($leftToSpend, (string) $days); + $perDay = bcdiv($leftToSpend, (string)$days); } $return[] = [ 'key' => sprintf('left-to-spend-in-%s', $row['currency_code']), 'title' => trans('firefly.box_left_to_spend_in_currency', ['currency' => $row['currency_symbol']]), - 'monetary_value' => $leftToSpend, + 'monetary_value' => $leftToSpend, 'currency_id' => $row['currency_id'], 'currency_code' => $row['currency_code'], 'currency_symbol' => $row['currency_symbol'], 'currency_decimal_places' => $row['currency_decimal_places'], 'value_parsed' => app('amount')->formatFlat($row['currency_symbol'], $row['currency_decimal_places'], $leftToSpend, false), 'local_icon' => 'money', - 'sub_title' => (string) trans( + 'sub_title' => (string)trans( 'firefly.box_spend_per_day', - ['amount' => app('amount')->formatFlat( - $row['currency_symbol'], - $row['currency_decimal_places'], - $perDay, - false - )] + [ + 'amount' => app('amount')->formatFlat( + $row['currency_symbol'], + $row['currency_decimal_places'], + $perDay, + false + ), + ] ), ]; } @@ -339,8 +341,8 @@ class BasicController extends Controller } /** - * @param Carbon $start - * @param Carbon $end + * @param Carbon $start + * @param Carbon $end * * @return array */ @@ -374,7 +376,7 @@ class BasicController extends Controller foreach ($netWorthSet as $data) { /** @var TransactionCurrency $currency */ $currency = $data['currency']; - $amount = $data['balance']; + $amount = $data['balance']; if (0 === bccomp($amount, '0')) { continue; } @@ -399,10 +401,10 @@ class BasicController extends Controller /** * Check if date is outside session range. * - * @param Carbon $date + * @param Carbon $date * - * @param Carbon $start - * @param Carbon $end + * @param Carbon $start + * @param Carbon $end * * @return bool */ diff --git a/app/Api/V1/Controllers/System/ConfigurationController.php b/app/Api/V1/Controllers/System/ConfigurationController.php index 552a901336..eb5f4437fd 100644 --- a/app/Api/V1/Controllers/System/ConfigurationController.php +++ b/app/Api/V1/Controllers/System/ConfigurationController.php @@ -108,8 +108,8 @@ class ConfigurationController extends Controller return [ 'is_demo_site' => $isDemoSite?->data, - 'permission_update_check' => null === $updateCheck ? null : (int) $updateCheck->data, - 'last_update_check' => null === $lastCheck ? null : (int) $lastCheck->data, + 'permission_update_check' => null === $updateCheck ? null : (int)$updateCheck->data, + 'last_update_check' => null === $lastCheck ? null : (int)$lastCheck->data, 'single_user_mode' => $singleUser?->data, ]; } @@ -132,7 +132,7 @@ class ConfigurationController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/configuration/getSingleConfiguration * - * @param string $configKey + * @param string $configKey * * @return JsonResponse * @throws FireflyException @@ -166,8 +166,8 @@ class ConfigurationController extends Controller * * Update the configuration. * - * @param UpdateRequest $request - * @param string $name + * @param UpdateRequest $request + * @param string $name * * @return JsonResponse * @throws FireflyException diff --git a/app/Api/V1/Controllers/System/CronController.php b/app/Api/V1/Controllers/System/CronController.php index 59ab407f03..c76a39c097 100644 --- a/app/Api/V1/Controllers/System/CronController.php +++ b/app/Api/V1/Controllers/System/CronController.php @@ -40,8 +40,8 @@ class CronController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/about/getCron * - * @param CronRequest $request - * @param string $token + * @param CronRequest $request + * @param string $token * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/System/UserController.php b/app/Api/V1/Controllers/System/UserController.php index a1ef8d64fa..b96ea03f24 100644 --- a/app/Api/V1/Controllers/System/UserController.php +++ b/app/Api/V1/Controllers/System/UserController.php @@ -67,7 +67,7 @@ class UserController extends Controller * * Remove the specified resource from storage. * - * @param User $user + * @param User $user * * @return JsonResponse * @throws FireflyException @@ -102,7 +102,7 @@ class UserController extends Controller public function index(): JsonResponse { // user preferences - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $manager = $this->getManager(); // build collection @@ -112,7 +112,7 @@ class UserController extends Controller // make paginator: $paginator = new LengthAwarePaginator($users, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.users.index') . $this->buildParams()); + $paginator->setPath(route('api.v1.users.index').$this->buildParams()); // make resource /** @var UserTransformer $transformer */ @@ -131,7 +131,7 @@ class UserController extends Controller * * Show a single user. * - * @param User $user + * @param User $user * * @return JsonResponse * @codeCoverageIgnore @@ -156,7 +156,7 @@ class UserController extends Controller * * Store a new user. * - * @param UserStoreRequest $request + * @param UserStoreRequest $request * * @return JsonResponse */ @@ -183,8 +183,8 @@ class UserController extends Controller * * Update a user. * - * @param UserUpdateRequest $request - * @param User $user + * @param UserUpdateRequest $request + * @param User $user * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/User/PreferencesController.php b/app/Api/V1/Controllers/User/PreferencesController.php index 8bd14d5d55..4baf172ba3 100644 --- a/app/Api/V1/Controllers/User/PreferencesController.php +++ b/app/Api/V1/Controllers/User/PreferencesController.php @@ -59,12 +59,12 @@ class PreferencesController extends Controller $collection = app('preferences')->all(); $manager = $this->getManager(); $count = $collection->count(); - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $preferences = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize); // make paginator: $paginator = new LengthAwarePaginator($preferences, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.preferences.index') . $this->buildParams()); + $paginator->setPath(route('api.v1.preferences.index').$this->buildParams()); /** @var PreferenceTransformer $transformer */ $transformer = app(PreferenceTransformer::class); @@ -82,7 +82,7 @@ class PreferencesController extends Controller * * Return a single preference by name. * - * @param Preference $preference + * @param Preference $preference * * @return JsonResponse * @codeCoverageIgnore @@ -103,7 +103,7 @@ class PreferencesController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/preferences/storePreference * - * @param PreferenceStoreRequest $request + * @param PreferenceStoreRequest $request * * @return JsonResponse * @throws FireflyException @@ -127,8 +127,8 @@ class PreferencesController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/preferences/updatePreference * - * @param PreferenceUpdateRequest $request - * @param Preference $preference + * @param PreferenceUpdateRequest $request + * @param Preference $preference * * @return JsonResponse * @throws FireflyException diff --git a/app/Api/V1/Controllers/Webhook/AttemptController.php b/app/Api/V1/Controllers/Webhook/AttemptController.php index 1f51ad302a..7b705a0a6a 100644 --- a/app/Api/V1/Controllers/Webhook/AttemptController.php +++ b/app/Api/V1/Controllers/Webhook/AttemptController.php @@ -64,8 +64,8 @@ class AttemptController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/webhooks/getWebhookMessageAttempts * - * @param Webhook $webhook - * @param WebhookMessage $message + * @param Webhook $webhook + * @param WebhookMessage $message * * @return JsonResponse * @throws FireflyException @@ -77,14 +77,14 @@ class AttemptController extends Controller } $manager = $this->getManager(); - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $collection = $this->repository->getAttempts($message); $count = $collection->count(); $attempts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize); // make paginator: $paginator = new LengthAwarePaginator($attempts, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.webhooks.attempts.index', [$webhook->id, $message->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.webhooks.attempts.index', [$webhook->id, $message->id]).$this->buildParams()); /** @var WebhookAttemptTransformer $transformer */ $transformer = app(WebhookAttemptTransformer::class); @@ -102,9 +102,9 @@ class AttemptController extends Controller * * Show single instance. * - * @param Webhook $webhook - * @param WebhookMessage $message - * @param WebhookAttempt $attempt + * @param Webhook $webhook + * @param WebhookMessage $message + * @param WebhookAttempt $attempt * * @return JsonResponse * @throws FireflyException diff --git a/app/Api/V1/Controllers/Webhook/DestroyController.php b/app/Api/V1/Controllers/Webhook/DestroyController.php index bbe2fbb833..329e9f5e56 100644 --- a/app/Api/V1/Controllers/Webhook/DestroyController.php +++ b/app/Api/V1/Controllers/Webhook/DestroyController.php @@ -61,7 +61,7 @@ class DestroyController extends Controller * * Remove the specified resource from storage. * - * @param Webhook $webhook + * @param Webhook $webhook * * @return JsonResponse * @codeCoverageIgnore @@ -80,9 +80,9 @@ class DestroyController extends Controller * * Remove the specified resource from storage. * - * @param Webhook $webhook - * @param WebhookMessage $message - * @param WebhookAttempt $attempt + * @param Webhook $webhook + * @param WebhookMessage $message + * @param WebhookAttempt $attempt * * @return JsonResponse * @throws FireflyException @@ -109,8 +109,8 @@ class DestroyController extends Controller * * Remove the specified resource from storage. * - * @param Webhook $webhook - * @param WebhookMessage $message + * @param Webhook $webhook + * @param WebhookMessage $message * * @return JsonResponse * @throws FireflyException diff --git a/app/Api/V1/Controllers/Webhook/MessageController.php b/app/Api/V1/Controllers/Webhook/MessageController.php index 6263cf7ea9..54a77fd2c5 100644 --- a/app/Api/V1/Controllers/Webhook/MessageController.php +++ b/app/Api/V1/Controllers/Webhook/MessageController.php @@ -60,7 +60,7 @@ class MessageController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/webhooks/getWebhookMessages * - * @param Webhook $webhook + * @param Webhook $webhook * * @return JsonResponse * @throws FireflyException @@ -68,7 +68,7 @@ class MessageController extends Controller public function index(Webhook $webhook): JsonResponse { $manager = $this->getManager(); - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $collection = $this->repository->getMessages($webhook); $count = $collection->count(); @@ -76,7 +76,7 @@ class MessageController extends Controller // make paginator: $paginator = new LengthAwarePaginator($messages, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.webhooks.messages.index', [$webhook->id]) . $this->buildParams()); + $paginator->setPath(route('api.v1.webhooks.messages.index', [$webhook->id]).$this->buildParams()); /** @var WebhookMessageTransformer $transformer */ $transformer = app(WebhookMessageTransformer::class); @@ -94,8 +94,8 @@ class MessageController extends Controller * * Show single instance. * - * @param Webhook $webhook - * @param WebhookMessage $message + * @param Webhook $webhook + * @param WebhookMessage $message * * @return JsonResponse * @throws FireflyException diff --git a/app/Api/V1/Controllers/Webhook/ShowController.php b/app/Api/V1/Controllers/Webhook/ShowController.php index 22550f00e3..177b960492 100644 --- a/app/Api/V1/Controllers/Webhook/ShowController.php +++ b/app/Api/V1/Controllers/Webhook/ShowController.php @@ -72,13 +72,13 @@ class ShowController extends Controller { $manager = $this->getManager(); $collection = $this->repository->all(); - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $count = $collection->count(); $webhooks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize); // make paginator: $paginator = new LengthAwarePaginator($webhooks, $count, $pageSize, $this->parameters->get('page')); - $paginator->setPath(route('api.v1.webhooks.index') . $this->buildParams()); + $paginator->setPath(route('api.v1.webhooks.index').$this->buildParams()); /** @var WebhookTransformer $transformer */ $transformer = app(WebhookTransformer::class); @@ -96,7 +96,7 @@ class ShowController extends Controller * * Show single instance. * - * @param Webhook $webhook + * @param Webhook $webhook * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Webhook/StoreController.php b/app/Api/V1/Controllers/Webhook/StoreController.php index a55a8659cd..057e1a8c25 100644 --- a/app/Api/V1/Controllers/Webhook/StoreController.php +++ b/app/Api/V1/Controllers/Webhook/StoreController.php @@ -58,7 +58,7 @@ class StoreController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/webhooks/storeWebhook * - * @param CreateRequest $request + * @param CreateRequest $request * * @return JsonResponse */ diff --git a/app/Api/V1/Controllers/Webhook/SubmitController.php b/app/Api/V1/Controllers/Webhook/SubmitController.php index 989a118b26..c8d9677382 100644 --- a/app/Api/V1/Controllers/Webhook/SubmitController.php +++ b/app/Api/V1/Controllers/Webhook/SubmitController.php @@ -58,7 +58,7 @@ class SubmitController extends Controller * * Remove the specified resource from storage. * - * @param Webhook $webhook + * @param Webhook $webhook * * @return JsonResponse * @codeCoverageIgnore diff --git a/app/Api/V1/Controllers/Webhook/UpdateController.php b/app/Api/V1/Controllers/Webhook/UpdateController.php index 144d6c4d8a..54b9f850d0 100644 --- a/app/Api/V1/Controllers/Webhook/UpdateController.php +++ b/app/Api/V1/Controllers/Webhook/UpdateController.php @@ -58,8 +58,8 @@ class UpdateController extends Controller * This endpoint is documented at: * https://api-docs.firefly-iii.org/#/webhooks/updateWebhook * - * @param Webhook $webhook - * @param UpdateRequest $request + * @param Webhook $webhook + * @param UpdateRequest $request * * @return JsonResponse */ diff --git a/app/Api/V1/Middleware/ApiDemoUser.php b/app/Api/V1/Middleware/ApiDemoUser.php index 00a369d3de..2573ee939d 100644 --- a/app/Api/V1/Middleware/ApiDemoUser.php +++ b/app/Api/V1/Middleware/ApiDemoUser.php @@ -1,4 +1,5 @@ getData(); + $data = $validator->getData(); $repository = app(AccountRepositoryInterface::class); $repository->setUser(auth()->user()); - $original = $repository->find((int) $data['original_account']); - $destination = $repository->find((int) $data['destination_account']); + $original = $repository->find((int)$data['original_account']); + $destination = $repository->find((int)$data['destination_account']); // not the same type: if ($original->accountType->type !== $destination->accountType->type) { - $validator->errors()->add('title', (string) trans('validation.same_account_type')); + $validator->errors()->add('title', (string)trans('validation.same_account_type')); return; } @@ -105,7 +105,7 @@ class MoveTransactionsRequest extends FormRequest // check different scenario's. if (null === $originalCurrency xor null === $destinationCurrency) { - $validator->errors()->add('title', (string) trans('validation.same_account_currency')); + $validator->errors()->add('title', (string)trans('validation.same_account_currency')); return; } @@ -114,7 +114,7 @@ class MoveTransactionsRequest extends FormRequest return; } if ($originalCurrency->code !== $destinationCurrency->code) { - $validator->errors()->add('title', (string) trans('validation.same_account_currency')); + $validator->errors()->add('title', (string)trans('validation.same_account_currency')); } } } diff --git a/app/Api/V1/Requests/Data/Bulk/TransactionRequest.php b/app/Api/V1/Requests/Data/Bulk/TransactionRequest.php index 59567b875d..df540c26db 100644 --- a/app/Api/V1/Requests/Data/Bulk/TransactionRequest.php +++ b/app/Api/V1/Requests/Data/Bulk/TransactionRequest.php @@ -72,7 +72,7 @@ class TransactionRequest extends FormRequest } /** - * @param Validator $validator + * @param Validator $validator * * @return void */ diff --git a/app/Api/V1/Requests/Data/DestroyRequest.php b/app/Api/V1/Requests/Data/DestroyRequest.php index 06df600ea5..bc8026c703 100644 --- a/app/Api/V1/Requests/Data/DestroyRequest.php +++ b/app/Api/V1/Requests/Data/DestroyRequest.php @@ -52,7 +52,7 @@ class DestroyRequest extends FormRequest */ public function rules(): array { - $valid = 'budgets,bills,piggy_banks,rules,recurring,categories,tags,object_groups' . + $valid = 'budgets,bills,piggy_banks,rules,recurring,categories,tags,object_groups'. ',accounts,asset_accounts,expense_accounts,revenue_accounts,liabilities,transactions,withdrawals,deposits,transfers'; return [ diff --git a/app/Api/V1/Requests/Data/Export/ExportRequest.php b/app/Api/V1/Requests/Data/Export/ExportRequest.php index d22a1f3d36..ce41ef1bc3 100644 --- a/app/Api/V1/Requests/Data/Export/ExportRequest.php +++ b/app/Api/V1/Requests/Data/Export/ExportRequest.php @@ -52,7 +52,7 @@ class ExportRequest extends FormRequest $accounts = new Collection(); foreach ($parts as $part) { - $accountId = (int) $part; + $accountId = (int)$part; if (0 !== $accountId) { $account = $repository->find($accountId); if (null !== $account && AccountType::ASSET === $account->accountType->type) { diff --git a/app/Api/V1/Requests/Insight/GenericRequest.php b/app/Api/V1/Requests/Insight/GenericRequest.php index 8d7103d111..3e9f3b255e 100644 --- a/app/Api/V1/Requests/Insight/GenericRequest.php +++ b/app/Api/V1/Requests/Insight/GenericRequest.php @@ -95,7 +95,7 @@ class GenericRequest extends FormRequest $array = $this->get('accounts'); if (is_array($array)) { foreach ($array as $accountId) { - $accountId = (int) $accountId; + $accountId = (int)$accountId; $account = $repository->find($accountId); if (null !== $account) { $this->accounts->push($account); @@ -127,7 +127,7 @@ class GenericRequest extends FormRequest $array = $this->get('bills'); if (is_array($array)) { foreach ($array as $billId) { - $billId = (int) $billId; + $billId = (int)$billId; $bill = $repository->find($billId); if (null !== $bill) { $this->bills->push($bill); @@ -159,7 +159,7 @@ class GenericRequest extends FormRequest $array = $this->get('budgets'); if (is_array($array)) { foreach ($array as $budgetId) { - $budgetId = (int) $budgetId; + $budgetId = (int)$budgetId; $budget = $repository->find($budgetId); if (null !== $budget) { $this->budgets->push($budget); @@ -191,7 +191,7 @@ class GenericRequest extends FormRequest $array = $this->get('categories'); if (is_array($array)) { foreach ($array as $categoryId) { - $categoryId = (int) $categoryId; + $categoryId = (int)$categoryId; $category = $repository->find($categoryId); if (null !== $category) { $this->categories->push($category); @@ -281,7 +281,7 @@ class GenericRequest extends FormRequest $array = $this->get('tags'); if (is_array($array)) { foreach ($array as $tagId) { - $tagId = (int) $tagId; + $tagId = (int)$tagId; $tag = $repository->find($tagId); if (null !== $tag) { $this->tags->push($tag); diff --git a/app/Api/V1/Requests/Models/Account/StoreRequest.php b/app/Api/V1/Requests/Models/Account/StoreRequest.php index da30e22c5b..e758863e66 100644 --- a/app/Api/V1/Requests/Models/Account/StoreRequest.php +++ b/app/Api/V1/Requests/Models/Account/StoreRequest.php @@ -106,7 +106,7 @@ class StoreRequest extends FormRequest $type = $this->convertString('type'); $rules = [ 'name' => 'required|min:1|uniqueAccountForUser', - 'type' => 'required|min:1|' . sprintf('in:%s', $types), + 'type' => 'required|min:1|'.sprintf('in:%s', $types), 'iban' => ['iban', 'nullable', new UniqueIban(null, $type)], 'bic' => 'bic|nullable', 'account_number' => ['between:1,255', 'nullable', new UniqueAccountNumber(null, $type)], diff --git a/app/Api/V1/Requests/Models/Account/UpdateRequest.php b/app/Api/V1/Requests/Models/Account/UpdateRequest.php index 20b228b802..1bacf98792 100644 --- a/app/Api/V1/Requests/Models/Account/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Account/UpdateRequest.php @@ -123,7 +123,7 @@ class UpdateRequest extends FormRequest 'include_net_worth' => [new IsBoolean()], 'account_role' => sprintf('in:%s|nullable|required_if:type,asset', $accountRoles), 'credit_card_type' => sprintf('in:%s|nullable|required_if:account_role,ccAsset', $ccPaymentTypes), - 'monthly_payment_date' => 'date' . '|nullable|required_if:account_role,ccAsset|required_if:credit_card_type,monthlyFull', + 'monthly_payment_date' => 'date'.'|nullable|required_if:account_role,ccAsset|required_if:credit_card_type,monthlyFull', 'liability_type' => 'required_if:type,liability|in:loan,debt,mortgage', 'liability_direction' => 'required_if:type,liability|in:credit,debit', 'interest' => 'required_if:type,liability|between:0,100|numeric', diff --git a/app/Api/V1/Requests/Models/AvailableBudget/Request.php b/app/Api/V1/Requests/Models/AvailableBudget/Request.php index 6bcca4dbfd..3e7fcb126a 100644 --- a/app/Api/V1/Requests/Models/AvailableBudget/Request.php +++ b/app/Api/V1/Requests/Models/AvailableBudget/Request.php @@ -77,7 +77,7 @@ class Request extends FormRequest /** * Configure the validator instance with special rules for after the basic validation rules. * - * @param Validator $validator + * @param Validator $validator * * @return void */ @@ -91,7 +91,7 @@ class Request extends FormRequest $start = new Carbon($data['start']); $end = new Carbon($data['end']); if ($end->isBefore($start)) { - $validator->errors()->add('end', (string) trans('validation.date_after')); + $validator->errors()->add('end', (string)trans('validation.date_after')); } } } diff --git a/app/Api/V1/Requests/Models/Bill/StoreRequest.php b/app/Api/V1/Requests/Models/Bill/StoreRequest.php index 59ec7b6dc8..deb73635c0 100644 --- a/app/Api/V1/Requests/Models/Bill/StoreRequest.php +++ b/app/Api/V1/Requests/Models/Bill/StoreRequest.php @@ -96,7 +96,7 @@ class StoreRequest extends FormRequest /** * Configure the validator instance. * - * @param Validator $validator + * @param Validator $validator * * @return void */ @@ -109,7 +109,7 @@ class StoreRequest extends FormRequest $max = $data['amount_max'] ?? '0'; if (1 === bccomp($min, $max)) { - $validator->errors()->add('amount_min', (string) trans('validation.amount_min_over_max')); + $validator->errors()->add('amount_min', (string)trans('validation.amount_min_over_max')); } } ); diff --git a/app/Api/V1/Requests/Models/Bill/UpdateRequest.php b/app/Api/V1/Requests/Models/Bill/UpdateRequest.php index 6b587390a8..26de59a084 100644 --- a/app/Api/V1/Requests/Models/Bill/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Bill/UpdateRequest.php @@ -98,7 +98,7 @@ class UpdateRequest extends FormRequest /** * Configure the validator instance. * - * @param Validator $validator + * @param Validator $validator * * @return void */ @@ -108,11 +108,11 @@ class UpdateRequest extends FormRequest static function (Validator $validator) { $data = $validator->getData(); if (array_key_exists('amount_min', $data) && array_key_exists('amount_max', $data)) { - $min = $data['amount_min'] ?? '0'; - $max = $data['amount_max'] ?? '0'; + $min = $data['amount_min'] ?? '0'; + $max = $data['amount_max'] ?? '0'; if (1 === bccomp($min, $max)) { - $validator->errors()->add('amount_min', (string) trans('validation.amount_min_over_max')); + $validator->errors()->add('amount_min', (string)trans('validation.amount_min_over_max')); } } } diff --git a/app/Api/V1/Requests/Models/Budget/StoreRequest.php b/app/Api/V1/Requests/Models/Budget/StoreRequest.php index 6e62053a73..c5344bb8b7 100644 --- a/app/Api/V1/Requests/Models/Budget/StoreRequest.php +++ b/app/Api/V1/Requests/Models/Budget/StoreRequest.php @@ -88,7 +88,7 @@ class StoreRequest extends FormRequest /** * Configure the validator instance with special rules for after the basic validation rules. * - * @param Validator $validator + * @param Validator $validator * * @return void */ diff --git a/app/Api/V1/Requests/Models/Budget/UpdateRequest.php b/app/Api/V1/Requests/Models/Budget/UpdateRequest.php index c989478415..46550b434e 100644 --- a/app/Api/V1/Requests/Models/Budget/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Budget/UpdateRequest.php @@ -99,7 +99,7 @@ class UpdateRequest extends FormRequest /** * Configure the validator instance with special rules for after the basic validation rules. * - * @param Validator $validator + * @param Validator $validator * * @return void */ diff --git a/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php b/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php index 5aa4858fa2..02aab4659d 100644 --- a/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php @@ -76,7 +76,7 @@ class UpdateRequest extends FormRequest /** * Configure the validator instance with special rules for after the basic validation rules. * - * @param Validator $validator + * @param Validator $validator * TODO duplicate code * * @return void @@ -91,7 +91,7 @@ class UpdateRequest extends FormRequest $start = new Carbon($data['start']); $end = new Carbon($data['end']); if ($end->isBefore($start)) { - $validator->errors()->add('end', (string) trans('validation.date_after')); + $validator->errors()->add('end', (string)trans('validation.date_after')); } } } diff --git a/app/Api/V1/Requests/Models/PiggyBank/UpdateRequest.php b/app/Api/V1/Requests/Models/PiggyBank/UpdateRequest.php index e3f41da58c..14af9dd6ae 100644 --- a/app/Api/V1/Requests/Models/PiggyBank/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/PiggyBank/UpdateRequest.php @@ -74,7 +74,7 @@ class UpdateRequest extends FormRequest $piggyBank = $this->route()->parameter('piggyBank'); return [ - 'name' => 'between:1,255|uniquePiggyBankForUser:' . $piggyBank->id, + 'name' => 'between:1,255|uniquePiggyBankForUser:'.$piggyBank->id, 'current_amount' => ['numeric', 'gte:0', new LessThanPiggyTarget()], 'target_amount' => 'numeric|gt:0', 'start_date' => 'date|nullable', diff --git a/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php b/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php index 1dfc9435a5..6892791352 100644 --- a/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php +++ b/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php @@ -120,10 +120,10 @@ class StoreRequest extends FormRequest $current['moment'] = $repetition['moment']; } if (array_key_exists('skip', $repetition)) { - $current['skip'] = (int) $repetition['skip']; + $current['skip'] = (int)$repetition['skip']; } if (array_key_exists('weekend', $repetition)) { - $current['weekend'] = (int) $repetition['weekend']; + $current['weekend'] = (int)$repetition['weekend']; } $return[] = $current; @@ -180,7 +180,7 @@ class StoreRequest extends FormRequest /** * Configure the validator instance. * - * @param Validator $validator + * @param Validator $validator * * @return void */ diff --git a/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php b/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php index 6fa38d1644..2677ab6157 100644 --- a/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php @@ -102,15 +102,15 @@ class UpdateRequest extends FormRequest } if (array_key_exists('moment', $repetition)) { - $current['moment'] = (string) $repetition['moment']; + $current['moment'] = (string)$repetition['moment']; } if (array_key_exists('skip', $repetition)) { - $current['skip'] = (int) $repetition['skip']; + $current['skip'] = (int)$repetition['skip']; } if (array_key_exists('weekend', $repetition)) { - $current['weekend'] = (int) $repetition['weekend']; + $current['weekend'] = (int)$repetition['weekend']; } $return[] = $current; } @@ -195,7 +195,7 @@ class UpdateRequest extends FormRequest /** * Configure the validator instance. * - * @param Validator $validator + * @param Validator $validator * * @return void */ diff --git a/app/Api/V1/Requests/Models/Rule/StoreRequest.php b/app/Api/V1/Requests/Models/Rule/StoreRequest.php index 7cc6b5c12b..024bfb4da5 100644 --- a/app/Api/V1/Requests/Models/Rule/StoreRequest.php +++ b/app/Api/V1/Requests/Models/Rule/StoreRequest.php @@ -79,8 +79,8 @@ class StoreRequest extends FormRequest $return[] = [ 'type' => $trigger['type'], 'value' => $trigger['value'], - 'active' => $this->convertBoolean((string) ($trigger['active'] ?? 'false')), - 'stop_processing' => $this->convertBoolean((string) ($trigger['stop_processing'] ?? 'false')), + 'active' => $this->convertBoolean((string)($trigger['active'] ?? 'false')), + 'stop_processing' => $this->convertBoolean((string)($trigger['stop_processing'] ?? 'false')), ]; } } @@ -100,8 +100,8 @@ class StoreRequest extends FormRequest $return[] = [ 'type' => $action['type'], 'value' => $action['value'], - 'active' => $this->convertBoolean((string) ($action['active'] ?? 'false')), - 'stop_processing' => $this->convertBoolean((string) ($action['stop_processing'] ?? 'false')), + 'active' => $this->convertBoolean((string)($action['active'] ?? 'false')), + 'stop_processing' => $this->convertBoolean((string)($action['stop_processing'] ?? 'false')), ]; } } @@ -129,12 +129,12 @@ class StoreRequest extends FormRequest 'rule_group_id' => 'belongsToUser:rule_groups|required_without:rule_group_title', 'rule_group_title' => 'nullable|between:1,255|required_without:rule_group_id|belongsToUser:rule_groups,title', 'trigger' => 'required|in:store-journal,update-journal', - 'triggers.*.type' => 'required|in:' . implode(',', $validTriggers), - 'triggers.*.value' => 'required_if:actions.*.type,' . $contextTriggers . '|min:1|ruleTriggerValue', + 'triggers.*.type' => 'required|in:'.implode(',', $validTriggers), + 'triggers.*.value' => 'required_if:actions.*.type,'.$contextTriggers.'|min:1|ruleTriggerValue', 'triggers.*.stop_processing' => [new IsBoolean()], 'triggers.*.active' => [new IsBoolean()], - 'actions.*.type' => 'required|in:' . implode(',', $validActions), - 'actions.*.value' => 'required_if:actions.*.type,' . $contextActions . '|ruleActionValue', + 'actions.*.type' => 'required|in:'.implode(',', $validActions), + 'actions.*.value' => 'required_if:actions.*.type,'.$contextActions.'|ruleActionValue', 'actions.*.stop_processing' => [new IsBoolean()], 'actions.*.active' => [new IsBoolean()], 'strict' => [new IsBoolean()], @@ -146,7 +146,7 @@ class StoreRequest extends FormRequest /** * Configure the validator instance. * - * @param Validator $validator + * @param Validator $validator * * @return void */ @@ -165,7 +165,7 @@ class StoreRequest extends FormRequest /** * Adds an error to the validator when there are no triggers in the array of data. * - * @param Validator $validator + * @param Validator $validator */ protected function atLeastOneTrigger(Validator $validator): void { @@ -173,14 +173,14 @@ class StoreRequest extends FormRequest $triggers = $data['triggers'] ?? []; // need at least one trigger if (!is_countable($triggers) || 0 === count($triggers)) { - $validator->errors()->add('title', (string) trans('validation.at_least_one_trigger')); + $validator->errors()->add('title', (string)trans('validation.at_least_one_trigger')); } } /** * Adds an error to the validator when there are no repetitions in the array of data. * - * @param Validator $validator + * @param Validator $validator */ protected function atLeastOneAction(Validator $validator): void { @@ -188,14 +188,14 @@ class StoreRequest extends FormRequest $actions = $data['actions'] ?? []; // need at least one trigger if (!is_countable($actions) || 0 === count($actions)) { - $validator->errors()->add('title', (string) trans('validation.at_least_one_action')); + $validator->errors()->add('title', (string)trans('validation.at_least_one_action')); } } /** * Adds an error to the validator when there are no ACTIVE triggers in the array of data. * - * @param Validator $validator + * @param Validator $validator */ protected function atLeastOneActiveTrigger(Validator $validator): void { @@ -217,14 +217,14 @@ class StoreRequest extends FormRequest } } if (true === $allInactive) { - $validator->errors()->add(sprintf('triggers.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_trigger')); + $validator->errors()->add(sprintf('triggers.%d.active', $inactiveIndex), (string)trans('validation.at_least_one_active_trigger')); } } /** * Adds an error to the validator when there are no ACTIVE actions in the array of data. * - * @param Validator $validator + * @param Validator $validator */ protected function atLeastOneActiveAction(Validator $validator): void { @@ -246,7 +246,7 @@ class StoreRequest extends FormRequest } } if (true === $allInactive) { - $validator->errors()->add(sprintf('actions.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_action')); + $validator->errors()->add(sprintf('actions.%d.active', $inactiveIndex), (string)trans('validation.at_least_one_active_action')); } } } diff --git a/app/Api/V1/Requests/Models/Rule/TestRequest.php b/app/Api/V1/Requests/Models/Rule/TestRequest.php index a34ce0408b..b4708f3df6 100644 --- a/app/Api/V1/Requests/Models/Rule/TestRequest.php +++ b/app/Api/V1/Requests/Models/Rule/TestRequest.php @@ -56,11 +56,11 @@ class TestRequest extends FormRequest */ private function getPage(): int { - return 0 === (int) $this->query('page') ? 1 : (int) $this->query('page'); + return 0 === (int)$this->query('page') ? 1 : (int)$this->query('page'); } /** - * @param string $field + * @param string $field * * @return Carbon|null */ diff --git a/app/Api/V1/Requests/Models/Rule/TriggerRequest.php b/app/Api/V1/Requests/Models/Rule/TriggerRequest.php index 12785842c1..ce5cc1b9a0 100644 --- a/app/Api/V1/Requests/Models/Rule/TriggerRequest.php +++ b/app/Api/V1/Requests/Models/Rule/TriggerRequest.php @@ -50,7 +50,7 @@ class TriggerRequest extends FormRequest } /** - * @param string $field + * @param string $field * * @return Carbon|null */ diff --git a/app/Api/V1/Requests/Models/Rule/UpdateRequest.php b/app/Api/V1/Requests/Models/Rule/UpdateRequest.php index dcbf686dd2..ab51cdd56c 100644 --- a/app/Api/V1/Requests/Models/Rule/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Rule/UpdateRequest.php @@ -114,8 +114,8 @@ class UpdateRequest extends FormRequest $return[] = [ 'type' => $action['type'], 'value' => $action['value'], - 'active' => $this->convertBoolean((string) ($action['active'] ?? 'false')), - 'stop_processing' => $this->convertBoolean((string) ($action['stop_processing'] ?? 'false')), + 'active' => $this->convertBoolean((string)($action['active'] ?? 'false')), + 'stop_processing' => $this->convertBoolean((string)($action['stop_processing'] ?? 'false')), ]; } } @@ -134,7 +134,7 @@ class UpdateRequest extends FormRequest $validActions = array_keys(config('firefly.rule-actions')); /** @var Rule $rule */ - $rule = $this->route()->parameter('rule'); + $rule = $this->route()->parameter('rule'); // some triggers and actions require text: $contextTriggers = implode(',', $this->getTriggersWithContext()); @@ -146,12 +146,12 @@ class UpdateRequest extends FormRequest 'rule_group_id' => 'belongsToUser:rule_groups', 'rule_group_title' => 'nullable|between:1,255|belongsToUser:rule_groups,title', 'trigger' => 'in:store-journal,update-journal', - 'triggers.*.type' => 'required|in:' . implode(',', $validTriggers), - 'triggers.*.value' => 'required_if:actions.*.type,' . $contextTriggers . '|min:1|ruleTriggerValue', + 'triggers.*.type' => 'required|in:'.implode(',', $validTriggers), + 'triggers.*.value' => 'required_if:actions.*.type,'.$contextTriggers.'|min:1|ruleTriggerValue', 'triggers.*.stop_processing' => [new IsBoolean()], 'triggers.*.active' => [new IsBoolean()], - 'actions.*.type' => 'required|in:' . implode(',', $validActions), - 'actions.*.value' => 'required_if:actions.*.type,' . $contextActions . '|ruleActionValue', + 'actions.*.type' => 'required|in:'.implode(',', $validActions), + 'actions.*.value' => 'required_if:actions.*.type,'.$contextActions.'|ruleActionValue', 'actions.*.stop_processing' => [new IsBoolean()], 'actions.*.active' => [new IsBoolean()], 'strict' => [new IsBoolean()], @@ -164,7 +164,7 @@ class UpdateRequest extends FormRequest /** * Configure the validator instance. * - * @param Validator $validator + * @param Validator $validator * * @return void */ @@ -183,7 +183,7 @@ class UpdateRequest extends FormRequest /** * Adds an error to the validator when there are no repetitions in the array of data. * - * @param Validator $validator + * @param Validator $validator */ protected function atLeastOneTrigger(Validator $validator): void { @@ -191,14 +191,14 @@ class UpdateRequest extends FormRequest $triggers = $data['triggers'] ?? null; // need at least one trigger if (is_array($triggers) && 0 === count($triggers)) { - $validator->errors()->add('title', (string) trans('validation.at_least_one_trigger')); + $validator->errors()->add('title', (string)trans('validation.at_least_one_trigger')); } } /** * Adds an error to the validator when there are no repetitions in the array of data. * - * @param Validator $validator + * @param Validator $validator */ protected function atLeastOneValidTrigger(Validator $validator): void { @@ -220,14 +220,14 @@ class UpdateRequest extends FormRequest } } if (true === $allInactive) { - $validator->errors()->add(sprintf('triggers.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_trigger')); + $validator->errors()->add(sprintf('triggers.%d.active', $inactiveIndex), (string)trans('validation.at_least_one_active_trigger')); } } /** * Adds an error to the validator when there are no repetitions in the array of data. * - * @param Validator $validator + * @param Validator $validator */ protected function atLeastOneAction(Validator $validator): void { @@ -235,14 +235,14 @@ class UpdateRequest extends FormRequest $actions = $data['actions'] ?? null; // need at least one action if (is_array($actions) && 0 === count($actions)) { - $validator->errors()->add('title', (string) trans('validation.at_least_one_action')); + $validator->errors()->add('title', (string)trans('validation.at_least_one_action')); } } /** * Adds an error to the validator when there are no repetitions in the array of data. * - * @param Validator $validator + * @param Validator $validator */ protected function atLeastOneValidAction(Validator $validator): void { @@ -265,7 +265,7 @@ class UpdateRequest extends FormRequest } } if (true === $allInactive) { - $validator->errors()->add(sprintf('actions.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_action')); + $validator->errors()->add(sprintf('actions.%d.active', $inactiveIndex), (string)trans('validation.at_least_one_active_action')); } } } diff --git a/app/Api/V1/Requests/Models/RuleGroup/TestRequest.php b/app/Api/V1/Requests/Models/RuleGroup/TestRequest.php index 81226973b5..b48c050cba 100644 --- a/app/Api/V1/Requests/Models/RuleGroup/TestRequest.php +++ b/app/Api/V1/Requests/Models/RuleGroup/TestRequest.php @@ -50,7 +50,7 @@ class TestRequest extends FormRequest } /** - * @param string $field + * @param string $field * * @return Carbon|null */ diff --git a/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.php b/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.php index 4d9514307a..cd84f3fe2e 100644 --- a/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.php +++ b/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.php @@ -50,7 +50,7 @@ class TriggerRequest extends FormRequest } /** - * @param string $field + * @param string $field * * @return Carbon|null */ diff --git a/app/Api/V1/Requests/Models/RuleGroup/UpdateRequest.php b/app/Api/V1/Requests/Models/RuleGroup/UpdateRequest.php index 2cab0d7552..3d354e475a 100644 --- a/app/Api/V1/Requests/Models/RuleGroup/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/RuleGroup/UpdateRequest.php @@ -67,7 +67,7 @@ class UpdateRequest extends FormRequest $ruleGroup = $this->route()->parameter('ruleGroup'); return [ - 'title' => 'between:1,100|uniqueObjectForUser:rule_groups,title,' . $ruleGroup->id, + 'title' => 'between:1,100|uniqueObjectForUser:rule_groups,title,'.$ruleGroup->id, 'description' => 'between:1,5000|nullable', 'active' => [new IsBoolean()], ]; diff --git a/app/Api/V1/Requests/Models/Tag/UpdateRequest.php b/app/Api/V1/Requests/Models/Tag/UpdateRequest.php index 9783e723c0..a5e2e059d7 100644 --- a/app/Api/V1/Requests/Models/Tag/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Tag/UpdateRequest.php @@ -71,7 +71,7 @@ class UpdateRequest extends FormRequest $tag = $this->route()->parameter('tagOrId'); // TODO check if uniqueObjectForUser is obsolete $rules = [ - 'tag' => 'min:1|uniqueObjectForUser:tags,tag,' . $tag->id, + 'tag' => 'min:1|uniqueObjectForUser:tags,tag,'.$tag->id, 'description' => 'min:1|nullable', 'date' => 'date|nullable', ]; diff --git a/app/Api/V1/Requests/Models/Transaction/StoreRequest.php b/app/Api/V1/Requests/Models/Transaction/StoreRequest.php index be900ae35a..20d5e6de13 100644 --- a/app/Api/V1/Requests/Models/Transaction/StoreRequest.php +++ b/app/Api/V1/Requests/Models/Transaction/StoreRequest.php @@ -85,73 +85,73 @@ class StoreRequest extends FormRequest $return[] = [ 'type' => $this->clearString($object['type'], false), 'date' => $this->dateFromValue($object['date']), - 'order' => $this->integerFromValue((string) $object['order']), + 'order' => $this->integerFromValue((string)$object['order']), - 'currency_id' => $this->integerFromValue((string) $object['currency_id']), - 'currency_code' => $this->clearString((string) $object['currency_code'], false), + 'currency_id' => $this->integerFromValue((string)$object['currency_id']), + 'currency_code' => $this->clearString((string)$object['currency_code'], false), // foreign currency info: - 'foreign_currency_id' => $this->integerFromValue((string) $object['foreign_currency_id']), - 'foreign_currency_code' => $this->clearString((string) $object['foreign_currency_code'], false), + 'foreign_currency_id' => $this->integerFromValue((string)$object['foreign_currency_id']), + 'foreign_currency_code' => $this->clearString((string)$object['foreign_currency_code'], false), // amount and foreign amount. Cannot be 0. - 'amount' => $this->clearString((string) $object['amount'], false), - 'foreign_amount' => $this->clearString((string) $object['foreign_amount'], false), + 'amount' => $this->clearString((string)$object['amount'], false), + 'foreign_amount' => $this->clearString((string)$object['foreign_amount'], false), // description. 'description' => $this->clearString($object['description'], false), // source of transaction. If everything is null, assume cash account. - 'source_id' => $this->integerFromValue((string) $object['source_id']), - 'source_name' => $this->clearString((string) $object['source_name'], false), - 'source_iban' => $this->clearString((string) $object['source_iban'], false), - 'source_number' => $this->clearString((string) $object['source_number'], false), - 'source_bic' => $this->clearString((string) $object['source_bic'], false), + 'source_id' => $this->integerFromValue((string)$object['source_id']), + 'source_name' => $this->clearString((string)$object['source_name'], false), + 'source_iban' => $this->clearString((string)$object['source_iban'], false), + 'source_number' => $this->clearString((string)$object['source_number'], false), + 'source_bic' => $this->clearString((string)$object['source_bic'], false), // destination of transaction. If everything is null, assume cash account. - 'destination_id' => $this->integerFromValue((string) $object['destination_id']), - 'destination_name' => $this->clearString((string) $object['destination_name'], false), - 'destination_iban' => $this->clearString((string) $object['destination_iban'], false), - 'destination_number' => $this->clearString((string) $object['destination_number'], false), - 'destination_bic' => $this->clearString((string) $object['destination_bic'], false), + 'destination_id' => $this->integerFromValue((string)$object['destination_id']), + 'destination_name' => $this->clearString((string)$object['destination_name'], false), + 'destination_iban' => $this->clearString((string)$object['destination_iban'], false), + 'destination_number' => $this->clearString((string)$object['destination_number'], false), + 'destination_bic' => $this->clearString((string)$object['destination_bic'], false), // budget info - 'budget_id' => $this->integerFromValue((string) $object['budget_id']), - 'budget_name' => $this->clearString((string) $object['budget_name'], false), + 'budget_id' => $this->integerFromValue((string)$object['budget_id']), + 'budget_name' => $this->clearString((string)$object['budget_name'], false), // category info - 'category_id' => $this->integerFromValue((string) $object['category_id']), - 'category_name' => $this->clearString((string) $object['category_name'], false), + 'category_id' => $this->integerFromValue((string)$object['category_id']), + 'category_name' => $this->clearString((string)$object['category_name'], false), // journal bill reference. Optional. Will only work for withdrawals - 'bill_id' => $this->integerFromValue((string) $object['bill_id']), - 'bill_name' => $this->clearString((string) $object['bill_name'], false), + 'bill_id' => $this->integerFromValue((string)$object['bill_id']), + 'bill_name' => $this->clearString((string)$object['bill_name'], false), // piggy bank reference. Optional. Will only work for transfers - 'piggy_bank_id' => $this->integerFromValue((string) $object['piggy_bank_id']), - 'piggy_bank_name' => $this->clearString((string) $object['piggy_bank_name'], false), + 'piggy_bank_id' => $this->integerFromValue((string)$object['piggy_bank_id']), + 'piggy_bank_name' => $this->clearString((string)$object['piggy_bank_name'], false), // some other interesting properties - 'reconciled' => $this->convertBoolean((string) $object['reconciled']), - 'notes' => $this->clearString((string) $object['notes']), + 'reconciled' => $this->convertBoolean((string)$object['reconciled']), + 'notes' => $this->clearString((string)$object['notes']), 'tags' => $this->arrayFromValue($object['tags']), // all custom fields: - 'internal_reference' => $this->clearString((string) $object['internal_reference'], false), - 'external_id' => $this->clearString((string) $object['external_id'], false), + 'internal_reference' => $this->clearString((string)$object['internal_reference'], false), + 'external_id' => $this->clearString((string)$object['external_id'], false), 'original_source' => sprintf('ff3-v%s|api-v%s', config('firefly.version'), config('firefly.api_version')), 'recurrence_id' => $this->integerFromValue($object['recurrence_id']), - 'bunq_payment_id' => $this->clearString((string) $object['bunq_payment_id'], false), - 'external_url' => $this->clearString((string) $object['external_url'], false), + 'bunq_payment_id' => $this->clearString((string)$object['bunq_payment_id'], false), + 'external_url' => $this->clearString((string)$object['external_url'], false), - 'sepa_cc' => $this->clearString((string) $object['sepa_cc'], false), - 'sepa_ct_op' => $this->clearString((string) $object['sepa_ct_op'], false), - 'sepa_ct_id' => $this->clearString((string) $object['sepa_ct_id'], false), - 'sepa_db' => $this->clearString((string) $object['sepa_db'], false), - 'sepa_country' => $this->clearString((string) $object['sepa_country'], false), - 'sepa_ep' => $this->clearString((string) $object['sepa_ep'], false), - 'sepa_ci' => $this->clearString((string) $object['sepa_ci'], false), - 'sepa_batch_id' => $this->clearString((string) $object['sepa_batch_id'], false), + 'sepa_cc' => $this->clearString((string)$object['sepa_cc'], false), + 'sepa_ct_op' => $this->clearString((string)$object['sepa_ct_op'], false), + 'sepa_ct_id' => $this->clearString((string)$object['sepa_ct_id'], false), + 'sepa_db' => $this->clearString((string)$object['sepa_db'], false), + 'sepa_country' => $this->clearString((string)$object['sepa_country'], false), + 'sepa_ep' => $this->clearString((string)$object['sepa_ep'], false), + 'sepa_ci' => $this->clearString((string)$object['sepa_ci'], false), + 'sepa_batch_id' => $this->clearString((string)$object['sepa_batch_id'], false), // custom date fields. Must be Carbon objects. Presence is optional. 'interest_date' => $this->dateFromValue($object['interest_date']), 'book_date' => $this->dateFromValue($object['book_date']), @@ -258,7 +258,7 @@ class StoreRequest extends FormRequest /** * Configure the validator instance. * - * @param Validator $validator + * @param Validator $validator * * @return void */ diff --git a/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php b/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php index a02c864854..3148f02422 100644 --- a/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php @@ -49,9 +49,9 @@ class UpdateRequest extends FormRequest private array $arrayFields; private array $booleanFields; private array $dateFields; + private array $floatFields; private array $integerFields; private array $stringFields; - private array $floatFields; private array $textareaFields; /** @@ -89,8 +89,8 @@ class UpdateRequest extends FormRequest ]; $this->floatFields = [ // not really floats, for validation. - 'amount', - 'foreign_amount', + 'amount', + 'foreign_amount', ]; $this->stringFields = [ @@ -180,8 +180,8 @@ class UpdateRequest extends FormRequest /** * For each field, add it to the array if a reference is present in the request: * - * @param array $current - * @param array $transaction + * @param array $current + * @param array $transaction * * @return array */ @@ -189,7 +189,7 @@ class UpdateRequest extends FormRequest { foreach ($this->integerFields as $fieldName) { if (array_key_exists($fieldName, $transaction)) { - $current[$fieldName] = $this->integerFromValue((string) $transaction[$fieldName]); + $current[$fieldName] = $this->integerFromValue((string)$transaction[$fieldName]); } } @@ -197,8 +197,8 @@ class UpdateRequest extends FormRequest } /** - * @param array $current - * @param array $transaction + * @param array $current + * @param array $transaction * * @return array */ @@ -206,7 +206,7 @@ class UpdateRequest extends FormRequest { foreach ($this->stringFields as $fieldName) { if (array_key_exists($fieldName, $transaction)) { - $current[$fieldName] = $this->clearString((string) $transaction[$fieldName], false); + $current[$fieldName] = $this->clearString((string)$transaction[$fieldName], false); } } @@ -214,8 +214,8 @@ class UpdateRequest extends FormRequest } /** - * @param array $current - * @param array $transaction + * @param array $current + * @param array $transaction * * @return array */ @@ -223,7 +223,7 @@ class UpdateRequest extends FormRequest { foreach ($this->textareaFields as $fieldName) { if (array_key_exists($fieldName, $transaction)) { - $current[$fieldName] = $this->clearString((string) $transaction[$fieldName]); + $current[$fieldName] = $this->clearString((string)$transaction[$fieldName]); } } @@ -231,8 +231,8 @@ class UpdateRequest extends FormRequest } /** - * @param array $current - * @param array $transaction + * @param array $current + * @param array $transaction * * @return array */ @@ -241,8 +241,8 @@ class UpdateRequest extends FormRequest foreach ($this->dateFields as $fieldName) { Log::debug(sprintf('Now at date field %s', $fieldName)); if (array_key_exists($fieldName, $transaction)) { - Log::debug(sprintf('New value: "%s"', (string) $transaction[$fieldName])); - $current[$fieldName] = $this->dateFromValue((string) $transaction[$fieldName]); + Log::debug(sprintf('New value: "%s"', (string)$transaction[$fieldName])); + $current[$fieldName] = $this->dateFromValue((string)$transaction[$fieldName]); } } @@ -250,8 +250,8 @@ class UpdateRequest extends FormRequest } /** - * @param array $current - * @param array $transaction + * @param array $current + * @param array $transaction * * @return array */ @@ -259,7 +259,7 @@ class UpdateRequest extends FormRequest { foreach ($this->booleanFields as $fieldName) { if (array_key_exists($fieldName, $transaction)) { - $current[$fieldName] = $this->convertBoolean((string) $transaction[$fieldName]); + $current[$fieldName] = $this->convertBoolean((string)$transaction[$fieldName]); } } @@ -267,8 +267,8 @@ class UpdateRequest extends FormRequest } /** - * @param array $current - * @param array $transaction + * @param array $current + * @param array $transaction * * @return array */ @@ -283,6 +283,28 @@ class UpdateRequest extends FormRequest return $current; } + /** + * @param array $current + * @param array $transaction + * @return array + */ + private function getFloatData(array $current, array $transaction): array + { + foreach ($this->floatFields as $fieldName) { + if (array_key_exists($fieldName, $transaction)) { + $value = $transaction[$fieldName]; + if (is_float($value)) { + $current[$fieldName] = sprintf('%.24f', $value); + } + if (!is_float($value)) { + $current[$fieldName] = (string)$value; + } + } + } + + return $current; + } + /** * The rules that the incoming request must be matched against. * @@ -368,7 +390,7 @@ class UpdateRequest extends FormRequest /** * Configure the validator instance. * - * @param Validator $validator + * @param Validator $validator * * @return void */ @@ -396,26 +418,4 @@ class UpdateRequest extends FormRequest } ); } - - /** - * @param array $current - * @param array $transaction - * @return array - */ - private function getFloatData(array $current, array $transaction): array - { - foreach ($this->floatFields as $fieldName) { - if (array_key_exists($fieldName, $transaction)) { - $value = $transaction[$fieldName]; - if (is_float($value)) { - $current[$fieldName] = sprintf('%.24f', $value); - } - if (!is_float($value)) { - $current[$fieldName] = (string) $value; - } - } - } - - return $current; - } } diff --git a/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php b/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php index 9d77154dff..af57c23d31 100644 --- a/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php +++ b/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php @@ -74,7 +74,7 @@ class StoreRequest extends FormRequest /** * Configure the validator instance. * - * @param Validator $validator + * @param Validator $validator * * @return void */ @@ -88,7 +88,7 @@ class StoreRequest extends FormRequest } /** - * @param Validator $validator + * @param Validator $validator */ private function validateExistingLink(Validator $validator): void { @@ -103,8 +103,8 @@ class StoreRequest extends FormRequest $journalRepos->setUser($user); $data = $validator->getData(); - $inwardId = (int) ($data['inward_id'] ?? 0); - $outwardId = (int) ($data['outward_id'] ?? 0); + $inwardId = (int)($data['inward_id'] ?? 0); + $outwardId = (int)($data['outward_id'] ?? 0); $inward = $journalRepos->find($inwardId); $outward = $journalRepos->find($outwardId); diff --git a/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php b/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php index 82e31be5d8..e63121c47b 100644 --- a/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php @@ -74,7 +74,7 @@ class UpdateRequest extends FormRequest /** * Configure the validator instance. * - * @param Validator $validator + * @param Validator $validator * * @return void */ @@ -88,7 +88,7 @@ class UpdateRequest extends FormRequest } /** - * @param Validator $validator + * @param Validator $validator */ private function validateUpdate(Validator $validator): void { @@ -105,8 +105,8 @@ class UpdateRequest extends FormRequest $inwardId = $data['inward_id'] ?? $existing->source_id; $outwardId = $data['outward_id'] ?? $existing->destination_id; - $inward = $journalRepos->find((int) $inwardId); - $outward = $journalRepos->find((int) $outwardId); + $inward = $journalRepos->find((int)$inwardId); + $outward = $journalRepos->find((int)$outwardId); if (null === $inward) { $inward = $existing->source; } diff --git a/app/Api/V1/Requests/Models/TransactionLinkType/UpdateRequest.php b/app/Api/V1/Requests/Models/TransactionLinkType/UpdateRequest.php index a49a1f4c17..5f4aaa79f0 100644 --- a/app/Api/V1/Requests/Models/TransactionLinkType/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/TransactionLinkType/UpdateRequest.php @@ -24,7 +24,6 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\TransactionLinkType; use FireflyIII\Models\LinkType; -use FireflyIII\Models\TransactionJournalLink; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; diff --git a/app/Api/V1/Requests/Models/Webhook/UpdateRequest.php b/app/Api/V1/Requests/Models/Webhook/UpdateRequest.php index 6aa3a907c3..0cff3d42c4 100644 --- a/app/Api/V1/Requests/Models/Webhook/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Webhook/UpdateRequest.php @@ -86,7 +86,7 @@ class UpdateRequest extends FormRequest $deliveries = implode(',', array_keys(Webhook::getDeliveriesForValidation())); /** @var Webhook $webhook */ - $webhook = $this->route()->parameter('webhook'); + $webhook = $this->route()->parameter('webhook'); return [ 'title' => sprintf('between:1,512|uniqueObjectForUser:webhooks,title,%d', $webhook->id), diff --git a/app/Api/V1/Requests/System/UserUpdateRequest.php b/app/Api/V1/Requests/System/UserUpdateRequest.php index b3383e1c80..bef66149fd 100644 --- a/app/Api/V1/Requests/System/UserUpdateRequest.php +++ b/app/Api/V1/Requests/System/UserUpdateRequest.php @@ -90,7 +90,7 @@ class UserUpdateRequest extends FormRequest /** * Configure the validator instance. * - * @param Validator $validator + * @param Validator $validator * * @return void */ @@ -103,7 +103,7 @@ class UserUpdateRequest extends FormRequest $isAdmin = auth()->user()->hasRole('owner'); // not admin, and not own user? if (auth()->check() && false === $isAdmin && $current?->id !== auth()->user()->id) { - $validator->errors()->add('email', (string) trans('validation.invalid_selection')); + $validator->errors()->add('email', (string)trans('validation.invalid_selection')); } } ); diff --git a/app/Api/V1/Requests/User/PreferenceStoreRequest.php b/app/Api/V1/Requests/User/PreferenceStoreRequest.php index 384c386d25..e1c9459ab4 100644 --- a/app/Api/V1/Requests/User/PreferenceStoreRequest.php +++ b/app/Api/V1/Requests/User/PreferenceStoreRequest.php @@ -48,7 +48,7 @@ class PreferenceStoreRequest extends FormRequest $array['data'] = false; } if (is_numeric($array['data'])) { - $array['data'] = (float) $array['data']; // intentional float. + $array['data'] = (float)$array['data']; // intentional float. } return $array; diff --git a/app/Api/V1/Requests/User/PreferenceUpdateRequest.php b/app/Api/V1/Requests/User/PreferenceUpdateRequest.php index d22fd73728..42f0a36992 100644 --- a/app/Api/V1/Requests/User/PreferenceUpdateRequest.php +++ b/app/Api/V1/Requests/User/PreferenceUpdateRequest.php @@ -49,7 +49,7 @@ class PreferenceUpdateRequest extends FormRequest $array['data'] = false; } if (is_numeric($array['data'])) { - $array['data'] = (float) $array['data']; // intentional float. + $array['data'] = (float)$array['data']; // intentional float. } return $array; diff --git a/app/Api/V2/Controllers/Chart/AccountController.php b/app/Api/V2/Controllers/Chart/AccountController.php index c9a44b9c1b..185947b255 100644 --- a/app/Api/V2/Controllers/Chart/AccountController.php +++ b/app/Api/V2/Controllers/Chart/AccountController.php @@ -56,7 +56,7 @@ class AccountController extends Controller } /** - * @param DateRequest $request + * @param DateRequest $request * @return JsonResponse */ public function dashboard(DateRequest $request): JsonResponse @@ -88,7 +88,7 @@ class AccountController extends Controller } $currentSet = [ 'label' => $account->name, - 'currency_id' => (string) $currency->id, + 'currency_id' => (string)$currency->id, 'currency_code' => $currency->code, 'currency_symbol' => $currency->symbol, 'currency_decimal_places' => $currency->decimal_places, @@ -107,7 +107,7 @@ class AccountController extends Controller // 2022-10-11: this method no longer converts to floats - $previous = array_values($range)[0]; + $previous = array_values($range)[0]; while ($currentStart <= $end) { $format = $currentStart->format('Y-m-d'); $label = $currentStart->toAtomString(); @@ -116,7 +116,7 @@ class AccountController extends Controller $currentStart->addDay(); $currentSet['entries'][$label] = $balance; } - $currentSet = $this->cerChartSet($currentSet); + $currentSet = $this->cerChartSet($currentSet); $chartData[] = $currentSet; } diff --git a/app/Api/V2/Controllers/Controller.php b/app/Api/V2/Controllers/Controller.php index 77da354c9c..4295397932 100644 --- a/app/Api/V2/Controllers/Controller.php +++ b/app/Api/V2/Controllers/Controller.php @@ -58,55 +58,10 @@ class Controller extends BaseController $this->parameters = $this->getParameters(); $this->pageSize = 50; if (auth()->check()) { - $this->pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; + $this->pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; } } - /** - * Returns a JSON API object and returns it. - * - * @param string $key - * @param Model $object - * @param AbstractTransformer $transformer - * @return array - */ - final protected function jsonApiObject(string $key, Model $object, AbstractTransformer $transformer): array - { - // create some objects: - $manager = new Manager(); - $baseUrl = request()->getSchemeAndHttpHost() . '/api/v2'; - $manager->setSerializer(new JsonApiSerializer($baseUrl)); - - $transformer->collectMetaData(new Collection([$object])); - - $resource = new Item($object, $transformer, $key); - return $manager->createData($resource)->toArray(); - } - - /** - * @param string $key - * @param LengthAwarePaginator $paginator - * @param AbstractTransformer $transformer - * @return array - */ - final protected function jsonApiList(string $key, LengthAwarePaginator $paginator, AbstractTransformer $transformer): array - { - $manager = new Manager(); - $baseUrl = request()->getSchemeAndHttpHost() . '/api/v2'; - $manager->setSerializer(new JsonApiSerializer($baseUrl)); - - $objects = $paginator->getCollection(); - - // the transformer, at this point, needs to collect information that ALL items in the collection - // require, like meta data and stuff like that, and save it for later. - $transformer->collectMetaData($objects); - - $resource = new FractalCollection($objects, $transformer, $key); - $resource->setPaginator(new IlluminatePaginatorAdapter($paginator)); - - return $manager->createData($resource)->toArray(); - } - /** * TODO duplicate from V1 controller * Method to grab all parameters from the URL. @@ -115,9 +70,9 @@ class Controller extends BaseController */ private function getParameters(): ParameterBag { - $bag = new ParameterBag(); + $bag = new ParameterBag(); try { - $page = (int) request()->get('page'); + $page = (int)request()->get('page'); } catch (ContainerExceptionInterface|NotFoundExceptionInterface $e) { $page = 1; } @@ -152,7 +107,7 @@ class Controller extends BaseController foreach ($integers as $integer) { $value = request()->query->get($integer); if (null !== $value) { - $bag->set($integer, (int) $value); + $bag->set($integer, (int)$value); } } @@ -161,4 +116,49 @@ class Controller extends BaseController return $bag; } + + /** + * @param string $key + * @param LengthAwarePaginator $paginator + * @param AbstractTransformer $transformer + * @return array + */ + final protected function jsonApiList(string $key, LengthAwarePaginator $paginator, AbstractTransformer $transformer): array + { + $manager = new Manager(); + $baseUrl = request()->getSchemeAndHttpHost().'/api/v2'; + $manager->setSerializer(new JsonApiSerializer($baseUrl)); + + $objects = $paginator->getCollection(); + + // the transformer, at this point, needs to collect information that ALL items in the collection + // require, like meta data and stuff like that, and save it for later. + $transformer->collectMetaData($objects); + + $resource = new FractalCollection($objects, $transformer, $key); + $resource->setPaginator(new IlluminatePaginatorAdapter($paginator)); + + return $manager->createData($resource)->toArray(); + } + + /** + * Returns a JSON API object and returns it. + * + * @param string $key + * @param Model $object + * @param AbstractTransformer $transformer + * @return array + */ + final protected function jsonApiObject(string $key, Model $object, AbstractTransformer $transformer): array + { + // create some objects: + $manager = new Manager(); + $baseUrl = request()->getSchemeAndHttpHost().'/api/v2'; + $manager->setSerializer(new JsonApiSerializer($baseUrl)); + + $transformer->collectMetaData(new Collection([$object])); + + $resource = new Item($object, $transformer, $key); + return $manager->createData($resource)->toArray(); + } } diff --git a/app/Api/V2/Controllers/Model/Account/ShowController.php b/app/Api/V2/Controllers/Model/Account/ShowController.php index 17def3cf5f..8755071334 100644 --- a/app/Api/V2/Controllers/Model/Account/ShowController.php +++ b/app/Api/V2/Controllers/Model/Account/ShowController.php @@ -36,7 +36,7 @@ use Illuminate\Http\Request; class ShowController extends Controller { /** - * @param Account $account + * @param Account $account * @return JsonResponse */ public function show(Request $request, Account $account): JsonResponse diff --git a/app/Api/V2/Controllers/Model/Bill/SumController.php b/app/Api/V2/Controllers/Model/Bill/SumController.php index 79b422afc0..ebb486953f 100644 --- a/app/Api/V2/Controllers/Model/Bill/SumController.php +++ b/app/Api/V2/Controllers/Model/Bill/SumController.php @@ -36,6 +36,7 @@ use Illuminate\Http\JsonResponse; class SumController extends Controller { use ConvertsExchangeRates; + private BillRepositoryInterface $repository; /** @@ -52,21 +53,7 @@ class SumController extends Controller } /** - * @param DateRequest $request - * @return JsonResponse - */ - public function unpaid(DateRequest $request): JsonResponse - { - $dates = $request->getAll(); - $result = $this->repository->sumUnpaidInRange($dates['start'], $dates['end']); - $converted = $this->cerSum($result); - - // convert to JSON response: - return response()->api($converted); - } - - /** - * @param DateRequest $request + * @param DateRequest $request * @return JsonResponse */ public function paid(DateRequest $request): JsonResponse @@ -78,4 +65,18 @@ class SumController extends Controller // convert to JSON response: return response()->api($converted); } + + /** + * @param DateRequest $request + * @return JsonResponse + */ + public function unpaid(DateRequest $request): JsonResponse + { + $dates = $request->getAll(); + $result = $this->repository->sumUnpaidInRange($dates['start'], $dates['end']); + $converted = $this->cerSum($result); + + // convert to JSON response: + return response()->api($converted); + } } diff --git a/app/Api/V2/Controllers/Model/Budget/ListController.php b/app/Api/V2/Controllers/Model/Budget/ListController.php index 240c488ec5..1e1c0ac56c 100644 --- a/app/Api/V2/Controllers/Model/Budget/ListController.php +++ b/app/Api/V2/Controllers/Model/Budget/ListController.php @@ -30,7 +30,6 @@ use FireflyIII\Transformers\V2\BudgetTransformer; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Pagination\LengthAwarePaginator; -use Illuminate\Support\Collection; class ListController extends Controller { @@ -52,8 +51,8 @@ class ListController extends Controller */ public function index(Request $request): JsonResponse { - $collection = $this->repository->getActiveBudgets(); - $total = $collection->count(); + $collection = $this->repository->getActiveBudgets(); + $total = $collection->count(); $collection->slice($this->pageSize * $this->parameters->get('page'), $this->pageSize); $paginator = new LengthAwarePaginator($collection, $total, $this->pageSize, $this->parameters->get('page')); diff --git a/app/Api/V2/Controllers/Model/Budget/SumController.php b/app/Api/V2/Controllers/Model/Budget/SumController.php index 993a0952bb..ebd2f71591 100644 --- a/app/Api/V2/Controllers/Model/Budget/SumController.php +++ b/app/Api/V2/Controllers/Model/Budget/SumController.php @@ -53,7 +53,7 @@ class SumController extends Controller } /** - * @param DateRequest $request + * @param DateRequest $request * @return JsonResponse */ public function budgeted(DateRequest $request): JsonResponse @@ -66,7 +66,7 @@ class SumController extends Controller } /** - * @param DateRequest $request + * @param DateRequest $request * @return JsonResponse */ public function spent(DateRequest $request): JsonResponse diff --git a/app/Api/V2/Controllers/NetWorthController.php b/app/Api/V2/Controllers/NetWorthController.php index 3c479565aa..ec46198fb4 100644 --- a/app/Api/V2/Controllers/NetWorthController.php +++ b/app/Api/V2/Controllers/NetWorthController.php @@ -57,7 +57,7 @@ class NetWorthController extends Controller } /** - * @param SingleDateRequest $request + * @param SingleDateRequest $request * @return JsonResponse */ public function get(SingleDateRequest $request): JsonResponse diff --git a/app/Api/V2/Controllers/System/PreferencesController.php b/app/Api/V2/Controllers/System/PreferencesController.php index 37a02c663b..cd3ac6bd31 100644 --- a/app/Api/V2/Controllers/System/PreferencesController.php +++ b/app/Api/V2/Controllers/System/PreferencesController.php @@ -35,7 +35,7 @@ use Illuminate\Http\JsonResponse; class PreferencesController extends Controller { /** - * @param Preference $preference + * @param Preference $preference * @return JsonResponse */ public function get(Preference $preference): JsonResponse diff --git a/app/Api/V2/Controllers/Transaction/List/AccountController.php b/app/Api/V2/Controllers/Transaction/List/AccountController.php index 27ec076fe1..07d6d126d6 100644 --- a/app/Api/V2/Controllers/Transaction/List/AccountController.php +++ b/app/Api/V2/Controllers/Transaction/List/AccountController.php @@ -29,7 +29,6 @@ use FireflyIII\Api\V2\Request\Transaction\ListRequest; use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Models\Account; use FireflyIII\Support\Http\Api\TransactionFilter; -use FireflyIII\Transformers\V2\PreferenceTransformer; use FireflyIII\Transformers\V2\TransactionGroupTransformer; use Illuminate\Http\JsonResponse; use Illuminate\Support\Collection; @@ -42,16 +41,16 @@ class AccountController extends Controller use TransactionFilter; /** - * @param ListRequest $request - * @param Account $account + * @param ListRequest $request + * @param Account $account * @return JsonResponse */ public function listTransactions(ListRequest $request, Account $account): JsonResponse { // collect transactions: $type = $request->get('type') ?? 'default'; - $limit = (int) $request->get('limit'); - $page = (int) $request->get('page'); + $limit = (int)$request->get('limit'); + $page = (int)$request->get('page'); $page = max($page, 1); if ($limit > 0 && $limit <= $this->pageSize) { diff --git a/app/Api/V2/Response/Sum/AutoSum.php b/app/Api/V2/Response/Sum/AutoSum.php index 1d2c0e8754..7b5ad63ada 100644 --- a/app/Api/V2/Response/Sum/AutoSum.php +++ b/app/Api/V2/Response/Sum/AutoSum.php @@ -36,9 +36,9 @@ use Illuminate\Support\Collection; class AutoSum { /** - * @param Collection $objects - * @param Closure $getCurrency - * @param Closure $getSum + * @param Collection $objects + * @param Closure $getCurrency + * @param Closure $getSum * @return array */ public function autoSum(Collection $objects, Closure $getCurrency, Closure $getSum): array @@ -52,13 +52,13 @@ class AutoSum $amount = $getSum($object); $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'], $amount); } diff --git a/app/Console/Commands/Correction/DeleteEmptyJournals.php b/app/Console/Commands/Correction/DeleteEmptyJournals.php index f0105a3f60..5a1ff07926 100644 --- a/app/Console/Commands/Correction/DeleteEmptyJournals.php +++ b/app/Console/Commands/Correction/DeleteEmptyJournals.php @@ -24,7 +24,6 @@ declare(strict_types=1); namespace FireflyIII\Console\Commands\Correction; use DB; -use Exception; use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionJournal; use Illuminate\Console\Command; diff --git a/app/Console/Commands/Correction/DeleteZeroAmount.php b/app/Console/Commands/Correction/DeleteZeroAmount.php index d4eb88442e..d4550e0949 100644 --- a/app/Console/Commands/Correction/DeleteZeroAmount.php +++ b/app/Console/Commands/Correction/DeleteZeroAmount.php @@ -23,7 +23,6 @@ declare(strict_types=1); namespace FireflyIII\Console\Commands\Correction; -use Exception; use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionJournal; use Illuminate\Console\Command; diff --git a/app/Console/Commands/Integrity/UpdateGroupInformation.php b/app/Console/Commands/Integrity/UpdateGroupInformation.php index b049d06db2..a373f9eb0b 100644 --- a/app/Console/Commands/Integrity/UpdateGroupInformation.php +++ b/app/Console/Commands/Integrity/UpdateGroupInformation.php @@ -118,7 +118,7 @@ class UpdateGroupInformation extends Command { try { $result = $className::where('user_id', $user->id)->where('user_group_id', null)->update(['user_group_id' => $group->id]); - } catch(QueryException $e) { + } catch (QueryException $e) { $this->error(sprintf('Could not update group information for "%s" because of error "%s"', $className, $e->getMessage())); return; } diff --git a/app/Console/Commands/Upgrade/MigrateJournalNotes.php b/app/Console/Commands/Upgrade/MigrateJournalNotes.php index d994210d43..0e578daf50 100644 --- a/app/Console/Commands/Upgrade/MigrateJournalNotes.php +++ b/app/Console/Commands/Upgrade/MigrateJournalNotes.php @@ -23,7 +23,6 @@ declare(strict_types=1); namespace FireflyIII\Console\Commands\Upgrade; -use Exception; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\Note; use FireflyIII\Models\TransactionJournalMeta; diff --git a/app/Console/Commands/Upgrade/MigrateToGroups.php b/app/Console/Commands/Upgrade/MigrateToGroups.php index 02da99037e..ca183bb25b 100644 --- a/app/Console/Commands/Upgrade/MigrateToGroups.php +++ b/app/Console/Commands/Upgrade/MigrateToGroups.php @@ -328,7 +328,7 @@ class MigrateToGroups extends Command { $set = $journal->transactions->filter( static function (Transaction $subject) use ($transaction) { - $amount = (float) $transaction->amount * -1 === (float) $subject->amount; // intentional float + $amount = (float)$transaction->amount * -1 === (float)$subject->amount; // intentional float $identifier = $transaction->identifier === $subject->identifier; Log::debug(sprintf('Amount the same? %s', var_export($amount, true))); Log::debug(sprintf('ID the same? %s', var_export($identifier, true))); diff --git a/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php b/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php index eb63e84f17..dd3761e175 100644 --- a/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php +++ b/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php @@ -56,12 +56,12 @@ class OtherCurrenciesCorrections extends Command * @var string */ protected $signature = 'firefly-iii:other-currencies {--F|force : Force the execution of this command.}'; - private array $accountCurrencies; - private AccountRepositoryInterface $accountRepos; + private array $accountCurrencies; + private AccountRepositoryInterface $accountRepos; private JournalCLIRepositoryInterface $cliRepos; - private int $count; - private CurrencyRepositoryInterface $currencyRepos; - private JournalRepositoryInterface $journalRepos; + private int $count; + private CurrencyRepositoryInterface $currencyRepos; + private JournalRepositoryInterface $journalRepos; /** * Execute the console command. diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 28fa63e7fb..53d1d5ef07 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -40,7 +40,7 @@ class Kernel extends ConsoleKernel */ protected function commands(): void { - $this->load(__DIR__ . '/Commands'); + $this->load(__DIR__.'/Commands'); require base_path('routes/console.php'); } @@ -48,7 +48,7 @@ class Kernel extends ConsoleKernel /** * Define the application's command schedule. * - * @param Schedule $schedule + * @param Schedule $schedule */ protected function schedule(Schedule $schedule): void { diff --git a/app/Events/ActuallyLoggedIn.php b/app/Events/ActuallyLoggedIn.php index 557dad3b38..6f0d07e691 100644 --- a/app/Events/ActuallyLoggedIn.php +++ b/app/Events/ActuallyLoggedIn.php @@ -37,7 +37,7 @@ class ActuallyLoggedIn extends Event public User $user; /** - * @param User $user + * @param User $user */ public function __construct(User $user) { diff --git a/app/Events/Admin/InvitationCreated.php b/app/Events/Admin/InvitationCreated.php index 3df959e956..37fab9cbd2 100644 --- a/app/Events/Admin/InvitationCreated.php +++ b/app/Events/Admin/InvitationCreated.php @@ -43,7 +43,7 @@ class InvitationCreated extends Event /** * Create a new event instance. * - * @param InvitedUser $invitee + * @param InvitedUser $invitee */ public function __construct(InvitedUser $invitee) { diff --git a/app/Events/AdminRequestedTestMessage.php b/app/Events/AdminRequestedTestMessage.php index 97836998c4..ed83fd47d0 100644 --- a/app/Events/AdminRequestedTestMessage.php +++ b/app/Events/AdminRequestedTestMessage.php @@ -42,7 +42,7 @@ class AdminRequestedTestMessage extends Event /** * Create a new event instance. * - * @param User $user + * @param User $user */ public function __construct(User $user) { diff --git a/app/Events/ChangedPiggyBankAmount.php b/app/Events/ChangedPiggyBankAmount.php index 84743f4e91..b5f02e2299 100644 --- a/app/Events/ChangedPiggyBankAmount.php +++ b/app/Events/ChangedPiggyBankAmount.php @@ -1,4 +1,5 @@ user(); - $route = $request->route(); + $user = auth()->user(); + $route = $request->route(); $param = $route->parameter('account'); if ($param instanceof Account) { - $accountId = (int) $param->id; + $accountId = (int)$param->id; } if (!($param instanceof Account)) { - $accountId = (int) $param; + $accountId = (int)$param; } /** @var Account $account */ $account = $user->accounts()->with(['accountType'])->withTrashed()->find($accountId); @@ -169,8 +169,8 @@ class GracefulNotFoundHandler extends ExceptionHandler } /** - * @param Request $request - * @param Throwable $exception + * @param Request $request + * @param Throwable $exception * * @return RedirectResponse|\Illuminate\Http\Response|Redirector|Response * @throws Throwable @@ -181,7 +181,7 @@ class GracefulNotFoundHandler extends ExceptionHandler /** @var User $user */ $user = auth()->user(); $route = $request->route(); - $groupId = (int) $route->parameter('transactionGroup'); + $groupId = (int)$route->parameter('transactionGroup'); /** @var TransactionGroup $group */ $group = $user->transactionGroups()->withTrashed()->find($groupId); @@ -208,8 +208,8 @@ class GracefulNotFoundHandler extends ExceptionHandler } /** - * @param Request $request - * @param Throwable $exception + * @param Request $request + * @param Throwable $exception * * @return RedirectResponse|Redirector|Response * @throws Throwable @@ -220,7 +220,7 @@ class GracefulNotFoundHandler extends ExceptionHandler /** @var User $user */ $user = auth()->user(); $route = $request->route(); - $attachmentId = (int) $route->parameter('attachment'); + $attachmentId = (int)$route->parameter('attachment'); /** @var Attachment $attachment */ $attachment = $user->attachments()->withTrashed()->find($attachmentId); if (null === $attachment) { diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 931aac41ef..1c503ce83c 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -38,8 +38,8 @@ use Illuminate\Support\Arr; use Illuminate\Validation\ValidationException as LaravelValidationException; use Laravel\Passport\Exceptions\OAuthServerException as LaravelOAuthException; use League\OAuth2\Server\Exception\OAuthServerException; -use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException; +use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -64,14 +64,14 @@ class Handler extends ExceptionHandler LaravelOAuthException::class, TokenMismatchException::class, HttpException::class, - SuspiciousOperationException::class + SuspiciousOperationException::class, ]; /** * Render an exception into an HTTP response. * - * @param Request $request - * @param Throwable $e + * @param Request $request + * @param Throwable $e * * @return mixed * @throws Throwable @@ -154,7 +154,7 @@ class Handler extends ExceptionHandler /** * Report or log an exception. * - * @param Throwable $e + * @param Throwable $e * * @return void * @throws Throwable @@ -200,14 +200,14 @@ class Handler extends ExceptionHandler // create job that will mail. $ipAddress = request()->ip() ?? '0.0.0.0'; - $job = new MailError($userData, (string) config('firefly.site_owner'), $ipAddress, $data); + $job = new MailError($userData, (string)config('firefly.site_owner'), $ipAddress, $data); dispatch($job); parent::report($e); } /** - * @param Throwable $e + * @param Throwable $e * * @return bool */ @@ -226,8 +226,8 @@ class Handler extends ExceptionHandler /** * Convert a validation exception into a response. * - * @param Request $request - * @param LaravelValidationException $exception + * @param Request $request + * @param LaravelValidationException $exception * * @return Application|RedirectResponse|Redirector */ @@ -245,7 +245,7 @@ class Handler extends ExceptionHandler /** * Only return the redirectTo property from the exception if it is a valid URL. Return NULL otherwise. * - * @param LaravelValidationException $exception + * @param LaravelValidationException $exception * * @return string|null */ diff --git a/app/Factory/AccountFactory.php b/app/Factory/AccountFactory.php index 5bf31bd99e..6bc903098c 100644 --- a/app/Factory/AccountFactory.php +++ b/app/Factory/AccountFactory.php @@ -70,8 +70,8 @@ class AccountFactory } /** - * @param string $accountName - * @param string $accountType + * @param string $accountName + * @param string $accountType * * @return Account * @throws FireflyException @@ -106,7 +106,7 @@ class AccountFactory } /** - * @param array $data + * @param array $data * * @return Account * @throws FireflyException @@ -132,14 +132,14 @@ class AccountFactory } /** - * @param array $data + * @param array $data * * @return AccountType|null * @throws FireflyException */ protected function getAccountType(array $data): ?AccountType { - $accountTypeId = array_key_exists('account_type_id', $data) ? (int) $data['account_type_id'] : 0; + $accountTypeId = array_key_exists('account_type_id', $data) ? (int)$data['account_type_id'] : 0; $accountTypeName = array_key_exists('account_type_name', $data) ? $data['account_type_name'] : null; $result = null; // find by name or ID @@ -167,8 +167,8 @@ class AccountFactory } /** - * @param string $accountName - * @param string $accountType + * @param string $accountName + * @param string $accountType * * @return Account|null */ @@ -180,8 +180,8 @@ class AccountFactory } /** - * @param AccountType $type - * @param array $data + * @param AccountType $type + * @param array $data * * @return Account * @throws FireflyException @@ -194,16 +194,17 @@ class AccountFactory // create it: $virtualBalance = array_key_exists('virtual_balance', $data) ? $data['virtual_balance'] : null; $active = array_key_exists('active', $data) ? $data['active'] : true; - $databaseData = ['user_id' => $this->user->id, - 'account_type_id' => $type->id, - 'name' => $data['name'], - 'order' => 25000, - 'virtual_balance' => $virtualBalance, - 'active' => $active, - 'iban' => $data['iban'], + $databaseData = [ + 'user_id' => $this->user->id, + 'account_type_id' => $type->id, + 'name' => $data['name'], + 'order' => 25000, + 'virtual_balance' => $virtualBalance, + 'active' => $active, + 'iban' => $data['iban'], ]; // fix virtual balance when it's empty - if ('' === (string) $databaseData['virtual_balance']) { + if ('' === (string)$databaseData['virtual_balance']) { $databaseData['virtual_balance'] = null; } // remove virtual balance when not an asset account @@ -248,16 +249,16 @@ class AccountFactory } /** - * @param Account $account - * @param array $data + * @param Account $account + * @param array $data * * @return array */ private function cleanMetaDataArray(Account $account, array $data): array { - $currencyId = array_key_exists('currency_id', $data) ? (int) $data['currency_id'] : 0; - $currencyCode = array_key_exists('currency_code', $data) ? (string) $data['currency_code'] : ''; - $accountRole = array_key_exists('account_role', $data) ? (string) $data['account_role'] : null; + $currencyId = array_key_exists('currency_id', $data) ? (int)$data['currency_id'] : 0; + $currencyCode = array_key_exists('currency_code', $data) ? (string)$data['currency_code'] : ''; + $accountRole = array_key_exists('account_role', $data) ? (string)$data['account_role'] : null; $currency = $this->getCurrency($currencyId, $currencyCode); // only asset account may have a role: @@ -275,8 +276,8 @@ class AccountFactory } /** - * @param Account $account - * @param array $data + * @param Account $account + * @param array $data */ private function storeMetaData(Account $account, array $data): void { @@ -312,14 +313,14 @@ class AccountFactory $data[$field] = 1; } - $factory->crud($account, $field, (string) $data[$field]); + $factory->crud($account, $field, (string)$data[$field]); } } } /** - * @param Account $account - * @param array $data + * @param Account $account + * @param array $data * * @throws FireflyException */ @@ -340,8 +341,8 @@ class AccountFactory } /** - * @param Account $account - * @param array $data + * @param Account $account + * @param array $data * * @throws FireflyException */ @@ -369,8 +370,8 @@ class AccountFactory } /** - * @param Account $account - * @param array $data + * @param Account $account + * @param array $data * * @throws FireflyException */ @@ -383,7 +384,7 @@ class AccountFactory $order = $maxOrder + 1; } if (array_key_exists('order', $data)) { - $order = (int) ($data['order'] > $maxOrder ? $maxOrder + 1 : $data['order']); + $order = (int)($data['order'] > $maxOrder ? $maxOrder + 1 : $data['order']); $order = 0 === $order ? $maxOrder + 1 : $order; } @@ -393,7 +394,7 @@ class AccountFactory } /** - * @param User $user + * @param User $user */ public function setUser(User $user): void { diff --git a/app/Factory/AccountMetaFactory.php b/app/Factory/AccountMetaFactory.php index a63768b780..1312b6670e 100644 --- a/app/Factory/AccountMetaFactory.php +++ b/app/Factory/AccountMetaFactory.php @@ -37,9 +37,9 @@ class AccountMetaFactory /** * Create update or delete meta data. * - * @param Account $account - * @param string $field - * @param string $value + * @param Account $account + * @param string $field + * @param string $value * * @return AccountMeta|null */ @@ -75,7 +75,7 @@ class AccountMetaFactory } /** - * @param array $data + * @param array $data * * @return AccountMeta|null */ diff --git a/app/Factory/AttachmentFactory.php b/app/Factory/AttachmentFactory.php index 4f1a36c2d8..26c8415f99 100644 --- a/app/Factory/AttachmentFactory.php +++ b/app/Factory/AttachmentFactory.php @@ -38,7 +38,7 @@ class AttachmentFactory private User $user; /** - * @param array $data + * @param array $data * * @return Attachment|null * @throws FireflyException @@ -52,7 +52,7 @@ class AttachmentFactory // get journal instead of transaction. if (Transaction::class === $model) { /** @var Transaction $transaction */ - $transaction = $this->user->transactions()->find((int) $data['attachable_id']); + $transaction = $this->user->transactions()->find((int)$data['attachable_id']); if (null === $transaction) { throw new FireflyException('Unexpectedly could not find transaction'); } @@ -75,7 +75,7 @@ class AttachmentFactory 'uploaded' => 0, ] ); - $notes = (string) ($data['notes'] ?? ''); + $notes = (string)($data['notes'] ?? ''); if ('' !== $notes) { $note = new Note(); $note->noteable()->associate($attachment); @@ -87,7 +87,7 @@ class AttachmentFactory } /** - * @param User $user + * @param User $user */ public function setUser(User $user): void { diff --git a/app/Factory/BillFactory.php b/app/Factory/BillFactory.php index 461e470443..2f1582db76 100644 --- a/app/Factory/BillFactory.php +++ b/app/Factory/BillFactory.php @@ -30,6 +30,7 @@ use FireflyIII\Repositories\ObjectGroup\CreatesObjectGroups; use FireflyIII\Services\Internal\Support\BillServiceTrait; use FireflyIII\User; use Illuminate\Database\QueryException; +use JsonException; use Log; /** @@ -43,17 +44,17 @@ class BillFactory private User $user; /** - * @param array $data + * @param array $data * * @return Bill|null * @throws FireflyException - * @throws \JsonException + * @throws JsonException */ public function create(array $data): ?Bill { Log::debug(sprintf('Now in %s', __METHOD__), $data); $factory = app(TransactionCurrencyFactory::class); - $currency = $factory->find((int) ($data['currency_id'] ?? null), (string) ($data['currency_code'] ?? null)) ?? + $currency = $factory->find((int)($data['currency_id'] ?? null), (string)($data['currency_code'] ?? null)) ?? app('amount')->getDefaultCurrencyByUser($this->user); try { @@ -84,7 +85,7 @@ class BillFactory } if (array_key_exists('notes', $data)) { - $this->updateNote($bill, (string) $data['notes']); + $this->updateNote($bill, (string)$data['notes']); } $objectGroupTitle = $data['object_group_title'] ?? ''; if ('' !== $objectGroupTitle) { @@ -95,7 +96,7 @@ class BillFactory } } // try also with ID: - $objectGroupId = (int) ($data['object_group_id'] ?? 0); + $objectGroupId = (int)($data['object_group_id'] ?? 0); if (0 !== $objectGroupId) { $objectGroup = $this->findObjectGroupById($objectGroupId); if (null !== $objectGroup) { @@ -108,15 +109,15 @@ class BillFactory } /** - * @param int|null $billId - * @param null|string $billName + * @param int|null $billId + * @param null|string $billName * * @return Bill|null */ public function find(?int $billId, ?string $billName): ?Bill { - $billId = (int) $billId; - $billName = (string) $billName; + $billId = (int)$billId; + $billName = (string)$billName; $bill = null; // first find by ID: if ($billId > 0) { @@ -133,7 +134,7 @@ class BillFactory } /** - * @param string $name + * @param string $name * * @return Bill|null */ @@ -143,7 +144,7 @@ class BillFactory } /** - * @param User $user + * @param User $user */ public function setUser(User $user): void { diff --git a/app/Factory/BudgetFactory.php b/app/Factory/BudgetFactory.php index 281e0bedd7..87b5a4fe9e 100644 --- a/app/Factory/BudgetFactory.php +++ b/app/Factory/BudgetFactory.php @@ -1,4 +1,5 @@ save(); if (array_key_exists('notes', $data['recurrence'])) { - $this->updateNote($recurrence, (string) $data['recurrence']['notes']); + $this->updateNote($recurrence, (string)$data['recurrence']['notes']); } $this->createRepetitions($recurrence, $data['repetitions'] ?? []); @@ -146,7 +146,7 @@ class RecurrenceFactory } /** - * @param User $user + * @param User $user */ public function setUser(User $user): void { diff --git a/app/Factory/TagFactory.php b/app/Factory/TagFactory.php index b474caea30..c8533cf28b 100644 --- a/app/Factory/TagFactory.php +++ b/app/Factory/TagFactory.php @@ -36,7 +36,7 @@ class TagFactory private User $user; /** - * @param string $tag + * @param string $tag * * @return Tag|null */ @@ -73,15 +73,15 @@ class TagFactory } /** - * @param array $data + * @param array $data * * @return Tag|null */ public function create(array $data): ?Tag { - $zoomLevel = 0 === (int) $data['zoom_level'] ? null : (int) $data['zoom_level']; - $latitude = 0.0 === (float) $data['latitude'] ? null : (float) $data['latitude']; // intentional float - $longitude = 0.0 === (float) $data['longitude'] ? null : (float) $data['longitude']; // intentional float + $zoomLevel = 0 === (int)$data['zoom_level'] ? null : (int)$data['zoom_level']; + $latitude = 0.0 === (float)$data['latitude'] ? null : (float)$data['latitude']; // intentional float + $longitude = 0.0 === (float)$data['longitude'] ? null : (float)$data['longitude']; // intentional float $array = [ 'user_id' => $this->user->id, 'tag' => trim($data['tag']), @@ -107,7 +107,7 @@ class TagFactory } /** - * @param User $user + * @param User $user */ public function setUser(User $user): void { diff --git a/app/Factory/TransactionCurrencyFactory.php b/app/Factory/TransactionCurrencyFactory.php index 414b9c62ca..0068e63352 100644 --- a/app/Factory/TransactionCurrencyFactory.php +++ b/app/Factory/TransactionCurrencyFactory.php @@ -34,7 +34,7 @@ use Log; class TransactionCurrencyFactory { /** - * @param array $data + * @param array $data * * @return TransactionCurrency * @throws FireflyException @@ -71,15 +71,15 @@ class TransactionCurrencyFactory } /** - * @param int|null $currencyId - * @param null|string $currencyCode + * @param int|null $currencyId + * @param null|string $currencyCode * * @return TransactionCurrency|null */ public function find(?int $currencyId, ?string $currencyCode): ?TransactionCurrency { - $currencyCode = (string) $currencyCode; - $currencyId = (int) $currencyId; + $currencyCode = (string)$currencyCode; + $currencyId = (int)$currencyId; if ('' === $currencyCode && 0 === $currencyId) { Log::debug('Cannot find anything on empty currency code and empty currency ID!'); diff --git a/app/Factory/TransactionFactory.php b/app/Factory/TransactionFactory.php index 8225cd451f..915fe6ec8f 100644 --- a/app/Factory/TransactionFactory.php +++ b/app/Factory/TransactionFactory.php @@ -58,8 +58,8 @@ class TransactionFactory /** * Create transaction with negative amount (for source accounts). * - * @param string $amount - * @param string|null $foreignAmount + * @param string $amount + * @param string|null $foreignAmount * * @return Transaction * @throws FireflyException @@ -77,8 +77,8 @@ class TransactionFactory } /** - * @param string $amount - * @param string|null $foreignAmount + * @param string $amount + * @param string|null $foreignAmount * * @return Transaction * @throws FireflyException @@ -138,8 +138,8 @@ class TransactionFactory /** * Create transaction with positive amount (for destination accounts). * - * @param string $amount - * @param string|null $foreignAmount + * @param string $amount + * @param string|null $foreignAmount * * @return Transaction * @throws FireflyException @@ -157,7 +157,7 @@ class TransactionFactory } /** - * @param Account $account + * @param Account $account * * @codeCoverageIgnore */ @@ -167,7 +167,7 @@ class TransactionFactory } /** - * @param TransactionCurrency $currency + * @param TransactionCurrency $currency * * @codeCoverageIgnore */ @@ -177,7 +177,7 @@ class TransactionFactory } /** - * @param TransactionCurrency|null $foreignCurrency |null + * @param TransactionCurrency|null $foreignCurrency |null * * @codeCoverageIgnore */ @@ -187,7 +187,7 @@ class TransactionFactory } /** - * @param TransactionJournal $journal + * @param TransactionJournal $journal * * @codeCoverageIgnore */ @@ -197,7 +197,7 @@ class TransactionFactory } /** - * @param bool $reconciled + * @param bool $reconciled * * @codeCoverageIgnore */ @@ -207,7 +207,7 @@ class TransactionFactory } /** - * @param User $user + * @param User $user * * @codeCoverageIgnore */ diff --git a/app/Factory/TransactionGroupFactory.php b/app/Factory/TransactionGroupFactory.php index 93996e735a..d71880386a 100644 --- a/app/Factory/TransactionGroupFactory.php +++ b/app/Factory/TransactionGroupFactory.php @@ -27,6 +27,7 @@ use FireflyIII\Exceptions\DuplicateTransactionException; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\TransactionGroup; use FireflyIII\User; +use JsonException; use Log; /** @@ -37,7 +38,7 @@ use Log; class TransactionGroupFactory { private TransactionJournalFactory $journalFactory; - private User $user; + private User $user; /** * TransactionGroupFactory constructor. @@ -50,12 +51,12 @@ class TransactionGroupFactory /** * Store a new transaction journal. * - * @param array $data + * @param array $data * * @return TransactionGroup * @throws DuplicateTransactionException * @throws FireflyException - * @throws \JsonException + * @throws JsonException */ public function create(array $data): TransactionGroup { @@ -91,7 +92,7 @@ class TransactionGroupFactory /** * Set the user. * - * @param User $user + * @param User $user */ public function setUser(User $user): void { diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.php index bed3b93c02..b006be8bd8 100644 --- a/app/Factory/TransactionJournalFactory.php +++ b/app/Factory/TransactionJournalFactory.php @@ -313,7 +313,7 @@ class TransactionJournalFactory unset($dataRow['import_hash_v2'], $dataRow['original_source']); $json = json_encode($dataRow, JSON_THROW_ON_ERROR); if (false === $json) { - $json = json_encode((string) microtime(), JSON_THROW_ON_ERROR); + $json = json_encode((string)microtime(), JSON_THROW_ON_ERROR); Log::error(sprintf('Could not hash the original row! %s', json_last_error_msg()), $dataRow); } $hash = hash('sha256', $json); @@ -399,6 +399,52 @@ class TransactionJournalFactory } } + /** + * Set the user. + * + * @param User $user + */ + public function setUser(User $user): void + { + $this->user = $user; + $this->currencyRepository->setUser($this->user); + $this->tagFactory->setUser($user); + $this->billRepository->setUser($this->user); + $this->budgetRepository->setUser($this->user); + $this->categoryRepository->setUser($this->user); + $this->piggyRepository->setUser($this->user); + $this->accountRepository->setUser($this->user); + } + + /** + * @param Account|null $sourceAccount + * @param Account|null $destinationAccount + * @return array + */ + private function reconciliationSanityCheck(?Account $sourceAccount, ?Account $destinationAccount): array + { + Log::debug(sprintf('Now in %s', __METHOD__)); + if (null !== $sourceAccount && null !== $destinationAccount) { + Log::debug('Both accounts exist, simply return them.'); + return [$sourceAccount, $destinationAccount]; + } + if (null !== $sourceAccount && null === $destinationAccount) { + Log::debug('Destination account is NULL, source account is not.'); + $account = $this->accountRepository->getReconciliation($sourceAccount); + Log::debug(sprintf('Will return account #%d ("%s") of type "%s"', $account->id, $account->name, $account->accountType->type)); + return [$sourceAccount, $account]; + } + + if (null === $sourceAccount && null !== $destinationAccount) { + Log::debug('Source account is NULL, destination account is not.'); + $account = $this->accountRepository->getReconciliation($destinationAccount); + Log::debug(sprintf('Will return account #%d ("%s") of type "%s"', $account->id, $account->name, $account->accountType->type)); + return [$account, $destinationAccount]; + } + Log::debug('Unused fallback'); + return [$sourceAccount, $destinationAccount]; + } + /** * @param string $type * @param TransactionCurrency|null $currency @@ -585,50 +631,4 @@ class TransactionJournalFactory Log::info('Will trigger duplication alert for this journal.'); } } - - /** - * Set the user. - * - * @param User $user - */ - public function setUser(User $user): void - { - $this->user = $user; - $this->currencyRepository->setUser($this->user); - $this->tagFactory->setUser($user); - $this->billRepository->setUser($this->user); - $this->budgetRepository->setUser($this->user); - $this->categoryRepository->setUser($this->user); - $this->piggyRepository->setUser($this->user); - $this->accountRepository->setUser($this->user); - } - - /** - * @param Account|null $sourceAccount - * @param Account|null $destinationAccount - * @return array - */ - private function reconciliationSanityCheck(?Account $sourceAccount, ?Account $destinationAccount): array - { - Log::debug(sprintf('Now in %s', __METHOD__)); - if (null !== $sourceAccount && null !== $destinationAccount) { - Log::debug('Both accounts exist, simply return them.'); - return [$sourceAccount, $destinationAccount]; - } - if (null !== $sourceAccount && null === $destinationAccount) { - Log::debug('Destination account is NULL, source account is not.'); - $account = $this->accountRepository->getReconciliation($sourceAccount); - Log::debug(sprintf('Will return account #%d ("%s") of type "%s"', $account->id, $account->name, $account->accountType->type)); - return [$sourceAccount, $account]; - } - - if (null === $sourceAccount && null !== $destinationAccount) { - Log::debug('Source account is NULL, destination account is not.'); - $account = $this->accountRepository->getReconciliation($destinationAccount); - Log::debug(sprintf('Will return account #%d ("%s") of type "%s"', $account->id, $account->name, $account->accountType->type)); - return [$account, $destinationAccount]; - } - Log::debug('Unused fallback'); - return [$sourceAccount, $destinationAccount]; - } } diff --git a/app/Factory/TransactionJournalMetaFactory.php b/app/Factory/TransactionJournalMetaFactory.php index 48f8ee1f83..b77e0d4566 100644 --- a/app/Factory/TransactionJournalMetaFactory.php +++ b/app/Factory/TransactionJournalMetaFactory.php @@ -24,7 +24,6 @@ declare(strict_types=1); namespace FireflyIII\Factory; use Carbon\Carbon; -use Exception; use FireflyIII\Models\TransactionJournalMeta; use Illuminate\Database\QueryException; use Log; @@ -35,7 +34,7 @@ use Log; class TransactionJournalMetaFactory { /** - * @param array $data + * @param array $data * * @return TransactionJournalMeta|null */ @@ -60,7 +59,7 @@ class TransactionJournalMetaFactory Log::debug('Is a carbon object.'); $value = $data['data']->toW3cString(); } - if ('' === (string) $value) { + if ('' === (string)$value) { // Log::debug('Is an empty string.'); // don't store blank strings. if (null !== $entry) { diff --git a/app/Factory/TransactionTypeFactory.php b/app/Factory/TransactionTypeFactory.php index 64294ef1ee..87b60c2b11 100644 --- a/app/Factory/TransactionTypeFactory.php +++ b/app/Factory/TransactionTypeFactory.php @@ -32,7 +32,7 @@ use FireflyIII\Models\TransactionType; class TransactionTypeFactory { /** - * @param string $type + * @param string $type * * @return TransactionType|null */ diff --git a/app/Generator/Chart/Basic/ChartJsGenerator.php b/app/Generator/Chart/Basic/ChartJsGenerator.php index 18d45c86a6..217cfa7933 100644 --- a/app/Generator/Chart/Basic/ChartJsGenerator.php +++ b/app/Generator/Chart/Basic/ChartJsGenerator.php @@ -1,4 +1,5 @@ [value => x, 'currency_symbol' => 'x'] * - * @param array $data + * @param array $data * * @return array */ @@ -50,7 +51,7 @@ class ChartJsGenerator implements GeneratorInterface $amounts = array_column($data, 'amount'); $next = next($amounts); $sortFlag = SORT_ASC; - if (!is_bool($next) && 1 === bccomp((string) $next, '0')) { + if (!is_bool($next) && 1 === bccomp((string)$next, '0')) { $sortFlag = SORT_DESC; } array_multisort($amounts, $sortFlag, $data); @@ -59,7 +60,7 @@ class ChartJsGenerator implements GeneratorInterface $index = 0; foreach ($data as $key => $valueArray) { // make larger than 0 - $chartData['datasets'][0]['data'][] = app('steam')->positive((string) $valueArray['amount']); + $chartData['datasets'][0]['data'][] = app('steam')->positive((string)$valueArray['amount']); $chartData['datasets'][0]['backgroundColor'][] = ChartColour::getColour($index); $chartData['datasets'][0]['currency_symbol'][] = $valueArray['currency_symbol']; $chartData['labels'][] = $key; @@ -99,7 +100,7 @@ class ChartJsGenerator implements GeneratorInterface * * // it's five. * - * @param array $data + * @param array $data * * @return array */ @@ -148,7 +149,7 @@ class ChartJsGenerator implements GeneratorInterface * * key => value * - * @param array $data + * @param array $data * * @return array */ @@ -165,7 +166,7 @@ class ChartJsGenerator implements GeneratorInterface // different sort when values are positive and when they're negative. asort($data); $next = next($data); - if (!is_bool($next) && 1 === bccomp((string) $next, '0')) { + if (!is_bool($next) && 1 === bccomp((string)$next, '0')) { // next is positive, sort other way around. arsort($data); } @@ -174,7 +175,7 @@ class ChartJsGenerator implements GeneratorInterface $index = 0; foreach ($data as $key => $value) { // make larger than 0 - $chartData['datasets'][0]['data'][] = app('steam')->positive((string) $value); + $chartData['datasets'][0]['data'][] = app('steam')->positive((string)$value); $chartData['datasets'][0]['backgroundColor'][] = ChartColour::getColour($index); $chartData['labels'][] = $key; @@ -189,8 +190,8 @@ class ChartJsGenerator implements GeneratorInterface * * 'label-of-entry' => value * - * @param string $setLabel - * @param array $data + * @param string $setLabel + * @param array $data * * @return array */ diff --git a/app/Generator/Chart/Basic/GeneratorInterface.php b/app/Generator/Chart/Basic/GeneratorInterface.php index b92994f858..e2209ccee1 100644 --- a/app/Generator/Chart/Basic/GeneratorInterface.php +++ b/app/Generator/Chart/Basic/GeneratorInterface.php @@ -1,4 +1,5 @@ value * - * @param array $data + * @param array $data * * @return array */ @@ -84,8 +85,8 @@ interface GeneratorInterface * * 'label-of-entry' => value * - * @param string $setLabel - * @param array $data + * @param string $setLabel + * @param array $data * * @return array */ diff --git a/app/Generator/Report/Account/MonthReportGenerator.php b/app/Generator/Report/Account/MonthReportGenerator.php index bfb2dcffe6..d14f6d6bb6 100644 --- a/app/Generator/Report/Account/MonthReportGenerator.php +++ b/app/Generator/Report/Account/MonthReportGenerator.php @@ -1,4 +1,5 @@ accounts->pluck('id')->toArray()); - $hideable = ['buttons', 'icon', 'description', 'balance_before', 'amount', 'balance_after', 'date', + $hideable = [ + 'buttons', + 'icon', + 'description', + 'balance_before', + 'amount', + 'balance_after', + 'date', - 'from', 'to', 'budget', 'category', 'bill', + 'from', + 'to', + 'budget', + 'category', + 'bill', - // more new optional fields - 'create_date', 'update_date', + // more new optional fields + 'create_date', + 'update_date', - // date fields. - 'interest_date', 'book_date', 'process_date', - 'due_date', 'payment_date', 'invoice_date', + // date fields. + 'interest_date', + 'book_date', + 'process_date', + 'due_date', + 'payment_date', + 'invoice_date', ]; try { $result = view('reports.audit.report', compact('reportType', 'accountIds', 'auditData', 'hideable', 'defaultShow')) @@ -95,8 +111,8 @@ class MonthReportGenerator implements ReportGeneratorInterface /** * Get the audit report. * - * @param Account $account - * @param Carbon $date + * @param Account $account + * @param Carbon $date * * @return array * @throws FireflyException @@ -157,9 +173,9 @@ class MonthReportGenerator implements ReportGeneratorInterface 'journals' => $journals, 'currency' => $currency, 'exists' => 0 !== count($journals), - 'end' => $this->end->isoFormat((string) trans('config.month_and_day_moment_js', [], $locale)), + 'end' => $this->end->isoFormat((string)trans('config.month_and_day_moment_js', [], $locale)), 'endBalance' => app('steam')->balance($account, $this->end), - 'dayBefore' => $date->isoFormat((string) trans('config.month_and_day_moment_js', [], $locale)), + 'dayBefore' => $date->isoFormat((string)trans('config.month_and_day_moment_js', [], $locale)), 'dayBeforeBalance' => $dayBeforeBalance, ]; } @@ -167,7 +183,7 @@ class MonthReportGenerator implements ReportGeneratorInterface /** * Account collection setter. * - * @param Collection $accounts + * @param Collection $accounts * * @return ReportGeneratorInterface * @codeCoverageIgnore @@ -182,7 +198,7 @@ class MonthReportGenerator implements ReportGeneratorInterface /** * Budget collection setter. * - * @param Collection $budgets + * @param Collection $budgets * * @return ReportGeneratorInterface * @codeCoverageIgnore @@ -195,7 +211,7 @@ class MonthReportGenerator implements ReportGeneratorInterface /** * Category collection setter. * - * @param Collection $categories + * @param Collection $categories * * @return ReportGeneratorInterface * @codeCoverageIgnore @@ -208,7 +224,7 @@ class MonthReportGenerator implements ReportGeneratorInterface /** * End date setter. * - * @param Carbon $date + * @param Carbon $date * * @return ReportGeneratorInterface * @codeCoverageIgnore @@ -223,7 +239,7 @@ class MonthReportGenerator implements ReportGeneratorInterface /** * Expenses collection setter. * - * @param Collection $expense + * @param Collection $expense * * @return ReportGeneratorInterface * @codeCoverageIgnore @@ -237,7 +253,7 @@ class MonthReportGenerator implements ReportGeneratorInterface /** * Start date collection setter. * - * @param Carbon $date + * @param Carbon $date * * @return ReportGeneratorInterface * @codeCoverageIgnore @@ -252,7 +268,7 @@ class MonthReportGenerator implements ReportGeneratorInterface /** * Tags collection setter. * - * @param Collection $tags + * @param Collection $tags * * @return ReportGeneratorInterface * @codeCoverageIgnore diff --git a/app/Generator/Report/Audit/MultiYearReportGenerator.php b/app/Generator/Report/Audit/MultiYearReportGenerator.php index 591251938c..ff654bc090 100644 --- a/app/Generator/Report/Audit/MultiYearReportGenerator.php +++ b/app/Generator/Report/Audit/MultiYearReportGenerator.php @@ -1,4 +1,5 @@ accounts = $accounts; - - return $this; - } - - /** - * Set the involved budgets. - * - * @param Collection $budgets - * - * @return ReportGeneratorInterface - */ - public function setBudgets(Collection $budgets): ReportGeneratorInterface - { - $this->budgets = $budgets; - - return $this; - } - /** * Unused category setter. * - * @param Collection $categories + * @param Collection $categories * * @return ReportGeneratorInterface */ @@ -124,7 +97,7 @@ class MonthReportGenerator implements ReportGeneratorInterface /** * Set the end date of the report. * - * @param Carbon $date + * @param Carbon $date * * @return ReportGeneratorInterface */ @@ -138,7 +111,7 @@ class MonthReportGenerator implements ReportGeneratorInterface /** * Unused expense setter. * - * @param Collection $expense + * @param Collection $expense * * @return ReportGeneratorInterface */ @@ -150,7 +123,7 @@ class MonthReportGenerator implements ReportGeneratorInterface /** * Set the start date of the report. * - * @param Carbon $date + * @param Carbon $date * * @return ReportGeneratorInterface */ @@ -164,7 +137,7 @@ class MonthReportGenerator implements ReportGeneratorInterface /** * Unused tags setter. * - * @param Collection $tags + * @param Collection $tags * * @return ReportGeneratorInterface */ @@ -199,4 +172,32 @@ class MonthReportGenerator implements ReportGeneratorInterface return $journals; } + + /** + * Set the involved budgets. + * + * @param Collection $budgets + * + * @return ReportGeneratorInterface + */ + public function setBudgets(Collection $budgets): ReportGeneratorInterface + { + $this->budgets = $budgets; + + return $this; + } + + /** + * Set the involved accounts. + * + * @param Collection $accounts + * + * @return ReportGeneratorInterface + */ + public function setAccounts(Collection $accounts): ReportGeneratorInterface + { + $this->accounts = $accounts; + + return $this; + } } diff --git a/app/Generator/Report/Budget/MultiYearReportGenerator.php b/app/Generator/Report/Budget/MultiYearReportGenerator.php index e9368a9834..54b36d8566 100644 --- a/app/Generator/Report/Budget/MultiYearReportGenerator.php +++ b/app/Generator/Report/Budget/MultiYearReportGenerator.php @@ -1,4 +1,5 @@ accounts = $accounts; - - return $this; - } - /** * Empty budget setter. * - * @param Collection $budgets + * @param Collection $budgets * * @return ReportGeneratorInterface */ @@ -115,24 +102,10 @@ class MonthReportGenerator implements ReportGeneratorInterface return $this; } - /** - * Set the categories involved in this report. - * - * @param Collection $categories - * - * @return ReportGeneratorInterface - */ - public function setCategories(Collection $categories): ReportGeneratorInterface - { - $this->categories = $categories; - - return $this; - } - /** * Set the end date for this report. * - * @param Carbon $date + * @param Carbon $date * * @return ReportGeneratorInterface */ @@ -146,7 +119,7 @@ class MonthReportGenerator implements ReportGeneratorInterface /** * Set the expenses involved in this report. * - * @param Collection $expense + * @param Collection $expense * * @return ReportGeneratorInterface */ @@ -158,7 +131,7 @@ class MonthReportGenerator implements ReportGeneratorInterface /** * Set the start date for this report. * - * @param Carbon $date + * @param Carbon $date * * @return ReportGeneratorInterface */ @@ -172,7 +145,7 @@ class MonthReportGenerator implements ReportGeneratorInterface /** * Unused tag setter. * - * @param Collection $tags + * @param Collection $tags * * @return ReportGeneratorInterface */ @@ -206,6 +179,34 @@ class MonthReportGenerator implements ReportGeneratorInterface return $transactions; } + /** + * Set the categories involved in this report. + * + * @param Collection $categories + * + * @return ReportGeneratorInterface + */ + public function setCategories(Collection $categories): ReportGeneratorInterface + { + $this->categories = $categories; + + return $this; + } + + /** + * Set the involved accounts. + * + * @param Collection $accounts + * + * @return ReportGeneratorInterface + */ + public function setAccounts(Collection $accounts): ReportGeneratorInterface + { + $this->accounts = $accounts; + + return $this; + } + /** * Get the income for this report. * diff --git a/app/Generator/Report/Category/MultiYearReportGenerator.php b/app/Generator/Report/Category/MultiYearReportGenerator.php index 16e08dae65..832836929a 100644 --- a/app/Generator/Report/Category/MultiYearReportGenerator.php +++ b/app/Generator/Report/Category/MultiYearReportGenerator.php @@ -1,4 +1,5 @@ find((int) $event->userId); + $user = $repository->find((int)$event->userId); if (null !== $user) { Notification::send($user, new NewAccessToken()); diff --git a/app/Handlers/Events/AdminEventHandler.php b/app/Handlers/Events/AdminEventHandler.php index 9a2c40b0ab..768ba63f11 100644 --- a/app/Handlers/Events/AdminEventHandler.php +++ b/app/Handlers/Events/AdminEventHandler.php @@ -1,4 +1,5 @@ hasRole($event->user, 'owner')) { - return; - } - - Notification::send($event->user, new TestNotification($event->user->email)); - } - - /** - * @param InvitationCreated $event + * @param InvitationCreated $event * @return void */ public function sendInvitationNotification(InvitationCreated $event): void @@ -83,7 +62,7 @@ class AdminEventHandler /** * Send new version message to admin. * - * @param NewVersionAvailable $event + * @param NewVersionAvailable $event * @return void */ public function sendNewVersion(NewVersionAvailable $event): void @@ -102,4 +81,23 @@ class AdminEventHandler } } } + + /** + * Sends a test message to an administrator. + * + * @param AdminRequestedTestMessage $event + * + * @return void + */ + public function sendTestMessage(AdminRequestedTestMessage $event): void + { + /** @var UserRepositoryInterface $repository */ + $repository = app(UserRepositoryInterface::class); + + if (!$repository->hasRole($event->user, 'owner')) { + return; + } + + Notification::send($event->user, new TestNotification($event->user->email)); + } } diff --git a/app/Handlers/Events/AuditEventHandler.php b/app/Handlers/Events/AuditEventHandler.php index 5bb7917715..b5a0471aff 100644 --- a/app/Handlers/Events/AuditEventHandler.php +++ b/app/Handlers/Events/AuditEventHandler.php @@ -30,7 +30,7 @@ use FireflyIII\Repositories\AuditLogEntry\ALERepositoryInterface; class AuditEventHandler { /** - * @param TriggeredAuditLog $event + * @param TriggeredAuditLog $event * @return void */ public function storeAuditEvent(TriggeredAuditLog $event) diff --git a/app/Handlers/Events/AutomationHandler.php b/app/Handlers/Events/AutomationHandler.php index 5e120c0391..6cdace98b6 100644 --- a/app/Handlers/Events/AutomationHandler.php +++ b/app/Handlers/Events/AutomationHandler.php @@ -23,18 +23,13 @@ declare(strict_types=1); namespace FireflyIII\Handlers\Events; -use Exception; use FireflyIII\Events\RequestedReportOnJournals; -use FireflyIII\Exceptions\FireflyException; -use FireflyIII\Mail\ReportNewJournalsMail; use FireflyIII\Models\TransactionGroup; -use FireflyIII\Notifications\User\NewAccessToken; use FireflyIII\Notifications\User\TransactionCreation; use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\Transformers\TransactionGroupTransformer; use Illuminate\Support\Facades\Notification; use Log; -use Mail; /** * Class AutomationHandler @@ -44,7 +39,7 @@ class AutomationHandler /** * Respond to the creation of X journals. * - * @param RequestedReportOnJournals $event + * @param RequestedReportOnJournals $event */ public function reportJournals(RequestedReportOnJournals $event): void { @@ -64,7 +59,7 @@ class AutomationHandler // transform groups into array: /** @var TransactionGroupTransformer $transformer */ $transformer = app(TransactionGroupTransformer::class); - $groups = []; + $groups = []; /** @var TransactionGroup $group */ foreach ($event->groups as $group) { $groups[] = $transformer->transformObject($group); diff --git a/app/Handlers/Events/BillEventHandler.php b/app/Handlers/Events/BillEventHandler.php index d13bce080e..802eec7e36 100644 --- a/app/Handlers/Events/BillEventHandler.php +++ b/app/Handlers/Events/BillEventHandler.php @@ -29,7 +29,6 @@ use FireflyIII\Notifications\User\BillReminder; use FireflyIII\Support\Facades\Preferences; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Notification; -use Mail; /** * Class BillEventHandler @@ -37,7 +36,7 @@ use Mail; class BillEventHandler { /** - * @param WarnUserAboutBill $event + * @param WarnUserAboutBill $event * @return void */ public function warnAboutBill(WarnUserAboutBill $event): void diff --git a/app/Handlers/Events/DestroyedGroupEventHandler.php b/app/Handlers/Events/DestroyedGroupEventHandler.php index f8b20503bd..093f3e48d8 100644 --- a/app/Handlers/Events/DestroyedGroupEventHandler.php +++ b/app/Handlers/Events/DestroyedGroupEventHandler.php @@ -27,7 +27,6 @@ use FireflyIII\Enums\WebhookTrigger; use FireflyIII\Events\DestroyedTransactionGroup; use FireflyIII\Events\RequestedSendWebhookMessages; use FireflyIII\Generator\Webhook\MessageGeneratorInterface; -use FireflyIII\Models\Webhook; use Illuminate\Support\Collection; use Log; @@ -37,7 +36,7 @@ use Log; class DestroyedGroupEventHandler { /** - * @param DestroyedTransactionGroup $destroyedGroupEvent + * @param DestroyedTransactionGroup $destroyedGroupEvent */ public function triggerWebhooks(DestroyedTransactionGroup $destroyedGroupEvent): void { diff --git a/app/Handlers/Events/PiggyBankEventHandler.php b/app/Handlers/Events/PiggyBankEventHandler.php index 2955364032..07430e133a 100644 --- a/app/Handlers/Events/PiggyBankEventHandler.php +++ b/app/Handlers/Events/PiggyBankEventHandler.php @@ -1,4 +1,5 @@ invitee->email; - $admin = $event->invitee->user->email; - $url = route('invite', [$event->invitee->invite_code]); - try { - Mail::to($invitee)->send(new InvitationMail($invitee, $admin, $url)); - } catch (Exception $e) { - Log::error($e->getMessage()); - throw new FireflyException($e->getMessage(), 0, $e); - } - } - - /** - * @param RegisteredUser $event - * @return bool - */ - public function createExchangeRates(RegisteredUser $event): void - { - $seeder = new ExchangeRateSeeder(); - $seeder->run(); - } - /** * Fires to see if a user is admin. * @@ -138,6 +111,16 @@ class UserEventHandler } } + /** + * @param RegisteredUser $event + * @return bool + */ + public function createExchangeRates(RegisteredUser $event): void + { + $seeder = new ExchangeRateSeeder(); + $seeder->run(); + } + /** * @param RegisteredUser $event * @@ -232,6 +215,24 @@ class UserEventHandler app('preferences')->setForUser($user, 'login_ip_history', $list); } + /** + * @param RegisteredUser $event + */ + public function sendAdminRegistrationNotification(RegisteredUser $event): void + { + $sendMail = FireflyConfig::get('notification_admin_new_reg', true)->data; + if ($sendMail) { + /** @var UserRepositoryInterface $repository */ + $repository = app(UserRepositoryInterface::class); + $all = $repository->all(); + foreach ($all as $user) { + if ($repository->hasRole($user, 'owner')) { + Notification::send($user, new AdminRegistrationNotification($event->user)); + } + } + } + } + /** * Send email to confirm email change. Will not be made into a notification, because * this requires some custom fields from the user and not just the "user" object. @@ -289,6 +290,23 @@ class UserEventHandler Notification::send($event->user, new UserNewPassword(route('password.reset', [$event->token]))); } + /** + * @param InvitationCreated $event + * @return void + */ + public function sendRegistrationInvite(InvitationCreated $event): void + { + $invitee = $event->invitee->email; + $admin = $event->invitee->user->email; + $url = route('invite', [$event->invitee->invite_code]); + try { + Mail::to($invitee)->send(new InvitationMail($invitee, $admin, $url)); + } catch (Exception $e) { + Log::error($e->getMessage()); + throw new FireflyException($e->getMessage(), 0, $e); + } + } + /** * This method will send the user a registration mail, welcoming him or her to Firefly III. * This message is only sent when the configuration of Firefly III says so. @@ -304,24 +322,6 @@ class UserEventHandler } } - /** - * @param RegisteredUser $event - */ - public function sendAdminRegistrationNotification(RegisteredUser $event): void - { - $sendMail = FireflyConfig::get('notification_admin_new_reg', true)->data; - if ($sendMail) { - /** @var UserRepositoryInterface $repository */ - $repository = app(UserRepositoryInterface::class); - $all = $repository->all(); - foreach ($all as $user) { - if ($repository->hasRole($user, 'owner')) { - Notification::send($user, new AdminRegistrationNotification($event->user)); - } - } - } - } - /** * @param ActuallyLoggedIn $event * @throws FireflyException diff --git a/app/Handlers/Events/VersionCheckEventHandler.php b/app/Handlers/Events/VersionCheckEventHandler.php index 2feb2ac916..55794f6e5a 100644 --- a/app/Handlers/Events/VersionCheckEventHandler.php +++ b/app/Handlers/Events/VersionCheckEventHandler.php @@ -1,4 +1,5 @@ get('permission_update_check', -1); - $value = (int) $permission->data; + $value = (int)$permission->data; if (1 !== $value) { Log::info('Update check is not enabled.'); $this->warnToCheckForUpdates($event); @@ -88,11 +91,11 @@ class VersionCheckEventHandler } /** - * @param RequestedVersionCheckStatus $event + * @param RequestedVersionCheckStatus $event * * @throws FireflyException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function warnToCheckForUpdates(RequestedVersionCheckStatus $event): void { @@ -118,7 +121,7 @@ class VersionCheckEventHandler // last check time was more than a week ago. Log::debug('Have warned about a new version in four weeks!'); - session()->flash('info', (string) trans('firefly.disabled_but_check')); + session()->flash('info', (string)trans('firefly.disabled_but_check')); app('fireflyconfig')->set('last_update_warning', time()); } } diff --git a/app/Handlers/Events/WebhookEventHandler.php b/app/Handlers/Events/WebhookEventHandler.php index 918d8a07c1..b5c51bc20a 100644 --- a/app/Handlers/Events/WebhookEventHandler.php +++ b/app/Handlers/Events/WebhookEventHandler.php @@ -40,12 +40,12 @@ class WebhookEventHandler // kick off the job! $messages = WebhookMessage::where('webhook_messages.sent', 0) //->where('webhook_messages.errored', 0) - ->get(['webhook_messages.*']) - ->filter( - function (WebhookMessage $message) { - return $message->webhookAttempts()->count() <= 2; - } - )->splice(0, 5); + ->get(['webhook_messages.*']) + ->filter( + function (WebhookMessage $message) { + return $message->webhookAttempts()->count() <= 2; + } + )->splice(0, 5); Log::debug(sprintf('Found %d webhook message(s) ready to be send.', $messages->count())); foreach ($messages as $message) { SendWebhookMessage::dispatch($message)->afterResponse(); diff --git a/app/Helpers/Attachments/AttachmentHelper.php b/app/Helpers/Attachments/AttachmentHelper.php index 2f307cec2f..9fe1160c44 100644 --- a/app/Helpers/Attachments/AttachmentHelper.php +++ b/app/Helpers/Attachments/AttachmentHelper.php @@ -1,4 +1,5 @@ maxUploadSize = (int) config('firefly.maxUploadSize'); - $this->allowedMimes = (array) config('firefly.allowedMimes'); + $this->maxUploadSize = (int)config('firefly.maxUploadSize'); + $this->allowedMimes = (array)config('firefly.allowedMimes'); $this->errors = new MessageBag(); $this->messages = new MessageBag(); $this->attachments = new Collection(); @@ -70,13 +71,13 @@ class AttachmentHelper implements AttachmentHelperInterface * * @codeCoverageIgnore * - * @param Attachment $attachment + * @param Attachment $attachment * * @return string */ public function getAttachmentContent(Attachment $attachment): string { - $encryptedData = (string) $this->uploadDisk->get(sprintf('at-%d.data', $attachment->id)); + $encryptedData = (string)$this->uploadDisk->get(sprintf('at-%d.data', $attachment->id)); try { $unencryptedData = Crypt::decrypt($encryptedData); // verified } catch (DecryptException $e) { @@ -90,14 +91,14 @@ class AttachmentHelper implements AttachmentHelperInterface /** * Returns the file path relative to upload disk for an attachment, * - * @param Attachment $attachment + * @param Attachment $attachment * * @codeCoverageIgnore * @return string */ public function getAttachmentLocation(Attachment $attachment): string { - return sprintf('%sat-%d.data', DIRECTORY_SEPARATOR, (int) $attachment->id); + return sprintf('%sat-%d.data', DIRECTORY_SEPARATOR, (int)$attachment->id); } /** @@ -136,8 +137,8 @@ class AttachmentHelper implements AttachmentHelperInterface /** * Uploads a file as a string. * - * @param Attachment $attachment - * @param string $content + * @param Attachment $attachment + * @param string $content * * @return bool */ @@ -185,8 +186,8 @@ class AttachmentHelper implements AttachmentHelperInterface /** * Save attachments that get uploaded with models, through the app. * - * @param object $model - * @param array|null $files + * @param object $model + * @param array|null $files * * @return bool * @throws FireflyException @@ -218,8 +219,8 @@ class AttachmentHelper implements AttachmentHelperInterface /** * Process the upload of a file. * - * @param UploadedFile $file - * @param Model $model + * @param UploadedFile $file + * @param Model $model * * @return Attachment|null * @throws FireflyException @@ -265,7 +266,7 @@ class AttachmentHelper implements AttachmentHelperInterface $this->attachments->push($attachment); $name = e($file->getClientOriginalName()); // add message: - $msg = (string) trans('validation.file_attached', ['name' => $name]); + $msg = (string)trans('validation.file_attached', ['name' => $name]); $this->messages->add('attachments', $msg); } @@ -275,8 +276,8 @@ class AttachmentHelper implements AttachmentHelperInterface /** * Verify if the file was uploaded correctly. * - * @param UploadedFile $file - * @param Model $model + * @param UploadedFile $file + * @param Model $model * * @return bool */ @@ -308,7 +309,7 @@ class AttachmentHelper implements AttachmentHelperInterface /** * Verify if the mime of a file is valid. * - * @param UploadedFile $file + * @param UploadedFile $file * * @return bool */ @@ -322,7 +323,7 @@ class AttachmentHelper implements AttachmentHelperInterface $result = true; if (!in_array($mime, $this->allowedMimes, true)) { - $msg = (string) trans('validation.file_invalid_mime', ['name' => $name, 'mime' => $mime]); + $msg = (string)trans('validation.file_invalid_mime', ['name' => $name, 'mime' => $mime]); $this->errors->add('attachments', $msg); Log::error($msg); @@ -337,7 +338,7 @@ class AttachmentHelper implements AttachmentHelperInterface * * @codeCoverageIgnore * - * @param UploadedFile $file + * @param UploadedFile $file * * @return bool */ @@ -347,7 +348,7 @@ class AttachmentHelper implements AttachmentHelperInterface $name = e($file->getClientOriginalName()); $result = true; if ($size > $this->maxUploadSize) { - $msg = (string) trans('validation.file_too_large', ['name' => $name]); + $msg = (string)trans('validation.file_too_large', ['name' => $name]); $this->errors->add('attachments', $msg); Log::error($msg); @@ -360,8 +361,8 @@ class AttachmentHelper implements AttachmentHelperInterface /** * Check if a model already has this file attached. * - * @param UploadedFile $file - * @param Model $model + * @param UploadedFile $file + * @param Model $model * * @return bool */ @@ -379,7 +380,7 @@ class AttachmentHelper implements AttachmentHelperInterface } $result = false; if ($count > 0) { - $msg = (string) trans('validation.file_already_attached', ['name' => $name]); + $msg = (string)trans('validation.file_already_attached', ['name' => $name]); $this->errors->add('attachments', $msg); Log::error($msg); $result = true; diff --git a/app/Helpers/Attachments/AttachmentHelperInterface.php b/app/Helpers/Attachments/AttachmentHelperInterface.php index b2fb2ae091..1b6173fc8a 100644 --- a/app/Helpers/Attachments/AttachmentHelperInterface.php +++ b/app/Helpers/Attachments/AttachmentHelperInterface.php @@ -1,4 +1,5 @@ postFilters[] = $filter; - - return $this; - } - - /** - * @param string $name - * @return GroupCollectorInterface - */ - public function attachmentNameDoesNotContain(string $name): GroupCollectorInterface - { - $this->hasAttachments(); - $this->withAttachmentInformation(); - $filter = function (int $index, array $object) use ($name): bool { - /** @var array $transaction */ - foreach ($object['transactions'] as $transaction) { - /** @var array $attachment */ - foreach ($transaction['attachments'] as $attachment) { - $result = !str_contains(strtolower($attachment['filename']), strtolower($name)) && !str_contains(strtolower($attachment['title']), strtolower($name)); + $result = str_contains(strtolower($attachment['filename']), strtolower($name)) || str_contains( + strtolower($attachment['title']), + strtolower($name) + ); if (true === $result) { return true; } @@ -137,10 +114,10 @@ trait AttachmentCollection } /** - * @param string $name + * @param string $name * @return GroupCollectorInterface */ - public function attachmentNameEnds(string $name): GroupCollectorInterface + public function attachmentNameDoesNotContain(string $name): GroupCollectorInterface { $this->hasAttachments(); $this->withAttachmentInformation(); @@ -149,7 +126,10 @@ trait AttachmentCollection foreach ($object['transactions'] as $transaction) { /** @var array $attachment */ foreach ($transaction['attachments'] as $attachment) { - $result = str_ends_with(strtolower($attachment['filename']), strtolower($name)) || str_ends_with(strtolower($attachment['title']), strtolower($name)); + $result = !str_contains(strtolower($attachment['filename']), strtolower($name)) && !str_contains( + strtolower($attachment['title']), + strtolower($name) + ); if (true === $result) { return true; } @@ -163,7 +143,7 @@ trait AttachmentCollection } /** - * @param string $name + * @param string $name * @return GroupCollectorInterface */ public function attachmentNameDoesNotEnd(string $name): GroupCollectorInterface @@ -175,7 +155,10 @@ trait AttachmentCollection foreach ($object['transactions'] as $transaction) { /** @var array $attachment */ foreach ($transaction['attachments'] as $attachment) { - $result = !str_ends_with(strtolower($attachment['filename']), strtolower($name)) && !str_ends_with(strtolower($attachment['title']), strtolower($name)); + $result = !str_ends_with(strtolower($attachment['filename']), strtolower($name)) && !str_ends_with( + strtolower($attachment['title']), + strtolower($name) + ); if (true === $result) { return true; } @@ -189,7 +172,65 @@ trait AttachmentCollection } /** - * @param string $name + * @param string $name + * @return GroupCollectorInterface + */ + public function attachmentNameDoesNotStart(string $name): GroupCollectorInterface + { + $this->hasAttachments(); + $this->withAttachmentInformation(); + $filter = function (int $index, array $object) use ($name): bool { + /** @var array $transaction */ + foreach ($object['transactions'] as $transaction) { + /** @var array $attachment */ + foreach ($transaction['attachments'] as $attachment) { + $result = !str_starts_with(strtolower($attachment['filename']), strtolower($name)) && !str_starts_with( + strtolower($attachment['title']), + strtolower($name) + ); + if (true === $result) { + return true; + } + } + } + return false; + }; + $this->postFilters[] = $filter; + + return $this; + } + + /** + * @param string $name + * @return GroupCollectorInterface + */ + public function attachmentNameEnds(string $name): GroupCollectorInterface + { + $this->hasAttachments(); + $this->withAttachmentInformation(); + $filter = function (int $index, array $object) use ($name): bool { + /** @var array $transaction */ + foreach ($object['transactions'] as $transaction) { + /** @var array $attachment */ + foreach ($transaction['attachments'] as $attachment) { + $result = str_ends_with(strtolower($attachment['filename']), strtolower($name)) || str_ends_with( + strtolower($attachment['title']), + strtolower($name) + ); + if (true === $result) { + return true; + } + } + } + return false; + }; + $this->postFilters[] = $filter; + + return $this; + } + + /** + * @param string $name * @return GroupCollectorInterface */ public function attachmentNameIs(string $name): GroupCollectorInterface @@ -215,7 +256,7 @@ trait AttachmentCollection } /** - * @param string $name + * @param string $name * @return GroupCollectorInterface */ public function attachmentNameIsNot(string $name): GroupCollectorInterface @@ -241,7 +282,7 @@ trait AttachmentCollection } /** - * @param string $name + * @param string $name * @return GroupCollectorInterface */ public function attachmentNameStarts(string $name): GroupCollectorInterface @@ -253,7 +294,10 @@ trait AttachmentCollection foreach ($object['transactions'] as $transaction) { /** @var array $attachment */ foreach ($transaction['attachments'] as $attachment) { - $result = str_starts_with(strtolower($attachment['filename']), strtolower($name)) || str_starts_with(strtolower($attachment['title']), strtolower($name)); + $result = str_starts_with(strtolower($attachment['filename']), strtolower($name)) || str_starts_with( + strtolower($attachment['title']), + strtolower($name) + ); if (true === $result) { return true; } @@ -267,33 +311,7 @@ trait AttachmentCollection } /** - * @param string $name - * @return GroupCollectorInterface - */ - public function attachmentNameDoesNotStart(string $name): GroupCollectorInterface - { - $this->hasAttachments(); - $this->withAttachmentInformation(); - $filter = function (int $index, array $object) use ($name): bool { - /** @var array $transaction */ - foreach ($object['transactions'] as $transaction) { - /** @var array $attachment */ - foreach ($transaction['attachments'] as $attachment) { - $result = !str_starts_with(strtolower($attachment['filename']), strtolower($name)) && !str_starts_with(strtolower($attachment['title']), strtolower($name)); - if (true === $result) { - return true; - } - } - } - return false; - }; - $this->postFilters[] = $filter; - - return $this; - } - - /** - * @param string $value + * @param string $value * @return GroupCollectorInterface */ public function attachmentNotesAre(string $value): GroupCollectorInterface @@ -307,7 +325,7 @@ trait AttachmentCollection foreach ($transaction['attachments'] as $attachment) { /** @var Attachment $object */ $object = auth()->user()->attachments()->find($attachment['id']); - $notes = (string) $object->notes()?->first()?->text; + $notes = (string)$object->notes()?->first()?->text; return $notes !== '' && $notes === $value; } } @@ -319,7 +337,7 @@ trait AttachmentCollection } /** - * @param string $value + * @param string $value * @return GroupCollectorInterface */ public function attachmentNotesAreNot(string $value): GroupCollectorInterface @@ -333,7 +351,7 @@ trait AttachmentCollection foreach ($transaction['attachments'] as $attachment) { /** @var Attachment $object */ $object = auth()->user()->attachments()->find($attachment['id']); - $notes = (string) $object->notes()?->first()?->text; + $notes = (string)$object->notes()?->first()?->text; return $notes !== '' && $notes !== $value; } } @@ -345,7 +363,7 @@ trait AttachmentCollection } /** - * @param string $value + * @param string $value * @return GroupCollectorInterface */ public function attachmentNotesContains(string $value): GroupCollectorInterface @@ -359,7 +377,7 @@ trait AttachmentCollection foreach ($transaction['attachments'] as $attachment) { /** @var Attachment $object */ $object = auth()->user()->attachments()->find($attachment['id']); - $notes = (string) $object->notes()?->first()?->text; + $notes = (string)$object->notes()?->first()?->text; return $notes !== '' && str_contains(strtolower($notes), strtolower($value)); } } @@ -371,7 +389,7 @@ trait AttachmentCollection } /** - * @param string $value + * @param string $value * @return GroupCollectorInterface */ public function attachmentNotesDoNotContain(string $value): GroupCollectorInterface @@ -385,7 +403,7 @@ trait AttachmentCollection foreach ($transaction['attachments'] as $attachment) { /** @var Attachment $object */ $object = auth()->user()->attachments()->find($attachment['id']); - $notes = (string) $object->notes()?->first()?->text; + $notes = (string)$object->notes()?->first()?->text; return $notes !== '' && !str_contains(strtolower($notes), strtolower($value)); } } @@ -397,33 +415,7 @@ trait AttachmentCollection } /** - * @param string $value - * @return GroupCollectorInterface - */ - public function attachmentNotesEnds(string $value): GroupCollectorInterface - { - $this->hasAttachments(); - $this->withAttachmentInformation(); - $filter = function (int $index, array $object) use ($value): bool { - /** @var array $transaction */ - foreach ($object['transactions'] as $transaction) { - /** @var array $attachment */ - foreach ($transaction['attachments'] as $attachment) { - /** @var Attachment $object */ - $object = auth()->user()->attachments()->find($attachment['id']); - $notes = (string) $object->notes()?->first()?->text; - return $notes !== '' && str_ends_with(strtolower($notes), strtolower($value)); - } - } - return false; - }; - $this->postFilters[] = $filter; - - return $this; - } - - /** - * @param string $value + * @param string $value * @return GroupCollectorInterface */ public function attachmentNotesDoNotEnd(string $value): GroupCollectorInterface @@ -437,7 +429,7 @@ trait AttachmentCollection foreach ($transaction['attachments'] as $attachment) { /** @var Attachment $object */ $object = auth()->user()->attachments()->find($attachment['id']); - $notes = (string) $object->notes()?->first()?->text; + $notes = (string)$object->notes()?->first()?->text; return $notes !== '' && !str_ends_with(strtolower($notes), strtolower($value)); } } @@ -449,33 +441,7 @@ trait AttachmentCollection } /** - * @param string $value - * @return GroupCollectorInterface - */ - public function attachmentNotesStarts(string $value): GroupCollectorInterface - { - $this->hasAttachments(); - $this->withAttachmentInformation(); - $filter = function (int $index, array $object) use ($value): bool { - /** @var array $transaction */ - foreach ($object['transactions'] as $transaction) { - /** @var array $attachment */ - foreach ($transaction['attachments'] as $attachment) { - /** @var Attachment $object */ - $object = auth()->user()->attachments()->find($attachment['id']); - $notes = (string) $object->notes()?->first()?->text; - return $notes !== '' && str_starts_with(strtolower($notes), strtolower($value)); - } - } - return false; - }; - $this->postFilters[] = $filter; - - return $this; - } - - /** - * @param string $value + * @param string $value * @return GroupCollectorInterface */ public function attachmentNotesDoNotStart(string $value): GroupCollectorInterface @@ -489,7 +455,7 @@ trait AttachmentCollection foreach ($transaction['attachments'] as $attachment) { /** @var Attachment $object */ $object = auth()->user()->attachments()->find($attachment['id']); - $notes = (string) $object->notes()?->first()?->text; + $notes = (string)$object->notes()?->first()?->text; return $notes !== '' && !str_starts_with(strtolower($notes), strtolower($value)); } } @@ -500,6 +466,58 @@ trait AttachmentCollection return $this; } + /** + * @param string $value + * @return GroupCollectorInterface + */ + public function attachmentNotesEnds(string $value): GroupCollectorInterface + { + $this->hasAttachments(); + $this->withAttachmentInformation(); + $filter = function (int $index, array $object) use ($value): bool { + /** @var array $transaction */ + foreach ($object['transactions'] as $transaction) { + /** @var array $attachment */ + foreach ($transaction['attachments'] as $attachment) { + /** @var Attachment $object */ + $object = auth()->user()->attachments()->find($attachment['id']); + $notes = (string)$object->notes()?->first()?->text; + return $notes !== '' && str_ends_with(strtolower($notes), strtolower($value)); + } + } + return false; + }; + $this->postFilters[] = $filter; + + return $this; + } + + /** + * @param string $value + * @return GroupCollectorInterface + */ + public function attachmentNotesStarts(string $value): GroupCollectorInterface + { + $this->hasAttachments(); + $this->withAttachmentInformation(); + $filter = function (int $index, array $object) use ($value): bool { + /** @var array $transaction */ + foreach ($object['transactions'] as $transaction) { + /** @var array $attachment */ + foreach ($transaction['attachments'] as $attachment) { + /** @var Attachment $object */ + $object = auth()->user()->attachments()->find($attachment['id']); + $notes = (string)$object->notes()?->first()?->text; + return $notes !== '' && str_starts_with(strtolower($notes), strtolower($value)); + } + } + return false; + }; + $this->postFilters[] = $filter; + + return $this; + } + /** * Has attachments * diff --git a/app/Helpers/Collector/Extensions/MetaCollection.php b/app/Helpers/Collector/Extensions/MetaCollection.php index 0af16d95a1..dff810fd7f 100644 --- a/app/Helpers/Collector/Extensions/MetaCollection.php +++ b/app/Helpers/Collector/Extensions/MetaCollection.php @@ -53,10 +53,29 @@ trait MetaCollection return $this; } + /** + * Will include bill name + ID, if any. + * + * @return GroupCollectorInterface + */ + public function withBillInformation(): GroupCollectorInterface + { + if (false === $this->hasBillInformation) { + // join bill table + $this->query->leftJoin('bills', 'bills.id', '=', 'transaction_journals.bill_id'); + // add fields + $this->fields[] = 'bills.id as bill_id'; + $this->fields[] = 'bills.name as bill_name'; + $this->hasBillInformation = true; + } + + return $this; + } + /** * Exclude a specific budget. * - * @param Budget $budget + * @param Budget $budget * * @return GroupCollectorInterface */ @@ -72,6 +91,27 @@ trait MetaCollection return $this; } + /** + * Will include budget ID + name, if any. + * + * @return GroupCollectorInterface + */ + public function withBudgetInformation(): GroupCollectorInterface + { + if (false === $this->hasBudgetInformation) { + // join link table + $this->query->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id'); + // join cat table + $this->query->leftJoin('budgets', 'budget_transaction_journal.budget_id', '=', 'budgets.id'); + // add fields + $this->fields[] = 'budgets.id as budget_id'; + $this->fields[] = 'budgets.name as budget_name'; + $this->hasBudgetInformation = true; + } + + return $this; + } + /** * @inheritDoc */ @@ -104,10 +144,31 @@ trait MetaCollection return $this; } + /** + * Will include category ID + name, if any. + * + * @return GroupCollectorInterface + */ + public function withCategoryInformation(): GroupCollectorInterface + { + if (false === $this->hasCatInformation) { + // join link table + $this->query->leftJoin('category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id'); + // join cat table + $this->query->leftJoin('categories', 'category_transaction_journal.category_id', '=', 'categories.id'); + // add fields + $this->fields[] = 'categories.id as category_id'; + $this->fields[] = 'categories.name as category_name'; + $this->hasCatInformation = true; + } + + return $this; + } + /** * Exclude a specific category. * - * @param Category $category + * @param Category $category * * @return GroupCollectorInterface */ @@ -126,11 +187,11 @@ trait MetaCollection /** * @inheritDoc */ - public function externalIdContains(string $externalId): GroupCollectorInterface + public function excludeExternalId(string $externalId): GroupCollectorInterface { $this->joinMetaDataTables(); $this->query->where('journal_meta.name', '=', 'external_id'); - $this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s%%', $externalId)); + $this->query->where('journal_meta.data', '!=', sprintf('%s', json_encode($externalId))); return $this; } @@ -138,11 +199,48 @@ trait MetaCollection /** * @inheritDoc */ - public function externalIdDoesNotContain(string $externalId): GroupCollectorInterface + public function excludeExternalUrl(string $url): GroupCollectorInterface + { + $this->joinMetaDataTables(); + $this->query->where('journal_meta.name', '=', 'external_url'); + $this->query->where('journal_meta.data', '!=', json_encode($url)); + + return $this; + } + + /** + * @inheritDoc + */ + public function excludeInternalReference(string $internalReference): GroupCollectorInterface + { + $this->joinMetaDataTables(); + + $this->query->where('journal_meta.name', '=', 'internal_reference'); + $this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s%%', $internalReference)); + + return $this; + } + + /** + * @inheritDoc + */ + public function excludeRecurrenceId(string $recurringId): GroupCollectorInterface + { + $this->joinMetaDataTables(); + $this->query->where('journal_meta.name', '=', 'recurrence_id'); + $this->query->where('journal_meta.data', '!=', sprintf('%s', json_encode($recurringId))); + + return $this; + } + + /** + * @inheritDoc + */ + public function externalIdContains(string $externalId): GroupCollectorInterface { $this->joinMetaDataTables(); $this->query->where('journal_meta.name', '=', 'external_id'); - $this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s%%', $externalId)); + $this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s%%', $externalId)); return $this; } @@ -163,11 +261,11 @@ trait MetaCollection /** * @inheritDoc */ - public function externalIdEnds(string $externalId): GroupCollectorInterface + public function externalIdDoesNotContain(string $externalId): GroupCollectorInterface { $this->joinMetaDataTables(); $this->query->where('journal_meta.name', '=', 'external_id'); - $this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s"', $externalId)); + $this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s%%', $externalId)); return $this; } @@ -187,7 +285,7 @@ trait MetaCollection /** * @inheritDoc */ - public function externalIdStarts(string $externalId): GroupCollectorInterface + public function externalIdDoesNotStart(string $externalId): GroupCollectorInterface { $this->joinMetaDataTables(); $this->query->where('journal_meta.name', '=', 'external_id'); @@ -199,7 +297,19 @@ trait MetaCollection /** * @inheritDoc */ - public function externalIdDoesNotStart(string $externalId): GroupCollectorInterface + public function externalIdEnds(string $externalId): GroupCollectorInterface + { + $this->joinMetaDataTables(); + $this->query->where('journal_meta.name', '=', 'external_id'); + $this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s"', $externalId)); + + return $this; + } + + /** + * @inheritDoc + */ + public function externalIdStarts(string $externalId): GroupCollectorInterface { $this->joinMetaDataTables(); $this->query->where('journal_meta.name', '=', 'external_id'); @@ -209,7 +319,7 @@ trait MetaCollection } /** - * @param string $url + * @param string $url * @return GroupCollectorInterface */ public function externalUrlContains(string $url): GroupCollectorInterface @@ -224,7 +334,7 @@ trait MetaCollection } /** - * @param string $url + * @param string $url * @return GroupCollectorInterface */ public function externalUrlDoesNotContain(string $url): GroupCollectorInterface @@ -237,8 +347,41 @@ trait MetaCollection return $this; } + /** - * @param string $url + * @param string $url + * @return GroupCollectorInterface + */ + public function externalUrlDoesNotEnd(string $url): GroupCollectorInterface + { + $this->joinMetaDataTables(); + $url = json_encode($url); + $url = str_replace('\\', '\\\\', ltrim($url, '"')); + $this->query->where('journal_meta.name', '=', 'external_url'); + $this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s', $url)); + + return $this; + } + + /** + * @param string $url + * @return GroupCollectorInterface + */ + public function externalUrlDoesNotStart(string $url): GroupCollectorInterface + { + $this->joinMetaDataTables(); + $url = json_encode($url); + $url = str_replace('\\', '\\\\', rtrim($url, '"')); + //var_dump($url); + + $this->query->where('journal_meta.name', '=', 'external_url'); + $this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%s%%', $url)); + + return $this; + } + + /** + * @param string $url * @return GroupCollectorInterface */ public function externalUrlEnds(string $url): GroupCollectorInterface @@ -253,21 +396,7 @@ trait MetaCollection } /** - * @param string $url - * @return GroupCollectorInterface - */ - public function externalUrlDoesNotEnd(string $url): GroupCollectorInterface - { - $this->joinMetaDataTables(); - $url = json_encode($url); - $url = str_replace('\\', '\\\\', ltrim($url, '"')); - $this->query->where('journal_meta.name', '=', 'external_url'); - $this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s', $url)); - - return $this; - } - /** - * @param string $url + * @param string $url * @return GroupCollectorInterface */ public function externalUrlStarts(string $url): GroupCollectorInterface @@ -283,23 +412,6 @@ trait MetaCollection return $this; } - /** - * @param string $url - * @return GroupCollectorInterface - */ - public function externalUrlDoesNotStart(string $url): GroupCollectorInterface - { - $this->joinMetaDataTables(); - $url = json_encode($url); - $url = str_replace('\\', '\\\\', rtrim($url, '"')); - //var_dump($url); - - $this->query->where('journal_meta.name', '=', 'external_url'); - $this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%s%%', $url)); - - return $this; - } - /** * Where has no tags. * @@ -368,18 +480,6 @@ trait MetaCollection return $this; } - /** - * @inheritDoc - */ - public function internalReferenceEnds(string $externalId): GroupCollectorInterface - { - $this->joinMetaDataTables(); - $this->query->where('journal_meta.name', '=', 'internal_reference'); - $this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s"', $externalId)); - - return $this; - } - /** * @inheritDoc */ @@ -392,18 +492,6 @@ trait MetaCollection return $this; } - /** - * @inheritDoc - */ - public function internalReferenceStarts(string $externalId): GroupCollectorInterface - { - $this->joinMetaDataTables(); - $this->query->where('journal_meta.name', '=', 'internal_reference'); - $this->query->where('journal_meta.data', 'LIKE', sprintf('"%s%%', $externalId)); - - return $this; - } - /** * @inheritDoc */ @@ -417,7 +505,31 @@ trait MetaCollection } /** - * @param string $value + * @inheritDoc + */ + public function internalReferenceEnds(string $externalId): GroupCollectorInterface + { + $this->joinMetaDataTables(); + $this->query->where('journal_meta.name', '=', 'internal_reference'); + $this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s"', $externalId)); + + return $this; + } + + /** + * @inheritDoc + */ + public function internalReferenceStarts(string $externalId): GroupCollectorInterface + { + $this->joinMetaDataTables(); + $this->query->where('journal_meta.name', '=', 'internal_reference'); + $this->query->where('journal_meta.data', 'LIKE', sprintf('"%s%%', $externalId)); + + return $this; + } + + /** + * @param string $value * * @return GroupCollectorInterface */ @@ -453,7 +565,7 @@ trait MetaCollection } /** - * @param string $value + * @param string $value * * @return GroupCollectorInterface */ @@ -469,7 +581,7 @@ trait MetaCollection } /** - * @param string $value + * @param string $value * * @return GroupCollectorInterface */ @@ -485,7 +597,7 @@ trait MetaCollection } /** - * @param string $value + * @param string $value * * @return GroupCollectorInterface */ @@ -501,7 +613,7 @@ trait MetaCollection } /** - * @param string $value + * @param string $value * * @return GroupCollectorInterface */ @@ -514,7 +626,7 @@ trait MetaCollection } /** - * @param string $value + * @param string $value * * @return GroupCollectorInterface */ @@ -527,7 +639,7 @@ trait MetaCollection } /** - * @param string $value + * @param string $value * * @return GroupCollectorInterface */ @@ -543,7 +655,7 @@ trait MetaCollection } /** - * @param string $value + * @param string $value * * @return GroupCollectorInterface */ @@ -558,7 +670,7 @@ trait MetaCollection /** * Limit the search to a specific bill. * - * @param Bill $bill + * @param Bill $bill * * @return GroupCollectorInterface */ @@ -570,29 +682,10 @@ trait MetaCollection return $this; } - /** - * Will include bill name + ID, if any. - * - * @return GroupCollectorInterface - */ - public function withBillInformation(): GroupCollectorInterface - { - if (false === $this->hasBillInformation) { - // join bill table - $this->query->leftJoin('bills', 'bills.id', '=', 'transaction_journals.bill_id'); - // add fields - $this->fields[] = 'bills.id as bill_id'; - $this->fields[] = 'bills.name as bill_name'; - $this->hasBillInformation = true; - } - - return $this; - } - /** * Limit the search to a specific set of bills. * - * @param Collection $bills + * @param Collection $bills * * @return GroupCollectorInterface */ @@ -607,7 +700,7 @@ trait MetaCollection /** * Limit the search to a specific budget. * - * @param Budget $budget + * @param Budget $budget * * @return GroupCollectorInterface */ @@ -619,31 +712,10 @@ trait MetaCollection return $this; } - /** - * Will include budget ID + name, if any. - * - * @return GroupCollectorInterface - */ - public function withBudgetInformation(): GroupCollectorInterface - { - if (false === $this->hasBudgetInformation) { - // join link table - $this->query->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id'); - // join cat table - $this->query->leftJoin('budgets', 'budget_transaction_journal.budget_id', '=', 'budgets.id'); - // add fields - $this->fields[] = 'budgets.id as budget_id'; - $this->fields[] = 'budgets.name as budget_name'; - $this->hasBudgetInformation = true; - } - - return $this; - } - /** * Limit the search to a specific set of budgets. * - * @param Collection $budgets + * @param Collection $budgets * * @return GroupCollectorInterface */ @@ -660,7 +732,7 @@ trait MetaCollection /** * Limit the search to a specific bunch of categories. * - * @param Collection $categories + * @param Collection $categories * * @return GroupCollectorInterface */ @@ -674,31 +746,10 @@ trait MetaCollection return $this; } - /** - * Will include category ID + name, if any. - * - * @return GroupCollectorInterface - */ - public function withCategoryInformation(): GroupCollectorInterface - { - if (false === $this->hasCatInformation) { - // join link table - $this->query->leftJoin('category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id'); - // join cat table - $this->query->leftJoin('categories', 'category_transaction_journal.category_id', '=', 'categories.id'); - // add fields - $this->fields[] = 'categories.id as category_id'; - $this->fields[] = 'categories.name as category_name'; - $this->hasCatInformation = true; - } - - return $this; - } - /** * Limit the search to a specific category. * - * @param Category $category + * @param Category $category * * @return GroupCollectorInterface */ @@ -722,19 +773,6 @@ trait MetaCollection return $this; } - - /** - * @inheritDoc - */ - public function excludeExternalId(string $externalId): GroupCollectorInterface - { - $this->joinMetaDataTables(); - $this->query->where('journal_meta.name', '=', 'external_id'); - $this->query->where('journal_meta.data', '!=', sprintf('%s', json_encode($externalId))); - - return $this; - } - /** * @inheritDoc */ @@ -747,18 +785,6 @@ trait MetaCollection return $this; } - /** - * @inheritDoc - */ - public function excludeExternalUrl(string $url): GroupCollectorInterface - { - $this->joinMetaDataTables(); - $this->query->where('journal_meta.name', '=', 'external_url'); - $this->query->where('journal_meta.data', '!=', json_encode($url)); - - return $this; - } - /** * @inheritDoc */ @@ -772,19 +798,6 @@ trait MetaCollection return $this; } - /** - * @inheritDoc - */ - public function excludeInternalReference(string $internalReference): GroupCollectorInterface - { - $this->joinMetaDataTables(); - - $this->query->where('journal_meta.name', '=', 'internal_reference'); - $this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s%%', $internalReference)); - - return $this; - } - /** * @inheritDoc */ @@ -800,11 +813,12 @@ trait MetaCollection /** * @inheritDoc */ - public function excludeRecurrenceId(string $recurringId): GroupCollectorInterface + public function setSepaCT(string $sepaCT): GroupCollectorInterface { $this->joinMetaDataTables(); - $this->query->where('journal_meta.name', '=', 'recurrence_id'); - $this->query->where('journal_meta.data', '!=', sprintf('%s', json_encode($recurringId))); + $this->query->where('journal_meta.name', '=', 'sepa_ct_id'); + $this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($sepaCT))); + $this->query->whereNull('journal_meta.deleted_at'); return $this; } @@ -812,7 +826,7 @@ trait MetaCollection /** * Limit results to a specific tag. * - * @param Tag $tag + * @param Tag $tag * * @return GroupCollectorInterface */ @@ -827,7 +841,7 @@ trait MetaCollection /** * Limit results to a specific set of tags. * - * @param Collection $tags + * @param Collection $tags * * @return GroupCollectorInterface */ @@ -842,7 +856,7 @@ trait MetaCollection /** * Without tags * - * @param Collection $tags + * @param Collection $tags * * @return GroupCollectorInterface */ @@ -921,10 +935,10 @@ trait MetaCollection /** * @inheritDoc */ - public function withExternalUrl(): GroupCollectorInterface + public function withExternalId(): GroupCollectorInterface { $this->joinMetaDataTables(); - $this->query->where('journal_meta.name', '=', 'external_url'); + $this->query->where('journal_meta.name', '=', 'external_id'); $this->query->whereNotNull('journal_meta.data'); return $this; @@ -933,10 +947,10 @@ trait MetaCollection /** * @inheritDoc */ - public function withExternalId(): GroupCollectorInterface + public function withExternalUrl(): GroupCollectorInterface { $this->joinMetaDataTables(); - $this->query->where('journal_meta.name', '=', 'external_id'); + $this->query->where('journal_meta.name', '=', 'external_url'); $this->query->whereNotNull('journal_meta.data'); return $this; @@ -980,26 +994,6 @@ trait MetaCollection return $this; } - /** - * @inheritDoc - */ - public function withoutExternalUrl(): GroupCollectorInterface - { - $this->joinMetaDataTables(); - // TODO not sure if this will work properly. - $this->query->where(function (Builder $q1) { - $q1->where(function (Builder $q2) { - $q2->where('journal_meta.name', '=', 'external_url'); - $q2->whereNull('journal_meta.data'); - })->orWhere(function (Builder $q3) { - $q3->where('journal_meta.name', '!=', 'external_url'); - })->orWhere(function (Builder $q4) { - $q4->whereNull('journal_meta.name'); - }); - }); - - return $this; - } /** * @inheritDoc */ @@ -1021,6 +1015,27 @@ trait MetaCollection return $this; } + /** + * @inheritDoc + */ + public function withoutExternalUrl(): GroupCollectorInterface + { + $this->joinMetaDataTables(); + // TODO not sure if this will work properly. + $this->query->where(function (Builder $q1) { + $q1->where(function (Builder $q2) { + $q2->where('journal_meta.name', '=', 'external_url'); + $q2->whereNull('journal_meta.data'); + })->orWhere(function (Builder $q3) { + $q3->where('journal_meta.name', '!=', 'external_url'); + })->orWhere(function (Builder $q4) { + $q4->whereNull('journal_meta.name'); + }); + }); + + return $this; + } + /** * @return GroupCollectorInterface */ @@ -1047,17 +1062,4 @@ trait MetaCollection return $this; } - - /** - * @inheritDoc - */ - public function setSepaCT(string $sepaCT): GroupCollectorInterface - { - $this->joinMetaDataTables(); - $this->query->where('journal_meta.name', '=', 'sepa_ct_id'); - $this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($sepaCT))); - $this->query->whereNull('journal_meta.deleted_at'); - - return $this; - } } diff --git a/app/Helpers/Collector/Extensions/TimeCollection.php b/app/Helpers/Collector/Extensions/TimeCollection.php index 605f8dcab5..31bbd13f03 100644 --- a/app/Helpers/Collector/Extensions/TimeCollection.php +++ b/app/Helpers/Collector/Extensions/TimeCollection.php @@ -33,7 +33,7 @@ use FireflyIII\Helpers\Collector\GroupCollectorInterface; trait TimeCollection { /** - * @param string $day + * @param string $day * @return GroupCollectorInterface */ public function dayAfter(string $day): GroupCollectorInterface @@ -43,7 +43,7 @@ trait TimeCollection } /** - * @param string $day + * @param string $day * @return GroupCollectorInterface */ public function dayBefore(string $day): GroupCollectorInterface @@ -53,7 +53,7 @@ trait TimeCollection } /** - * @param string $day + * @param string $day * @return GroupCollectorInterface */ public function dayIs(string $day): GroupCollectorInterface @@ -63,7 +63,7 @@ trait TimeCollection } /** - * @param string $day + * @param string $day * @return GroupCollectorInterface */ public function dayIsNot(string $day): GroupCollectorInterface @@ -73,9 +73,9 @@ trait TimeCollection } /** - * @param Carbon $start - * @param Carbon $end - * @param string $field + * @param Carbon $start + * @param Carbon $end + * @param string $field * @return GroupCollectorInterface */ public function excludeMetaDateRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface @@ -103,9 +103,21 @@ trait TimeCollection } /** - * @param Carbon $start - * @param Carbon $end - * @param string $field + * @inheritDoc + */ + public function withMetaDate(string $field): GroupCollectorInterface + { + $this->joinMetaDataTables(); + $this->query->where('journal_meta.name', '=', $field); + $this->query->whereNotNull('journal_meta.data'); + + return $this; + } + + /** + * @param Carbon $start + * @param Carbon $end + * @param string $field * @return GroupCollectorInterface */ public function excludeObjectRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface @@ -120,8 +132,8 @@ trait TimeCollection } /** - * @param Carbon $start - * @param Carbon $end + * @param Carbon $start + * @param Carbon $end * @return GroupCollectorInterface */ public function excludeRange(Carbon $start, Carbon $end): GroupCollectorInterface @@ -139,8 +151,8 @@ trait TimeCollection } /** - * @param string $day - * @param string $field + * @param string $day + * @param string $field * @return GroupCollectorInterface */ public function metaDayAfter(string $day, string $field): GroupCollectorInterface @@ -150,7 +162,7 @@ trait TimeCollection foreach ($object['transactions'] as $transaction) { if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon ) { - return $transaction[$field]->day >= (int) $day; + return $transaction[$field]->day >= (int)$day; } } @@ -162,20 +174,8 @@ trait TimeCollection } /** - * @inheritDoc - */ - public function withMetaDate(string $field): GroupCollectorInterface - { - $this->joinMetaDataTables(); - $this->query->where('journal_meta.name', '=', $field); - $this->query->whereNotNull('journal_meta.data'); - - return $this; - } - - /** - * @param string $day - * @param string $field + * @param string $day + * @param string $field * @return GroupCollectorInterface */ public function metaDayBefore(string $day, string $field): GroupCollectorInterface @@ -185,7 +185,7 @@ trait TimeCollection foreach ($object['transactions'] as $transaction) { if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon ) { - return $transaction[$field]->day <= (int) $day; + return $transaction[$field]->day <= (int)$day; } } @@ -197,8 +197,8 @@ trait TimeCollection } /** - * @param string $day - * @param string $field + * @param string $day + * @param string $field * @return GroupCollectorInterface */ public function metaDayIs(string $day, string $field): GroupCollectorInterface @@ -208,7 +208,7 @@ trait TimeCollection foreach ($object['transactions'] as $transaction) { if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon ) { - return (int) $day === $transaction[$field]->day; + return (int)$day === $transaction[$field]->day; } } @@ -219,8 +219,8 @@ trait TimeCollection } /** - * @param string $day - * @param string $field + * @param string $day + * @param string $field * @return GroupCollectorInterface */ public function metaDayIsNot(string $day, string $field): GroupCollectorInterface @@ -230,7 +230,7 @@ trait TimeCollection foreach ($object['transactions'] as $transaction) { if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon ) { - return (int) $day !== $transaction[$field]->day; + return (int)$day !== $transaction[$field]->day; } } @@ -241,8 +241,8 @@ trait TimeCollection } /** - * @param string $month - * @param string $field + * @param string $month + * @param string $field * @return GroupCollectorInterface */ public function metaMonthAfter(string $month, string $field): GroupCollectorInterface @@ -252,7 +252,7 @@ trait TimeCollection foreach ($object['transactions'] as $transaction) { if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon ) { - return $transaction[$field]->month >= (int) $month; + return $transaction[$field]->month >= (int)$month; } } @@ -264,8 +264,8 @@ trait TimeCollection } /** - * @param string $month - * @param string $field + * @param string $month + * @param string $field * @return GroupCollectorInterface */ public function metaMonthBefore(string $month, string $field): GroupCollectorInterface @@ -275,7 +275,7 @@ trait TimeCollection foreach ($object['transactions'] as $transaction) { if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon ) { - return $transaction[$field]->month <= (int) $month; + return $transaction[$field]->month <= (int)$month; } } @@ -287,8 +287,8 @@ trait TimeCollection } /** - * @param string $month - * @param string $field + * @param string $month + * @param string $field * @return GroupCollectorInterface */ public function metaMonthIs(string $month, string $field): GroupCollectorInterface @@ -298,7 +298,7 @@ trait TimeCollection foreach ($object['transactions'] as $transaction) { if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon ) { - return (int) $month === $transaction[$field]->month; + return (int)$month === $transaction[$field]->month; } } @@ -309,8 +309,8 @@ trait TimeCollection } /** - * @param string $month - * @param string $field + * @param string $month + * @param string $field * @return GroupCollectorInterface */ public function metaMonthIsNot(string $month, string $field): GroupCollectorInterface @@ -320,7 +320,7 @@ trait TimeCollection foreach ($object['transactions'] as $transaction) { if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon ) { - return (int) $month !== $transaction[$field]->month; + return (int)$month !== $transaction[$field]->month; } } @@ -331,8 +331,8 @@ trait TimeCollection } /** - * @param string $year - * @param string $field + * @param string $year + * @param string $field * @return GroupCollectorInterface */ public function metaYearAfter(string $year, string $field): GroupCollectorInterface @@ -342,7 +342,7 @@ trait TimeCollection foreach ($object['transactions'] as $transaction) { if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon ) { - return $transaction[$field]->year >= (int) $year; + return $transaction[$field]->year >= (int)$year; } } @@ -354,8 +354,8 @@ trait TimeCollection } /** - * @param string $year - * @param string $field + * @param string $year + * @param string $field * @return GroupCollectorInterface */ public function metaYearBefore(string $year, string $field): GroupCollectorInterface @@ -365,7 +365,7 @@ trait TimeCollection foreach ($object['transactions'] as $transaction) { if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon ) { - return $transaction[$field]->year <= (int) $year; + return $transaction[$field]->year <= (int)$year; } } @@ -377,8 +377,8 @@ trait TimeCollection } /** - * @param string $year - * @param string $field + * @param string $year + * @param string $field * @return GroupCollectorInterface */ public function metaYearIs(string $year, string $field): GroupCollectorInterface @@ -388,7 +388,7 @@ trait TimeCollection foreach ($object['transactions'] as $transaction) { if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon ) { - return $year === (string) $transaction[$field]->year; + return $year === (string)$transaction[$field]->year; } } @@ -400,8 +400,8 @@ trait TimeCollection } /** - * @param string $year - * @param string $field + * @param string $year + * @param string $field * @return GroupCollectorInterface */ public function metaYearIsNot(string $year, string $field): GroupCollectorInterface @@ -411,7 +411,7 @@ trait TimeCollection foreach ($object['transactions'] as $transaction) { if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon ) { - return $year !== (string) $transaction[$field]->year; + return $year !== (string)$transaction[$field]->year; } } return true; @@ -422,7 +422,7 @@ trait TimeCollection } /** - * @param string $month + * @param string $month * @return GroupCollectorInterface */ public function monthAfter(string $month): GroupCollectorInterface @@ -432,7 +432,7 @@ trait TimeCollection } /** - * @param string $month + * @param string $month * @return GroupCollectorInterface */ public function monthBefore(string $month): GroupCollectorInterface @@ -442,7 +442,7 @@ trait TimeCollection } /** - * @param string $month + * @param string $month * @return GroupCollectorInterface */ public function monthIs(string $month): GroupCollectorInterface @@ -452,7 +452,7 @@ trait TimeCollection } /** - * @param string $month + * @param string $month * @return GroupCollectorInterface */ public function monthIsNot(string $month): GroupCollectorInterface @@ -462,8 +462,8 @@ trait TimeCollection } /** - * @param string $day - * @param string $field + * @param string $day + * @param string $field * @return GroupCollectorInterface */ public function objectDayAfter(string $day, string $field): GroupCollectorInterface @@ -473,8 +473,8 @@ trait TimeCollection } /** - * @param string $day - * @param string $field + * @param string $day + * @param string $field * @return GroupCollectorInterface */ public function objectDayBefore(string $day, string $field): GroupCollectorInterface @@ -484,8 +484,8 @@ trait TimeCollection } /** - * @param string $day - * @param string $field + * @param string $day + * @param string $field * @return GroupCollectorInterface */ public function objectDayIs(string $day, string $field): GroupCollectorInterface @@ -495,8 +495,8 @@ trait TimeCollection } /** - * @param string $day - * @param string $field + * @param string $day + * @param string $field * @return GroupCollectorInterface */ public function objectDayIsNot(string $day, string $field): GroupCollectorInterface @@ -506,8 +506,8 @@ trait TimeCollection } /** - * @param string $month - * @param string $field + * @param string $month + * @param string $field * @return GroupCollectorInterface */ public function objectMonthAfter(string $month, string $field): GroupCollectorInterface @@ -517,8 +517,8 @@ trait TimeCollection } /** - * @param string $month - * @param string $field + * @param string $month + * @param string $field * @return GroupCollectorInterface */ public function objectMonthBefore(string $month, string $field): GroupCollectorInterface @@ -528,8 +528,8 @@ trait TimeCollection } /** - * @param string $month - * @param string $field + * @param string $month + * @param string $field * @return GroupCollectorInterface */ public function objectMonthIs(string $month, string $field): GroupCollectorInterface @@ -539,8 +539,8 @@ trait TimeCollection } /** - * @param string $month - * @param string $field + * @param string $month + * @param string $field * @return GroupCollectorInterface */ public function objectMonthIsNot(string $month, string $field): GroupCollectorInterface @@ -550,8 +550,8 @@ trait TimeCollection } /** - * @param string $year - * @param string $field + * @param string $year + * @param string $field * @return GroupCollectorInterface */ public function objectYearAfter(string $year, string $field): GroupCollectorInterface @@ -561,8 +561,8 @@ trait TimeCollection } /** - * @param string $year - * @param string $field + * @param string $year + * @param string $field * @return GroupCollectorInterface */ public function objectYearBefore(string $year, string $field): GroupCollectorInterface @@ -572,8 +572,8 @@ trait TimeCollection } /** - * @param string $year - * @param string $field + * @param string $year + * @param string $field * @return GroupCollectorInterface */ public function objectYearIs(string $year, string $field): GroupCollectorInterface @@ -583,8 +583,8 @@ trait TimeCollection } /** - * @param string $year - * @param string $field + * @param string $year + * @param string $field * @return GroupCollectorInterface */ public function objectYearIsNot(string $year, string $field): GroupCollectorInterface @@ -596,7 +596,7 @@ trait TimeCollection /** * Collect transactions after a specific date. * - * @param Carbon $date + * @param Carbon $date * * @return GroupCollectorInterface */ @@ -611,7 +611,7 @@ trait TimeCollection /** * Collect transactions before a specific date. * - * @param Carbon $date + * @param Carbon $date * * @return GroupCollectorInterface */ @@ -626,7 +626,7 @@ trait TimeCollection /** * Collect transactions created on a specific date. * - * @param Carbon $date + * @param Carbon $date * * @return GroupCollectorInterface */ @@ -641,8 +641,8 @@ trait TimeCollection } /** - * @param Carbon $date - * @param string $field + * @param Carbon $date + * @param string $field * @return GroupCollectorInterface */ public function setMetaAfter(Carbon $date, string $field): GroupCollectorInterface @@ -665,8 +665,8 @@ trait TimeCollection } /** - * @param Carbon $date - * @param string $field + * @param Carbon $date + * @param string $field * @return GroupCollectorInterface */ public function setMetaBefore(Carbon $date, string $field): GroupCollectorInterface @@ -688,9 +688,9 @@ trait TimeCollection } /** - * @param Carbon $start - * @param Carbon $end - * @param string $field + * @param Carbon $start + * @param Carbon $end + * @param string $field * @return GroupCollectorInterface */ public function setMetaDateRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface @@ -718,8 +718,8 @@ trait TimeCollection } /** - * @param Carbon $date - * @param string $field + * @param Carbon $date + * @param string $field * @return GroupCollectorInterface */ public function setObjectAfter(Carbon $date, string $field): GroupCollectorInterface @@ -731,8 +731,8 @@ trait TimeCollection } /** - * @param Carbon $date - * @param string $field + * @param Carbon $date + * @param string $field * @return GroupCollectorInterface */ public function setObjectBefore(Carbon $date, string $field): GroupCollectorInterface @@ -743,9 +743,9 @@ trait TimeCollection } /** - * @param Carbon $start - * @param Carbon $end - * @param string $field + * @param Carbon $start + * @param Carbon $end + * @param string $field * @return GroupCollectorInterface */ public function setObjectRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface @@ -761,8 +761,8 @@ trait TimeCollection /** * Set the start and end time of the results to return. * - * @param Carbon $start - * @param Carbon $end + * @param Carbon $start + * @param Carbon $end * * @return GroupCollectorInterface */ @@ -784,7 +784,7 @@ trait TimeCollection /** * Collect transactions updated on a specific date. * - * @param Carbon $date + * @param Carbon $date * * @return GroupCollectorInterface */ @@ -799,7 +799,7 @@ trait TimeCollection } /** - * @param string $year + * @param string $year * @return GroupCollectorInterface */ public function yearAfter(string $year): GroupCollectorInterface @@ -809,7 +809,7 @@ trait TimeCollection } /** - * @param string $year + * @param string $year * @return GroupCollectorInterface */ public function yearBefore(string $year): GroupCollectorInterface @@ -819,7 +819,7 @@ trait TimeCollection } /** - * @param string $year + * @param string $year * @return GroupCollectorInterface */ public function yearIs(string $year): GroupCollectorInterface @@ -829,7 +829,7 @@ trait TimeCollection } /** - * @param string $year + * @param string $year * @return GroupCollectorInterface */ public function yearIsNot(string $year): GroupCollectorInterface diff --git a/app/Helpers/Collector/GroupCollector.php b/app/Helpers/Collector/GroupCollector.php index 04389cf846..835d7ef57c 100644 --- a/app/Helpers/Collector/GroupCollector.php +++ b/app/Helpers/Collector/GroupCollector.php @@ -315,7 +315,7 @@ class GroupCollector implements GroupCollectorInterface /** * Limit results to NOT a specific currency, either foreign or normal one. * - * @param TransactionCurrency $currency + * @param TransactionCurrency $currency * * @return GroupCollectorInterface */ @@ -352,7 +352,7 @@ class GroupCollector implements GroupCollectorInterface /** * Limit the result to NOT a set of specific transaction groups. * - * @param array $groupIds + * @param array $groupIds * * @return GroupCollectorInterface */ @@ -366,7 +366,7 @@ class GroupCollector implements GroupCollectorInterface /** * Limit the result to NOT a set of specific journals. * - * @param array $journalIds + * @param array $journalIds * * @return GroupCollectorInterface */ @@ -386,7 +386,7 @@ class GroupCollector implements GroupCollectorInterface /** * Search for words in descriptions. * - * @param array $array + * @param array $array * * @return GroupCollectorInterface */ @@ -500,7 +500,7 @@ class GroupCollector implements GroupCollectorInterface } /** - * @param Collection $collection + * @param Collection $collection * * @return Collection */ @@ -515,21 +515,21 @@ class GroupCollector implements GroupCollectorInterface // make new array $parsedGroup = $this->parseAugmentedJournal($augumentedJournal); $groupArray = [ - 'id' => (int) $augumentedJournal->transaction_group_id, - 'user_id' => (int) $augumentedJournal->user_id, + 'id' => (int)$augumentedJournal->transaction_group_id, + 'user_id' => (int)$augumentedJournal->user_id, 'title' => $augumentedJournal->transaction_group_title, 'transaction_type' => $parsedGroup['transaction_type_type'], 'count' => 1, 'sums' => [], 'transactions' => [], ]; - $journalId = (int) $augumentedJournal->transaction_journal_id; + $journalId = (int)$augumentedJournal->transaction_journal_id; $groupArray['transactions'][$journalId] = $parsedGroup; $groups[$groupId] = $groupArray; continue; } // or parse the rest. - $journalId = (int) $augumentedJournal->transaction_journal_id; + $journalId = (int)$augumentedJournal->transaction_journal_id; if (array_key_exists($journalId, $groups[$groupId]['transactions'])) { // append data to existing group + journal (for multiple tags or multiple attachments) $groups[$groupId]['transactions'][$journalId] = $this->mergeTags($groups[$groupId]['transactions'][$journalId], $augumentedJournal); @@ -549,7 +549,7 @@ class GroupCollector implements GroupCollectorInterface } /** - * @param TransactionJournal $augumentedJournal + * @param TransactionJournal $augumentedJournal * * @return array */ @@ -582,7 +582,7 @@ class GroupCollector implements GroupCollectorInterface $dates = ['interest_date', 'payment_date', 'invoice_date', 'book_date', 'due_date', 'process_date']; if (array_key_exists('meta_name', $result) && in_array($result['meta_name'], $dates, true)) { $name = $result['meta_name']; - if (array_key_exists('meta_data', $result) && '' !== (string) $result['meta_data']) { + if (array_key_exists('meta_data', $result) && '' !== (string)$result['meta_data']) { $result[$name] = Carbon::createFromFormat('!Y-m-d', substr(json_decode($result['meta_data']), 0, 10)); } } @@ -593,9 +593,9 @@ class GroupCollector implements GroupCollectorInterface // convert back to strings because SQLite is dumb like that. $result = $this->convertToStrings($result); - $result['reconciled'] = 1 === (int) $result['reconciled']; + $result['reconciled'] = 1 === (int)$result['reconciled']; if (array_key_exists('tag_id', $result) && null !== $result['tag_id']) { // assume the other fields are present as well. - $tagId = (int) $augumentedJournal['tag_id']; + $tagId = (int)$augumentedJournal['tag_id']; $tagDate = null; try { $tagDate = Carbon::parse($augumentedJournal['tag_date']); @@ -604,7 +604,7 @@ class GroupCollector implements GroupCollectorInterface } $result['tags'][$tagId] = [ - 'id' => (int) $result['tag_id'], + 'id' => (int)$result['tag_id'], 'name' => $result['tag_name'], 'date' => $tagDate, 'description' => $result['tag_description'], @@ -613,8 +613,8 @@ class GroupCollector implements GroupCollectorInterface // also merge attachments: if (array_key_exists('attachment_id', $result)) { - $uploaded = 1 === (int) $result['attachment_uploaded']; - $attachmentId = (int) $augumentedJournal['attachment_id']; + $uploaded = 1 === (int)$result['attachment_uploaded']; + $attachmentId = (int)$augumentedJournal['attachment_id']; if (0 !== $attachmentId && $uploaded) { $result['attachments'][$attachmentId] = [ 'id' => $attachmentId, @@ -624,7 +624,8 @@ class GroupCollector implements GroupCollectorInterface } } // unset various fields: - unset($result['tag_id'], $result['meta_data'], $result['meta_name'], + unset( + $result['tag_id'], $result['meta_data'], $result['meta_name'], $result['tag_name'], $result['tag_date'], $result['tag_description'], $result['tag_latitude'], $result['tag_longitude'], $result['tag_zoom_level'], $result['attachment_filename'], $result['attachment_id'] @@ -637,35 +638,35 @@ class GroupCollector implements GroupCollectorInterface /** * Convert a selected set of fields to arrays. * - * @param array $array + * @param array $array * * @return array */ private function convertToInteger(array $array): array { foreach ($this->integerFields as $field) { - $array[$field] = array_key_exists($field, $array) ? (int) $array[$field] : null; + $array[$field] = array_key_exists($field, $array) ? (int)$array[$field] : null; } return $array; } /** - * @param array $array + * @param array $array * @return array */ private function convertToStrings(array $array): array { foreach ($this->stringFields as $field) { - $array[$field] = array_key_exists($field, $array) && null !== $array[$field] ? (string) $array[$field] : null; + $array[$field] = array_key_exists($field, $array) && null !== $array[$field] ? (string)$array[$field] : null; } return $array; } /** - * @param array $existingJournal - * @param TransactionJournal $newJournal + * @param array $existingJournal + * @param TransactionJournal $newJournal * * @return array */ @@ -673,7 +674,7 @@ class GroupCollector implements GroupCollectorInterface { $newArray = $newJournal->toArray(); if (array_key_exists('tag_id', $newArray)) { // assume the other fields are present as well. - $tagId = (int) $newJournal['tag_id']; + $tagId = (int)$newJournal['tag_id']; $tagDate = null; try { @@ -683,7 +684,7 @@ class GroupCollector implements GroupCollectorInterface } $existingJournal['tags'][$tagId] = [ - 'id' => (int) $newArray['tag_id'], + 'id' => (int)$newArray['tag_id'], 'name' => $newArray['tag_name'], 'date' => $tagDate, 'description' => $newArray['tag_description'], @@ -694,8 +695,8 @@ class GroupCollector implements GroupCollectorInterface } /** - * @param array $existingJournal - * @param TransactionJournal $newJournal + * @param array $existingJournal + * @param TransactionJournal $newJournal * * @return array */ @@ -703,7 +704,7 @@ class GroupCollector implements GroupCollectorInterface { $newArray = $newJournal->toArray(); if (array_key_exists('attachment_id', $newArray)) { - $attachmentId = (int) $newJournal['attachment_id']; + $attachmentId = (int)$newJournal['attachment_id']; $existingJournal['attachments'][$attachmentId] = [ 'id' => $attachmentId, @@ -714,20 +715,20 @@ class GroupCollector implements GroupCollectorInterface } /** - * @param array $groups + * @param array $groups * * @return array */ private function parseSums(array $groups): array { /** - * @var int $groudId + * @var int $groudId * @var array $group */ foreach ($groups as $groudId => $group) { /** @var array $transaction */ foreach ($group['transactions'] as $transaction) { - $currencyId = (int) $transaction['currency_id']; + $currencyId = (int)$transaction['currency_id']; // set default: if (!array_key_exists($currencyId, $groups[$groudId]['sums'])) { @@ -740,7 +741,7 @@ class GroupCollector implements GroupCollectorInterface $groups[$groudId]['sums'][$currencyId]['amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['amount'], $transaction['amount']); if (null !== $transaction['foreign_amount'] && null !== $transaction['foreign_currency_id']) { - $currencyId = (int) $transaction['foreign_currency_id']; + $currencyId = (int)$transaction['foreign_currency_id']; // set default: if (!array_key_exists($currencyId, $groups[$groudId]['sums'])) { @@ -762,14 +763,14 @@ class GroupCollector implements GroupCollectorInterface } /** - * @param Collection $collection + * @param Collection $collection * @return Collection */ private function postFilterCollection(Collection $collection): Collection { $currentCollection = $collection; /** - * @var int $i + * @var int $i * @var Closure $function */ foreach ($this->postFilters as $function) { @@ -778,7 +779,7 @@ class GroupCollector implements GroupCollectorInterface // and save it (or not) in the new collection. // that new collection is the next current collection /** - * @var int $index + * @var int $index * @var array $item */ foreach ($currentCollection as $ii => $item) { @@ -812,7 +813,7 @@ class GroupCollector implements GroupCollectorInterface /** * Limit the number of returned entries. * - * @param int $limit + * @param int $limit * * @return GroupCollectorInterface */ @@ -845,7 +846,7 @@ class GroupCollector implements GroupCollectorInterface /** * Limit results to a specific currency, either foreign or normal one. * - * @param TransactionCurrency $currency + * @param TransactionCurrency $currency * * @return GroupCollectorInterface */ @@ -874,7 +875,7 @@ class GroupCollector implements GroupCollectorInterface /** * Limit the result to a set of specific transaction groups. * - * @param array $groupIds + * @param array $groupIds * * @return GroupCollectorInterface */ @@ -888,7 +889,7 @@ class GroupCollector implements GroupCollectorInterface /** * Limit the result to a set of specific journals. * - * @param array $journalIds + * @param array $journalIds * * @return GroupCollectorInterface */ @@ -908,7 +909,7 @@ class GroupCollector implements GroupCollectorInterface /** * Set the page to get. * - * @param int $page + * @param int $page * * @return GroupCollectorInterface */ @@ -924,7 +925,7 @@ class GroupCollector implements GroupCollectorInterface /** * Search for words in descriptions. * - * @param array $array + * @param array $array * * @return GroupCollectorInterface */ @@ -960,7 +961,7 @@ class GroupCollector implements GroupCollectorInterface /** * Limit the search to one specific transaction group. * - * @param TransactionGroup $transactionGroup + * @param TransactionGroup $transactionGroup * * @return GroupCollectorInterface */ @@ -974,7 +975,7 @@ class GroupCollector implements GroupCollectorInterface /** * Limit the included transaction types. * - * @param array $types + * @param array $types * * @return GroupCollectorInterface */ @@ -988,7 +989,7 @@ class GroupCollector implements GroupCollectorInterface /** * Set the user object and start the query. * - * @param User $user + * @param User $user * * @return GroupCollectorInterface */ diff --git a/app/Helpers/Collector/GroupCollectorInterface.php b/app/Helpers/Collector/GroupCollectorInterface.php index 65b9dfd07c..ff2351a66a 100644 --- a/app/Helpers/Collector/GroupCollectorInterface.php +++ b/app/Helpers/Collector/GroupCollectorInterface.php @@ -42,14 +42,14 @@ interface GroupCollectorInterface /** * Get transactions with a specific amount. * - * @param string $amount + * @param string $amount * * @return GroupCollectorInterface */ public function amountIs(string $amount): GroupCollectorInterface; /** - * @param string $amount + * @param string $amount * * @return GroupCollectorInterface */ @@ -58,7 +58,7 @@ interface GroupCollectorInterface /** * Get transactions where the amount is less than. * - * @param string $amount + * @param string $amount * * @return GroupCollectorInterface */ @@ -67,128 +67,128 @@ interface GroupCollectorInterface /** * Get transactions where the foreign amount is more than. * - * @param string $amount + * @param string $amount * * @return GroupCollectorInterface */ public function amountMore(string $amount): GroupCollectorInterface; /** - * @param string $name + * @param string $name * @return GroupCollectorInterface */ public function attachmentNameContains(string $name): GroupCollectorInterface; /** - * @param string $name + * @param string $name * @return GroupCollectorInterface */ public function attachmentNameDoesNotContain(string $name): GroupCollectorInterface; /** - * @param string $name - * @return GroupCollectorInterface - */ - public function attachmentNameEnds(string $name): GroupCollectorInterface; - - /** - * @param string $name + * @param string $name * @return GroupCollectorInterface */ public function attachmentNameDoesNotEnd(string $name): GroupCollectorInterface; /** - * @param string $name - * @return GroupCollectorInterface - */ - public function attachmentNameIs(string $name): GroupCollectorInterface; - - /** - * @param string $name - * @return GroupCollectorInterface - */ - public function attachmentNameIsNot(string $name): GroupCollectorInterface; - - /** - * @param string $name + * @param string $name * @return GroupCollectorInterface */ public function attachmentNameDoesNotStart(string $name): GroupCollectorInterface; /** - * @param string $name + * @param string $name + * @return GroupCollectorInterface + */ + public function attachmentNameEnds(string $name): GroupCollectorInterface; + + /** + * @param string $name + * @return GroupCollectorInterface + */ + public function attachmentNameIs(string $name): GroupCollectorInterface; + + /** + * @param string $name + * @return GroupCollectorInterface + */ + public function attachmentNameIsNot(string $name): GroupCollectorInterface; + + /** + * @param string $name * @return GroupCollectorInterface */ public function attachmentNameStarts(string $name): GroupCollectorInterface; /** - * @param string $value + * @param string $value * @return GroupCollectorInterface */ public function attachmentNotesAre(string $value): GroupCollectorInterface; /** - * @param string $value + * @param string $value * @return GroupCollectorInterface */ public function attachmentNotesAreNot(string $value): GroupCollectorInterface; /** - * @param string $value + * @param string $value * @return GroupCollectorInterface */ public function attachmentNotesContains(string $value): GroupCollectorInterface; /** - * @param string $value + * @param string $value * @return GroupCollectorInterface */ public function attachmentNotesDoNotContain(string $value): GroupCollectorInterface; /** - * @param string $value - * @return GroupCollectorInterface - */ - public function attachmentNotesEnds(string $value): GroupCollectorInterface; - - /** - * @param string $value - * @return GroupCollectorInterface - */ - public function attachmentNotesStarts(string $value): GroupCollectorInterface; - - /** - * @param string $value + * @param string $value * @return GroupCollectorInterface */ public function attachmentNotesDoNotEnd(string $value): GroupCollectorInterface; /** - * @param string $value + * @param string $value * @return GroupCollectorInterface */ public function attachmentNotesDoNotStart(string $value): GroupCollectorInterface; /** - * @param string $day + * @param string $value + * @return GroupCollectorInterface + */ + public function attachmentNotesEnds(string $value): GroupCollectorInterface; + + /** + * @param string $value + * @return GroupCollectorInterface + */ + public function attachmentNotesStarts(string $value): GroupCollectorInterface; + + /** + * @param string $day * @return GroupCollectorInterface */ public function dayAfter(string $day): GroupCollectorInterface; /** - * @param string $day + * @param string $day * @return GroupCollectorInterface */ public function dayBefore(string $day): GroupCollectorInterface; /** - * @param string $day + * @param string $day * @return GroupCollectorInterface */ public function dayIs(string $day): GroupCollectorInterface; /** - * @param string $day + * @param string $day * @return GroupCollectorInterface */ public function dayIsNot(string $day): GroupCollectorInterface; @@ -196,7 +196,7 @@ interface GroupCollectorInterface /** * End of the description must not match: * - * @param array $array + * @param array $array * * @return GroupCollectorInterface */ @@ -205,7 +205,7 @@ interface GroupCollectorInterface /** * Beginning of the description must not start with: * - * @param array $array + * @param array $array * * @return GroupCollectorInterface */ @@ -214,7 +214,7 @@ interface GroupCollectorInterface /** * End of the description must match: * - * @param array $array + * @param array $array * * @return GroupCollectorInterface */ @@ -223,7 +223,7 @@ interface GroupCollectorInterface /** * Description must be: * - * @param string $value + * @param string $value * * @return GroupCollectorInterface */ @@ -232,7 +232,7 @@ interface GroupCollectorInterface /** * Description must not be: * - * @param string $value + * @param string $value * * @return GroupCollectorInterface */ @@ -241,7 +241,7 @@ interface GroupCollectorInterface /** * Beginning of the description must match: * - * @param array $array + * @param array $array * * @return GroupCollectorInterface */ @@ -250,7 +250,7 @@ interface GroupCollectorInterface /** * These accounts must not be accounts. * - * @param Collection $accounts + * @param Collection $accounts * * @return GroupCollectorInterface */ @@ -259,7 +259,7 @@ interface GroupCollectorInterface /** * Exclude a specific set of bills * - * @param Collection $bills + * @param Collection $bills * * @return GroupCollectorInterface */ @@ -268,7 +268,7 @@ interface GroupCollectorInterface /** * Exclude a budget * - * @param Budget $budget + * @param Budget $budget * * @return GroupCollectorInterface */ @@ -277,7 +277,7 @@ interface GroupCollectorInterface /** * Exclude a budget. * - * @param Collection $budgets + * @param Collection $budgets * * @return GroupCollectorInterface */ @@ -286,7 +286,7 @@ interface GroupCollectorInterface /** * Exclude a set of categories. * - * @param Collection $categories + * @param Collection $categories * @return GroupCollectorInterface */ public function excludeCategories(Collection $categories): GroupCollectorInterface; @@ -294,7 +294,7 @@ interface GroupCollectorInterface /** * Exclude a specific category * - * @param Category $category + * @param Category $category * * @return GroupCollectorInterface */ @@ -303,7 +303,7 @@ interface GroupCollectorInterface /** * Limit results to NOT a specific currency, either foreign or normal one. * - * @param TransactionCurrency $currency + * @param TransactionCurrency $currency * * @return GroupCollectorInterface */ @@ -312,16 +312,31 @@ interface GroupCollectorInterface /** * Exclude destination accounts. * - * @param Collection $accounts + * @param Collection $accounts * * @return GroupCollectorInterface */ public function excludeDestinationAccounts(Collection $accounts): GroupCollectorInterface; + /** + * Look for specific external ID's. + * + * @param string $externalId + * + * @return GroupCollectorInterface + */ + public function excludeExternalId(string $externalId): GroupCollectorInterface; + + /** + * @param string $url + * @return GroupCollectorInterface + */ + public function excludeExternalUrl(string $url): GroupCollectorInterface; + /** * Limit results to exclude a specific foreign currency. * - * @param TransactionCurrency $currency + * @param TransactionCurrency $currency * * @return GroupCollectorInterface */ @@ -330,48 +345,64 @@ interface GroupCollectorInterface /** * Limit the result to NOT a set of specific transaction groups. * - * @param array $groupIds + * @param array $groupIds * * @return GroupCollectorInterface */ public function excludeIds(array $groupIds): GroupCollectorInterface; + /** + * Look for specific external ID's. + * + * @param string $externalId + * + * @return GroupCollectorInterface + */ + public function excludeInternalReference(string $externalId): GroupCollectorInterface; + /** * Limit the result to NOT a set of specific transaction journals. * - * @param array $journalIds + * @param array $journalIds * * @return GroupCollectorInterface */ public function excludeJournalIds(array $journalIds): GroupCollectorInterface; /** - * @param Carbon $start - * @param Carbon $end - * @param string $field + * @param Carbon $start + * @param Carbon $end + * @param string $field * @return GroupCollectorInterface */ public function excludeMetaDateRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface; /** - * @param Carbon $start - * @param Carbon $end - * @param string $field + * @param Carbon $start + * @param Carbon $end + * @param string $field * @return GroupCollectorInterface */ public function excludeObjectRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface; /** - * @param Carbon $start - * @param Carbon $end + * @param Carbon $start + * @param Carbon $end * @return GroupCollectorInterface */ public function excludeRange(Carbon $start, Carbon $end): GroupCollectorInterface; + /** + * @param string $recurringId + * + * @return GroupCollectorInterface + */ + public function excludeRecurrenceId(string $recurringId): GroupCollectorInterface; + /** * Exclude words in descriptions. * - * @param array $array + * @param array $array * * @return GroupCollectorInterface */ @@ -380,7 +411,7 @@ interface GroupCollectorInterface /** * These accounts must not be source accounts. * - * @param Collection $accounts + * @param Collection $accounts * * @return GroupCollectorInterface */ @@ -389,7 +420,7 @@ interface GroupCollectorInterface /** * Limit the included transaction types. * - * @param array $types + * @param array $types * * @return GroupCollectorInterface */ @@ -401,75 +432,77 @@ interface GroupCollectorInterface public function exists(): GroupCollectorInterface; /** - * @param string $externalId + * @param string $externalId * @return GroupCollectorInterface */ public function externalIdContains(string $externalId): GroupCollectorInterface; /** - * @param string $externalId + * @param string $externalId * @return GroupCollectorInterface */ public function externalIdDoesNotContain(string $externalId): GroupCollectorInterface; - /** - * @param string $externalId - * @return GroupCollectorInterface - */ - public function externalIdEnds(string $externalId): GroupCollectorInterface; /** - * @param string $externalId + * @param string $externalId * @return GroupCollectorInterface */ public function externalIdDoesNotEnd(string $externalId): GroupCollectorInterface; /** - * @param string $externalId + * @param string $externalId + * @return GroupCollectorInterface + */ + public function externalIdDoesNotStart(string $externalId): GroupCollectorInterface; + + /** + * @param string $externalId + * @return GroupCollectorInterface + */ + public function externalIdEnds(string $externalId): GroupCollectorInterface; + + /** + * @param string $externalId * @return GroupCollectorInterface */ public function externalIdStarts(string $externalId): GroupCollectorInterface; /** - * @param string $externalId - * @return GroupCollectorInterface - */ - public function externalIdDoesNotStart(string $externalId): GroupCollectorInterface; - /** - * @param string $url + * @param string $url * @return GroupCollectorInterface */ public function externalUrlContains(string $url): GroupCollectorInterface; /** - * @param string $url + * @param string $url * @return GroupCollectorInterface */ public function externalUrlDoesNotContain(string $url): GroupCollectorInterface; /** - * @param string $url - * @return GroupCollectorInterface - */ - public function externalUrlEnds(string $url): GroupCollectorInterface; - - /** - * @param string $url + * @param string $url * @return GroupCollectorInterface */ public function externalUrlDoesNotEnd(string $url): GroupCollectorInterface; /** - * @param string $url - * @return GroupCollectorInterface - */ - public function externalUrlStarts(string $url): GroupCollectorInterface; - - /** - * @param string $url + * @param string $url * @return GroupCollectorInterface */ public function externalUrlDoesNotStart(string $url): GroupCollectorInterface; + /** + * @param string $url + * @return GroupCollectorInterface + */ + public function externalUrlEnds(string $url): GroupCollectorInterface; + + /** + * @param string $url + * @return GroupCollectorInterface + */ + public function externalUrlStarts(string $url): GroupCollectorInterface; + /** * Ensure the search will find nothing at all, zero results. * @@ -480,7 +513,7 @@ interface GroupCollectorInterface /** * Get transactions with a specific foreign amount. * - * @param string $amount + * @param string $amount * * @return GroupCollectorInterface */ @@ -489,7 +522,7 @@ interface GroupCollectorInterface /** * Get transactions with a specific foreign amount. * - * @param string $amount + * @param string $amount * * @return GroupCollectorInterface */ @@ -498,7 +531,7 @@ interface GroupCollectorInterface /** * Get transactions where the amount is less than. * - * @param string $amount + * @param string $amount * * @return GroupCollectorInterface */ @@ -507,7 +540,7 @@ interface GroupCollectorInterface /** * Get transactions where the foreign amount is more than. * - * @param string $amount + * @param string $amount * * @return GroupCollectorInterface */ @@ -554,41 +587,41 @@ interface GroupCollectorInterface public function hasNoAttachments(): GroupCollectorInterface; /** - * @param string $externalId + * @param string $externalId * @return GroupCollectorInterface */ public function internalReferenceContains(string $externalId): GroupCollectorInterface; /** - * @param string $externalId + * @param string $externalId * @return GroupCollectorInterface */ public function internalReferenceDoesNotContain(string $externalId): GroupCollectorInterface; /** - * @param string $externalId - * @return GroupCollectorInterface - */ - public function internalReferenceEnds(string $externalId): GroupCollectorInterface; - - /** - * @param string $externalId + * @param string $externalId * @return GroupCollectorInterface */ public function internalReferenceDoesNotEnd(string $externalId): GroupCollectorInterface; /** - * @param string $externalId - * @return GroupCollectorInterface - */ - public function internalReferenceStarts(string $externalId): GroupCollectorInterface; - - /** - * @param string $externalId + * @param string $externalId * @return GroupCollectorInterface */ public function internalReferenceDoesNotStart(string $externalId): GroupCollectorInterface; + /** + * @param string $externalId + * @return GroupCollectorInterface + */ + public function internalReferenceEnds(string $externalId): GroupCollectorInterface; + + /** + * @param string $externalId + * @return GroupCollectorInterface + */ + public function internalReferenceStarts(string $externalId): GroupCollectorInterface; + /** * Only journals that are reconciled. * @@ -604,248 +637,248 @@ interface GroupCollectorInterface public function isReconciled(): GroupCollectorInterface; /** - * @param string $day - * @param string $field + * @param string $day + * @param string $field * @return GroupCollectorInterface */ public function metaDayAfter(string $day, string $field): GroupCollectorInterface; /** - * @param string $day - * @param string $field + * @param string $day + * @param string $field * @return GroupCollectorInterface */ public function metaDayBefore(string $day, string $field): GroupCollectorInterface; /** - * @param string $day - * @param string $field + * @param string $day + * @param string $field * @return GroupCollectorInterface */ public function metaDayIs(string $day, string $field): GroupCollectorInterface; /** - * @param string $day - * @param string $field + * @param string $day + * @param string $field * @return GroupCollectorInterface */ public function metaDayIsNot(string $day, string $field): GroupCollectorInterface; /** - * @param string $month - * @param string $field + * @param string $month + * @param string $field * @return GroupCollectorInterface */ public function metaMonthAfter(string $month, string $field): GroupCollectorInterface; /** - * @param string $month - * @param string $field + * @param string $month + * @param string $field * @return GroupCollectorInterface */ public function metaMonthBefore(string $month, string $field): GroupCollectorInterface; /** - * @param string $month - * @param string $field + * @param string $month + * @param string $field * @return GroupCollectorInterface */ public function metaMonthIs(string $month, string $field): GroupCollectorInterface; /** - * @param string $month - * @param string $field + * @param string $month + * @param string $field * @return GroupCollectorInterface */ public function metaMonthIsNot(string $month, string $field): GroupCollectorInterface; /** - * @param string $year - * @param string $field + * @param string $year + * @param string $field * @return GroupCollectorInterface */ public function metaYearAfter(string $year, string $field): GroupCollectorInterface; /** - * @param string $year - * @param string $field + * @param string $year + * @param string $field * @return GroupCollectorInterface */ public function metaYearBefore(string $year, string $field): GroupCollectorInterface; /** - * @param string $year - * @param string $field + * @param string $year + * @param string $field * @return GroupCollectorInterface */ public function metaYearIs(string $year, string $field): GroupCollectorInterface; /** - * @param string $year - * @param string $field + * @param string $year + * @param string $field * @return GroupCollectorInterface */ public function metaYearIsNot(string $year, string $field): GroupCollectorInterface; /** - * @param string $month + * @param string $month * @return GroupCollectorInterface */ public function monthAfter(string $month): GroupCollectorInterface; /** - * @param string $month + * @param string $month * @return GroupCollectorInterface */ public function monthBefore(string $month): GroupCollectorInterface; /** - * @param string $month + * @param string $month * @return GroupCollectorInterface */ public function monthIs(string $month): GroupCollectorInterface; /** - * @param string $month + * @param string $month * @return GroupCollectorInterface */ public function monthIsNot(string $month): GroupCollectorInterface; /** - * @param string $value + * @param string $value * * @return GroupCollectorInterface */ public function notesContain(string $value): GroupCollectorInterface; /** - * @param string $value + * @param string $value * * @return GroupCollectorInterface */ public function notesDoNotContain(string $value): GroupCollectorInterface; /** - * @param string $value + * @param string $value * * @return GroupCollectorInterface */ public function notesDontEndWith(string $value): GroupCollectorInterface; /** - * @param string $value + * @param string $value * @return GroupCollectorInterface */ public function notesDontStartWith(string $value): GroupCollectorInterface; /** - * @param string $value + * @param string $value * * @return GroupCollectorInterface */ public function notesEndWith(string $value): GroupCollectorInterface; /** - * @param string $value + * @param string $value * * @return GroupCollectorInterface */ public function notesExactly(string $value): GroupCollectorInterface; /** - * @param string $value + * @param string $value * * @return GroupCollectorInterface */ public function notesExactlyNot(string $value): GroupCollectorInterface; /** - * @param string $value + * @param string $value * * @return GroupCollectorInterface */ public function notesStartWith(string $value): GroupCollectorInterface; /** - * @param string $day - * @param string $field + * @param string $day + * @param string $field * @return GroupCollectorInterface */ public function objectDayAfter(string $day, string $field): GroupCollectorInterface; /** - * @param string $day - * @param string $field + * @param string $day + * @param string $field * @return GroupCollectorInterface */ public function objectDayBefore(string $day, string $field): GroupCollectorInterface; /** - * @param string $day - * @param string $field + * @param string $day + * @param string $field * @return GroupCollectorInterface */ public function objectDayIs(string $day, string $field): GroupCollectorInterface; /** - * @param string $day - * @param string $field + * @param string $day + * @param string $field * @return GroupCollectorInterface */ public function objectDayIsNot(string $day, string $field): GroupCollectorInterface; /** - * @param string $month - * @param string $field + * @param string $month + * @param string $field * @return GroupCollectorInterface */ public function objectMonthAfter(string $month, string $field): GroupCollectorInterface; /** - * @param string $month - * @param string $field + * @param string $month + * @param string $field * @return GroupCollectorInterface */ public function objectMonthBefore(string $month, string $field): GroupCollectorInterface; /** - * @param string $month - * @param string $field + * @param string $month + * @param string $field * @return GroupCollectorInterface */ public function objectMonthIs(string $month, string $field): GroupCollectorInterface; /** - * @param string $month - * @param string $field + * @param string $month + * @param string $field * @return GroupCollectorInterface */ public function objectMonthIsNot(string $month, string $field): GroupCollectorInterface; /** - * @param string $year - * @param string $field + * @param string $year + * @param string $field * @return GroupCollectorInterface */ public function objectYearAfter(string $year, string $field): GroupCollectorInterface; /** - * @param string $year - * @param string $field + * @param string $year + * @param string $field * @return GroupCollectorInterface */ public function objectYearBefore(string $year, string $field): GroupCollectorInterface; /** - * @param string $year - * @param string $field + * @param string $year + * @param string $field * @return GroupCollectorInterface */ public function objectYearIs(string $year, string $field): GroupCollectorInterface; /** - * @param string $year - * @param string $field + * @param string $year + * @param string $field * @return GroupCollectorInterface */ public function objectYearIsNot(string $year, string $field): GroupCollectorInterface; @@ -853,7 +886,7 @@ interface GroupCollectorInterface /** * Define which accounts can be part of the source and destination transactions. * - * @param Collection $accounts + * @param Collection $accounts * * @return GroupCollectorInterface */ @@ -862,7 +895,7 @@ interface GroupCollectorInterface /** * Collect transactions after a specific date. * - * @param Carbon $date + * @param Carbon $date * * @return GroupCollectorInterface */ @@ -871,7 +904,7 @@ interface GroupCollectorInterface /** * Collect transactions before a specific date. * - * @param Carbon $date + * @param Carbon $date * * @return GroupCollectorInterface */ @@ -880,7 +913,7 @@ interface GroupCollectorInterface /** * Limit the search to a specific bill. * - * @param Bill $bill + * @param Bill $bill * * @return GroupCollectorInterface */ @@ -889,7 +922,7 @@ interface GroupCollectorInterface /** * Limit the search to a specific set of bills. * - * @param Collection $bills + * @param Collection $bills * * @return GroupCollectorInterface */ @@ -898,7 +931,7 @@ interface GroupCollectorInterface /** * Both source AND destination must be in this list of accounts. * - * @param Collection $accounts + * @param Collection $accounts * * @return GroupCollectorInterface */ @@ -907,7 +940,7 @@ interface GroupCollectorInterface /** * Limit the search to a specific budget. * - * @param Budget $budget + * @param Budget $budget * * @return GroupCollectorInterface */ @@ -916,7 +949,7 @@ interface GroupCollectorInterface /** * Limit the search to a specific set of budgets. * - * @param Collection $budgets + * @param Collection $budgets * * @return GroupCollectorInterface */ @@ -925,7 +958,7 @@ interface GroupCollectorInterface /** * Limit the search to a specific bunch of categories. * - * @param Collection $categories + * @param Collection $categories * * @return GroupCollectorInterface */ @@ -934,7 +967,7 @@ interface GroupCollectorInterface /** * Limit the search to a specific category. * - * @param Category $category + * @param Category $category * * @return GroupCollectorInterface */ @@ -943,7 +976,7 @@ interface GroupCollectorInterface /** * Collect transactions created on a specific date. * - * @param Carbon $date + * @param Carbon $date * * @return GroupCollectorInterface */ @@ -952,7 +985,7 @@ interface GroupCollectorInterface /** * Limit results to a specific currency, either foreign or normal one. * - * @param TransactionCurrency $currency + * @param TransactionCurrency $currency * * @return GroupCollectorInterface */ @@ -961,7 +994,7 @@ interface GroupCollectorInterface /** * Set destination accounts. * - * @param Collection $accounts + * @param Collection $accounts * * @return GroupCollectorInterface */ @@ -970,37 +1003,22 @@ interface GroupCollectorInterface /** * Look for specific external ID's. * - * @param string $externalId + * @param string $externalId * * @return GroupCollectorInterface */ public function setExternalId(string $externalId): GroupCollectorInterface; /** - * Look for specific external ID's. - * - * @param string $externalId - * - * @return GroupCollectorInterface - */ - public function excludeExternalId(string $externalId): GroupCollectorInterface; - - /** - * @param string $url + * @param string $url * @return GroupCollectorInterface */ public function setExternalUrl(string $url): GroupCollectorInterface; - /** - * @param string $url - * @return GroupCollectorInterface - */ - public function excludeExternalUrl(string $url): GroupCollectorInterface; - /** * Limit results to a specific foreign currency. * - * @param TransactionCurrency $currency + * @param TransactionCurrency $currency * * @return GroupCollectorInterface */ @@ -1009,7 +1027,7 @@ interface GroupCollectorInterface /** * Limit the result to a set of specific transaction groups. * - * @param array $groupIds + * @param array $groupIds * * @return GroupCollectorInterface */ @@ -1018,24 +1036,16 @@ interface GroupCollectorInterface /** * Look for specific external ID's. * - * @param string $externalId + * @param string $externalId * * @return GroupCollectorInterface */ public function setInternalReference(string $externalId): GroupCollectorInterface; - /** - * Look for specific external ID's. - * - * @param string $externalId - * - * @return GroupCollectorInterface - */ - public function excludeInternalReference(string $externalId): GroupCollectorInterface; /** * Limit the result to a set of specific transaction journals. * - * @param array $journalIds + * @param array $journalIds * * @return GroupCollectorInterface */ @@ -1044,7 +1054,7 @@ interface GroupCollectorInterface /** * Limit the number of returned entries. * - * @param int $limit + * @param int $limit * * @return GroupCollectorInterface */ @@ -1053,8 +1063,8 @@ interface GroupCollectorInterface /** * Collect transactions after a specific date. * - * @param Carbon $date - * @param string $field + * @param Carbon $date + * @param string $field * @return GroupCollectorInterface */ public function setMetaAfter(Carbon $date, string $field): GroupCollectorInterface; @@ -1062,8 +1072,8 @@ interface GroupCollectorInterface /** * Collect transactions before a specific date. * - * @param Carbon $date - * @param string $field + * @param Carbon $date + * @param string $field * @return GroupCollectorInterface */ public function setMetaBefore(Carbon $date, string $field): GroupCollectorInterface; @@ -1071,9 +1081,9 @@ interface GroupCollectorInterface /** * Set the start and end time of the results to return, based on meta data. * - * @param Carbon $start - * @param Carbon $end - * @param string $field + * @param Carbon $start + * @param Carbon $end + * @param string $field * * @return GroupCollectorInterface */ @@ -1082,30 +1092,30 @@ interface GroupCollectorInterface /** * Define which accounts can NOT be part of the source and destination transactions. * - * @param Collection $accounts + * @param Collection $accounts * * @return GroupCollectorInterface */ public function setNotAccounts(Collection $accounts): GroupCollectorInterface; /** - * @param Carbon $date - * @param string $field + * @param Carbon $date + * @param string $field * @return GroupCollectorInterface */ public function setObjectAfter(Carbon $date, string $field): GroupCollectorInterface; /** - * @param Carbon $date - * @param string $field + * @param Carbon $date + * @param string $field * @return GroupCollectorInterface */ public function setObjectBefore(Carbon $date, string $field): GroupCollectorInterface; /** - * @param Carbon $start - * @param Carbon $end - * @param string $field + * @param Carbon $start + * @param Carbon $end + * @param string $field * @return GroupCollectorInterface */ public function setObjectRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface; @@ -1113,7 +1123,7 @@ interface GroupCollectorInterface /** * Set the page to get. * - * @param int $page + * @param int $page * * @return GroupCollectorInterface */ @@ -1122,8 +1132,8 @@ interface GroupCollectorInterface /** * Set the start and end time of the results to return. * - * @param Carbon $start - * @param Carbon $end + * @param Carbon $start + * @param Carbon $end * * @return GroupCollectorInterface */ @@ -1132,23 +1142,16 @@ interface GroupCollectorInterface /** * Look for specific recurring ID's. * - * @param string $recurringId + * @param string $recurringId * * @return GroupCollectorInterface */ public function setRecurrenceId(string $recurringId): GroupCollectorInterface; - /** - * @param string $recurringId - * - * @return GroupCollectorInterface - */ - public function excludeRecurrenceId(string $recurringId): GroupCollectorInterface; - /** * Search for words in descriptions. * - * @param array $array + * @param array $array * * @return GroupCollectorInterface */ @@ -1157,7 +1160,7 @@ interface GroupCollectorInterface /** * Set source accounts. * - * @param Collection $accounts + * @param Collection $accounts * * @return GroupCollectorInterface */ @@ -1166,7 +1169,7 @@ interface GroupCollectorInterface /** * Limit results to a specific tag. * - * @param Tag $tag + * @param Tag $tag * * @return GroupCollectorInterface */ @@ -1175,7 +1178,7 @@ interface GroupCollectorInterface /** * Limit results to a specific set of tags. * - * @param Collection $tags + * @param Collection $tags * * @return GroupCollectorInterface */ @@ -1184,7 +1187,7 @@ interface GroupCollectorInterface /** * Limit the search to one specific transaction group. * - * @param TransactionGroup $transactionGroup + * @param TransactionGroup $transactionGroup * * @return GroupCollectorInterface */ @@ -1193,7 +1196,7 @@ interface GroupCollectorInterface /** * Limit the included transaction types. * - * @param array $types + * @param array $types * * @return GroupCollectorInterface */ @@ -1202,7 +1205,7 @@ interface GroupCollectorInterface /** * Collect transactions updated on a specific date. * - * @param Carbon $date + * @param Carbon $date * * @return GroupCollectorInterface */ @@ -1211,7 +1214,7 @@ interface GroupCollectorInterface /** * Set the user object and start the query. * - * @param User $user + * @param User $user * * @return GroupCollectorInterface */ @@ -1220,7 +1223,7 @@ interface GroupCollectorInterface /** * Only when does not have these tags * - * @param Collection $tags + * @param Collection $tags * * @return GroupCollectorInterface */ @@ -1229,7 +1232,7 @@ interface GroupCollectorInterface /** * Either account can be set, but NOT both. This effectively excludes internal transfers. * - * @param Collection $accounts + * @param Collection $accounts * * @return GroupCollectorInterface */ @@ -1305,13 +1308,6 @@ interface GroupCollectorInterface */ public function withCategoryInformation(): GroupCollectorInterface; - /** - * Transactions with any external URL - * - * @return GroupCollectorInterface - */ - public function withExternalUrl(): GroupCollectorInterface; - /** * Transactions with any external ID * @@ -1319,10 +1315,17 @@ interface GroupCollectorInterface */ public function withExternalId(): GroupCollectorInterface; + /** + * Transactions with any external URL + * + * @return GroupCollectorInterface + */ + public function withExternalUrl(): GroupCollectorInterface; + /** * Transaction must have meta date field X. * - * @param string $field + * @param string $field * @return GroupCollectorInterface */ public function withMetaDate(string $field): GroupCollectorInterface; @@ -1362,13 +1365,6 @@ interface GroupCollectorInterface */ public function withoutCategory(): GroupCollectorInterface; - /** - * Transactions without an external URL - * - * @return GroupCollectorInterface - */ - public function withoutExternalUrl(): GroupCollectorInterface; - /** * Transactions without an external ID * @@ -1376,6 +1372,13 @@ interface GroupCollectorInterface */ public function withoutExternalId(): GroupCollectorInterface; + /** + * Transactions without an external URL + * + * @return GroupCollectorInterface + */ + public function withoutExternalUrl(): GroupCollectorInterface; + /** * @return GroupCollectorInterface */ @@ -1387,25 +1390,25 @@ interface GroupCollectorInterface public function withoutTags(): GroupCollectorInterface; /** - * @param string $year + * @param string $year * @return GroupCollectorInterface */ public function yearAfter(string $year): GroupCollectorInterface; /** - * @param string $year + * @param string $year * @return GroupCollectorInterface */ public function yearBefore(string $year): GroupCollectorInterface; /** - * @param string $year + * @param string $year * @return GroupCollectorInterface */ public function yearIs(string $year): GroupCollectorInterface; /** - * @param string $year + * @param string $year * @return GroupCollectorInterface */ public function yearIsNot(string $year): GroupCollectorInterface; diff --git a/app/Helpers/Fiscal/FiscalHelper.php b/app/Helpers/Fiscal/FiscalHelper.php index 68af77a004..86f5605567 100644 --- a/app/Helpers/Fiscal/FiscalHelper.php +++ b/app/Helpers/Fiscal/FiscalHelper.php @@ -1,4 +1,5 @@ useCustomFiscalYear) { $prefStartStr = app('preferences')->get('fiscalYearStart', '01-01')->data; [$mth, $day] = explode('-', $prefStartStr); - $startDate->day((int) $day)->month((int) $mth); + $startDate->day((int)$day)->month((int)$mth); // if start date is after passed date, sub 1 year. if ($startDate > $date) { diff --git a/app/Helpers/Fiscal/FiscalHelperInterface.php b/app/Helpers/Fiscal/FiscalHelperInterface.php index 4888dce3c5..559f2fe672 100644 --- a/app/Helpers/Fiscal/FiscalHelperInterface.php +++ b/app/Helpers/Fiscal/FiscalHelperInterface.php @@ -1,4 +1,5 @@ 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); } } diff --git a/app/Helpers/Report/NetWorthInterface.php b/app/Helpers/Report/NetWorthInterface.php index b1f65500f2..6cab67a017 100644 --- a/app/Helpers/Report/NetWorthInterface.php +++ b/app/Helpers/Report/NetWorthInterface.php @@ -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 */ diff --git a/app/Helpers/Report/PopupReport.php b/app/Helpers/Report/PopupReport.php index 66bbdd5228..15a2a8ea34 100644 --- a/app/Helpers/Report/PopupReport.php +++ b/app/Helpers/Report/PopupReport.php @@ -1,4 +1,5 @@ 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 */ diff --git a/app/Helpers/Report/PopupReportInterface.php b/app/Helpers/Report/PopupReportInterface.php index 45bad68c83..2b5c4b821a 100644 --- a/app/Helpers/Report/PopupReportInterface.php +++ b/app/Helpers/Report/PopupReportInterface.php @@ -1,4 +1,5 @@ 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, diff --git a/app/Helpers/Report/ReportHelperInterface.php b/app/Helpers/Report/ReportHelperInterface.php index e246ee946f..f5eb876bf3 100644 --- a/app/Helpers/Report/ReportHelperInterface.php +++ b/app/Helpers/Report/ReportHelperInterface.php @@ -1,4 +1,5 @@ middleware( function ($request, $next) { app('view')->share('mainTitleIcon', 'fa-credit-card'); - app('view')->share('title', (string) trans('firefly.accounts')); + app('view')->share('title', (string)trans('firefly.accounts')); $this->repository = app(AccountRepositoryInterface::class); @@ -65,7 +65,7 @@ class DeleteController extends Controller /** * Delete account screen. * - * @param Account $account + * @param Account $account * * @return Factory|RedirectResponse|Redirector|View */ @@ -76,7 +76,7 @@ class DeleteController extends Controller } $typeName = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type)); - $subTitle = (string) trans(sprintf('firefly.delete_%s_account', $typeName), ['name' => $account->name]); + $subTitle = (string)trans(sprintf('firefly.delete_%s_account', $typeName), ['name' => $account->name]); $accountList = app('expandedform')->makeSelectListWithEmpty($this->repository->getAccountsByType([$account->accountType->type])); $objectType = $typeName; unset($accountList[$account->id]); @@ -90,8 +90,8 @@ class DeleteController extends Controller /** * Delete the account. * - * @param Request $request - * @param Account $account + * @param Request $request + * @param Account $account * * @return RedirectResponse|Redirector */ @@ -104,11 +104,11 @@ class DeleteController extends Controller $type = $account->accountType->type; $typeName = config(sprintf('firefly.shortNamesByFullName.%s', $type)); $name = $account->name; - $moveTo = $this->repository->find((int) $request->get('move_account_before_delete')); + $moveTo = $this->repository->find((int)$request->get('move_account_before_delete')); $this->repository->destroy($account, $moveTo); - $request->session()->flash('success', (string) trans(sprintf('firefly.%s_deleted', $typeName), ['name' => $name])); + $request->session()->flash('success', (string)trans(sprintf('firefly.%s_deleted', $typeName), ['name' => $name])); app('preferences')->mark(); return redirect($this->getPreviousUrl('accounts.delete.url')); diff --git a/app/Http/Controllers/Account/EditController.php b/app/Http/Controllers/Account/EditController.php index 363896bfe8..b84b2851f5 100644 --- a/app/Http/Controllers/Account/EditController.php +++ b/app/Http/Controllers/Account/EditController.php @@ -59,7 +59,7 @@ class EditController extends Controller $this->middleware( function ($request, $next) { app('view')->share('mainTitleIcon', 'fa-credit-card'); - app('view')->share('title', (string) trans('firefly.accounts')); + app('view')->share('title', (string)trans('firefly.accounts')); $this->repository = app(AccountRepositoryInterface::class); $this->currencyRepos = app(CurrencyRepositoryInterface::class); @@ -73,9 +73,9 @@ class EditController extends Controller /** * Edit account overview. * - * @param Request $request - * @param Account $account - * @param AccountRepositoryInterface $repository + * @param Request $request + * @param Account $account + * @param AccountRepositoryInterface $repository * * @return Factory|RedirectResponse|Redirector|View */ @@ -86,7 +86,7 @@ class EditController extends Controller } $objectType = config('firefly.shortNamesByFullName')[$account->accountType->type]; - $subTitle = (string) trans(sprintf('firefly.edit_%s_account', $objectType), ['name' => $account->name]); + $subTitle = (string)trans(sprintf('firefly.edit_%s_account', $objectType), ['name' => $account->name]); $subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType)); $roles = $this->getRoles(); $liabilityTypes = $this->getLiabilityTypes(); @@ -111,9 +111,9 @@ class EditController extends Controller // interest calculation periods: $interestPeriods = [ - 'daily' => (string) trans('firefly.interest_calc_daily'), - 'monthly' => (string) trans('firefly.interest_calc_monthly'), - 'yearly' => (string) trans('firefly.interest_calc_yearly'), + 'daily' => (string)trans('firefly.interest_calc_daily'), + 'monthly' => (string)trans('firefly.interest_calc_monthly'), + 'yearly' => (string)trans('firefly.interest_calc_yearly'), ]; // put previous url in session if not redirect from store (not "return_to_edit"). @@ -122,7 +122,7 @@ class EditController extends Controller } $request->session()->forget('accounts.edit.fromUpdate'); - $openingBalanceAmount = (string) $repository->getOpeningBalanceAmount($account); + $openingBalanceAmount = (string)$repository->getOpeningBalanceAmount($account); if ('0' === $openingBalanceAmount) { $openingBalanceAmount = ''; } @@ -134,9 +134,9 @@ class EditController extends Controller $includeNetWorth = null === $includeNetWorth ? true : '1' === $includeNetWorth; // code to handle active-checkboxes - $hasOldInput = null !== $request->old('_token'); + $hasOldInput = null !== $request->old('_token'); $virtualBalance = null === $account->virtual_balance ? '0' : $account->virtual_balance; - $preFilled = [ + $preFilled = [ 'account_number' => $repository->getMetaValue($account, 'account_number'), 'account_role' => $repository->getMetaValue($account, 'account_role'), 'cc_type' => $repository->getMetaValue($account, 'cc_type'), @@ -152,7 +152,7 @@ class EditController extends Controller 'interest' => $repository->getMetaValue($account, 'interest'), 'interest_period' => $repository->getMetaValue($account, 'interest_period'), 'notes' => $this->repository->getNoteText($account), - 'active' => $hasOldInput ? (bool) $request->old('active') : $account->active, + 'active' => $hasOldInput ? (bool)$request->old('active') : $account->active, ]; if ('' === $openingBalanceAmount) { $preFilled['opening_balance'] = ''; @@ -181,8 +181,8 @@ class EditController extends Controller /** * Update the account. * - * @param AccountFormRequest $request - * @param Account $account + * @param AccountFormRequest $request + * @param Account $account * * @return $this|RedirectResponse|Redirector */ @@ -195,7 +195,7 @@ class EditController extends Controller $data = $request->getAccountData(); $this->repository->update($account, $data); - $request->session()->flash('success', (string) trans('firefly.updated_account', ['name' => $account->name])); + $request->session()->flash('success', (string)trans('firefly.updated_account', ['name' => $account->name])); // store new attachment(s): @@ -204,7 +204,7 @@ class EditController extends Controller $this->attachments->saveAttachmentsForModel($account, $files); } if (null !== $files && auth()->user()->hasRole('demo')) { - session()->flash('info', (string) trans('firefly.no_att_demo_user')); + session()->flash('info', (string)trans('firefly.no_att_demo_user')); } if (count($this->attachments->getMessages()->get('attachments')) > 0) { @@ -213,7 +213,7 @@ class EditController extends Controller // redirect $redirect = redirect($this->getPreviousUrl('accounts.edit.url')); - if (1 === (int) $request->get('return_to_edit')) { + if (1 === (int)$request->get('return_to_edit')) { // set value so edit routine will not overwrite URL: $request->session()->put('accounts.edit.fromUpdate', true); diff --git a/app/Http/Controllers/Account/IndexController.php b/app/Http/Controllers/Account/IndexController.php index af7ed34f17..b19d6c5558 100644 --- a/app/Http/Controllers/Account/IndexController.php +++ b/app/Http/Controllers/Account/IndexController.php @@ -1,4 +1,5 @@ middleware( function ($request, $next) { app('view')->share('mainTitleIcon', 'fa-credit-card'); - app('view')->share('title', (string) trans('firefly.accounts')); + app('view')->share('title', (string)trans('firefly.accounts')); $this->repository = app(AccountRepositoryInterface::class); @@ -68,25 +71,25 @@ class IndexController extends Controller } /** - * @param Request $request - * @param string $objectType + * @param Request $request + * @param string $objectType * * @return Factory|View * @throws FireflyException - * @throws \JsonException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws JsonException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function inactive(Request $request, string $objectType) { $inactivePage = true; - $subTitle = (string) trans(sprintf('firefly.%s_accounts_inactive', $objectType)); + $subTitle = (string)trans(sprintf('firefly.%s_accounts_inactive', $objectType)); $subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType)); $types = config(sprintf('firefly.accountTypesByIdentifier.%s', $objectType)); $collection = $this->repository->getInactiveAccountsByType($types); $total = $collection->count(); - $page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page'); - $pageSize = (int) app('preferences')->get('listPageSize', 50)->data; + $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page'); + $pageSize = (int)app('preferences')->get('listPageSize', 50)->data; $accounts = $collection->slice(($page - 1) * $pageSize, $pageSize); unset($collection); /** @var Carbon $start */ @@ -107,10 +110,10 @@ class IndexController extends Controller $account->endBalance = $this->isInArray($endBalances, $account->id); $account->difference = bcsub($account->endBalance, $account->startBalance); $account->interest = app('steam')->bcround($this->repository->getMetaValue($account, 'interest'), 4); - $account->interestPeriod = (string) trans(sprintf('firefly.interest_calc_%s', $this->repository->getMetaValue($account, 'interest_period'))); - $account->accountTypeString = (string) trans(sprintf('firefly.account_type_%s', $account->accountType->type)); + $account->interestPeriod = (string)trans(sprintf('firefly.interest_calc_%s', $this->repository->getMetaValue($account, 'interest_period'))); + $account->accountTypeString = (string)trans(sprintf('firefly.account_type_%s', $account->accountType->type)); $account->current_debt = '0'; - $account->iban = implode(' ', str_split((string) $account->iban, 4)); + $account->iban = implode(' ', str_split((string)$account->iban, 4)); } ); @@ -124,19 +127,19 @@ class IndexController extends Controller /** * Show list of accounts. * - * @param Request $request - * @param string $objectType + * @param Request $request + * @param string $objectType * * @return Factory|View * @throws FireflyException - * @throws \JsonException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws JsonException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function index(Request $request, string $objectType) { Log::debug(sprintf('Now at %s', __METHOD__)); - $subTitle = (string) trans(sprintf('firefly.%s_accounts', $objectType)); + $subTitle = (string)trans(sprintf('firefly.%s_accounts', $objectType)); $subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType)); $types = config(sprintf('firefly.accountTypesByIdentifier.%s', $objectType)); @@ -144,8 +147,8 @@ class IndexController extends Controller $collection = $this->repository->getActiveAccountsByType($types); $total = $collection->count(); - $page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page'); - $pageSize = (int) app('preferences')->get('listPageSize', 50)->data; + $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page'); + $pageSize = (int)app('preferences')->get('listPageSize', 50)->data; $accounts = $collection->slice(($page - 1) * $pageSize, $pageSize); $inactiveCount = $this->repository->getInactiveAccountsByType($types)->count(); @@ -175,14 +178,14 @@ class IndexController extends Controller $account->endBalance = $this->isInArray($endBalances, $account->id); $account->difference = bcsub($account->endBalance, $account->startBalance); $account->interest = app('steam')->bcround($interest, 4); - $account->interestPeriod = (string) trans( + $account->interestPeriod = (string)trans( sprintf('firefly.interest_calc_%s', $this->repository->getMetaValue($account, 'interest_period')) ); - $account->accountTypeString = (string) trans(sprintf('firefly.account_type_%s', $account->accountType->type)); + $account->accountTypeString = (string)trans(sprintf('firefly.account_type_%s', $account->accountType->type)); $account->location = $this->repository->getLocation($account); $account->liability_direction = $this->repository->getMetaValue($account, 'liability_direction'); $account->current_debt = $this->repository->getMetaValue($account, 'current_debt') ?? '-'; - $account->iban = implode(' ', str_split((string) $account->iban, 4)); + $account->iban = implode(' ', str_split((string)$account->iban, 4)); } ); // make paginator: diff --git a/app/Http/Controllers/Account/ReconcileController.php b/app/Http/Controllers/Account/ReconcileController.php index 9fa3aa4b79..fd8acc54ce 100644 --- a/app/Http/Controllers/Account/ReconcileController.php +++ b/app/Http/Controllers/Account/ReconcileController.php @@ -1,4 +1,5 @@ middleware( function ($request, $next) { app('view')->share('mainTitleIcon', 'fa-credit-card'); - app('view')->share('title', (string) trans('firefly.accounts')); + app('view')->share('title', (string)trans('firefly.accounts')); $this->repository = app(JournalRepositoryInterface::class); $this->accountRepos = app(AccountRepositoryInterface::class); $this->currencyRepos = app(CurrencyRepositoryInterface::class); @@ -80,15 +83,15 @@ class ReconcileController extends Controller /** * Reconciliation overview. * - * @param Account $account - * @param Carbon|null $start - * @param Carbon|null $end + * @param Account $account + * @param Carbon|null $start + * @param Carbon|null $end * * @return Factory|RedirectResponse|Redirector|View * @throws FireflyException - * @throws \JsonException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws JsonException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function reconcile(Account $account, Carbon $start = null, Carbon $end = null) // @phpstan-ignore-line { @@ -96,7 +99,7 @@ class ReconcileController extends Controller return $this->redirectAccountToAccount($account); } if (AccountType::ASSET !== $account->accountType->type) { - session()->flash('error', (string) trans('firefly.must_be_asset_account')); + session()->flash('error', (string)trans('firefly.must_be_asset_account')); return redirect(route('accounts.index', [config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type))])); } @@ -127,7 +130,7 @@ class ReconcileController extends Controller $startBalance = app('steam')->bcround(app('steam')->balance($account, $startDate), $currency->decimal_places); $endBalance = app('steam')->bcround(app('steam')->balance($account, $end), $currency->decimal_places); $subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $account->accountType->type)); - $subTitle = (string) trans('firefly.reconcile_account', ['account' => $account->name]); + $subTitle = (string)trans('firefly.reconcile_account', ['account' => $account->name]); // various links $transactionsUrl = route('accounts.reconcile.transactions', [$account->id, '%start%', '%end%']); @@ -157,10 +160,10 @@ class ReconcileController extends Controller /** * Submit a new reconciliation. * - * @param ReconciliationStoreRequest $request - * @param Account $account - * @param Carbon $start - * @param Carbon $end + * @param ReconciliationStoreRequest $request + * @param Account $account + * @param Carbon $start + * @param Carbon $end * * @return RedirectResponse|Redirector * @throws DuplicateTransactionException @@ -176,7 +179,7 @@ class ReconcileController extends Controller /** @var string $journalId */ foreach ($data['journals'] as $journalId) { - $this->repository->reconcileById((int) $journalId); + $this->repository->reconcileById((int)$journalId); } Log::debug('Reconciled all transactions.'); @@ -193,10 +196,10 @@ class ReconcileController extends Controller Log::debug('End of routine.'); app('preferences')->mark(); if ('' === $result) { - session()->flash('success', (string) trans('firefly.reconciliation_stored')); + session()->flash('success', (string)trans('firefly.reconciliation_stored')); } if ('' !== $result) { - session()->flash('error', (string) trans('firefly.reconciliation_error', ['error' => $result])); + session()->flash('error', (string)trans('firefly.reconciliation_error', ['error' => $result])); } return redirect(route('accounts.show', [$account->id])); @@ -205,10 +208,10 @@ class ReconcileController extends Controller /** * Creates a reconciliation group. * - * @param Account $account - * @param Carbon $start - * @param Carbon $end - * @param string $difference + * @param Account $account + * @param Carbon $start + * @param Carbon $end + * @param string $difference * * @return RedirectResponse|Redirector|string * @throws DuplicateTransactionException @@ -236,8 +239,10 @@ class ReconcileController extends Controller // title: $description = trans( 'firefly.reconciliation_transaction_title', - ['from' => $start->isoFormat($this->monthAndDayFormat), - 'to' => $end->isoFormat($this->monthAndDayFormat)] + [ + 'from' => $start->isoFormat($this->monthAndDayFormat), + 'to' => $end->isoFormat($this->monthAndDayFormat), + ] ); $submission = [ 'user' => auth()->user()->id, diff --git a/app/Http/Controllers/Account/ShowController.php b/app/Http/Controllers/Account/ShowController.php index ac860dc5ea..1417122bba 100644 --- a/app/Http/Controllers/Account/ShowController.php +++ b/app/Http/Controllers/Account/ShowController.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Account; use Carbon\Carbon; -use Exception; +use FireflyIII\Exceptions\FireflyException; use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Models\Account; @@ -37,6 +37,9 @@ use Illuminate\Http\Request; use Illuminate\Routing\Redirector; use Illuminate\Support\Collection; use Illuminate\View\View; +use JsonException; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; /** * Class ShowController @@ -64,7 +67,7 @@ class ShowController extends Controller $this->middleware( function ($request, $next) { app('view')->share('mainTitleIcon', 'fa-credit-card'); - app('view')->share('title', (string) trans('firefly.accounts')); + app('view')->share('title', (string)trans('firefly.accounts')); $this->repository = app(AccountRepositoryInterface::class); $this->currencyRepos = app(CurrencyRepositoryInterface::class); @@ -77,16 +80,16 @@ class ShowController extends Controller /** * Show an account. * - * @param Request $request - * @param Account $account - * @param Carbon|null $start - * @param Carbon|null $end + * @param Request $request + * @param Account $account + * @param Carbon|null $start + * @param Carbon|null $end * * @return RedirectResponse|Redirector|Factory|View - * @throws \FireflyIII\Exceptions\FireflyException - * @throws \JsonException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws FireflyException + * @throws JsonException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function show(Request $request, Account $account, Carbon $start = null, Carbon $end = null) // @phpstan-ignore-line { @@ -108,19 +111,19 @@ class ShowController extends Controller $attachments = $this->repository->getAttachments($account); $today = today(config('app.timezone')); $subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $account->accountType->type)); - $page = (int) $request->get('page'); - $pageSize = (int) app('preferences')->get('listPageSize', 50)->data; + $page = (int)$request->get('page'); + $pageSize = (int)app('preferences')->get('listPageSize', 50)->data; $currency = $this->repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency(); $fStart = $start->isoFormat($this->monthAndDayFormat); $fEnd = $end->isoFormat($this->monthAndDayFormat); - $subTitle = (string) trans('firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $fStart, 'end' => $fEnd]); + $subTitle = (string)trans('firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $fStart, 'end' => $fEnd]); $chartUrl = route('chart.account.period', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]); $firstTransaction = $this->repository->oldestJournalDate($account) ?? $start; $periods = $this->getAccountPeriodOverview($account, $firstTransaction, $end); // if layout = v2, overrule the page title. if ('v1' !== config('firefly.layout')) { - $subTitle = (string) trans('firefly.all_journals_for_account', ['name' => $account->name]); + $subTitle = (string)trans('firefly.all_journals_for_account', ['name' => $account->name]); } @@ -162,14 +165,14 @@ class ShowController extends Controller /** * Show an account. * - * @param Request $request - * @param Account $account + * @param Request $request + * @param Account $account * * @return RedirectResponse|Redirector|Factory|View - * @throws \FireflyIII\Exceptions\FireflyException - * @throws \JsonException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws FireflyException + * @throws JsonException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function showAll(Request $request, Account $account) { @@ -183,11 +186,11 @@ class ShowController extends Controller $end = today(config('app.timezone')); $today = today(config('app.timezone')); $start = $this->repository->oldestJournalDate($account) ?? Carbon::now()->startOfMonth(); - $subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type); - $page = (int) $request->get('page'); - $pageSize = (int) app('preferences')->get('listPageSize', 50)->data; + $subTitleIcon = config('firefly.subIconsByIdentifier.'.$account->accountType->type); + $page = (int)$request->get('page'); + $pageSize = (int)app('preferences')->get('listPageSize', 50)->data; $currency = $this->repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency(); - $subTitle = (string) trans('firefly.all_journals_for_account', ['name' => $account->name]); + $subTitle = (string)trans('firefly.all_journals_for_account', ['name' => $account->name]); $periods = new Collection(); /** @var GroupCollectorInterface $collector */ $collector = app(GroupCollectorInterface::class); diff --git a/app/Http/Controllers/Admin/ConfigurationController.php b/app/Http/Controllers/Admin/ConfigurationController.php index 0b15f2247b..1fbcfd7fa3 100644 --- a/app/Http/Controllers/Admin/ConfigurationController.php +++ b/app/Http/Controllers/Admin/ConfigurationController.php @@ -1,4 +1,5 @@ middleware( static function ($request, $next) { - app('view')->share('title', (string) trans('firefly.administration')); + app('view')->share('title', (string)trans('firefly.administration')); app('view')->share('mainTitleIcon', 'fa-hand-spock-o'); return $next($request); @@ -61,12 +64,12 @@ class ConfigurationController extends Controller * * @return Factory|View * @throws FireflyException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function index() { - $subTitle = (string) trans('firefly.instance_configuration'); + $subTitle = (string)trans('firefly.instance_configuration'); $subTitleIcon = 'fa-wrench'; Log::channel('audit')->info('User visits admin config index.'); @@ -86,7 +89,7 @@ class ConfigurationController extends Controller /** * Store new configuration values. * - * @param ConfigurationRequest $request + * @param ConfigurationRequest $request * * @return RedirectResponse */ @@ -102,7 +105,7 @@ class ConfigurationController extends Controller app('fireflyconfig')->set('is_demo_site', $data['is_demo_site']); // flash message - session()->flash('success', (string) trans('firefly.configuration_updated')); + session()->flash('success', (string)trans('firefly.configuration_updated')); app('preferences')->mark(); return redirect()->route('admin.configuration.index'); diff --git a/app/Http/Controllers/Admin/HomeController.php b/app/Http/Controllers/Admin/HomeController.php index bbea3d0f15..55f945d397 100644 --- a/app/Http/Controllers/Admin/HomeController.php +++ b/app/Http/Controllers/Admin/HomeController.php @@ -1,4 +1,5 @@ info('User visits admin index.'); - $title = (string) trans('firefly.administration'); + $title = (string)trans('firefly.administration'); $mainTitleIcon = 'fa-hand-spock-o'; $email = auth()->user()->email; $pref = app('preferences')->get('remote_guard_alt_email'); @@ -89,7 +92,7 @@ class HomeController extends Controller } FireflyConfig::set(sprintf('notification_%s', $item), $value); } - $url = (string) $request->get('slackUrl'); + $url = (string)$request->get('slackUrl'); if ('' === $url) { FireflyConfig::delete('slack_webhook_url'); } @@ -97,14 +100,14 @@ class HomeController extends Controller FireflyConfig::set('slack_webhook_url', $url); } - session()->flash('success', (string) trans('firefly.notification_settings_saved')); + session()->flash('success', (string)trans('firefly.notification_settings_saved')); return redirect(route('admin.index')); } /** * Send a test message to the admin. * - * @param Request $request + * @param Request $request * * @return RedirectResponse|Redirector */ @@ -115,7 +118,7 @@ class HomeController extends Controller $user = auth()->user(); Log::debug('Now in testMessage() controller.'); event(new AdminRequestedTestMessage($user)); - session()->flash('info', (string) trans('firefly.send_test_triggered')); + session()->flash('info', (string)trans('firefly.send_test_triggered')); return redirect(route('admin.index')); } diff --git a/app/Http/Controllers/Admin/LinkController.php b/app/Http/Controllers/Admin/LinkController.php index 5cda12b263..7adf4717fe 100644 --- a/app/Http/Controllers/Admin/LinkController.php +++ b/app/Http/Controllers/Admin/LinkController.php @@ -1,4 +1,5 @@ middleware( function ($request, $next) { - app('view')->share('title', (string) trans('firefly.administration')); + app('view')->share('title', (string)trans('firefly.administration')); app('view')->share('mainTitleIcon', 'fa-hand-spock-o'); $this->repository = app(LinkTypeRepositoryInterface::class); @@ -71,7 +72,7 @@ class LinkController extends Controller { Log::channel('audit')->info('User visits link index.'); - $subTitle = (string) trans('firefly.create_new_link_type'); + $subTitle = (string)trans('firefly.create_new_link_type'); $subTitleIcon = 'fa-link'; // put previous url in session if not redirect from store (not "create another"). @@ -85,25 +86,25 @@ class LinkController extends Controller /** * Delete a link form. * - * @param Request $request - * @param LinkType $linkType + * @param Request $request + * @param LinkType $linkType * * @return Factory|RedirectResponse|Redirector|View */ public function delete(Request $request, LinkType $linkType) { if (!$linkType->editable) { - $request->session()->flash('error', (string) trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)])); + $request->session()->flash('error', (string)trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)])); return redirect(route('admin.links.index')); } Log::channel('audit')->info(sprintf('User wants to delete link type #%d', $linkType->id)); - $subTitle = (string) trans('firefly.delete_link_type', ['name' => $linkType->name]); + $subTitle = (string)trans('firefly.delete_link_type', ['name' => $linkType->name]); $otherTypes = $this->repository->get(); $count = $this->repository->countJournals($linkType); $moveTo = []; - $moveTo[0] = (string) trans('firefly.do_not_save_connection'); + $moveTo[0] = (string)trans('firefly.do_not_save_connection'); /** @var LinkType $otherType */ foreach ($otherTypes as $otherType) { @@ -121,8 +122,8 @@ class LinkController extends Controller /** * Actually destroy the link. * - * @param Request $request - * @param LinkType $linkType + * @param Request $request + * @param LinkType $linkType * * @return RedirectResponse|Redirector */ @@ -130,10 +131,10 @@ class LinkController extends Controller { Log::channel('audit')->info(sprintf('User destroyed link type #%d', $linkType->id)); $name = $linkType->name; - $moveTo = $this->repository->find((int) $request->get('move_link_type_before_delete')); + $moveTo = $this->repository->find((int)$request->get('move_link_type_before_delete')); $this->repository->destroy($linkType, $moveTo); - $request->session()->flash('success', (string) trans('firefly.deleted_link_type', ['name' => $name])); + $request->session()->flash('success', (string)trans('firefly.deleted_link_type', ['name' => $name])); app('preferences')->mark(); return redirect($this->getPreviousUrl('link-types.delete.url')); @@ -142,19 +143,19 @@ class LinkController extends Controller /** * Edit a link form. * - * @param Request $request - * @param LinkType $linkType + * @param Request $request + * @param LinkType $linkType * * @return Factory|RedirectResponse|Redirector|View */ public function edit(Request $request, LinkType $linkType) { if (!$linkType->editable) { - $request->session()->flash('error', (string) trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)])); + $request->session()->flash('error', (string)trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)])); return redirect(route('admin.links.index')); } - $subTitle = (string) trans('firefly.edit_link_type', ['name' => $linkType->name]); + $subTitle = (string)trans('firefly.edit_link_type', ['name' => $linkType->name]); $subTitleIcon = 'fa-link'; Log::channel('audit')->info(sprintf('User wants to edit link type #%d', $linkType->id)); @@ -175,7 +176,7 @@ class LinkController extends Controller */ public function index() { - $subTitle = (string) trans('firefly.journal_link_configuration'); + $subTitle = (string)trans('firefly.journal_link_configuration'); $subTitleIcon = 'fa-link'; $linkTypes = $this->repository->get(); @@ -192,13 +193,13 @@ class LinkController extends Controller /** * Show a single link. * - * @param LinkType $linkType + * @param LinkType $linkType * * @return Factory|View */ public function show(LinkType $linkType) { - $subTitle = (string) trans('firefly.overview_for_link', ['name' => $linkType->name]); + $subTitle = (string)trans('firefly.overview_for_link', ['name' => $linkType->name]); $subTitleIcon = 'fa-link'; $links = $this->repository->getJournalLinks($linkType); @@ -210,7 +211,7 @@ class LinkController extends Controller /** * Store the new link. * - * @param LinkTypeFormRequest $request + * @param LinkTypeFormRequest $request * * @return $this|RedirectResponse|Redirector */ @@ -225,9 +226,9 @@ class LinkController extends Controller Log::channel('audit')->info('User stored new link type.', $linkType->toArray()); - $request->session()->flash('success', (string) trans('firefly.stored_new_link_type', ['name' => $linkType->name])); + $request->session()->flash('success', (string)trans('firefly.stored_new_link_type', ['name' => $linkType->name])); $redirect = redirect($this->getPreviousUrl('link-types.create.url')); - if (1 === (int) $request->get('create_another')) { + if (1 === (int)$request->get('create_another')) { // set value so create routine will not overwrite URL: $request->session()->put('link-types.create.fromStore', true); @@ -241,15 +242,15 @@ class LinkController extends Controller /** * Update an existing link. * - * @param LinkTypeFormRequest $request - * @param LinkType $linkType + * @param LinkTypeFormRequest $request + * @param LinkType $linkType * * @return $this|RedirectResponse|Redirector */ public function update(LinkTypeFormRequest $request, LinkType $linkType) { if (!$linkType->editable) { - $request->session()->flash('error', (string) trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)])); + $request->session()->flash('error', (string)trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)])); return redirect(route('admin.links.index')); } @@ -263,10 +264,10 @@ class LinkController extends Controller Log::channel('audit')->info(sprintf('User update link type #%d.', $linkType->id), $data); - $request->session()->flash('success', (string) trans('firefly.updated_link_type', ['name' => $linkType->name])); + $request->session()->flash('success', (string)trans('firefly.updated_link_type', ['name' => $linkType->name])); app('preferences')->mark(); $redirect = redirect($this->getPreviousUrl('link-types.edit.url')); - if (1 === (int) $request->get('return_to_edit')) { + if (1 === (int)$request->get('return_to_edit')) { // set value so edit routine will not overwrite URL: $request->session()->put('link-types.edit.fromUpdate', true); diff --git a/app/Http/Controllers/Admin/UpdateController.php b/app/Http/Controllers/Admin/UpdateController.php index e5444ba97d..5334f27843 100644 --- a/app/Http/Controllers/Admin/UpdateController.php +++ b/app/Http/Controllers/Admin/UpdateController.php @@ -1,4 +1,5 @@ middleware( static function ($request, $next) { - app('view')->share('title', (string) trans('firefly.administration')); + app('view')->share('title', (string)trans('firefly.administration')); app('view')->share('mainTitleIcon', 'fa-hand-spock-o'); return $next($request); @@ -61,27 +64,27 @@ class UpdateController extends Controller * * @return Factory|View * @throws FireflyException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function index() { - $subTitle = (string) trans('firefly.update_check_title'); + $subTitle = (string)trans('firefly.update_check_title'); $subTitleIcon = 'fa-star'; $permission = app('fireflyconfig')->get('permission_update_check', -1); $channel = app('fireflyconfig')->get('update_channel', 'stable'); $selected = $permission->data; $channelSelected = $channel->data; $options = [ - -1 => (string) trans('firefly.updates_ask_me_later'), - 0 => (string) trans('firefly.updates_do_not_check'), - 1 => (string) trans('firefly.updates_enable_check'), + -1 => (string)trans('firefly.updates_ask_me_later'), + 0 => (string)trans('firefly.updates_do_not_check'), + 1 => (string)trans('firefly.updates_enable_check'), ]; $channelOptions = [ - 'stable' => (string) trans('firefly.update_channel_stable'), - 'beta' => (string) trans('firefly.update_channel_beta'), - 'alpha' => (string) trans('firefly.update_channel_alpha'), + 'stable' => (string)trans('firefly.update_channel_stable'), + 'beta' => (string)trans('firefly.update_channel_beta'), + 'alpha' => (string)trans('firefly.update_channel_alpha'), ]; return view('admin.update.index', compact('subTitle', 'subTitleIcon', 'selected', 'options', 'channelSelected', 'channelOptions')); @@ -90,20 +93,20 @@ class UpdateController extends Controller /** * Post new settings. * - * @param Request $request + * @param Request $request * * @return RedirectResponse|Redirector */ public function post(Request $request) { - $checkForUpdates = (int) $request->get('check_for_updates'); + $checkForUpdates = (int)$request->get('check_for_updates'); $channel = $request->get('update_channel'); $channel = in_array($channel, ['stable', 'beta', 'alpha'], true) ? $channel : 'stable'; app('fireflyconfig')->set('permission_update_check', $checkForUpdates); app('fireflyconfig')->set('last_update_check', time()); app('fireflyconfig')->set('update_channel', $channel); - session()->flash('success', (string) trans('firefly.configuration_updated')); + session()->flash('success', (string)trans('firefly.configuration_updated')); return redirect(route('admin.update-check')); } diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 706234633c..b5107d4d28 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -1,4 +1,5 @@ middleware( function ($request, $next) { - app('view')->share('title', (string) trans('firefly.administration')); + app('view')->share('title', (string)trans('firefly.administration')); app('view')->share('mainTitleIcon', 'fa-hand-spock-o'); $this->repository = app(UserRepositoryInterface::class); @@ -68,7 +68,7 @@ class UserController extends Controller } /** - * @param User $user + * @param User $user * * @return Application|Factory|RedirectResponse|Redirector|View */ @@ -80,7 +80,7 @@ class UserController extends Controller return redirect(route('admin.users')); } - $subTitle = (string) trans('firefly.delete_user', ['email' => $user->email]); + $subTitle = (string)trans('firefly.delete_user', ['email' => $user->email]); return view('admin.users.delete', compact('user', 'subTitle')); } @@ -88,7 +88,7 @@ class UserController extends Controller /** * Destroy a user. * - * @param User $user + * @param User $user * * @return RedirectResponse|Redirector */ @@ -100,7 +100,7 @@ class UserController extends Controller return redirect(route('admin.users')); } $this->repository->destroy($user); - session()->flash('success', (string) trans('firefly.user_deleted')); + session()->flash('success', (string)trans('firefly.user_deleted')); return redirect(route('admin.users')); } @@ -108,7 +108,7 @@ class UserController extends Controller /** * Edit user form. * - * @param User $user + * @param User $user * * @return Factory|View */ @@ -124,15 +124,15 @@ class UserController extends Controller } session()->forget('users.edit.fromUpdate'); - $subTitle = (string) trans('firefly.edit_user', ['email' => $user->email]); + $subTitle = (string)trans('firefly.edit_user', ['email' => $user->email]); $subTitleIcon = 'fa-user-o'; $currentUser = auth()->user(); $isAdmin = $this->repository->hasRole($user, 'owner'); $codes = [ - '' => (string) trans('firefly.no_block_code'), - 'bounced' => (string) trans('firefly.block_code_bounced'), - 'expired' => (string) trans('firefly.block_code_expired'), - 'email_changed' => (string) trans('firefly.block_code_email_changed'), + '' => (string)trans('firefly.no_block_code'), + 'bounced' => (string)trans('firefly.block_code_bounced'), + 'expired' => (string)trans('firefly.block_code_expired'), + 'email_changed' => (string)trans('firefly.block_code_email_changed'), ]; return view('admin.users.edit', compact('user', 'canEditDetails', 'subTitle', 'subTitleIcon', 'codes', 'currentUser', 'isAdmin')); @@ -145,7 +145,7 @@ class UserController extends Controller */ public function index() { - $subTitle = (string) trans('firefly.user_administration'); + $subTitle = (string)trans('firefly.user_administration'); $subTitleIcon = 'fa-users'; $users = $this->repository->all(); $singleUserMode = app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data; @@ -168,18 +168,34 @@ class UserController extends Controller return view('admin.users.index', compact('subTitle', 'subTitleIcon', 'users', 'allowInvites', 'invitedUsers')); } + /** + * @param InviteUserFormRequest $request + * @return RedirectResponse + */ + public function invite(InviteUserFormRequest $request): RedirectResponse + { + $address = (string)$request->get('invited_user'); + $invitee = $this->repository->inviteUser(auth()->user(), $address); + session()->flash('info', trans('firefly.user_is_invited', ['address' => $address])); + + // event! + event(new InvitationCreated($invitee)); + + return redirect(route('admin.users')); + } + /** * Show single user. * - * @param User $user + * @param User $user * * @return Factory|View */ public function show(User $user) { - $title = (string) trans('firefly.administration'); + $title = (string)trans('firefly.administration'); $mainTitleIcon = 'fa-hand-spock-o'; - $subTitle = (string) trans('firefly.single_user_administration', ['email' => $user->email]); + $subTitle = (string)trans('firefly.single_user_administration', ['email' => $user->email]); $subTitleIcon = 'fa-user'; $information = $this->repository->getUserData($user); @@ -196,27 +212,11 @@ class UserController extends Controller ); } - /** - * @param InviteUserFormRequest $request - * @return RedirectResponse - */ - public function invite(InviteUserFormRequest $request): RedirectResponse - { - $address = (string) $request->get('invited_user'); - $invitee = $this->repository->inviteUser(auth()->user(), $address); - session()->flash('info', trans('firefly.user_is_invited', ['address' => $address])); - - // event! - event(new InvitationCreated($invitee)); - - return redirect(route('admin.users')); - } - /** * Update single user. * - * @param UserFormRequest $request - * @param User $user + * @param UserFormRequest $request + * @param User $user * * @return $this|RedirectResponse|Redirector */ @@ -242,10 +242,10 @@ class UserController extends Controller $this->repository->changeStatus($user, $data['blocked'], $data['blocked_code']); $this->repository->updateEmail($user, $data['email']); - session()->flash('success', (string) trans('firefly.updated_user', ['email' => $user->email])); + session()->flash('success', (string)trans('firefly.updated_user', ['email' => $user->email])); app('preferences')->mark(); $redirect = redirect($this->getPreviousUrl('users.edit.url')); - if (1 === (int) $request->get('return_to_edit')) { + if (1 === (int)$request->get('return_to_edit')) { session()->put('users.edit.fromUpdate', true); $redirect = redirect(route('admin.users.edit', [$user->id]))->withInput(['return_to_edit' => 1]); diff --git a/app/Http/Controllers/AttachmentController.php b/app/Http/Controllers/AttachmentController.php index c33e0f26f0..db72125f8a 100644 --- a/app/Http/Controllers/AttachmentController.php +++ b/app/Http/Controllers/AttachmentController.php @@ -1,4 +1,5 @@ middleware( function ($request, $next) { app('view')->share('mainTitleIcon', 'fa-paperclip'); - app('view')->share('title', (string) trans('firefly.attachments')); + app('view')->share('title', (string)trans('firefly.attachments')); $this->repository = app(AttachmentRepositoryInterface::class); return $next($request); @@ -67,13 +68,13 @@ class AttachmentController extends Controller /** * Form to delete an attachment. * - * @param Attachment $attachment + * @param Attachment $attachment * * @return Factory|View */ public function delete(Attachment $attachment) { - $subTitle = (string) trans('firefly.delete_attachment', ['name' => $attachment->filename]); + $subTitle = (string)trans('firefly.delete_attachment', ['name' => $attachment->filename]); // put previous url in session $this->rememberPreviousUrl('attachments.delete.url'); @@ -84,8 +85,8 @@ class AttachmentController extends Controller /** * Destroy attachment. * - * @param Request $request - * @param Attachment $attachment + * @param Request $request + * @param Attachment $attachment * * @return RedirectResponse|Redirector */ @@ -95,7 +96,7 @@ class AttachmentController extends Controller $this->repository->destroy($attachment); - $request->session()->flash('success', (string) trans('firefly.attachment_deleted', ['name' => $name])); + $request->session()->flash('success', (string)trans('firefly.attachment_deleted', ['name' => $name])); app('preferences')->mark(); return redirect($this->getPreviousUrl('attachments.delete.url')); @@ -104,7 +105,7 @@ class AttachmentController extends Controller /** * Download attachment to PC. * - * @param Attachment $attachment + * @param Attachment $attachment * * @return LaravelResponse * @@ -121,7 +122,7 @@ class AttachmentController extends Controller $response ->header('Content-Description', 'File Transfer') ->header('Content-Type', 'application/octet-stream') - ->header('Content-Disposition', 'attachment; filename=' . $quoted) + ->header('Content-Disposition', 'attachment; filename='.$quoted) ->header('Content-Transfer-Encoding', 'binary') ->header('Connection', 'Keep-Alive') ->header('Expires', '0') @@ -137,15 +138,15 @@ class AttachmentController extends Controller /** * Edit an attachment. * - * @param Request $request - * @param Attachment $attachment + * @param Request $request + * @param Attachment $attachment * * @return Factory|View */ public function edit(Request $request, Attachment $attachment) { $subTitleIcon = 'fa-pencil'; - $subTitle = (string) trans('firefly.edit_attachment', ['name' => $attachment->filename]); + $subTitle = (string)trans('firefly.edit_attachment', ['name' => $attachment->filename]); // put previous url in session if not redirect from store (not "return_to_edit"). if (true !== session('attachments.edit.fromUpdate')) { @@ -182,8 +183,8 @@ class AttachmentController extends Controller /** * Update attachment. * - * @param AttachmentFormRequest $request - * @param Attachment $attachment + * @param AttachmentFormRequest $request + * @param Attachment $attachment * * @return RedirectResponse */ @@ -192,11 +193,11 @@ class AttachmentController extends Controller $data = $request->getAttachmentData(); $this->repository->update($attachment, $data); - $request->session()->flash('success', (string) trans('firefly.attachment_updated', ['name' => $attachment->filename])); + $request->session()->flash('success', (string)trans('firefly.attachment_updated', ['name' => $attachment->filename])); app('preferences')->mark(); $redirect = redirect($this->getPreviousUrl('attachments.edit.url')); - if (1 === (int) $request->get('return_to_edit')) { + if (1 === (int)$request->get('return_to_edit')) { $request->session()->put('attachments.edit.fromUpdate', true); $redirect = redirect(route('attachments.edit', [$attachment->id]))->withInput(['return_to_edit' => 1]); @@ -209,8 +210,8 @@ class AttachmentController extends Controller /** * View attachment in browser. * - * @param Request $request - * @param Attachment $attachment + * @param Request $request + * @param Attachment $attachment * * @return LaravelResponse * @throws FireflyException @@ -240,7 +241,7 @@ class AttachmentController extends Controller [ 'Content-Security-Policy' => implode('; ', $csp), 'Content-Type' => $attachment->mime, - 'Content-Disposition' => 'inline; filename="' . $attachment->filename . '"', + 'Content-Disposition' => 'inline; filename="'.$attachment->filename.'"', ] ); } diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index dbdd2d7af3..bd0004d992 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -1,4 +1,5 @@ get('email'))->first(); if (null !== $user && $repository->hasRole($user, 'demo')) { - return back()->withErrors(['email' => (string) trans('firefly.cannot_reset_demo_user')]); + return back()->withErrors(['email' => (string)trans('firefly.cannot_reset_demo_user')]); } // We will send the password reset link to this user. Once we have attempted @@ -110,8 +113,8 @@ class ForgotPasswordController extends Controller * * @return Factory|View * @throws FireflyException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function showLinkRequestForm() { @@ -126,7 +129,7 @@ class ForgotPasswordController extends Controller $singleUserMode = app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data; $userCount = User::count(); $allowRegistration = true; - $pageTitle = (string) trans('firefly.forgot_pw_page_title'); + $pageTitle = (string)trans('firefly.forgot_pw_page_title'); if (true === $singleUserMode && $userCount > 0) { $allowRegistration = false; } diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 872714bc26..33632e8b49 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -1,4 +1,5 @@ count(); $guard = config('auth.defaults.guard'); - $title = (string) trans('firefly.login_page_title'); + $title = (string)trans('firefly.login_page_title'); if (0 === $count && 'web' === $guard) { return redirect(route('register')); diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 1d05c8ad5d..e82f23449e 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -1,4 +1,5 @@ allowedToRegister(); - $inviteCode = (string) $request->get('invite_code'); + $inviteCode = (string)$request->get('invite_code'); $repository = app(UserRepositoryInterface::class); $validCode = $repository->validateInviteCode($inviteCode); @@ -105,7 +106,7 @@ class RegisterController extends Controller $this->guard()->login($user); - session()->flash('success', (string) trans('firefly.registered')); + session()->flash('success', (string)trans('firefly.registered')); $this->registered($request, $user); @@ -140,37 +141,10 @@ class RegisterController extends Controller return $allowRegistration; } - /** - * Show the application registration form. - * - * @param Request $request - * - * @return Factory|View - * @throws ContainerExceptionInterface - * @throws FireflyException - * @throws NotFoundExceptionInterface - */ - public function showRegistrationForm(Request $request) - { - $isDemoSite = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site'))->data; - $pageTitle = (string) trans('firefly.register_page_title'); - $allowRegistration = $this->allowedToRegister(); - - if (false === $allowRegistration) { - $message = 'Registration is currently not available. If you are the administrator, you can enable this in the administration.'; - - return view('error', compact('message')); - } - - $email = $request->old('email'); - - return view('auth.register', compact('isDemoSite', 'email', 'pageTitle')); - } - /** * Show the application registration form if the invitation code is valid. * - * @param Request $request + * @param Request $request * * @return Factory|View * @throws ContainerExceptionInterface @@ -180,7 +154,7 @@ class RegisterController extends Controller public function showInviteForm(Request $request, string $code) { $isDemoSite = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site'))->data; - $pageTitle = (string) trans('firefly.register_page_title'); + $pageTitle = (string)trans('firefly.register_page_title'); $repository = app(UserRepositoryInterface::class); $allowRegistration = $this->allowedToRegister(); $inviteCode = $code; @@ -201,4 +175,31 @@ class RegisterController extends Controller return view('auth.register', compact('isDemoSite', 'email', 'pageTitle', 'inviteCode')); } + + /** + * Show the application registration form. + * + * @param Request $request + * + * @return Factory|View + * @throws ContainerExceptionInterface + * @throws FireflyException + * @throws NotFoundExceptionInterface + */ + public function showRegistrationForm(Request $request) + { + $isDemoSite = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site'))->data; + $pageTitle = (string)trans('firefly.register_page_title'); + $allowRegistration = $this->allowedToRegister(); + + if (false === $allowRegistration) { + $message = 'Registration is currently not available. If you are the administrator, you can enable this in the administration.'; + + return view('error', compact('message')); + } + + $email = $request->old('email'); + + return view('auth.register', compact('isDemoSite', 'email', 'pageTitle')); + } } diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index af4b3087f4..9e8ce72d90 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -1,4 +1,5 @@ get('single_user_mode', config('firefly.configuration.single_user_mode'))->data; $userCount = User::count(); $allowRegistration = true; - $pageTitle = (string) trans('firefly.reset_pw_page_title'); + $pageTitle = (string)trans('firefly.reset_pw_page_title'); if (true === $singleUserMode && $userCount > 0) { $allowRegistration = false; } diff --git a/app/Http/Controllers/Auth/TwoFactorController.php b/app/Http/Controllers/Auth/TwoFactorController.php index bec3852b4a..c50ec7051a 100644 --- a/app/Http/Controllers/Auth/TwoFactorController.php +++ b/app/Http/Controllers/Auth/TwoFactorController.php @@ -1,4 +1,5 @@ user(); $siteOwner = config('firefly.site_owner'); - $title = (string) trans('firefly.two_factor_forgot_title'); + $title = (string)trans('firefly.two_factor_forgot_title'); return view('auth.lost-two-factor', compact('user', 'siteOwner', 'title')); } /** - * @param Request $request + * @param Request $request * * @return RedirectResponse|Redirector */ @@ -61,7 +62,7 @@ class TwoFactorController extends Controller { /** @var array $mfaHistory */ $mfaHistory = Preferences::get('mfa_history', [])->data; - $mfaCode = (string) $request->get('one_time_password'); + $mfaCode = (string)$request->get('one_time_password'); // is in history? then refuse to use it. if ($this->inMFAHistory($mfaCode, $mfaHistory)) { @@ -101,8 +102,8 @@ class TwoFactorController extends Controller * Each MFA history has a timestamp and a code, saving the MFA entries for 5 minutes. So if the * submitted MFA code has been submitted in the last 5 minutes, it won't work despite being valid. * - * @param string $mfaCode - * @param array $mfaHistory + * @param string $mfaCode + * @param array $mfaHistory * * @return bool */ @@ -143,7 +144,7 @@ class TwoFactorController extends Controller } /** - * @param string $mfaCode + * @param string $mfaCode */ private function addToMFAHistory(string $mfaCode): void { @@ -162,7 +163,7 @@ class TwoFactorController extends Controller /** * Checks if code is in users backup codes. * - * @param string $mfaCode + * @param string $mfaCode * * @return bool */ @@ -179,7 +180,7 @@ class TwoFactorController extends Controller /** * Remove the used code from the list of backup codes. * - * @param string $mfaCode + * @param string $mfaCode */ private function removeFromBackupCodes(string $mfaCode): void { diff --git a/app/Http/Controllers/Bill/CreateController.php b/app/Http/Controllers/Bill/CreateController.php index 4520d73561..0035275412 100644 --- a/app/Http/Controllers/Bill/CreateController.php +++ b/app/Http/Controllers/Bill/CreateController.php @@ -54,7 +54,7 @@ class CreateController extends Controller $this->middleware( function ($request, $next) { - app('view')->share('title', (string) trans('firefly.bills')); + app('view')->share('title', (string)trans('firefly.bills')); app('view')->share('mainTitleIcon', 'fa-calendar-o'); $this->attachments = app(AttachmentHelperInterface::class); $this->repository = app(BillRepositoryInterface::class); @@ -67,7 +67,7 @@ class CreateController extends Controller /** * Create a new bill. * - * @param Request $request + * @param Request $request * * @return Factory|View */ @@ -77,9 +77,9 @@ class CreateController extends Controller /** @var array $billPeriods */ $billPeriods = config('firefly.bill_periods'); foreach ($billPeriods as $current) { - $periods[$current] = (string) trans('firefly.repeat_freq_' . $current); + $periods[$current] = (string)trans('firefly.repeat_freq_'.$current); } - $subTitle = (string) trans('firefly.create_new_bill'); + $subTitle = (string)trans('firefly.create_new_bill'); $defaultCurrency = app('amount')->getDefaultCurrency(); // put previous url in session if not redirect from store (not "create another"). @@ -94,7 +94,7 @@ class CreateController extends Controller /** * Store a new bill. * - * @param BillStoreRequest $request + * @param BillStoreRequest $request * * @return RedirectResponse * @@ -108,11 +108,11 @@ class CreateController extends Controller $bill = $this->repository->store($billData); } catch (FireflyException $e) { Log::error($e->getMessage()); - $request->session()->flash('error', (string) trans('firefly.bill_store_error')); + $request->session()->flash('error', (string)trans('firefly.bill_store_error')); return redirect(route('bills.create'))->withInput(); } - $request->session()->flash('success', (string) trans('firefly.stored_new_bill', ['name' => $bill->name])); + $request->session()->flash('success', (string)trans('firefly.stored_new_bill', ['name' => $bill->name])); app('preferences')->mark(); /** @var array $files */ @@ -121,7 +121,7 @@ class CreateController extends Controller $this->attachments->saveAttachmentsForModel($bill, $files); } if (null !== $files && auth()->user()->hasRole('demo')) { - session()->flash('info', (string) trans('firefly.no_att_demo_user')); + session()->flash('info', (string)trans('firefly.no_att_demo_user')); } if (count($this->attachments->getMessages()->get('attachments')) > 0) { diff --git a/app/Http/Controllers/Bill/DeleteController.php b/app/Http/Controllers/Bill/DeleteController.php index ada888dec3..7b812f28ac 100644 --- a/app/Http/Controllers/Bill/DeleteController.php +++ b/app/Http/Controllers/Bill/DeleteController.php @@ -53,7 +53,7 @@ class DeleteController extends Controller $this->middleware( function ($request, $next) { - app('view')->share('title', (string) trans('firefly.bills')); + app('view')->share('title', (string)trans('firefly.bills')); app('view')->share('mainTitleIcon', 'fa-calendar-o'); $this->repository = app(BillRepositoryInterface::class); @@ -65,7 +65,7 @@ class DeleteController extends Controller /** * Delete a bill. * - * @param Bill $bill + * @param Bill $bill * * @return Factory|View */ @@ -73,7 +73,7 @@ class DeleteController extends Controller { // put previous url in session $this->rememberPreviousUrl('bills.delete.url'); - $subTitle = (string) trans('firefly.delete_bill', ['name' => $bill->name]); + $subTitle = (string)trans('firefly.delete_bill', ['name' => $bill->name]); return view('bills.delete', compact('bill', 'subTitle')); } @@ -81,8 +81,8 @@ class DeleteController extends Controller /** * Destroy a bill. * - * @param Request $request - * @param Bill $bill + * @param Request $request + * @param Bill $bill * * @return RedirectResponse|Redirector */ @@ -91,7 +91,7 @@ class DeleteController extends Controller $name = $bill->name; $this->repository->destroy($bill); - $request->session()->flash('success', (string) trans('firefly.deleted_bill', ['name' => $name])); + $request->session()->flash('success', (string)trans('firefly.deleted_bill', ['name' => $name])); app('preferences')->mark(); return redirect($this->getPreviousUrl('bills.delete.url')); diff --git a/app/Http/Controllers/Bill/EditController.php b/app/Http/Controllers/Bill/EditController.php index 5d0236b6ce..4c9c716b90 100644 --- a/app/Http/Controllers/Bill/EditController.php +++ b/app/Http/Controllers/Bill/EditController.php @@ -53,7 +53,7 @@ class EditController extends Controller $this->middleware( function ($request, $next) { - app('view')->share('title', (string) trans('firefly.bills')); + app('view')->share('title', (string)trans('firefly.bills')); app('view')->share('mainTitleIcon', 'fa-calendar-o'); $this->attachments = app(AttachmentHelperInterface::class); $this->repository = app(BillRepositoryInterface::class); @@ -66,8 +66,8 @@ class EditController extends Controller /** * Edit a bill. * - * @param Request $request - * @param Bill $bill + * @param Request $request + * @param Bill $bill * * @return Factory|View */ @@ -78,10 +78,10 @@ class EditController extends Controller $billPeriods = config('firefly.bill_periods'); foreach ($billPeriods as $current) { - $periods[$current] = (string) trans('firefly.' . $current); + $periods[$current] = (string)trans('firefly.'.$current); } - $subTitle = (string) trans('firefly.edit_bill', ['name' => $bill->name]); + $subTitle = (string)trans('firefly.edit_bill', ['name' => $bill->name]); // put previous url in session if not redirect from store (not "return_to_edit"). if (true !== session('bills.edit.fromUpdate')) { @@ -102,7 +102,7 @@ class EditController extends Controller 'extension_date' => $bill->extension_date, 'notes' => $this->repository->getNoteText($bill), 'transaction_currency_id' => $bill->transaction_currency_id, - 'active' => $hasOldInput ? (bool) $request->old('active') : $bill->active, + 'active' => $hasOldInput ? (bool)$request->old('active') : $bill->active, 'object_group' => $bill->objectGroups->first() ? $bill->objectGroups->first()->title : '', ]; @@ -115,8 +115,8 @@ class EditController extends Controller /** * Update a bill. * - * @param BillUpdateRequest $request - * @param Bill $bill + * @param BillUpdateRequest $request + * @param Bill $bill * * @return RedirectResponse */ @@ -125,7 +125,7 @@ class EditController extends Controller $billData = $request->getBillData(); $bill = $this->repository->update($bill, $billData); - $request->session()->flash('success', (string) trans('firefly.updated_bill', ['name' => $bill->name])); + $request->session()->flash('success', (string)trans('firefly.updated_bill', ['name' => $bill->name])); app('preferences')->mark(); /** @var array $files */ @@ -134,7 +134,7 @@ class EditController extends Controller $this->attachments->saveAttachmentsForModel($bill, $files); } if (null !== $files && auth()->user()->hasRole('demo')) { - session()->flash('info', (string) trans('firefly.no_att_demo_user')); + session()->flash('info', (string)trans('firefly.no_att_demo_user')); } // flash messages @@ -143,7 +143,7 @@ class EditController extends Controller } $redirect = redirect($this->getPreviousUrl('bills.edit.url')); - if (1 === (int) $request->get('return_to_edit')) { + if (1 === (int)$request->get('return_to_edit')) { $request->session()->put('bills.edit.fromUpdate', true); $redirect = redirect(route('bills.edit', [$bill->id]))->withInput(['return_to_edit' => 1]); diff --git a/app/Http/Controllers/Bill/IndexController.php b/app/Http/Controllers/Bill/IndexController.php index eff331c03f..f40768057a 100644 --- a/app/Http/Controllers/Bill/IndexController.php +++ b/app/Http/Controllers/Bill/IndexController.php @@ -33,6 +33,8 @@ use FireflyIII\Transformers\BillTransformer; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Log; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use Symfony\Component\HttpFoundation\ParameterBag; /** @@ -55,7 +57,7 @@ class IndexController extends Controller $this->middleware( function ($request, $next) { - app('view')->share('title', (string) trans('firefly.bills')); + app('view')->share('title', (string)trans('firefly.bills')); app('view')->share('mainTitleIcon', 'fa-calendar-o'); $this->repository = app(BillRepositoryInterface::class); @@ -92,20 +94,20 @@ class IndexController extends Controller $bills = [ 0 => [ // the index is the order, not the ID. 'object_group_id' => 0, - 'object_group_title' => (string) trans('firefly.default_group_title_name'), + 'object_group_title' => (string)trans('firefly.default_group_title_name'), 'bills' => [], ], ]; /** @var Bill $bill */ foreach ($collection as $bill) { $array = $transformer->transform($bill); - $groupOrder = (int) $array['object_group_order']; + $groupOrder = (int)$array['object_group_order']; // make group array if necessary: $bills[$groupOrder] = $bills[$groupOrder] ?? [ - 'object_group_id' => $array['object_group_id'], - 'object_group_title' => $array['object_group_title'], - 'bills' => [], - ]; + 'object_group_id' => $array['object_group_id'], + 'object_group_title' => $array['object_group_title'], + 'bills' => [], + ]; // var_dump($array);exit; // // expected today? default: // $array['next_expected_match_diff'] = trans('firefly.not_expected_period'); @@ -142,12 +144,12 @@ class IndexController extends Controller } /** - * @param array $bills + * @param array $bills * * @return array * @throws FireflyException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ private function getSums(array $bills): array { @@ -164,19 +166,19 @@ class IndexController extends Controller $currencyId = $bill['currency_id']; $sums[$groupOrder][$currencyId] = $sums[$groupOrder][$currencyId] ?? [ - 'currency_id' => $currencyId, - 'currency_code' => $bill['currency_code'], - 'currency_name' => $bill['currency_name'], - 'currency_symbol' => $bill['currency_symbol'], - 'currency_decimal_places' => $bill['currency_decimal_places'], - 'avg' => '0', - 'period' => $range, - 'per_period' => '0', - ]; + 'currency_id' => $currencyId, + 'currency_code' => $bill['currency_code'], + 'currency_name' => $bill['currency_name'], + 'currency_symbol' => $bill['currency_symbol'], + 'currency_decimal_places' => $bill['currency_decimal_places'], + 'avg' => '0', + 'period' => $range, + 'per_period' => '0', + ]; // only fill in avg when bill is active. if (count($bill['pay_dates']) > 0) { - $avg = bcdiv(bcadd((string) $bill['amount_min'], (string) $bill['amount_max']), '2'); - $avg = bcmul($avg, (string) count($bill['pay_dates'])); + $avg = bcdiv(bcadd((string)$bill['amount_min'], (string)$bill['amount_max']), '2'); + $avg = bcmul($avg, (string)count($bill['pay_dates'])); $sums[$groupOrder][$currencyId]['avg'] = bcadd($sums[$groupOrder][$currencyId]['avg'], $avg); } // fill in per period regardless: @@ -188,14 +190,14 @@ class IndexController extends Controller } /** - * @param array $bill - * @param string $range + * @param array $bill + * @param string $range * * @return string */ private function amountPerPeriod(array $bill, string $range): string { - $avg = bcdiv(bcadd((string) $bill['amount_min'], (string) $bill['amount_max']), '2'); + $avg = bcdiv(bcadd((string)$bill['amount_min'], (string)$bill['amount_max']), '2'); Log::debug(sprintf('Amount per period for bill #%d "%s"', $bill['id'], $bill['name'])); Log::debug(sprintf('Average is %s', $avg)); @@ -208,8 +210,8 @@ class IndexController extends Controller 'weekly' => '52.17', 'daily' => '365.24', ]; - $yearAmount = bcmul($avg, bcdiv($multiplies[$bill['repeat_freq']], (string) ($bill['skip'] + 1))); - Log::debug(sprintf('Amount per year is %s (%s * %s / %s)', $yearAmount, $avg, $multiplies[$bill['repeat_freq']], (string) ($bill['skip'] + 1))); + $yearAmount = bcmul($avg, bcdiv($multiplies[$bill['repeat_freq']], (string)($bill['skip'] + 1))); + Log::debug(sprintf('Amount per year is %s (%s * %s / %s)', $yearAmount, $avg, $multiplies[$bill['repeat_freq']], (string)($bill['skip'] + 1))); // per period: $division = [ @@ -228,7 +230,7 @@ class IndexController extends Controller } /** - * @param array $sums + * @param array $sums * * @return array */ @@ -243,20 +245,20 @@ class IndexController extends Controller */ foreach ($sums as $array) { /** - * @var int $currencyId + * @var int $currencyId * @var array $entry */ foreach ($array as $currencyId => $entry) { $totals[$currencyId] = $totals[$currencyId] ?? [ - 'currency_id' => $currencyId, - 'currency_code' => $entry['currency_code'], - 'currency_name' => $entry['currency_name'], - 'currency_symbol' => $entry['currency_symbol'], - 'currency_decimal_places' => $entry['currency_decimal_places'], - 'avg' => '0', - 'period' => $entry['period'], - 'per_period' => '0', - ]; + 'currency_id' => $currencyId, + 'currency_code' => $entry['currency_code'], + 'currency_name' => $entry['currency_name'], + 'currency_symbol' => $entry['currency_symbol'], + 'currency_decimal_places' => $entry['currency_decimal_places'], + 'avg' => '0', + 'period' => $entry['period'], + 'per_period' => '0', + ]; $totals[$currencyId]['avg'] = bcadd($totals[$currencyId]['avg'], $entry['avg']); $totals[$currencyId]['per_period'] = bcadd($totals[$currencyId]['per_period'], $entry['per_period']); } @@ -268,15 +270,15 @@ class IndexController extends Controller /** * Set the order of a bill. * - * @param Request $request - * @param Bill $bill + * @param Request $request + * @param Bill $bill * * @return JsonResponse */ public function setOrder(Request $request, Bill $bill): JsonResponse { - $objectGroupTitle = (string) $request->get('objectGroupTitle'); - $newOrder = (int) $request->get('order'); + $objectGroupTitle = (string)$request->get('objectGroupTitle'); + $newOrder = (int)$request->get('order'); $this->repository->setOrder($bill, $newOrder); if ('' !== $objectGroupTitle) { $this->repository->setObjectGroup($bill, $objectGroupTitle); diff --git a/app/Http/Controllers/Bill/ShowController.php b/app/Http/Controllers/Bill/ShowController.php index 421ded5214..5abc4d9fe3 100644 --- a/app/Http/Controllers/Bill/ShowController.php +++ b/app/Http/Controllers/Bill/ShowController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Bill; use Carbon\Carbon; +use FireflyIII\Exceptions\FireflyException; use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Models\Attachment; @@ -41,6 +42,8 @@ use Illuminate\View\View; use League\Fractal\Manager; use League\Fractal\Resource\Item; use League\Fractal\Serializer\DataArraySerializer; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use Symfony\Component\HttpFoundation\ParameterBag; /** @@ -63,7 +66,7 @@ class ShowController extends Controller $this->middleware( function ($request, $next) { - app('view')->share('title', (string) trans('firefly.bills')); + app('view')->share('title', (string)trans('firefly.bills')); app('view')->share('mainTitleIcon', 'fa-calendar-o'); $this->repository = app(BillRepositoryInterface::class); @@ -75,8 +78,8 @@ class ShowController extends Controller /** * Rescan bills for transactions. * - * @param Request $request - * @param Bill $bill + * @param Request $request + * @param Bill $bill * * @return RedirectResponse|Redirector */ @@ -84,7 +87,7 @@ class ShowController extends Controller { $total = 0; if (false === $bill->active) { - $request->session()->flash('warning', (string) trans('firefly.cannot_scan_inactive_bill')); + $request->session()->flash('warning', (string)trans('firefly.cannot_scan_inactive_bill')); return redirect(route('bills.show', [$bill->id])); } @@ -94,7 +97,7 @@ class ShowController extends Controller $total = 0; } if (0 === $set->count()) { - $request->session()->flash('error', (string) trans('firefly.no_rules_for_bill')); + $request->session()->flash('error', (string)trans('firefly.no_rules_for_bill')); return redirect(route('bills.show', [$bill->id])); } @@ -110,7 +113,7 @@ class ShowController extends Controller // file the rule(s) $ruleEngine->fire(); - $request->session()->flash('success', (string) trans_choice('firefly.rescanned_bill', $total)); + $request->session()->flash('success', (string)trans_choice('firefly.rescanned_bill', $total)); app('preferences')->mark(); return redirect(route('bills.show', [$bill->id])); @@ -119,13 +122,13 @@ class ShowController extends Controller /** * Show a bill. * - * @param Request $request - * @param Bill $bill + * @param Request $request + * @param Bill $bill * * @return Factory|View - * @throws \FireflyIII\Exceptions\FireflyException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws FireflyException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function show(Request $request, Bill $bill) { @@ -137,8 +140,8 @@ class ShowController extends Controller /** @var Carbon $end */ $end = session('end'); $year = $start->year; - $page = (int) $request->get('page'); - $pageSize = (int) app('preferences')->get('listPageSize', 50)->data; + $page = (int)$request->get('page'); + $pageSize = (int)app('preferences')->get('listPageSize', 50)->data; $yearAverage = $this->repository->getYearAverage($bill, $start); $overallAverage = $this->repository->getOverallAverage($bill); $manager = new Manager(); diff --git a/app/Http/Controllers/Budget/CreateController.php b/app/Http/Controllers/Budget/CreateController.php index 83f777b48f..ad97bd998a 100644 --- a/app/Http/Controllers/Budget/CreateController.php +++ b/app/Http/Controllers/Budget/CreateController.php @@ -52,7 +52,7 @@ class CreateController extends Controller parent::__construct(); $this->middleware( function ($request, $next) { - app('view')->share('title', (string) trans('firefly.budgets')); + app('view')->share('title', (string)trans('firefly.budgets')); app('view')->share('mainTitleIcon', 'fa-pie-chart'); $this->repository = app(BudgetRepositoryInterface::class); $this->attachments = app(AttachmentHelperInterface::class); @@ -65,7 +65,7 @@ class CreateController extends Controller /** * Form to create a budget. * - * @param Request $request + * @param Request $request * * @return Factory|View */ @@ -75,23 +75,23 @@ class CreateController extends Controller // auto budget types $autoBudgetTypes = [ - 0 => (string) trans('firefly.auto_budget_none'), - AutoBudget::AUTO_BUDGET_RESET => (string) trans('firefly.auto_budget_reset'), - AutoBudget::AUTO_BUDGET_ROLLOVER => (string) trans('firefly.auto_budget_rollover'), + 0 => (string)trans('firefly.auto_budget_none'), + AutoBudget::AUTO_BUDGET_RESET => (string)trans('firefly.auto_budget_reset'), + AutoBudget::AUTO_BUDGET_ROLLOVER => (string)trans('firefly.auto_budget_rollover'), ]; $autoBudgetPeriods = [ - 'daily' => (string) trans('firefly.auto_budget_period_daily'), - 'weekly' => (string) trans('firefly.auto_budget_period_weekly'), - 'monthly' => (string) trans('firefly.auto_budget_period_monthly'), - 'quarterly' => (string) trans('firefly.auto_budget_period_quarterly'), - 'half_year' => (string) trans('firefly.auto_budget_period_half_year'), - 'yearly' => (string) trans('firefly.auto_budget_period_yearly'), + 'daily' => (string)trans('firefly.auto_budget_period_daily'), + 'weekly' => (string)trans('firefly.auto_budget_period_weekly'), + 'monthly' => (string)trans('firefly.auto_budget_period_monthly'), + 'quarterly' => (string)trans('firefly.auto_budget_period_quarterly'), + 'half_year' => (string)trans('firefly.auto_budget_period_half_year'), + 'yearly' => (string)trans('firefly.auto_budget_period_yearly'), ]; $currency = app('amount')->getDefaultCurrency(); $preFilled = [ - 'auto_budget_period' => $hasOldInput ? (bool) $request->old('auto_budget_period') : 'monthly', - 'auto_budget_currency_id' => $hasOldInput ? (int) $request->old('auto_budget_currency_id') : $currency->id, + 'auto_budget_period' => $hasOldInput ? (bool)$request->old('auto_budget_period') : 'monthly', + 'auto_budget_currency_id' => $hasOldInput ? (int)$request->old('auto_budget_currency_id') : $currency->id, ]; $request->session()->flash('preFilled', $preFilled); @@ -101,7 +101,7 @@ class CreateController extends Controller $this->rememberPreviousUrl('budgets.create.url'); } $request->session()->forget('budgets.create.fromStore'); - $subTitle = (string) trans('firefly.create_new_budget'); + $subTitle = (string)trans('firefly.create_new_budget'); return view('budgets.create', compact('subTitle', 'autoBudgetTypes', 'autoBudgetPeriods')); } @@ -109,7 +109,7 @@ class CreateController extends Controller /** * Stores a budget. * - * @param BudgetFormStoreRequest $request + * @param BudgetFormStoreRequest $request * * @return RedirectResponse * @throws FireflyException @@ -120,7 +120,7 @@ class CreateController extends Controller $budget = $this->repository->store($data); $this->repository->cleanupBudgets(); - $request->session()->flash('success', (string) trans('firefly.stored_new_budget', ['name' => $budget->name])); + $request->session()->flash('success', (string)trans('firefly.stored_new_budget', ['name' => $budget->name])); app('preferences')->mark(); // store attachment(s): @@ -129,7 +129,7 @@ class CreateController extends Controller $this->attachments->saveAttachmentsForModel($budget, $files); } if (null !== $files && auth()->user()->hasRole('demo')) { - session()->flash('info', (string) trans('firefly.no_att_demo_user')); + session()->flash('info', (string)trans('firefly.no_att_demo_user')); } if (count($this->attachments->getMessages()->get('attachments')) > 0) { @@ -138,7 +138,7 @@ class CreateController extends Controller $redirect = redirect($this->getPreviousUrl('budgets.create.url')); - if (1 === (int) $request->get('create_another')) { + if (1 === (int)$request->get('create_another')) { $request->session()->put('budgets.create.fromStore', true); $redirect = redirect(route('budgets.create'))->withInput(); diff --git a/app/Http/Controllers/Budget/DeleteController.php b/app/Http/Controllers/Budget/DeleteController.php index d4cfa19ff8..de6394536b 100644 --- a/app/Http/Controllers/Budget/DeleteController.php +++ b/app/Http/Controllers/Budget/DeleteController.php @@ -52,7 +52,7 @@ class DeleteController extends Controller $this->middleware( function ($request, $next) { - app('view')->share('title', (string) trans('firefly.budgets')); + app('view')->share('title', (string)trans('firefly.budgets')); app('view')->share('mainTitleIcon', 'fa-pie-chart'); $this->repository = app(BudgetRepositoryInterface::class); @@ -64,13 +64,13 @@ class DeleteController extends Controller /** * Deletes a budget. * - * @param Budget $budget + * @param Budget $budget * * @return Factory|View */ public function delete(Budget $budget) { - $subTitle = (string) trans('firefly.delete_budget', ['name' => $budget->name]); + $subTitle = (string)trans('firefly.delete_budget', ['name' => $budget->name]); // put previous url in session $this->rememberPreviousUrl('budgets.delete.url'); @@ -81,8 +81,8 @@ class DeleteController extends Controller /** * Destroys a budget. * - * @param Request $request - * @param Budget $budget + * @param Request $request + * @param Budget $budget * * @return RedirectResponse|Redirector */ @@ -90,7 +90,7 @@ class DeleteController extends Controller { $name = $budget->name; $this->repository->destroy($budget); - $request->session()->flash('success', (string) trans('firefly.deleted_budget', ['name' => $name])); + $request->session()->flash('success', (string)trans('firefly.deleted_budget', ['name' => $name])); app('preferences')->mark(); return redirect($this->getPreviousUrl('budgets.delete.url')); diff --git a/app/Http/Controllers/Budget/IndexController.php b/app/Http/Controllers/Budget/IndexController.php index 1506e11d95..f04c813ad7 100644 --- a/app/Http/Controllers/Budget/IndexController.php +++ b/app/Http/Controllers/Budget/IndexController.php @@ -41,7 +41,10 @@ use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Collection; use Illuminate\View\View; +use JsonException; use Log; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; /** * @@ -68,7 +71,7 @@ class IndexController extends Controller $this->middleware( function ($request, $next) { - app('view')->share('title', (string) trans('firefly.budgets')); + app('view')->share('title', (string)trans('firefly.budgets')); app('view')->share('mainTitleIcon', 'fa-pie-chart'); $this->repository = app(BudgetRepositoryInterface::class); $this->opsRepository = app(OperationsRepositoryInterface::class); @@ -85,23 +88,23 @@ class IndexController extends Controller /** * Show all budgets. * - * @param Request $request + * @param Request $request * - * @param Carbon|null $start - * @param Carbon|null $end + * @param Carbon|null $start + * @param Carbon|null $end * * @return Factory|View * @throws FireflyException - * @throws \JsonException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws JsonException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function index(Request $request, Carbon $start = null, Carbon $end = null) // @phpstan-ignore-line { Log::debug('Start of IndexController::index()'); // collect some basic vars: - $range = (string) app('preferences')->get('viewRange', '1M')->data; + $range = (string)app('preferences')->get('viewRange', '1M')->data; $start = $start ?? session('start', Carbon::now()->startOfMonth()); $end = $end ?? app('navigation')->endOfPeriod($start, $range); $defaultCurrency = app('amount')->getDefaultCurrency(); @@ -160,8 +163,8 @@ class IndexController extends Controller } /** - * @param Carbon $start - * @param Carbon $end + * @param Carbon $start + * @param Carbon $end * * @return array */ @@ -192,10 +195,10 @@ class IndexController extends Controller } /** - * @param Carbon $start - * @param Carbon $end - * @param Collection $currencies - * @param TransactionCurrency $defaultCurrency + * @param Carbon $start + * @param Carbon $end + * @param Collection $currencies + * @param TransactionCurrency $defaultCurrency * * @return array */ @@ -250,7 +253,7 @@ class IndexController extends Controller } /** - * @param array $budgets + * @param array $budgets * * @return array */ @@ -312,8 +315,8 @@ class IndexController extends Controller } /** - * @param Request $request - * @param BudgetRepositoryInterface $repository + * @param Request $request + * @param BudgetRepositoryInterface $repository * * @return JsonResponse */ @@ -322,7 +325,7 @@ class IndexController extends Controller $budgetIds = $request->get('budgetIds'); foreach ($budgetIds as $index => $budgetId) { - $budgetId = (int) $budgetId; + $budgetId = (int)$budgetId; $budget = $repository->find($budgetId); if (null !== $budget) { Log::debug(sprintf('Set budget #%d ("%s") to position %d', $budget->id, $budget->name, $index + 1)); diff --git a/app/Http/Controllers/Budget/ShowController.php b/app/Http/Controllers/Budget/ShowController.php index 653d247264..111b1c1041 100644 --- a/app/Http/Controllers/Budget/ShowController.php +++ b/app/Http/Controllers/Budget/ShowController.php @@ -37,6 +37,9 @@ use FireflyIII\Support\Http\Controllers\PeriodOverview; use Illuminate\Contracts\View\Factory; use Illuminate\Http\Request; use Illuminate\View\View; +use JsonException; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; /** * @@ -61,7 +64,7 @@ class ShowController extends Controller parent::__construct(); $this->middleware( function ($request, $next) { - app('view')->share('title', (string) trans('firefly.budgets')); + app('view')->share('title', (string)trans('firefly.budgets')); app('view')->share('mainTitleIcon', 'fa-pie-chart'); $this->journalRepos = app(JournalRepositoryInterface::class); $this->repository = app(BudgetRepositoryInterface::class); @@ -74,15 +77,15 @@ class ShowController extends Controller /** * Show transactions without a budget. * - * @param Request $request - * @param Carbon|null $start - * @param Carbon|null $end + * @param Request $request + * @param Carbon|null $start + * @param Carbon|null $end * * @return Factory|View * @throws FireflyException - * @throws \JsonException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws JsonException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function noBudget(Request $request, Carbon $start = null, Carbon $end = null)// @phpstan-ignore-line { @@ -99,8 +102,8 @@ class ShowController extends Controller $first = $this->journalRepos->firstNull(); $firstDate = null !== $first ? $first->date : $start; $periods = $this->getNoBudgetPeriodOverview($firstDate, $end); - $page = (int) $request->get('page'); - $pageSize = (int) app('preferences')->get('listPageSize', 50)->data; + $page = (int)$request->get('page'); + $pageSize = (int)app('preferences')->get('listPageSize', 50)->data; /** @var GroupCollectorInterface $collector */ $collector = app(GroupCollectorInterface::class); @@ -115,21 +118,21 @@ class ShowController extends Controller /** * Shows ALL transactions without a budget. * - * @param Request $request + * @param Request $request * * @return Factory|View * @throws FireflyException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function noBudgetAll(Request $request) { - $subTitle = (string) trans('firefly.all_journals_without_budget'); + $subTitle = (string)trans('firefly.all_journals_without_budget'); $first = $this->journalRepos->firstNull(); $start = null === $first ? new Carbon() : $first->date; $end = today(config('app.timezone')); - $page = (int) $request->get('page'); - $pageSize = (int) app('preferences')->get('listPageSize', 50)->data; + $page = (int)$request->get('page'); + $pageSize = (int)app('preferences')->get('listPageSize', 50)->data; /** @var GroupCollectorInterface $collector */ $collector = app(GroupCollectorInterface::class); @@ -144,22 +147,22 @@ class ShowController extends Controller /** * Show a single budget. * - * @param Request $request - * @param Budget $budget + * @param Request $request + * @param Budget $budget * * @return Factory|View * @throws FireflyException - * @throws \JsonException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws JsonException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function show(Request $request, Budget $budget) { /** @var Carbon $allStart */ $allStart = session('first', Carbon::now()->startOfYear()); $allEnd = today(); - $page = (int) $request->get('page'); - $pageSize = (int) app('preferences')->get('listPageSize', 50)->data; + $page = (int)$request->get('page'); + $pageSize = (int)app('preferences')->get('listPageSize', 50)->data; $limits = $this->getLimits($budget, $allStart, $allEnd); $repetition = null; $attachments = $this->repository->getAttachments($budget); @@ -173,7 +176,7 @@ class ShowController extends Controller $groups = $collector->getPaginatedGroups(); $groups->setPath(route('budgets.show', [$budget->id])); - $subTitle = (string) trans('firefly.all_journals_for_budget', ['name' => $budget->name]); + $subTitle = (string)trans('firefly.all_journals_for_budget', ['name' => $budget->name]); return view('budgets.show', compact('limits', 'attachments', 'budget', 'repetition', 'groups', 'subTitle')); } @@ -181,15 +184,15 @@ class ShowController extends Controller /** * Show a single budget by a budget limit. * - * @param Request $request - * @param Budget $budget - * @param BudgetLimit $budgetLimit + * @param Request $request + * @param Budget $budget + * @param BudgetLimit $budgetLimit * * @return Factory|View * @throws FireflyException - * @throws \JsonException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws JsonException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function showByBudgetLimit(Request $request, Budget $budget, BudgetLimit $budgetLimit) { @@ -197,8 +200,8 @@ class ShowController extends Controller throw new FireflyException('This budget limit is not part of this budget.'); } - $page = (int) $request->get('page'); - $pageSize = (int) app('preferences')->get('listPageSize', 50)->data; + $page = (int)$request->get('page'); + $pageSize = (int)app('preferences')->get('listPageSize', 50)->data; $subTitle = trans( 'firefly.budget_in_period', [ diff --git a/app/Http/Controllers/Category/CreateController.php b/app/Http/Controllers/Category/CreateController.php index 725c39e71b..9643859d73 100644 --- a/app/Http/Controllers/Category/CreateController.php +++ b/app/Http/Controllers/Category/CreateController.php @@ -53,7 +53,7 @@ class CreateController extends Controller $this->middleware( function ($request, $next) { - app('view')->share('title', (string) trans('firefly.categories')); + app('view')->share('title', (string)trans('firefly.categories')); app('view')->share('mainTitleIcon', 'fa-bookmark'); $this->repository = app(CategoryRepositoryInterface::class); $this->attachments = app(AttachmentHelperInterface::class); @@ -66,7 +66,7 @@ class CreateController extends Controller /** * Create category. * - * @param Request $request + * @param Request $request * * @return Factory|View */ @@ -76,7 +76,7 @@ class CreateController extends Controller $this->rememberPreviousUrl('categories.create.url'); } $request->session()->forget('categories.create.fromStore'); - $subTitle = (string) trans('firefly.create_new_category'); + $subTitle = (string)trans('firefly.create_new_category'); return view('categories.create', compact('subTitle')); } @@ -84,7 +84,7 @@ class CreateController extends Controller /** * Store new category. * - * @param CategoryFormRequest $request + * @param CategoryFormRequest $request * * @return $this|RedirectResponse|Redirector * @throws FireflyException @@ -94,7 +94,7 @@ class CreateController extends Controller $data = $request->getCategoryData(); $category = $this->repository->store($data); - $request->session()->flash('success', (string) trans('firefly.stored_category', ['name' => $category->name])); + $request->session()->flash('success', (string)trans('firefly.stored_category', ['name' => $category->name])); app('preferences')->mark(); // store attachment(s): @@ -103,7 +103,7 @@ class CreateController extends Controller $this->attachments->saveAttachmentsForModel($category, $files); } if (null !== $files && auth()->user()->hasRole('demo')) { - session()->flash('info', (string) trans('firefly.no_att_demo_user')); + session()->flash('info', (string)trans('firefly.no_att_demo_user')); } if (count($this->attachments->getMessages()->get('attachments')) > 0) { @@ -111,7 +111,7 @@ class CreateController extends Controller } $redirect = redirect(route('categories.index')); - if (1 === (int) $request->get('create_another')) { + if (1 === (int)$request->get('create_another')) { $request->session()->put('categories.create.fromStore', true); $redirect = redirect(route('categories.create'))->withInput(); diff --git a/app/Http/Controllers/Category/DeleteController.php b/app/Http/Controllers/Category/DeleteController.php index 4f0a44464e..4d8bb058f1 100644 --- a/app/Http/Controllers/Category/DeleteController.php +++ b/app/Http/Controllers/Category/DeleteController.php @@ -51,7 +51,7 @@ class DeleteController extends Controller $this->middleware( function ($request, $next) { - app('view')->share('title', (string) trans('firefly.categories')); + app('view')->share('title', (string)trans('firefly.categories')); app('view')->share('mainTitleIcon', 'fa-bookmark'); $this->repository = app(CategoryRepositoryInterface::class); @@ -63,13 +63,13 @@ class DeleteController extends Controller /** * Delete a category. * - * @param Category $category + * @param Category $category * * @return Factory|View */ public function delete(Category $category) { - $subTitle = (string) trans('firefly.delete_category', ['name' => $category->name]); + $subTitle = (string)trans('firefly.delete_category', ['name' => $category->name]); // put previous url in session $this->rememberPreviousUrl('categories.delete.url'); @@ -80,8 +80,8 @@ class DeleteController extends Controller /** * Destroy a category. * - * @param Request $request - * @param Category $category + * @param Request $request + * @param Category $category * * @return RedirectResponse|Redirector */ @@ -90,7 +90,7 @@ class DeleteController extends Controller $name = $category->name; $this->repository->destroy($category); - $request->session()->flash('success', (string) trans('firefly.deleted_category', ['name' => $name])); + $request->session()->flash('success', (string)trans('firefly.deleted_category', ['name' => $name])); app('preferences')->mark(); return redirect($this->getPreviousUrl('categories.delete.url')); diff --git a/app/Http/Controllers/Category/EditController.php b/app/Http/Controllers/Category/EditController.php index f94bf53808..45496408c4 100644 --- a/app/Http/Controllers/Category/EditController.php +++ b/app/Http/Controllers/Category/EditController.php @@ -53,7 +53,7 @@ class EditController extends Controller $this->middleware( function ($request, $next) { - app('view')->share('title', (string) trans('firefly.categories')); + app('view')->share('title', (string)trans('firefly.categories')); app('view')->share('mainTitleIcon', 'fa-bookmark'); $this->repository = app(CategoryRepositoryInterface::class); $this->attachments = app(AttachmentHelperInterface::class); @@ -66,14 +66,14 @@ class EditController extends Controller /** * Edit a category. * - * @param Request $request - * @param Category $category + * @param Request $request + * @param Category $category * * @return Factory|View */ public function edit(Request $request, Category $category) { - $subTitle = (string) trans('firefly.edit_category', ['name' => $category->name]); + $subTitle = (string)trans('firefly.edit_category', ['name' => $category->name]); // put previous url in session if not redirect from store (not "return_to_edit"). if (true !== session('categories.edit.fromUpdate')) { @@ -91,8 +91,8 @@ class EditController extends Controller /** * Update category. * - * @param CategoryFormRequest $request - * @param Category $category + * @param CategoryFormRequest $request + * @param Category $category * * @return RedirectResponse|Redirector */ @@ -101,7 +101,7 @@ class EditController extends Controller $data = $request->getCategoryData(); $this->repository->update($category, $data); - $request->session()->flash('success', (string) trans('firefly.updated_category', ['name' => $category->name])); + $request->session()->flash('success', (string)trans('firefly.updated_category', ['name' => $category->name])); app('preferences')->mark(); // store new attachment(s): @@ -110,7 +110,7 @@ class EditController extends Controller $this->attachments->saveAttachmentsForModel($category, $files); } if (null !== $files && auth()->user()->hasRole('demo')) { - session()->flash('info', (string) trans('firefly.no_att_demo_user')); + session()->flash('info', (string)trans('firefly.no_att_demo_user')); } if (count($this->attachments->getMessages()->get('attachments')) > 0) { @@ -118,7 +118,7 @@ class EditController extends Controller } $redirect = redirect($this->getPreviousUrl('categories.edit.url')); - if (1 === (int) $request->get('return_to_edit')) { + if (1 === (int)$request->get('return_to_edit')) { $request->session()->put('categories.edit.fromUpdate', true); $redirect = redirect(route('categories.edit', [$category->id])); diff --git a/app/Http/Controllers/Category/IndexController.php b/app/Http/Controllers/Category/IndexController.php index 27dab05624..768e469b6c 100644 --- a/app/Http/Controllers/Category/IndexController.php +++ b/app/Http/Controllers/Category/IndexController.php @@ -32,6 +32,8 @@ use Illuminate\Http\Request; use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Support\Collection; use Illuminate\View\View; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; /** * Class IndexController @@ -52,7 +54,7 @@ class IndexController extends Controller $this->middleware( function ($request, $next) { - app('view')->share('title', (string) trans('firefly.categories')); + app('view')->share('title', (string)trans('firefly.categories')); app('view')->share('mainTitleIcon', 'fa-bookmark'); $this->repository = app(CategoryRepositoryInterface::class); @@ -64,17 +66,17 @@ class IndexController extends Controller /** * Show all categories. * - * @param Request $request + * @param Request $request * * @return Factory|View * @throws FireflyException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function index(Request $request) { - $page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page'); - $pageSize = (int) app('preferences')->get('listPageSize', 50)->data; + $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page'); + $pageSize = (int)app('preferences')->get('listPageSize', 50)->data; $collection = $this->repository->getCategories(); $total = $collection->count(); $collection = $collection->slice(($page - 1) * $pageSize, $pageSize); diff --git a/app/Http/Controllers/Category/NoCategoryController.php b/app/Http/Controllers/Category/NoCategoryController.php index a8680cfe0c..aa363f3208 100644 --- a/app/Http/Controllers/Category/NoCategoryController.php +++ b/app/Http/Controllers/Category/NoCategoryController.php @@ -34,7 +34,10 @@ use Illuminate\Contracts\View\Factory; use Illuminate\Http\Request; use Illuminate\Support\Collection; use Illuminate\View\View; +use JsonException; use Log; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; /** * @@ -58,7 +61,7 @@ class NoCategoryController extends Controller $this->middleware( function ($request, $next) { - app('view')->share('title', (string) trans('firefly.categories')); + app('view')->share('title', (string)trans('firefly.categories')); app('view')->share('mainTitleIcon', 'fa-bookmark'); $this->journalRepos = app(JournalRepositoryInterface::class); @@ -70,15 +73,15 @@ class NoCategoryController extends Controller /** * Show transactions without a category. * - * @param Request $request - * @param Carbon|null $start - * @param Carbon|null $end + * @param Request $request + * @param Carbon|null $start + * @param Carbon|null $end * * @return Factory|View * @throws FireflyException - * @throws \JsonException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws JsonException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function show(Request $request, Carbon $start = null, Carbon $end = null)// @phpstan-ignore-line { @@ -87,8 +90,8 @@ class NoCategoryController extends Controller $start = $start ?? session('start'); /** @var Carbon $end */ $end = $end ?? session('end'); - $page = (int) $request->get('page'); - $pageSize = (int) app('preferences')->get('listPageSize', 50)->data; + $page = (int)$request->get('page'); + $pageSize = (int)app('preferences')->get('listPageSize', 50)->data; $subTitle = trans( 'firefly.without_category_between', ['start' => $start->isoFormat($this->monthAndDayFormat), 'end' => $end->isoFormat($this->monthAndDayFormat)] @@ -113,12 +116,12 @@ class NoCategoryController extends Controller /** * Show all transactions without a category. * - * @param Request $request + * @param Request $request * * @return Factory|View * @throws FireflyException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function showAll(Request $request) { @@ -126,10 +129,10 @@ class NoCategoryController extends Controller $start = null; $end = null; $periods = new Collection(); - $page = (int) $request->get('page'); - $pageSize = (int) app('preferences')->get('listPageSize', 50)->data; + $page = (int)$request->get('page'); + $pageSize = (int)app('preferences')->get('listPageSize', 50)->data; Log::debug('Start of noCategory()'); - $subTitle = (string) trans('firefly.all_journals_without_category'); + $subTitle = (string)trans('firefly.all_journals_without_category'); $first = $this->journalRepos->firstNull(); $start = null === $first ? new Carbon() : $first->date; $end = today(config('app.timezone')); diff --git a/app/Http/Controllers/Category/ShowController.php b/app/Http/Controllers/Category/ShowController.php index adbb693fc9..dba00078fb 100644 --- a/app/Http/Controllers/Category/ShowController.php +++ b/app/Http/Controllers/Category/ShowController.php @@ -34,6 +34,9 @@ use Illuminate\Contracts\View\Factory; use Illuminate\Http\Request; use Illuminate\Support\Collection; use Illuminate\View\View; +use JsonException; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; /** * @@ -59,7 +62,7 @@ class ShowController extends Controller $this->middleware( function ($request, $next) { - app('view')->share('title', (string) trans('firefly.categories')); + app('view')->share('title', (string)trans('firefly.categories')); app('view')->share('mainTitleIcon', 'fa-bookmark'); $this->repository = app(CategoryRepositoryInterface::class); @@ -71,16 +74,16 @@ class ShowController extends Controller /** * Show a single category. * - * @param Request $request - * @param Category $category - * @param Carbon|null $start - * @param Carbon|null $end + * @param Request $request + * @param Category $category + * @param Carbon|null $start + * @param Carbon|null $end * * @return Factory|View * @throws FireflyException - * @throws \JsonException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws JsonException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function show(Request $request, Category $category, Carbon $start = null, Carbon $end = null) // @phpstan-ignore-line { @@ -89,16 +92,19 @@ class ShowController extends Controller /** @var Carbon $end */ $end = $end ?? session('end', Carbon::now()->endOfMonth()); $subTitleIcon = 'fa-bookmark'; - $page = (int) $request->get('page'); + $page = (int)$request->get('page'); $attachments = $this->repository->getAttachments($category); - $pageSize = (int) app('preferences')->get('listPageSize', 50)->data; + $pageSize = (int)app('preferences')->get('listPageSize', 50)->data; $oldest = $this->repository->firstUseDate($category) ?? Carbon::now()->startOfYear(); $periods = $this->getCategoryPeriodOverview($category, $oldest, $end); $path = route('categories.show', [$category->id, $start->format('Y-m-d'), $end->format('Y-m-d')]); $subTitle = trans( 'firefly.journals_in_period_for_category', - ['name' => $category->name, 'start' => $start->isoFormat($this->monthAndDayFormat), - 'end' => $end->isoFormat($this->monthAndDayFormat),] + [ + 'name' => $category->name, + 'start' => $start->isoFormat($this->monthAndDayFormat), + 'end' => $end->isoFormat($this->monthAndDayFormat), + ] ); /** @var GroupCollectorInterface $collector */ @@ -116,25 +122,25 @@ class ShowController extends Controller /** * Show all transactions within a category. * - * @param Request $request - * @param Category $category + * @param Request $request + * @param Category $category * * @return Factory|View * @throws FireflyException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function showAll(Request $request, Category $category) { // default values: $subTitleIcon = 'fa-bookmark'; - $page = (int) $request->get('page'); - $pageSize = (int) app('preferences')->get('listPageSize', 50)->data; + $page = (int)$request->get('page'); + $pageSize = (int)app('preferences')->get('listPageSize', 50)->data; $start = null; $end = null; $periods = new Collection(); - $subTitle = (string) trans('firefly.all_journals_for_category', ['name' => $category->name]); + $subTitle = (string)trans('firefly.all_journals_for_category', ['name' => $category->name]); $first = $this->repository->firstUseDate($category); /** @var Carbon $start */ $start = $first ?? today(config('app.timezone')); diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php index ae88733d36..6df7bed7bd 100644 --- a/app/Http/Controllers/Chart/AccountController.php +++ b/app/Http/Controllers/Chart/AccountController.php @@ -42,6 +42,8 @@ use Illuminate\Http\JsonResponse; use Illuminate\Support\Collection; use JsonException; use Log; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; /** * Class AccountController. @@ -130,7 +132,7 @@ class AccountController extends Controller $tempData[] = [ 'name' => $accountNames[$accountId], 'difference' => $diff, - 'diff_float' => (float) $diff, // intentional float + 'diff_float' => (float)$diff, // intentional float 'currency_id' => $currencyId, ]; } @@ -327,8 +329,8 @@ class AccountController extends Controller * @return JsonResponse * @throws FireflyException * @throws JsonException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function frontpage(AccountRepositoryInterface $repository): JsonResponse { @@ -580,7 +582,7 @@ class AccountController extends Controller $tempData[] = [ 'name' => $accountNames[$accountId], 'difference' => $diff, - 'diff_float' => (float) $diff, // intentional float + 'diff_float' => (float)$diff, // intentional float 'currency_id' => $currencyId, ]; } diff --git a/app/Http/Controllers/Chart/BillController.php b/app/Http/Controllers/Chart/BillController.php index 5c5b1a5a86..807f254289 100644 --- a/app/Http/Controllers/Chart/BillController.php +++ b/app/Http/Controllers/Chart/BillController.php @@ -1,4 +1,5 @@ $amount) { $currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepository->find($currencyId); - $label = (string) trans('firefly.paid_in_currency', ['currency' => $currencies[$currencyId]->name]); - $chartData[$label] = ['amount' => $amount, 'currency_symbol' => $currencies[$currencyId]->symbol, - 'currency_code' => $currencies[$currencyId]->code]; + $label = (string)trans('firefly.paid_in_currency', ['currency' => $currencies[$currencyId]->name]); + $chartData[$label] = [ + 'amount' => $amount, + 'currency_symbol' => $currencies[$currencyId]->symbol, + 'currency_code' => $currencies[$currencyId]->code, + ]; } foreach ($unpaid as $currencyId => $amount) { $currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepository->find($currencyId); - $label = (string) trans('firefly.unpaid_in_currency', ['currency' => $currencies[$currencyId]->name]); - $chartData[$label] = ['amount' => $amount, 'currency_symbol' => $currencies[$currencyId]->symbol, - 'currency_code' => $currencies[$currencyId]->code]; + $label = (string)trans('firefly.unpaid_in_currency', ['currency' => $currencies[$currencyId]->name]); + $chartData[$label] = [ + 'amount' => $amount, + 'currency_symbol' => $currencies[$currencyId]->symbol, + 'currency_code' => $currencies[$currencyId]->code, + ]; } $data = $this->generator->multiCurrencyPieChart($chartData); @@ -99,10 +107,10 @@ class BillController extends Controller /** * Shows overview for a single bill. * - * @param Bill $bill + * @param Bill $bill * * @return JsonResponse - * @throws \FireflyIII\Exceptions\FireflyException + * @throws FireflyException */ public function single(Bill $bill): JsonResponse { @@ -134,16 +142,31 @@ class BillController extends Controller ); $chartData = [ - ['type' => 'line', 'label' => (string) trans('firefly.min-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol, - 'currency_code' => $bill->transactionCurrency->code, 'entries' => []], - ['type' => 'line', 'label' => (string) trans('firefly.max-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol, - 'currency_code' => $bill->transactionCurrency->code, 'entries' => []], - ['type' => 'bar', 'label' => (string) trans('firefly.journal-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol, - 'currency_code' => $bill->transactionCurrency->code, 'entries' => []], + [ + 'type' => 'line', + 'label' => (string)trans('firefly.min-amount'), + 'currency_symbol' => $bill->transactionCurrency->symbol, + 'currency_code' => $bill->transactionCurrency->code, + 'entries' => [], + ], + [ + 'type' => 'line', + 'label' => (string)trans('firefly.max-amount'), + 'currency_symbol' => $bill->transactionCurrency->symbol, + 'currency_code' => $bill->transactionCurrency->code, + 'entries' => [], + ], + [ + 'type' => 'bar', + 'label' => (string)trans('firefly.journal-amount'), + 'currency_symbol' => $bill->transactionCurrency->symbol, + 'currency_code' => $bill->transactionCurrency->code, + 'entries' => [], + ], ]; - $currencyId = (int) $bill->transaction_currency_id; + $currencyId = (int)$bill->transaction_currency_id; foreach ($journals as $journal) { - $date = $journal['date']->isoFormat((string) trans('config.month_and_day_js', [], $locale)); + $date = $journal['date']->isoFormat((string)trans('config.month_and_day_js', [], $locale)); $chartData[0]['entries'][$date] = $bill->amount_min; // minimum amount of bill $chartData[1]['entries'][$date] = $bill->amount_max; // maximum amount of bill diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php index 4b8defd6a6..d9138d1894 100644 --- a/app/Http/Controllers/Chart/BudgetController.php +++ b/app/Http/Controllers/Chart/BudgetController.php @@ -1,4 +1,5 @@ opsRepository->sumExpenses($current, $current, null, $budgetCollection, $currency); - $spent = $expenses[(int) $currency->id]['sum'] ?? '0'; + $spent = $expenses[(int)$currency->id]['sum'] ?? '0'; $amount = bcadd($amount, $spent); - $format = $start->isoFormat((string) trans('config.month_and_day_js', [], $locale)); + $format = $start->isoFormat((string)trans('config.month_and_day_js', [], $locale)); $entries[$format] = $amount; $start->addDay(); } - $data = $this->generator->singleSet((string) trans('firefly.left'), $entries); + $data = $this->generator->singleSet((string)trans('firefly.left'), $entries); // add currency symbol from budget limit: $data['datasets'][0]['currency_symbol'] = $budgetLimit->transactionCurrency->symbol; $data['datasets'][0]['currency_code'] = $budgetLimit->transactionCurrency->code; @@ -200,8 +200,8 @@ class BudgetController extends Controller /** * Shows how much is spent per asset account. * - * @param Budget $budget - * @param BudgetLimit|null $budgetLimit + * @param Budget $budget + * @param BudgetLimit|null $budgetLimit * * @return JsonResponse */ @@ -236,20 +236,20 @@ class BudgetController extends Controller // group by asset account ID: foreach ($journals as $journal) { - $key = sprintf('%d-%d', (int) $journal['source_account_id'], $journal['currency_id']); + $key = sprintf('%d-%d', (int)$journal['source_account_id'], $journal['currency_id']); $result[$key] = $result[$key] ?? [ - 'amount' => '0', - 'currency_symbol' => $journal['currency_symbol'], - 'currency_code' => $journal['currency_code'], - 'currency_name' => $journal['currency_name'], - ]; + 'amount' => '0', + 'currency_symbol' => $journal['currency_symbol'], + 'currency_code' => $journal['currency_code'], + 'currency_name' => $journal['currency_name'], + ]; $result[$key]['amount'] = bcadd($journal['amount'], $result[$key]['amount']); } $names = $this->getAccountNames(array_keys($result)); foreach ($result as $combinedId => $info) { $parts = explode('-', $combinedId); - $assetId = (int) $parts[0]; + $assetId = (int)$parts[0]; $title = sprintf('%s (%s)', $names[$assetId] ?? '(empty)', $info['currency_name']); $chartData[$title] = [ @@ -268,8 +268,8 @@ class BudgetController extends Controller /** * Shows how much is spent per category. * - * @param Budget $budget - * @param BudgetLimit|null $budgetLimit + * @param Budget $budget + * @param BudgetLimit|null $budgetLimit * * @return JsonResponse */ @@ -303,18 +303,18 @@ class BudgetController extends Controller foreach ($journals as $journal) { $key = sprintf('%d-%d', $journal['category_id'], $journal['currency_id']); $result[$key] = $result[$key] ?? [ - 'amount' => '0', - 'currency_symbol' => $journal['currency_symbol'], - 'currency_code' => $journal['currency_code'], - 'currency_name' => $journal['currency_name'], - ]; + 'amount' => '0', + 'currency_symbol' => $journal['currency_symbol'], + 'currency_code' => $journal['currency_code'], + 'currency_name' => $journal['currency_name'], + ]; $result[$key]['amount'] = bcadd($journal['amount'], $result[$key]['amount']); } $names = $this->getCategoryNames(array_keys($result)); foreach ($result as $combinedId => $info) { $parts = explode('-', $combinedId); - $categoryId = (int) $parts[0]; + $categoryId = (int)$parts[0]; $title = sprintf('%s (%s)', $names[$categoryId] ?? '(empty)', $info['currency_name']); $chartData[$title] = [ 'amount' => $info['amount'], @@ -332,8 +332,8 @@ class BudgetController extends Controller * Shows how much is spent per expense account. * * - * @param Budget $budget - * @param BudgetLimit|null $budgetLimit + * @param Budget $budget + * @param BudgetLimit|null $budgetLimit * * @return JsonResponse */ @@ -368,18 +368,18 @@ class BudgetController extends Controller foreach ($journals as $journal) { $key = sprintf('%d-%d', $journal['destination_account_id'], $journal['currency_id']); $result[$key] = $result[$key] ?? [ - 'amount' => '0', - 'currency_symbol' => $journal['currency_symbol'], - 'currency_code' => $journal['currency_code'], - 'currency_name' => $journal['currency_name'], - ]; + 'amount' => '0', + 'currency_symbol' => $journal['currency_symbol'], + 'currency_code' => $journal['currency_code'], + 'currency_name' => $journal['currency_name'], + ]; $result[$key]['amount'] = bcadd($journal['amount'], $result[$key]['amount']); } $names = $this->getAccountNames(array_keys($result)); foreach ($result as $combinedId => $info) { $parts = explode('-', $combinedId); - $opposingId = (int) $parts[0]; + $opposingId = (int)$parts[0]; $name = $names[$opposingId] ?? 'no name'; $title = sprintf('%s (%s)', $name, $info['currency_name']); $chartData[$title] = [ @@ -429,11 +429,11 @@ class BudgetController extends Controller /** * Shows a budget overview chart (spent and budgeted). * - * @param Budget $budget - * @param TransactionCurrency $currency - * @param Collection $accounts - * @param Carbon $start - * @param Carbon $end + * @param Budget $budget + * @param TransactionCurrency $currency + * @param Collection $accounts + * @param Carbon $start + * @param Carbon $end * * @return JsonResponse */ @@ -454,14 +454,14 @@ class BudgetController extends Controller $preferredRange = app('navigation')->preferredRangeFormat($start, $end); $chartData = [ [ - 'label' => (string) trans('firefly.box_spent_in_currency', ['currency' => $currency->name]), + 'label' => (string)trans('firefly.box_spent_in_currency', ['currency' => $currency->name]), 'type' => 'bar', 'entries' => [], 'currency_symbol' => $currency->symbol, 'currency_code' => $currency->code, ], [ - 'label' => (string) trans('firefly.box_budgeted_in_currency', ['currency' => $currency->name]), + 'label' => (string)trans('firefly.box_budgeted_in_currency', ['currency' => $currency->name]), 'type' => 'bar', 'currency_symbol' => $currency->symbol, 'currency_code' => $currency->code, @@ -505,10 +505,10 @@ class BudgetController extends Controller /** * Shows a chart for transactions without a budget. * - * @param TransactionCurrency $currency - * @param Collection $accounts - * @param Carbon $start - * @param Carbon $end + * @param TransactionCurrency $currency + * @param Collection $accounts + * @param Carbon $start + * @param Carbon $end * * @return JsonResponse */ @@ -539,7 +539,7 @@ class BudgetController extends Controller $currentStart = app('navigation')->addPeriod($currentStart, $preferredRange, 0); } - $data = $this->generator->singleSet((string) trans('firefly.spent'), $chartData); + $data = $this->generator->singleSet((string)trans('firefly.spent'), $chartData); $cache->store($data); return response()->json($data); diff --git a/app/Http/Controllers/Chart/BudgetReportController.php b/app/Http/Controllers/Chart/BudgetReportController.php index 46529e2304..02de0fe349 100644 --- a/app/Http/Controllers/Chart/BudgetReportController.php +++ b/app/Http/Controllers/Chart/BudgetReportController.php @@ -71,10 +71,10 @@ class BudgetReportController extends Controller /** * Chart that groups the expenses by budget. * - * @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 JsonResponse */ @@ -88,10 +88,10 @@ class BudgetReportController extends Controller foreach ($currency['budgets'] as $budget) { $title = sprintf('%s (%s)', $budget['name'], $currency['currency_name']); $result[$title] = $result[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; foreach ($budget['transaction_journals'] as $journal) { $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); @@ -107,10 +107,10 @@ class BudgetReportController extends Controller /** * Chart that groups the expenses by budget. * - * @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 JsonResponse */ @@ -125,10 +125,10 @@ class BudgetReportController extends Controller $categoryName = $journal['category_name'] ?? trans('firefly.no_category'); $title = sprintf('%s (%s)', $categoryName, $currency['currency_name']); $result[$title] = $result[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); @@ -144,10 +144,10 @@ class BudgetReportController extends Controller /** * Chart that groups expenses by the account. * - * @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 JsonResponse */ @@ -162,10 +162,10 @@ class BudgetReportController extends Controller foreach ($budget['transaction_journals'] as $journal) { $title = sprintf('%s (%s)', $journal['destination_account_name'], $currency['currency_name']); $result[$title] = $result[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); @@ -181,10 +181,10 @@ class BudgetReportController extends Controller /** * Main overview of a budget in the budget report. * - * @param Collection $accounts - * @param Budget $budget - * @param Carbon $start - * @param Carbon $end + * @param Collection $accounts + * @param Budget $budget + * @param Carbon $start + * @param Carbon $end * * @return JsonResponse */ @@ -199,17 +199,17 @@ class BudgetReportController extends Controller // add things to chart Data for each currency: $spentKey = sprintf('%d-spent', $currency['currency_id']); $chartData[$spentKey] = $chartData[$spentKey] ?? [ - 'label' => sprintf( - '%s (%s)', - (string) trans('firefly.spent_in_specific_budget', ['budget' => $budget->name]), - $currency['currency_name'] - ), - 'type' => 'bar', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - 'currency_id' => $currency['currency_id'], - 'entries' => $this->makeEntries($start, $end), - ]; + 'label' => sprintf( + '%s (%s)', + (string)trans('firefly.spent_in_specific_budget', ['budget' => $budget->name]), + $currency['currency_name'] + ), + 'type' => 'bar', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + 'currency_id' => $currency['currency_id'], + 'entries' => $this->makeEntries($start, $end), + ]; foreach ($currency['budgets'] as $currentBudget) { foreach ($currentBudget['transaction_journals'] as $journal) { @@ -227,8 +227,8 @@ class BudgetReportController extends Controller } /** - * @param Carbon $start - * @param Carbon $end + * @param Carbon $start + * @param Carbon $end * * @return array */ @@ -252,10 +252,10 @@ class BudgetReportController extends Controller /** * Chart that groups expenses by the account. * - * @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 JsonResponse */ @@ -270,10 +270,10 @@ class BudgetReportController extends Controller foreach ($budget['transaction_journals'] as $journal) { $title = sprintf('%s (%s)', $journal['source_account_name'], $currency['currency_name']); $result[$title] = $result[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php index 74cccb1bf9..aadd6e1e2b 100644 --- a/app/Http/Controllers/Chart/CategoryController.php +++ b/app/Http/Controllers/Chart/CategoryController.php @@ -39,6 +39,8 @@ use FireflyIII\Support\Http\Controllers\ChartGeneration; use FireflyIII\Support\Http\Controllers\DateCalculation; use Illuminate\Http\JsonResponse; use Illuminate\Support\Collection; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; /** * Class CategoryController. @@ -72,8 +74,8 @@ class CategoryController extends Controller * * @return JsonResponse * @throws FireflyException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function all(Category $category): JsonResponse { @@ -286,8 +288,8 @@ class CategoryController extends Controller * * @return JsonResponse * @throws FireflyException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function specificPeriod(Category $category, Carbon $date): JsonResponse { diff --git a/app/Http/Controllers/Chart/CategoryReportController.php b/app/Http/Controllers/Chart/CategoryReportController.php index c89b98a9b7..32daf8d3c1 100644 --- a/app/Http/Controllers/Chart/CategoryReportController.php +++ b/app/Http/Controllers/Chart/CategoryReportController.php @@ -1,4 +1,5 @@ '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); } @@ -102,10 +103,10 @@ class CategoryReportController extends Controller } /** - * @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 JsonResponse */ @@ -120,10 +121,10 @@ class CategoryReportController extends Controller foreach ($currency['categories'] as $category) { $title = sprintf('%s (%s)', $category['name'], $currency['currency_name']); $result[$title] = $result[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; foreach ($category['transaction_journals'] as $journal) { $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); @@ -137,10 +138,10 @@ class CategoryReportController extends Controller } /** - * @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 JsonResponse */ @@ -155,10 +156,10 @@ class CategoryReportController extends Controller foreach ($currency['categories'] as $category) { $title = sprintf('%s (%s)', $category['name'], $currency['currency_name']); $result[$title] = $result[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; foreach ($category['transaction_journals'] as $journal) { $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); @@ -172,10 +173,10 @@ class CategoryReportController extends Controller } /** - * @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 JsonResponse */ @@ -192,10 +193,10 @@ class CategoryReportController extends Controller $objectName = $journal['destination_account_name'] ?? trans('firefly.empty'); $title = sprintf('%s (%s)', $objectName, $currency['currency_name']); $result[$title] = $result[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); } @@ -208,10 +209,10 @@ class CategoryReportController extends Controller } /** - * @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 JsonResponse */ @@ -228,10 +229,10 @@ class CategoryReportController extends Controller $objectName = $journal['destination_account_name'] ?? trans('firefly.empty'); $title = sprintf('%s (%s)', $objectName, $currency['currency_name']); $result[$title] = $result[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); } @@ -244,10 +245,10 @@ class CategoryReportController extends Controller } /** - * @param Collection $accounts - * @param Category $category - * @param Carbon $start - * @param Carbon $end + * @param Collection $accounts + * @param Category $category + * @param Carbon $start + * @param Carbon $end * * @return JsonResponse * @@ -264,17 +265,17 @@ class CategoryReportController extends Controller // add things to chart Data for each currency: $spentKey = sprintf('%d-spent', $currency['currency_id']); $chartData[$spentKey] = $chartData[$spentKey] ?? [ - 'label' => sprintf( - '%s (%s)', - (string) trans('firefly.spent_in_specific_category', ['category' => $category->name]), - $currency['currency_name'] - ), - 'type' => 'bar', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - 'currency_id' => $currency['currency_id'], - 'entries' => $this->makeEntries($start, $end), - ]; + 'label' => sprintf( + '%s (%s)', + (string)trans('firefly.spent_in_specific_category', ['category' => $category->name]), + $currency['currency_name'] + ), + 'type' => 'bar', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + 'currency_id' => $currency['currency_id'], + 'entries' => $this->makeEntries($start, $end), + ]; foreach ($currency['categories'] as $currentCategory) { foreach ($currentCategory['transaction_journals'] as $journal) { @@ -291,17 +292,17 @@ class CategoryReportController extends Controller // add things to chart Data for each currency: $spentKey = sprintf('%d-earned', $currency['currency_id']); $chartData[$spentKey] = $chartData[$spentKey] ?? [ - 'label' => sprintf( - '%s (%s)', - (string) trans('firefly.earned_in_specific_category', ['category' => $category->name]), - $currency['currency_name'] - ), - 'type' => 'bar', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - 'currency_id' => $currency['currency_id'], - 'entries' => $this->makeEntries($start, $end), - ]; + 'label' => sprintf( + '%s (%s)', + (string)trans('firefly.earned_in_specific_category', ['category' => $category->name]), + $currency['currency_name'] + ), + 'type' => 'bar', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + 'currency_id' => $currency['currency_id'], + 'entries' => $this->makeEntries($start, $end), + ]; foreach ($currency['categories'] as $currentCategory) { foreach ($currentCategory['transaction_journals'] as $journal) { @@ -321,8 +322,8 @@ class CategoryReportController extends Controller /** * TODO duplicate function * - * @param Carbon $start - * @param Carbon $end + * @param Carbon $start + * @param Carbon $end * * @return array */ @@ -344,10 +345,10 @@ class CategoryReportController extends Controller } /** - * @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 JsonResponse */ @@ -364,10 +365,10 @@ class CategoryReportController extends Controller $objectName = $journal['source_account_name'] ?? trans('firefly.empty'); $title = sprintf('%s (%s)', $objectName, $currency['currency_name']); $result[$title] = $result[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); } @@ -380,10 +381,10 @@ class CategoryReportController extends Controller } /** - * @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 JsonResponse */ @@ -400,10 +401,10 @@ class CategoryReportController extends Controller $objectName = $journal['source_account_name'] ?? trans('firefly.empty'); $title = sprintf('%s (%s)', $objectName, $currency['currency_name']); $result[$title] = $result[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); } diff --git a/app/Http/Controllers/Chart/DoubleReportController.php b/app/Http/Controllers/Chart/DoubleReportController.php index 719b17f950..cd665346c9 100644 --- a/app/Http/Controllers/Chart/DoubleReportController.php +++ b/app/Http/Controllers/Chart/DoubleReportController.php @@ -66,10 +66,10 @@ class DoubleReportController extends Controller } /** - * @param Collection $accounts - * @param Collection $others - * @param Carbon $start - * @param Carbon $end + * @param Collection $accounts + * @param Collection $others + * @param Carbon $start + * @param Carbon $end * * @return JsonResponse */ @@ -86,10 +86,10 @@ class DoubleReportController extends Controller $categoryName = $journal['budget_name'] ?? trans('firefly.no_budget'); $title = sprintf('%s (%s)', $categoryName, $currency['currency_name']); $result[$title] = $result[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); } @@ -101,10 +101,10 @@ class DoubleReportController extends Controller } /** - * @param Collection $accounts - * @param Collection $others - * @param Carbon $start - * @param Carbon $end + * @param Collection $accounts + * @param Collection $others + * @param Carbon $start + * @param Carbon $end * * @return JsonResponse */ @@ -121,10 +121,10 @@ class DoubleReportController extends Controller $categoryName = $journal['category_name'] ?? trans('firefly.no_category'); $title = sprintf('%s (%s)', $categoryName, $currency['currency_name']); $result[$title] = $result[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); } @@ -136,10 +136,10 @@ class DoubleReportController extends Controller } /** - * @param Collection $accounts - * @param Collection $others - * @param Carbon $start - * @param Carbon $end + * @param Collection $accounts + * @param Collection $others + * @param Carbon $start + * @param Carbon $end * * @return JsonResponse */ @@ -156,10 +156,10 @@ class DoubleReportController extends Controller $categoryName = $journal['category_name'] ?? trans('firefly.no_category'); $title = sprintf('%s (%s)', $categoryName, $currency['currency_name']); $result[$title] = $result[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); } @@ -171,10 +171,10 @@ class DoubleReportController extends Controller } /** - * @param Collection $accounts - * @param Account $account - * @param Carbon $start - * @param Carbon $end + * @param Collection $accounts + * @param Account $account + * @param Carbon $start + * @param Carbon $end * * @return JsonResponse * @@ -196,17 +196,17 @@ class DoubleReportController extends Controller $name = $this->getCounterpartName($accounts, $account->id, $account->name, $account->iban); $chartData[$spentKey] = $chartData[$spentKey] ?? [ - 'label' => sprintf( - '%s (%s)', - (string) trans('firefly.spent_in_specific_double', ['account' => $name]), - $currency['currency_name'] - ), - 'type' => 'bar', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - 'currency_id' => $currency['currency_id'], - 'entries' => $this->makeEntries($start, $end), - ]; + 'label' => sprintf( + '%s (%s)', + (string)trans('firefly.spent_in_specific_double', ['account' => $name]), + $currency['currency_name'] + ), + 'type' => 'bar', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + 'currency_id' => $currency['currency_id'], + 'entries' => $this->makeEntries($start, $end), + ]; foreach ($currency['transaction_journals'] as $journal) { $key = $journal['date']->isoFormat($format); @@ -222,17 +222,17 @@ class DoubleReportController extends Controller $name = $this->getCounterpartName($accounts, $account->id, $account->name, $account->iban); $chartData[$earnedKey] = $chartData[$earnedKey] ?? [ - 'label' => sprintf( - '%s (%s)', - (string) trans('firefly.earned_in_specific_double', ['account' => $name]), - $currency['currency_name'] - ), - 'type' => 'bar', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - 'currency_id' => $currency['currency_id'], - 'entries' => $this->makeEntries($start, $end), - ]; + 'label' => sprintf( + '%s (%s)', + (string)trans('firefly.earned_in_specific_double', ['account' => $name]), + $currency['currency_name'] + ), + 'type' => 'bar', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + 'currency_id' => $currency['currency_id'], + 'entries' => $this->makeEntries($start, $end), + ]; foreach ($currency['transaction_journals'] as $journal) { $key = $journal['date']->isoFormat($format); @@ -250,10 +250,10 @@ class DoubleReportController extends Controller /** * TODO duplicate function * - * @param Collection $accounts - * @param int $id - * @param string $name - * @param null|string $iban + * @param Collection $accounts + * @param int $id + * @param string $name + * @param null|string $iban * * @return string */ @@ -275,8 +275,8 @@ class DoubleReportController extends Controller /** * TODO duplicate function * - * @param Carbon $start - * @param Carbon $end + * @param Carbon $start + * @param Carbon $end * * @return array */ @@ -298,10 +298,10 @@ class DoubleReportController extends Controller } /** - * @param Collection $accounts - * @param Collection $others - * @param Carbon $start - * @param Carbon $end + * @param Collection $accounts + * @param Collection $others + * @param Carbon $start + * @param Carbon $end * * @return JsonResponse */ @@ -324,10 +324,10 @@ class DoubleReportController extends Controller $tagName = trans('firefly.no_tags'); $title = sprintf('%s (%s)', $tagName, $currency['currency_name']); $result[$title] = $result[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); } @@ -342,10 +342,10 @@ class DoubleReportController extends Controller $tagName = $tag['name']; $title = sprintf('%s (%s)', $tagName, $currency['currency_name']); $result[$title] = $result[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); } @@ -358,10 +358,10 @@ class DoubleReportController extends Controller } /** - * @param Collection $accounts - * @param Collection $others - * @param Carbon $start - * @param Carbon $end + * @param Collection $accounts + * @param Collection $others + * @param Carbon $start + * @param Carbon $end * * @return JsonResponse */ @@ -384,10 +384,10 @@ class DoubleReportController extends Controller $tagName = trans('firefly.no_tags'); $title = sprintf('%s (%s)', $tagName, $currency['currency_name']); $result[$title] = $result[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); } @@ -402,10 +402,10 @@ class DoubleReportController extends Controller $tagName = $tag['name']; $title = sprintf('%s (%s)', $tagName, $currency['currency_name']); $result[$title] = $result[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); } diff --git a/app/Http/Controllers/Chart/ExpenseReportController.php b/app/Http/Controllers/Chart/ExpenseReportController.php index e2c4975338..be3a777d5d 100644 --- a/app/Http/Controllers/Chart/ExpenseReportController.php +++ b/app/Http/Controllers/Chart/ExpenseReportController.php @@ -73,10 +73,10 @@ class ExpenseReportController extends Controller * * TODO this chart is not multi currency aware. * - * @param Collection $accounts - * @param Collection $expense - * @param Carbon $start - * @param Carbon $end + * @param Collection $accounts + * @param Collection $expense + * @param Carbon $start + * @param Carbon $end * * @return JsonResponse * @throws JsonException @@ -106,35 +106,35 @@ class ExpenseReportController extends Controller // prep chart data: /** - * @var string $name + * @var string $name * @var Collection $combination */ foreach ($combined as $name => $combination) { // first is always expense account: /** @var Account $exp */ - $exp = $combination->first(); - $chartData[$exp->id . '-in'] = [ - 'label' => sprintf('%s (%s)', $name, (string) trans('firefly.income')), + $exp = $combination->first(); + $chartData[$exp->id.'-in'] = [ + 'label' => sprintf('%s (%s)', $name, (string)trans('firefly.income')), 'type' => 'bar', 'yAxisID' => 'y-axis-0', 'entries' => [], ]; - $chartData[$exp->id . '-out'] = [ - 'label' => sprintf('%s (%s)', $name, (string) trans('firefly.expenses')), + $chartData[$exp->id.'-out'] = [ + 'label' => sprintf('%s (%s)', $name, (string)trans('firefly.expenses')), 'type' => 'bar', 'yAxisID' => 'y-axis-0', 'entries' => [], ]; // total in, total out: - $chartData[$exp->id . '-total-in'] = [ - 'label' => sprintf('%s (%s)', $name, (string) trans('firefly.sum_of_income')), + $chartData[$exp->id.'-total-in'] = [ + 'label' => sprintf('%s (%s)', $name, (string)trans('firefly.sum_of_income')), 'type' => 'line', 'fill' => false, 'yAxisID' => 'y-axis-1', 'entries' => [], ]; - $chartData[$exp->id . '-total-out'] = [ - 'label' => sprintf('%s (%s)', $name, (string) trans('firefly.sum_of_expenses')), + $chartData[$exp->id.'-total-out'] = [ + 'label' => sprintf('%s (%s)', $name, (string)trans('firefly.sum_of_expenses')), 'type' => 'line', 'fill' => false, 'yAxisID' => 'y-axis-1', @@ -158,10 +158,10 @@ class ExpenseReportController extends Controller // first is always expense account: /** @var Account $exp */ $exp = $combination->first(); - $labelIn = $exp->id . '-in'; - $labelOut = $exp->id . '-out'; - $labelSumIn = $exp->id . '-total-in'; - $labelSumOut = $exp->id . '-total-out'; + $labelIn = $exp->id.'-in'; + $labelOut = $exp->id.'-out'; + $labelSumIn = $exp->id.'-total-in'; + $labelSumOut = $exp->id.'-total-out'; $currentIncome = bcmul($income[$name] ?? '0', '-1'); $currentExpense = $expenses[$name] ?? '0'; diff --git a/app/Http/Controllers/Chart/PiggyBankController.php b/app/Http/Controllers/Chart/PiggyBankController.php index 8a054f9ac9..ebdd6cb8f1 100644 --- a/app/Http/Controllers/Chart/PiggyBankController.php +++ b/app/Http/Controllers/Chart/PiggyBankController.php @@ -1,4 +1,5 @@ sum('amount'); - $label = $oldest->isoFormat((string) trans('config.month_and_day_js', [], $locale)); + $label = $oldest->isoFormat((string)trans('config.month_and_day_js', [], $locale)); $chartData[$label] = $currentSum; $oldest = app('navigation')->addPeriod($oldest, $step, 0); } @@ -110,7 +111,7 @@ class PiggyBankController extends Controller } ); $finalSum = $finalFiltered->sum('amount'); - $finalLabel = $today->isoFormat((string) trans('config.month_and_day_js', [], $locale)); + $finalLabel = $today->isoFormat((string)trans('config.month_and_day_js', [], $locale)); $chartData[$finalLabel] = $finalSum; $data = $this->generator->singleSet($piggyBank->name, $chartData); diff --git a/app/Http/Controllers/Chart/ReportController.php b/app/Http/Controllers/Chart/ReportController.php index f30510220b..915934fd44 100644 --- a/app/Http/Controllers/Chart/ReportController.php +++ b/app/Http/Controllers/Chart/ReportController.php @@ -1,4 +1,5 @@ id; - $label = $current->isoFormat((string) trans('config.month_and_day_js', [], $locale)); + $label = $current->isoFormat((string)trans('config.month_and_day_js', [], $locale)); if (!array_key_exists($currencyId, $chartData)) { $chartData[$currencyId] = [ - 'label' => 'Net worth in ' . $netWorthItem['currency']->name, + 'label' => 'Net worth in '.$netWorthItem['currency']->name, 'type' => 'line', 'currency_symbol' => $netWorthItem['currency']->symbol, 'currency_code' => $netWorthItem['currency']->code, @@ -139,9 +141,9 @@ class ReportController extends Controller /** * Shows income and expense, debit/credit: operations. * - * @param Collection $accounts - * @param Carbon $start - * @param Carbon $end + * @param Collection $accounts + * @param Carbon $start + * @param Carbon $end * * @return JsonResponse * @throws JsonException @@ -179,13 +181,13 @@ class ReportController extends Controller /** @var array $journal */ foreach ($journals as $journal) { $period = $journal['date']->format($format); - $currencyId = (int) $journal['currency_id']; + $currencyId = (int)$journal['currency_id']; $data[$currencyId] = $data[$currencyId] ?? [ 'currency_id' => $currencyId, 'currency_symbol' => $journal['currency_symbol'], 'currency_code' => $journal['currency_code'], 'currency_name' => $journal['currency_name'], - 'currency_decimal_places' => (int) $journal['currency_decimal_places'], + 'currency_decimal_places' => (int)$journal['currency_decimal_places'], ]; $data[$currencyId][$period] = $data[$currencyId][$period] ?? [ 'period' => $period, @@ -220,7 +222,7 @@ class ReportController extends Controller /** @var array $currency */ foreach ($data as $currency) { $income = [ - 'label' => (string) trans('firefly.box_earned_in_currency', ['currency' => $currency['currency_name']]), + 'label' => (string)trans('firefly.box_earned_in_currency', ['currency' => $currency['currency_name']]), 'type' => 'bar', 'backgroundColor' => 'rgba(0, 141, 76, 0.5)', // green 'currency_id' => $currency['currency_id'], @@ -229,7 +231,7 @@ class ReportController extends Controller 'entries' => [], ]; $expense = [ - 'label' => (string) trans('firefly.box_spent_in_currency', ['currency' => $currency['currency_name']]), + 'label' => (string)trans('firefly.box_spent_in_currency', ['currency' => $currency['currency_name']]), 'type' => 'bar', 'backgroundColor' => 'rgba(219, 68, 55, 0.5)', // red 'currency_id' => $currency['currency_id'], diff --git a/app/Http/Controllers/Chart/TagReportController.php b/app/Http/Controllers/Chart/TagReportController.php index 1828b887cb..355b240a4c 100644 --- a/app/Http/Controllers/Chart/TagReportController.php +++ b/app/Http/Controllers/Chart/TagReportController.php @@ -1,4 +1,5 @@ '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); } @@ -103,10 +104,10 @@ class TagReportController extends Controller } /** - * @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 JsonResponse */ @@ -123,10 +124,10 @@ class TagReportController extends Controller $objectName = $journal['category_name'] ?? trans('firefly.no_category'); $title = sprintf('%s (%s)', $objectName, $currency['currency_name']); $result[$title] = $result[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); } @@ -139,10 +140,10 @@ class TagReportController extends Controller } /** - * @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 JsonResponse */ @@ -159,10 +160,10 @@ class TagReportController extends Controller $objectName = $journal['category_name'] ?? trans('firefly.no_category'); $title = sprintf('%s (%s)', $objectName, $currency['currency_name']); $result[$title] = $result[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); } @@ -175,10 +176,10 @@ class TagReportController extends Controller } /** - * @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 JsonResponse */ @@ -195,10 +196,10 @@ class TagReportController extends Controller $objectName = $journal['destination_account_name'] ?? trans('firefly.empty'); $title = sprintf('%s (%s)', $objectName, $currency['currency_name']); $result[$title] = $result[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); } @@ -211,10 +212,10 @@ class TagReportController extends Controller } /** - * @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 JsonResponse */ @@ -231,10 +232,10 @@ class TagReportController extends Controller $objectName = $journal['destination_account_name'] ?? trans('firefly.empty'); $title = sprintf('%s (%s)', $objectName, $currency['currency_name']); $result[$title] = $result[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); } @@ -249,10 +250,10 @@ class TagReportController extends Controller /** * Generate main tag overview chart. * - * @param Collection $accounts - * @param Tag $tag - * @param Carbon $start - * @param Carbon $end + * @param Collection $accounts + * @param Tag $tag + * @param Carbon $start + * @param Carbon $end * * @return JsonResponse * @@ -269,17 +270,17 @@ class TagReportController extends Controller // add things to chart Data for each currency: $spentKey = sprintf('%d-spent', $currency['currency_id']); $chartData[$spentKey] = $chartData[$spentKey] ?? [ - 'label' => sprintf( - '%s (%s)', - (string) trans('firefly.spent_in_specific_tag', ['tag' => $tag->tag]), - $currency['currency_name'] - ), - 'type' => 'bar', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - 'currency_id' => $currency['currency_id'], - 'entries' => $this->makeEntries($start, $end), - ]; + 'label' => sprintf( + '%s (%s)', + (string)trans('firefly.spent_in_specific_tag', ['tag' => $tag->tag]), + $currency['currency_name'] + ), + 'type' => 'bar', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + 'currency_id' => $currency['currency_id'], + 'entries' => $this->makeEntries($start, $end), + ]; foreach ($currency['tags'] as $currentTag) { foreach ($currentTag['transaction_journals'] as $journal) { @@ -296,17 +297,17 @@ class TagReportController extends Controller // add things to chart Data for each currency: $spentKey = sprintf('%d-earned', $currency['currency_id']); $chartData[$spentKey] = $chartData[$spentKey] ?? [ - 'label' => sprintf( - '%s (%s)', - (string) trans('firefly.earned_in_specific_tag', ['tag' => $tag->tag]), - $currency['currency_name'] - ), - 'type' => 'bar', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - 'currency_id' => $currency['currency_id'], - 'entries' => $this->makeEntries($start, $end), - ]; + 'label' => sprintf( + '%s (%s)', + (string)trans('firefly.earned_in_specific_tag', ['tag' => $tag->tag]), + $currency['currency_name'] + ), + 'type' => 'bar', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + 'currency_id' => $currency['currency_id'], + 'entries' => $this->makeEntries($start, $end), + ]; foreach ($currency['tags'] as $currentTag) { foreach ($currentTag['transaction_journals'] as $journal) { @@ -326,8 +327,8 @@ class TagReportController extends Controller /** * TODO duplicate function * - * @param Carbon $start - * @param Carbon $end + * @param Carbon $start + * @param Carbon $end * * @return array */ @@ -349,10 +350,10 @@ class TagReportController extends Controller } /** - * @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 JsonResponse */ @@ -369,10 +370,10 @@ class TagReportController extends Controller $objectName = $journal['source_account_name'] ?? trans('firefly.empty'); $title = sprintf('%s (%s)', $objectName, $currency['currency_name']); $result[$title] = $result[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); } @@ -385,10 +386,10 @@ class TagReportController extends Controller } /** - * @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 JsonResponse */ @@ -405,10 +406,10 @@ class TagReportController extends Controller $objectName = $journal['source_account_name'] ?? trans('firefly.empty'); $title = sprintf('%s (%s)', $objectName, $currency['currency_name']); $result[$title] = $result[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); } @@ -421,10 +422,10 @@ class TagReportController extends Controller } /** - * @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 JsonResponse */ @@ -439,10 +440,10 @@ class TagReportController extends Controller foreach ($currency['tags'] as $tag) { $title = sprintf('%s (%s)', $tag['name'], $currency['currency_name']); $result[$title] = $result[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; foreach ($tag['transaction_journals'] as $journal) { $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); @@ -455,10 +456,10 @@ class TagReportController extends Controller } /** - * @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 JsonResponse */ @@ -473,10 +474,10 @@ class TagReportController extends Controller foreach ($currency['tags'] as $tag) { $title = sprintf('%s (%s)', $tag['name'], $currency['currency_name']); $result[$title] = $result[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $currency['currency_symbol'], - 'currency_code' => $currency['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $currency['currency_symbol'], + 'currency_code' => $currency['currency_code'], + ]; foreach ($tag['transaction_journals'] as $journal) { $amount = app('steam')->positive($journal['amount']); $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount); diff --git a/app/Http/Controllers/Chart/TransactionController.php b/app/Http/Controllers/Chart/TransactionController.php index aeee55ed8c..01a65da0e7 100644 --- a/app/Http/Controllers/Chart/TransactionController.php +++ b/app/Http/Controllers/Chart/TransactionController.php @@ -32,7 +32,6 @@ use FireflyIII\Http\Controllers\Controller; use FireflyIII\Models\TransactionType; use FireflyIII\Support\CacheProperties; use Illuminate\Http\JsonResponse; -use JsonException; /** * Class TransactionController @@ -52,8 +51,8 @@ class TransactionController extends Controller } /** - * @param Carbon $start - * @param Carbon $end + * @param Carbon $start + * @param Carbon $end * * @return JsonResponse */ @@ -78,13 +77,13 @@ class TransactionController extends Controller // group by category. /** @var array $journal */ foreach ($result as $journal) { - $budget = $journal['budget_name'] ?? (string) trans('firefly.no_budget'); + $budget = $journal['budget_name'] ?? (string)trans('firefly.no_budget'); $title = sprintf('%s (%s)', $budget, $journal['currency_symbol']); $data[$title] = $data[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $journal['currency_symbol'], - 'currency_code' => $journal['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $journal['currency_symbol'], + 'currency_code' => $journal['currency_code'], + ]; $data[$title]['amount'] = bcadd($data[$title]['amount'], $journal['amount']); } $chart = $this->generator->multiCurrencyPieChart($data); @@ -94,9 +93,9 @@ class TransactionController extends Controller } /** - * @param string $objectType - * @param Carbon $start - * @param Carbon $end + * @param string $objectType + * @param Carbon $start + * @param Carbon $end * * @return JsonResponse * @throws FireflyException @@ -132,13 +131,13 @@ class TransactionController extends Controller // group by category. /** @var array $journal */ foreach ($result as $journal) { - $category = $journal['category_name'] ?? (string) trans('firefly.no_category'); + $category = $journal['category_name'] ?? (string)trans('firefly.no_category'); $title = sprintf('%s (%s)', $category, $journal['currency_symbol']); $data[$title] = $data[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $journal['currency_symbol'], - 'currency_code' => $journal['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $journal['currency_symbol'], + 'currency_code' => $journal['currency_code'], + ]; $data[$title]['amount'] = bcadd($data[$title]['amount'], $journal['amount']); } $chart = $this->generator->multiCurrencyPieChart($data); @@ -148,9 +147,9 @@ class TransactionController extends Controller } /** - * @param string $objectType - * @param Carbon $start - * @param Carbon $end + * @param string $objectType + * @param Carbon $start + * @param Carbon $end * * @return JsonResponse * @throws FireflyException @@ -189,10 +188,10 @@ class TransactionController extends Controller $name = $journal['destination_account_name']; $title = sprintf('%s (%s)', $name, $journal['currency_symbol']); $data[$title] = $data[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $journal['currency_symbol'], - 'currency_code' => $journal['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $journal['currency_symbol'], + 'currency_code' => $journal['currency_code'], + ]; $data[$title]['amount'] = bcadd($data[$title]['amount'], $journal['amount']); } $chart = $this->generator->multiCurrencyPieChart($data); @@ -202,9 +201,9 @@ class TransactionController extends Controller } /** - * @param string $objectType - * @param Carbon $start - * @param Carbon $end + * @param string $objectType + * @param Carbon $start + * @param Carbon $end * * @return JsonResponse * @throws FireflyException @@ -243,10 +242,10 @@ class TransactionController extends Controller $name = $journal['source_account_name']; $title = sprintf('%s (%s)', $name, $journal['currency_symbol']); $data[$title] = $data[$title] ?? [ - 'amount' => '0', - 'currency_symbol' => $journal['currency_symbol'], - 'currency_code' => $journal['currency_code'], - ]; + 'amount' => '0', + 'currency_symbol' => $journal['currency_symbol'], + 'currency_code' => $journal['currency_code'], + ]; $data[$title]['amount'] = bcadd($data[$title]['amount'], $journal['amount']); } $chart = $this->generator->multiCurrencyPieChart($data); diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 87a4293967..b71dd07d2a 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -1,4 +1,5 @@ getLocale(); // translations for specific strings: - $this->monthFormat = (string) trans('config.month_js', [], $locale); - $this->monthAndDayFormat = (string) trans('config.month_and_day_js', [], $locale); - $this->dateTimeFormat = (string) trans('config.date_time_js', [], $locale); + $this->monthFormat = (string)trans('config.month_js', [], $locale); + $this->monthAndDayFormat = (string)trans('config.month_and_day_js', [], $locale); + $this->dateTimeFormat = (string)trans('config.date_time_js', [], $locale); // get shown-intro-preference: if (auth()->check()) { diff --git a/app/Http/Controllers/CurrencyController.php b/app/Http/Controllers/CurrencyController.php index c5a95a6e1b..cce7d35805 100644 --- a/app/Http/Controllers/CurrencyController.php +++ b/app/Http/Controllers/CurrencyController.php @@ -1,4 +1,5 @@ middleware( function ($request, $next) { - app('view')->share('title', (string) trans('firefly.currencies')); + app('view')->share('title', (string)trans('firefly.currencies')); app('view')->share('mainTitleIcon', 'fa-usd'); $this->repository = app(CurrencyRepositoryInterface::class); $this->userRepository = app(UserRepositoryInterface::class); @@ -69,7 +72,7 @@ class CurrencyController extends Controller /** * Create a currency. * - * @param Request $request + * @param Request $request * * @return Factory|RedirectResponse|Redirector|View */ @@ -78,13 +81,13 @@ class CurrencyController extends Controller /** @var User $user */ $user = auth()->user(); if (!$this->userRepository->hasRole($user, 'owner')) { - $request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); + $request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); return redirect(route('currencies.index')); } $subTitleIcon = 'fa-plus'; - $subTitle = (string) trans('firefly.create_currency'); + $subTitle = (string)trans('firefly.create_currency'); // put previous url in session if not redirect from store (not "create another"). if (true !== session('currencies.create.fromStore')) { @@ -100,14 +103,14 @@ class CurrencyController extends Controller /** * Make currency the default currency. * - * @param Request $request + * @param Request $request * * @return RedirectResponse|Redirector * @throws FireflyException */ public function defaultCurrency(Request $request) { - $currencyId = (int) $request->get('id'); + $currencyId = (int)$request->get('id'); if ($currencyId > 0) { // valid currency? $currency = $this->repository->find($currencyId); @@ -117,7 +120,7 @@ class CurrencyController extends Controller Log::channel('audit')->info(sprintf('Make %s the default currency.', $currency->code)); $this->repository->enable($currency); - $request->session()->flash('success', (string) trans('firefly.new_default_currency', ['name' => $currency->name])); + $request->session()->flash('success', (string)trans('firefly.new_default_currency', ['name' => $currency->name])); return redirect(route('currencies.index')); } @@ -129,8 +132,8 @@ class CurrencyController extends Controller /** * Deletes a currency. * - * @param Request $request - * @param TransactionCurrency $currency + * @param Request $request + * @param TransactionCurrency $currency * * @return Factory|RedirectResponse|Redirector|View */ @@ -139,7 +142,7 @@ class CurrencyController extends Controller /** @var User $user */ $user = auth()->user(); if (!$this->userRepository->hasRole($user, 'owner')) { - $request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); + $request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); Log::channel('audit')->info(sprintf('Tried to visit page to delete currency %s but is not site owner.', $currency->code)); return redirect(route('currencies.index')); @@ -147,7 +150,7 @@ class CurrencyController extends Controller if ($this->repository->currencyInUse($currency)) { $location = $this->repository->currencyInUseAt($currency); - $message = (string) trans(sprintf('firefly.cannot_disable_currency_%s', $location), ['name' => e($currency->name)]); + $message = (string)trans(sprintf('firefly.cannot_disable_currency_%s', $location), ['name' => e($currency->name)]); $request->session()->flash('error', $message); Log::channel('audit')->info(sprintf('Tried to visit page to delete currency %s but currency is in use.', $currency->code)); @@ -156,7 +159,7 @@ class CurrencyController extends Controller // put previous url in session $this->rememberPreviousUrl('currencies.delete.url'); - $subTitle = (string) trans('form.delete_currency', ['name' => $currency->name]); + $subTitle = (string)trans('form.delete_currency', ['name' => $currency->name]); Log::channel('audit')->info(sprintf('Visit page to delete currency %s.', $currency->code)); return view('currencies.delete', compact('currency', 'subTitle')); @@ -165,8 +168,8 @@ class CurrencyController extends Controller /** * Destroys a currency. * - * @param Request $request - * @param TransactionCurrency $currency + * @param Request $request + * @param TransactionCurrency $currency * * @return RedirectResponse|Redirector */ @@ -175,21 +178,21 @@ class CurrencyController extends Controller /** @var User $user */ $user = auth()->user(); if (!$this->userRepository->hasRole($user, 'owner')) { - $request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); + $request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); Log::channel('audit')->info(sprintf('Tried to delete currency %s but is not site owner.', $currency->code)); return redirect(route('currencies.index')); } if ($this->repository->currencyInUse($currency)) { - $request->session()->flash('error', (string) trans('firefly.cannot_delete_currency', ['name' => e($currency->name)])); + $request->session()->flash('error', (string)trans('firefly.cannot_delete_currency', ['name' => e($currency->name)])); Log::channel('audit')->info(sprintf('Tried to delete currency %s but is in use.', $currency->code)); return redirect(route('currencies.index')); } if ($this->repository->isFallbackCurrency($currency)) { - $request->session()->flash('error', (string) trans('firefly.cannot_delete_fallback_currency', ['name' => e($currency->name)])); + $request->session()->flash('error', (string)trans('firefly.cannot_delete_fallback_currency', ['name' => e($currency->name)])); Log::channel('audit')->info(sprintf('Tried to delete currency %s but is FALLBACK.', $currency->code)); return redirect(route('currencies.index')); @@ -198,19 +201,19 @@ class CurrencyController extends Controller Log::channel('audit')->info(sprintf('Deleted currency %s.', $currency->code)); $this->repository->destroy($currency); - $request->session()->flash('success', (string) trans('firefly.deleted_currency', ['name' => $currency->name])); + $request->session()->flash('success', (string)trans('firefly.deleted_currency', ['name' => $currency->name])); return redirect($this->getPreviousUrl('currencies.delete.url')); } /** - * @param Request $request + * @param Request $request * @return JsonResponse * @throws FireflyException */ public function disableCurrency(Request $request): JsonResponse { - $currencyId = (int) $request->get('id'); + $currencyId = (int)$request->get('id'); $currency = $this->repository->find($currencyId); // valid currency? @@ -224,7 +227,7 @@ class CurrencyController extends Controller /** @var User $user */ $user = auth()->user(); if (!$this->userRepository->hasRole($user, 'owner')) { - $request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); + $request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); Log::channel('audit')->info(sprintf('Tried to disable currency %s but is not site owner.', $currency->code)); return response()->json([]); } @@ -232,7 +235,7 @@ class CurrencyController extends Controller // currency cannot be in use. if ($this->repository->currencyInUse($currency)) { $location = $this->repository->currencyInUseAt($currency); - $message = (string) trans(sprintf('firefly.cannot_disable_currency_%s', $location), ['name' => e($currency->name)]); + $message = (string)trans(sprintf('firefly.cannot_disable_currency_%s', $location), ['name' => e($currency->name)]); $request->session()->flash('error', $message); Log::channel('audit')->info(sprintf('Tried to disable currency %s but is in use.', $currency->code)); @@ -247,18 +250,18 @@ class CurrencyController extends Controller // extra warning if ('EUR' === $currency->code) { - session()->flash('warning', (string) trans('firefly.disable_EUR_side_effects')); + session()->flash('warning', (string)trans('firefly.disable_EUR_side_effects')); } - session()->flash('success', (string) trans('firefly.currency_is_now_disabled', ['name' => $currency->name])); + session()->flash('success', (string)trans('firefly.currency_is_now_disabled', ['name' => $currency->name])); return response()->json([]); } /** * Edit a currency. * - * @param Request $request - * @param TransactionCurrency $currency + * @param Request $request + * @param TransactionCurrency $currency * * @return Factory|RedirectResponse|Redirector|View */ @@ -267,20 +270,20 @@ class CurrencyController extends Controller /** @var User $user */ $user = auth()->user(); if (!$this->userRepository->hasRole($user, 'owner')) { - $request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); + $request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); Log::channel('audit')->info(sprintf('Tried to edit currency %s but is not owner.', $currency->code)); return redirect(route('currencies.index')); } $subTitleIcon = 'fa-pencil'; - $subTitle = (string) trans('breadcrumbs.edit_currency', ['name' => $currency->name]); + $subTitle = (string)trans('breadcrumbs.edit_currency', ['name' => $currency->name]); $currency->symbol = htmlentities($currency->symbol); // code to handle active-checkboxes $hasOldInput = null !== $request->old('_token'); $preFilled = [ - 'enabled' => $hasOldInput ? (bool) $request->old('enabled') : $currency->enabled, + 'enabled' => $hasOldInput ? (bool)$request->old('enabled') : $currency->enabled, ]; $request->session()->flash('preFilled', $preFilled); @@ -296,12 +299,12 @@ class CurrencyController extends Controller } /** - * @param Request $request + * @param Request $request * @return RedirectResponse|Redirector */ public function enableCurrency(Request $request): JsonResponse { - $currencyId = (int) $request->get('id'); + $currencyId = (int)$request->get('id'); if ($currencyId > 0) { // valid currency? $currency = $this->repository->find($currencyId); @@ -309,7 +312,7 @@ class CurrencyController extends Controller app('preferences')->mark(); $this->repository->enable($currency); - session()->flash('success', (string) trans('firefly.currency_is_now_enabled', ['name' => $currency->name])); + session()->flash('success', (string)trans('firefly.currency_is_now_enabled', ['name' => $currency->name])); Log::channel('audit')->info(sprintf('Enabled currency %s.', $currency->code)); } } @@ -320,19 +323,19 @@ class CurrencyController extends Controller /** * Show overview of currencies. * - * @param Request $request + * @param Request $request * * @return Factory|View * @throws FireflyException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function index(Request $request) { /** @var User $user */ $user = auth()->user(); - $page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page'); - $pageSize = (int) app('preferences')->get('listPageSize', 50)->data; + $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page'); + $pageSize = (int)app('preferences')->get('listPageSize', 50)->data; $collection = $this->repository->getAll(); $total = $collection->count(); $collection = $collection->slice(($page - 1) * $pageSize, $pageSize); @@ -342,7 +345,7 @@ class CurrencyController extends Controller $defaultCurrency = $this->repository->getCurrencyByPreference(app('preferences')->get('currencyPreference', config('firefly.default_currency', 'EUR'))); $isOwner = true; if (!$this->userRepository->hasRole($user, 'owner')) { - $request->session()->flash('info', (string) trans('firefly.ask_site_owner', ['owner' => config('firefly.site_owner')])); + $request->session()->flash('info', (string)trans('firefly.ask_site_owner', ['owner' => config('firefly.site_owner')])); $isOwner = false; } @@ -352,7 +355,7 @@ class CurrencyController extends Controller /** * Store new currency. * - * @param CurrencyFormRequest $request + * @param CurrencyFormRequest $request * * @return $this|RedirectResponse|Redirector */ @@ -362,7 +365,7 @@ class CurrencyController extends Controller $user = auth()->user(); $data = $request->getCurrencyData(); if (!$this->userRepository->hasRole($user, 'owner')) { - Log::error('User ' . auth()->user()->id . ' is not admin, but tried to store a currency.'); + Log::error('User '.auth()->user()->id.' is not admin, but tried to store a currency.'); Log::channel('audit')->info('Tried to create (POST) currency without admin rights.', $data); return redirect($this->getPreviousUrl('currencies.create.url')); @@ -374,15 +377,15 @@ class CurrencyController extends Controller } catch (FireflyException $e) { Log::error($e->getMessage()); Log::channel('audit')->info('Could not store (POST) currency without admin rights.', $data); - $request->session()->flash('error', (string) trans('firefly.could_not_store_currency')); + $request->session()->flash('error', (string)trans('firefly.could_not_store_currency')); $currency = null; } $redirect = redirect($this->getPreviousUrl('currencies.create.url')); if (null !== $currency) { - $request->session()->flash('success', (string) trans('firefly.created_currency', ['name' => $currency->name])); + $request->session()->flash('success', (string)trans('firefly.created_currency', ['name' => $currency->name])); Log::channel('audit')->info('Created (POST) currency.', $data); - if (1 === (int) $request->get('create_another')) { + if (1 === (int)$request->get('create_another')) { $request->session()->put('currencies.create.fromStore', true); $redirect = redirect(route('currencies.create'))->withInput(); @@ -395,8 +398,8 @@ class CurrencyController extends Controller /** * Updates a currency. * - * @param CurrencyFormRequest $request - * @param TransactionCurrency $currency + * @param CurrencyFormRequest $request + * @param TransactionCurrency $currency * * @return RedirectResponse|Redirector */ @@ -410,17 +413,17 @@ class CurrencyController extends Controller $data['enabled'] = true; } if (!$this->userRepository->hasRole($user, 'owner')) { - $request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); + $request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); Log::channel('audit')->info('Tried to update (POST) currency without admin rights.', $data); return redirect(route('currencies.index')); } $currency = $this->repository->update($currency, $data); Log::channel('audit')->info('Updated (POST) currency.', $data); - $request->session()->flash('success', (string) trans('firefly.updated_currency', ['name' => $currency->name])); + $request->session()->flash('success', (string)trans('firefly.updated_currency', ['name' => $currency->name])); app('preferences')->mark(); - if (1 === (int) $request->get('return_to_edit')) { + if (1 === (int)$request->get('return_to_edit')) { $request->session()->put('currencies.edit.fromUpdate', true); return redirect(route('currencies.edit', [$currency->id])); diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.php index cb01d5040a..3edc22846b 100644 --- a/app/Http/Controllers/DebugController.php +++ b/app/Http/Controllers/DebugController.php @@ -81,14 +81,14 @@ class DebugController extends Controller /** * Clear log and session. * - * @param Request $request + * @param Request $request * * @return RedirectResponse|Redirector */ public function flush(Request $request) { app('preferences')->mark(); - $request->session()->forget(['start', 'end', '_previous', 'viewRange', 'range', 'is_custom_range','temp-mfa-secret','temp-mfa-codes']); + $request->session()->forget(['start', 'end', '_previous', 'viewRange', 'range', 'is_custom_range', 'temp-mfa-secret', 'temp-mfa-codes']); Log::debug('Call cache:clear...'); Artisan::call('cache:clear'); Log::debug('Call config:clear...'); @@ -112,7 +112,7 @@ class DebugController extends Controller /** * Show debug info. * - * @param Request $request + * @param Request $request * * @return Factory|View * @throws FireflyException @@ -142,10 +142,10 @@ class DebugController extends Controller $logChannel = config('logging.default'); $appLogLevel = config('logging.level'); $displayErrors = ini_get('display_errors'); - $errorReporting = $this->errorReporting((int) ini_get('error_reporting')); + $errorReporting = $this->errorReporting((int)ini_get('error_reporting')); $interface = PHP_SAPI; - $defaultLanguage = (string) config('firefly.default_language'); - $defaultLocale = (string) config('firefly.default_locale'); + $defaultLanguage = (string)config('firefly.default_language'); + $defaultLocale = (string)config('firefly.default_locale'); $bcscale = bcscale(); $drivers = implode(', ', DB::availableDrivers()); $currentDriver = DB::getDriverName(); @@ -196,7 +196,7 @@ class DebugController extends Controller } if ('' !== $logContent) { // last few lines - $logContent = 'Truncated from this point <----|' . substr($logContent, -8192); + $logContent = 'Truncated from this point <----|'.substr($logContent, -8192); } return view( @@ -247,21 +247,59 @@ class DebugController extends Controller public function routes(): string { $set = RouteFacade::getRoutes(); - $ignore = ['chart.', 'javascript.', 'json.', 'report-data.', 'popup.', 'debugbar.', 'attachments.download', 'attachments.preview', - 'bills.rescan', 'budgets.income', 'currencies.def', 'error', 'flush', 'help.show', - 'login', 'logout', 'password.reset', 'profile.confirm-email-change', 'profile.undo-email-change', - 'register', 'report.options', 'routes', 'rule-groups.down', 'rule-groups.up', 'rules.up', 'rules.down', - 'rules.select', 'search.search', 'test-flash', 'transactions.link.delete', 'transactions.link.switch', - 'two-factor.lost', 'reports.options', 'debug', - 'preferences.delete-code', 'rules.test-triggers', 'piggy-banks.remove-money', 'piggy-banks.add-money', - 'accounts.reconcile.transactions', 'accounts.reconcile.overview', - 'transactions.clone', 'two-factor.index', 'api.v1', 'installer.', 'attachments.view', 'recurring.events', - 'recurring.suggest', + $ignore = [ + 'chart.', + 'javascript.', + 'json.', + 'report-data.', + 'popup.', + 'debugbar.', + 'attachments.download', + 'attachments.preview', + 'bills.rescan', + 'budgets.income', + 'currencies.def', + 'error', + 'flush', + 'help.show', + 'login', + 'logout', + 'password.reset', + 'profile.confirm-email-change', + 'profile.undo-email-change', + 'register', + 'report.options', + 'routes', + 'rule-groups.down', + 'rule-groups.up', + 'rules.up', + 'rules.down', + 'rules.select', + 'search.search', + 'test-flash', + 'transactions.link.delete', + 'transactions.link.switch', + 'two-factor.lost', + 'reports.options', + 'debug', + 'preferences.delete-code', + 'rules.test-triggers', + 'piggy-banks.remove-money', + 'piggy-banks.add-money', + 'accounts.reconcile.transactions', + 'accounts.reconcile.overview', + 'transactions.clone', + 'two-factor.index', + 'api.v1', + 'installer.', + 'attachments.view', + 'recurring.events', + 'recurring.suggest', ]; $return = ' '; /** @var Route $route */ foreach ($set as $route) { - $name = (string) $route->getName(); + $name = (string)$route->getName(); if (in_array('GET', $route->methods(), true)) { $found = false; foreach ($ignore as $string) { @@ -271,7 +309,7 @@ class DebugController extends Controller } } if (false === $found) { - $return .= 'touch ' . $route->getName() . '.md;'; + $return .= 'touch '.$route->getName().'.md;'; } } } @@ -282,7 +320,7 @@ class DebugController extends Controller /** * Flash all types of messages. * - * @param Request $request + * @param Request $request * * @return RedirectResponse|Redirector */ diff --git a/app/Http/Controllers/Export/IndexController.php b/app/Http/Controllers/Export/IndexController.php index 7d1a5fc1c9..ba72ae174b 100644 --- a/app/Http/Controllers/Export/IndexController.php +++ b/app/Http/Controllers/Export/IndexController.php @@ -53,7 +53,7 @@ class IndexController extends Controller $this->middleware( function ($request, $next) { app('view')->share('mainTitleIcon', 'fa-life-bouy'); - app('view')->share('title', (string) trans('firefly.export_data_title')); + app('view')->share('title', (string)trans('firefly.export_data_title')); $this->journalRepository = app(JournalRepositoryInterface::class); $this->middleware(IsDemoUser::class)->except(['index']); @@ -92,7 +92,7 @@ class IndexController extends Controller $response ->header('Content-Description', 'File Transfer') ->header('Content-Type', 'text/x-csv') - ->header('Content-Disposition', 'attachment; filename=' . $quoted) + ->header('Content-Disposition', 'attachment; filename='.$quoted) //->header('Content-Transfer-Encoding', 'binary') ->header('Connection', 'Keep-Alive') ->header('Expires', '0') diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index f8cdbf68d2..ef5037cea3 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -1,4 +1,5 @@ $request->get('start'), 'end' => $request->get('end'), 'label' => $request->get('label')]); // check if the label is "everything" or "Custom range" which will betray // a possible problem with the budgets. - if ($label === (string) trans('firefly.everything') || $label === (string) trans('firefly.customRange')) { + if ($label === (string)trans('firefly.everything') || $label === (string)trans('firefly.customRange')) { $isCustomRange = true; Log::debug('Range is now marked as "custom".'); } @@ -80,7 +82,7 @@ class HomeController extends Controller $diff = $start->diffInDays($end) + 1; if ($diff > 50) { - $request->session()->flash('warning', (string) trans('firefly.warning_much_data', ['days' => $diff])); + $request->session()->flash('warning', (string)trans('firefly.warning_much_data', ['days' => $diff])); } $request->session()->put('is_custom_range', $isCustomRange); @@ -96,10 +98,10 @@ class HomeController extends Controller /** * Show index. * - * @param AccountRepositoryInterface $repository + * @param AccountRepositoryInterface $repository * * @return mixed - * @throws \FireflyIII\Exceptions\FireflyException + * @throws FireflyException */ public function index(AccountRepositoryInterface $repository): mixed { @@ -113,13 +115,13 @@ class HomeController extends Controller if (0 === $count) { return redirect(route('new-user.index')); } - $subTitle = (string) trans('firefly.welcome_back'); + $subTitle = (string)trans('firefly.welcome_back'); $transactions = []; $frontPage = app('preferences')->getFresh('frontPageAccounts', $repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray()); /** @var Carbon $start */ $start = session('start', Carbon::now()->startOfMonth()); /** @var Carbon $end */ - $end = session('end', Carbon::now()->endOfMonth()); + $end = session('end', Carbon::now()->endOfMonth()); $accounts = $repository->getAccountsById($frontPage->data); $today = today(config('app.timezone')); diff --git a/app/Http/Controllers/JavascriptController.php b/app/Http/Controllers/JavascriptController.php index 1acb51fa84..68c390fe90 100644 --- a/app/Http/Controllers/JavascriptController.php +++ b/app/Http/Controllers/JavascriptController.php @@ -1,4 +1,5 @@ get('currencyPreference', config('firefly.default_currency', 'EUR')); - $default = $currencyRepository->findByCodeNull((string) $preference->data); + $default = $currencyRepository->findByCodeNull((string)$preference->data); $data = ['accounts' => []]; /** @var Account $account */ foreach ($accounts as $account) { - $accountId = $account->id; - $currency = (int) $repository->getMetaValue($account, 'currency_id'); + $accountId = $account->id; + $currency = (int)$repository->getMetaValue($account, 'currency_id'); $currency = 0 === $currency ? $default->id : $currency; $entry = ['preferredCurrency' => $currency, 'name' => $account->name]; $data['accounts'][$accountId] = $entry; @@ -78,7 +82,7 @@ class JavascriptController extends Controller /** * Get info about currencies. * - * @param CurrencyRepositoryInterface $repository + * @param CurrencyRepositoryInterface $repository * * @return Response */ @@ -101,19 +105,19 @@ class JavascriptController extends Controller /** * Show some common variables to be used in scripts. * - * @param Request $request - * @param AccountRepositoryInterface $repository - * @param CurrencyRepositoryInterface $currencyRepository + * @param Request $request + * @param AccountRepositoryInterface $repository + * @param CurrencyRepositoryInterface $currencyRepository * * @return Response * @throws FireflyException - * @throws \JsonException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws JsonException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function variables(Request $request, AccountRepositoryInterface $repository, CurrencyRepositoryInterface $currencyRepository): Response { - $account = $repository->find((int) $request->get('account')); + $account = $repository->find((int)$request->get('account')); $currency = app('amount')->getDefaultCurrency(); if (null !== $account) { $currency = $repository->getAccountCurrency($account) ?? $currency; @@ -122,9 +126,9 @@ class JavascriptController extends Controller $accounting = app('amount')->getJsConfig(); $accounting['frac_digits'] = $currency->decimal_places; $pref = app('preferences')->get('language', config('firefly.default_language', 'en_US')); - $lang = $pref->data; - $dateRange = $this->getDateRangeConfig(); - $uid = substr(hash('sha256', sprintf('%s-%s-%s', (string) config('app.key'), auth()->user()->id, auth()->user()->email)), 0, 12); + $lang = $pref->data; + $dateRange = $this->getDateRangeConfig(); + $uid = substr(hash('sha256', sprintf('%s-%s-%s', (string)config('app.key'), auth()->user()->id, auth()->user()->email)), 0, 12); $data = [ 'currencyCode' => $currency->code, @@ -146,7 +150,7 @@ class JavascriptController extends Controller /** * Bit of a hack but OK. * - * @param Request $request + * @param Request $request * * @return Response */ diff --git a/app/Http/Controllers/Json/AutoCompleteController.php b/app/Http/Controllers/Json/AutoCompleteController.php index 331514e7d2..f77c76c8e2 100644 --- a/app/Http/Controllers/Json/AutoCompleteController.php +++ b/app/Http/Controllers/Json/AutoCompleteController.php @@ -1,4 +1,5 @@ endOfMonth()); $today = today(config('app.timezone')); $display = 2; // see method docs. - $boxTitle = (string) trans('firefly.spent'); + $boxTitle = (string)trans('firefly.spent'); $cache = new CacheProperties(); $cache->addProperty($start); @@ -92,21 +92,21 @@ class BoxController extends Controller // spent in this period, in budgets, for default currency. // also calculate spent per day. $spent = $opsRepository->sumExpenses($start, $end, null, null, $currency); - $spentAmount = $spent[(int) $currency->id]['sum'] ?? '0'; + $spentAmount = $spent[(int)$currency->id]['sum'] ?? '0'; $days = $today->between($start, $end) ? $today->diffInDays($start) + 1 : $end->diffInDays($start) + 1; - $spentPerDay = bcdiv($spentAmount, (string) $days); + $spentPerDay = bcdiv($spentAmount, (string)$days); if ($availableBudgets->count() > 0) { $display = 0; // assume user overspent - $boxTitle = (string) trans('firefly.overspent'); - $totalAvailableSum = (string) $availableBudgets->sum('amount'); + $boxTitle = (string)trans('firefly.overspent'); + $totalAvailableSum = (string)$availableBudgets->sum('amount'); // calculate with available budget. $leftToSpendAmount = bcadd($totalAvailableSum, $spentAmount); if (1 === bccomp($leftToSpendAmount, '0')) { - $boxTitle = (string) trans('firefly.left_to_spend'); + $boxTitle = (string)trans('firefly.left_to_spend'); $days = $today->diffInDays($end) + 1; $display = 1; // not overspent - $leftPerDayAmount = bcdiv($leftToSpendAmount, (string) $days); + $leftPerDayAmount = bcdiv($leftToSpendAmount, (string)$days); } } @@ -127,7 +127,7 @@ class BoxController extends Controller /** * Current total balance. * - * @param CurrencyRepositoryInterface $repository + * @param CurrencyRepositoryInterface $repository * * @return JsonResponse */ @@ -159,7 +159,7 @@ class BoxController extends Controller $set = $collector->getExtractedJournals(); /** @var array $journal */ foreach ($set as $journal) { - $currencyId = (int) $journal['currency_id']; + $currencyId = (int)$journal['currency_id']; $amount = $journal['amount'] ?? '0'; $incomes[$currencyId] = $incomes[$currencyId] ?? '0'; $incomes[$currencyId] = bcadd($incomes[$currencyId], app('steam')->positive($amount)); @@ -175,7 +175,7 @@ class BoxController extends Controller $set = $collector->getExtractedJournals(); /** @var array $journal */ foreach ($set as $journal) { - $currencyId = (int) $journal['currency_id']; + $currencyId = (int)$journal['currency_id']; $expenses[$currencyId] = $expenses[$currencyId] ?? '0'; $expenses[$currencyId] = bcadd($expenses[$currencyId], $journal['amount'] ?? '0'); $sums[$currencyId] = $sums[$currencyId] ?? '0'; diff --git a/app/Http/Controllers/Json/BudgetController.php b/app/Http/Controllers/Json/BudgetController.php index 14e1129ffa..59ac6fd3a3 100644 --- a/app/Http/Controllers/Json/BudgetController.php +++ b/app/Http/Controllers/Json/BudgetController.php @@ -64,7 +64,7 @@ class BudgetController extends Controller $this->middleware( function ($request, $next) { - app('view')->share('title', (string) trans('firefly.budgets')); + app('view')->share('title', (string)trans('firefly.budgets')); app('view')->share('mainTitleIcon', 'fa-pie-chart'); $this->repository = app(BudgetRepositoryInterface::class); $this->opsRepository = app(OperationsRepositoryInterface::class); @@ -79,9 +79,9 @@ class BudgetController extends Controller } /** - * @param TransactionCurrency $currency - * @param Carbon $start - * @param Carbon $end + * @param TransactionCurrency $currency + * @param Carbon $start + * @param Carbon $end * * @return JsonResponse */ diff --git a/app/Http/Controllers/Json/IntroController.php b/app/Http/Controllers/Json/IntroController.php index 670a17fccd..947a19517d 100644 --- a/app/Http/Controllers/Json/IntroController.php +++ b/app/Http/Controllers/Json/IntroController.php @@ -1,4 +1,5 @@ set($key, false); app('preferences')->mark(); - return response()->json(['message' => (string) trans('firefly.intro_boxes_after_refresh')]); + return response()->json(['message' => (string)trans('firefly.intro_boxes_after_refresh')]); } /** * Set that you saw them. * - * @param string $route - * @param string|null $specialPage + * @param string $route + * @param string|null $specialPage * * @return JsonResponse * @throws FireflyException @@ -131,9 +132,9 @@ class IntroController extends Controller public function postFinished(string $route, string $specialPage = null): JsonResponse // @phpstan-ignore-line { $specialPage = $specialPage ?? ''; - $key = 'shown_demo_' . $route; + $key = 'shown_demo_'.$route; if ('' !== $specialPage) { - $key .= '_' . $specialPage; + $key .= '_'.$specialPage; } Log::debug(sprintf('Going to mark the following route as done: %s with special "%s" (%s)', $route, $specialPage, $key)); app('preferences')->set($key, true); diff --git a/app/Http/Controllers/Json/ReconcileController.php b/app/Http/Controllers/Json/ReconcileController.php index 99127e93a3..68a1338656 100644 --- a/app/Http/Controllers/Json/ReconcileController.php +++ b/app/Http/Controllers/Json/ReconcileController.php @@ -63,7 +63,7 @@ class ReconcileController extends Controller $this->middleware( function ($request, $next) { app('view')->share('mainTitleIcon', 'fa-credit-card'); - app('view')->share('title', (string) trans('firefly.accounts')); + app('view')->share('title', (string)trans('firefly.accounts')); $this->repository = app(JournalRepositoryInterface::class); $this->accountRepos = app(AccountRepositoryInterface::class); $this->currencyRepos = app(CurrencyRepositoryInterface::class); @@ -76,10 +76,10 @@ class ReconcileController extends Controller /** * Overview of reconciliation. * - * @param Request $request - * @param Account|null $account - * @param Carbon|null $start - * @param Carbon|null $end + * @param Request $request + * @param Account|null $account + * @param Carbon|null $start + * @param Carbon|null $end * * @return JsonResponse * @throws FireflyException @@ -176,10 +176,10 @@ class ReconcileController extends Controller } /** - * @param Account $account - * @param TransactionCurrency $currency - * @param array $journal - * @param string $amount + * @param Account $account + * @param TransactionCurrency $currency + * @param array $journal + * @param string $amount * * @return string */ @@ -218,9 +218,9 @@ class ReconcileController extends Controller /** * Returns a list of transactions in a modal. * - * @param Account $account - * @param Carbon|null $start - * @param Carbon|null $end + * @param Account $account + * @param Carbon|null $start + * @param Carbon|null $end * * @return JsonResponse * @throws FireflyException @@ -274,8 +274,8 @@ class ReconcileController extends Controller /** * "fix" amounts to make it easier on the reconciliation overview: * - * @param Account $account - * @param array $array + * @param Account $account + * @param array $array * * @return array */ diff --git a/app/Http/Controllers/Json/RecurrenceController.php b/app/Http/Controllers/Json/RecurrenceController.php index d5e56ccdfa..7df5dd2746 100644 --- a/app/Http/Controllers/Json/RecurrenceController.php +++ b/app/Http/Controllers/Json/RecurrenceController.php @@ -31,6 +31,8 @@ use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Log; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; /** * Class RecurrenceController @@ -61,7 +63,7 @@ class RecurrenceController extends Controller /** * Shows all events for a repetition. Used in calendar. * - * @param Request $request + * @param Request $request * * @return JsonResponse * @@ -73,10 +75,10 @@ class RecurrenceController extends Controller $start = Carbon::createFromFormat('Y-m-d', $request->get('start')); $end = Carbon::createFromFormat('Y-m-d', $request->get('end')); $firstDate = Carbon::createFromFormat('Y-m-d', $request->get('first_date')); - $endDate = '' !== (string) $request->get('end_date') ? Carbon::createFromFormat('Y-m-d', $request->get('end_date')) : null; - $endsAt = (string) $request->get('ends'); + $endDate = '' !== (string)$request->get('end_date') ? Carbon::createFromFormat('Y-m-d', $request->get('end_date')) : null; + $endsAt = (string)$request->get('ends'); $repetitionType = explode(',', $request->get('type'))[0]; - $repetitions = (int) $request->get('reps'); + $repetitions = (int)$request->get('reps'); $repetitionMoment = ''; $start->startOfDay(); @@ -100,8 +102,8 @@ class RecurrenceController extends Controller $repetition = new RecurrenceRepetition(); $repetition->repetition_type = $repetitionType; $repetition->repetition_moment = $repetitionMoment; - $repetition->repetition_skip = (int) $request->get('skip'); - $repetition->weekend = (int) $request->get('weekend'); + $repetition->repetition_skip = (int)$request->get('skip'); + $repetition->weekend = (int)$request->get('weekend'); $actualEnd = clone $end; switch ($endsAt) { @@ -122,7 +124,7 @@ class RecurrenceController extends Controller foreach ($occurrences as $current) { if ($current->gte($start)) { $event = [ - 'id' => $repetitionType . $firstDate->format('Ymd'), + 'id' => $repetitionType.$firstDate->format('Ymd'), 'title' => 'X', 'allDay' => true, 'start' => $current->format('Y-m-d'), @@ -140,43 +142,51 @@ class RecurrenceController extends Controller /** * Suggests repetition moments. * - * @param Request $request + * @param Request $request * * @return JsonResponse * @throws FireflyException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function suggest(Request $request): JsonResponse { $string = $request->get('date') ?? date('Y-m-d'); $today = Carbon::now()->startOfDay(); $date = Carbon::createFromFormat('Y-m-d', $string)->startOfDay(); - $preSelected = (string) $request->get('pre_select'); + $preSelected = (string)$request->get('pre_select'); $locale = app('steam')->getLocale(); Log::debug(sprintf('date = %s, today = %s. date > today? %s', $date->toAtomString(), $today->toAtomString(), var_export($date > $today, true))); - Log::debug(sprintf('past = true? %s', var_export('true' === (string) $request->get('past'), true))); + Log::debug(sprintf('past = true? %s', var_export('true' === (string)$request->get('past'), true))); $result = []; - if ($date > $today || 'true' === (string) $request->get('past')) { + if ($date > $today || 'true' === (string)$request->get('past')) { Log::debug('Will fill dropdown.'); $weekly = sprintf('weekly,%s', $date->dayOfWeekIso); $monthly = sprintf('monthly,%s', $date->day); - $dayOfWeek = (string) trans(sprintf('config.dow_%s', $date->dayOfWeekIso)); + $dayOfWeek = (string)trans(sprintf('config.dow_%s', $date->dayOfWeekIso)); $ndom = sprintf('ndom,%s,%s', $date->weekOfMonth, $date->dayOfWeekIso); $yearly = sprintf('yearly,%s', $date->format('Y-m-d')); - $yearlyDate = $date->isoFormat((string) trans('config.month_and_day_no_year_js', [], $locale)); + $yearlyDate = $date->isoFormat((string)trans('config.month_and_day_no_year_js', [], $locale)); $result = [ - 'daily' => ['label' => (string) trans('firefly.recurring_daily'), 'selected' => str_starts_with($preSelected, 'daily')], - $weekly => ['label' => (string) trans('firefly.recurring_weekly', ['weekday' => $dayOfWeek]), - 'selected' => str_starts_with($preSelected, 'weekly')], - $monthly => ['label' => (string) trans('firefly.recurring_monthly', ['dayOfMonth' => $date->day]), - 'selected' => str_starts_with($preSelected, 'monthly')], - $ndom => ['label' => (string) trans('firefly.recurring_ndom', ['weekday' => $dayOfWeek, 'dayOfMonth' => $date->weekOfMonth]), - 'selected' => str_starts_with($preSelected, 'ndom')], - $yearly => ['label' => (string) trans('firefly.recurring_yearly', ['date' => $yearlyDate]), - 'selected' => str_starts_with($preSelected, 'yearly')], + 'daily' => ['label' => (string)trans('firefly.recurring_daily'), 'selected' => str_starts_with($preSelected, 'daily')], + $weekly => [ + 'label' => (string)trans('firefly.recurring_weekly', ['weekday' => $dayOfWeek]), + 'selected' => str_starts_with($preSelected, 'weekly'), + ], + $monthly => [ + 'label' => (string)trans('firefly.recurring_monthly', ['dayOfMonth' => $date->day]), + 'selected' => str_starts_with($preSelected, 'monthly'), + ], + $ndom => [ + 'label' => (string)trans('firefly.recurring_ndom', ['weekday' => $dayOfWeek, 'dayOfMonth' => $date->weekOfMonth]), + 'selected' => str_starts_with($preSelected, 'ndom'), + ], + $yearly => [ + 'label' => (string)trans('firefly.recurring_yearly', ['date' => $yearlyDate]), + 'selected' => str_starts_with($preSelected, 'yearly'), + ], ]; } Log::debug('Dropdown is', $result); diff --git a/app/Http/Controllers/Json/RuleController.php b/app/Http/Controllers/Json/RuleController.php index ed419b65ca..669edb381e 100644 --- a/app/Http/Controllers/Json/RuleController.php +++ b/app/Http/Controllers/Json/RuleController.php @@ -38,17 +38,17 @@ class RuleController extends Controller /** * Render HTML form for rule action. * - * @param Request $request + * @param Request $request * * @return JsonResponse */ public function action(Request $request): JsonResponse { - $count = (int) $request->get('count') > 0 ? (int) $request->get('count') : 1; + $count = (int)$request->get('count') > 0 ? (int)$request->get('count') : 1; $keys = array_keys(config('firefly.rule-actions')); $actions = []; foreach ($keys as $key) { - $actions[$key] = (string) trans('firefly.rule_action_' . $key . '_choice'); + $actions[$key] = (string)trans('firefly.rule_action_'.$key.'_choice'); } try { $view = view('rules.partials.action', compact('actions', 'count'))->render(); @@ -64,18 +64,18 @@ class RuleController extends Controller /** * Render HTML for rule trigger. * - * @param Request $request + * @param Request $request * * @return JsonResponse */ public function trigger(Request $request): JsonResponse { - $count = (int) $request->get('count') > 0 ? (int) $request->get('count') : 1; + $count = (int)$request->get('count') > 0 ? (int)$request->get('count') : 1; $operators = config('search.operators'); $triggers = []; foreach ($operators as $key => $operator) { if ('user_action' !== $key && false === $operator['alias']) { - $triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key)); + $triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key)); } } asort($triggers); diff --git a/app/Http/Controllers/NewUserController.php b/app/Http/Controllers/NewUserController.php index 36bded971b..cfae0db8c8 100644 --- a/app/Http/Controllers/NewUserController.php +++ b/app/Http/Controllers/NewUserController.php @@ -1,4 +1,5 @@ share('title', (string) trans('firefly.welcome')); + app('view')->share('title', (string)trans('firefly.welcome')); app('view')->share('mainTitleIcon', 'fa-fire'); $types = config('firefly.accountTypesByIdentifier.asset'); @@ -84,8 +85,8 @@ class NewUserController extends Controller /** * Store his new settings. * - * @param NewUserFormRequest $request - * @param CurrencyRepositoryInterface $currencyRepository + * @param NewUserFormRequest $request + * @param CurrencyRepositoryInterface $currencyRepository * * @return RedirectResponse|Redirector * @throws FireflyException @@ -100,7 +101,7 @@ class NewUserController extends Controller // set language preference: app('preferences')->set('language', $language); // Store currency preference from input: - $currency = $currencyRepository->find((int) $request->input('amount_currency_id_bank_balance')); + $currency = $currencyRepository->find((int)$request->input('amount_currency_id_bank_balance')); // if is null, set to EUR: if (null === $currency) { @@ -123,11 +124,20 @@ class NewUserController extends Controller app('preferences')->mark(); // set default optional fields: - $visibleFields = ['interest_date' => true, 'book_date' => false, 'process_date' => false, 'due_date' => false, 'payment_date' => false, - 'invoice_date' => false, 'internal_reference' => false, 'notes' => true, 'attachments' => true,]; + $visibleFields = [ + 'interest_date' => true, + 'book_date' => false, + 'process_date' => false, + 'due_date' => false, + 'payment_date' => false, + 'invoice_date' => false, + 'internal_reference' => false, + 'notes' => true, + 'attachments' => true, + ]; app('preferences')->set('transaction_journal_optional_fields', $visibleFields); - session()->flash('success', (string) trans('firefly.stored_new_accounts_new_user')); + session()->flash('success', (string)trans('firefly.stored_new_accounts_new_user')); app('preferences')->mark(); return redirect(route('index')); diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php index 2fb6ce79fe..05f4b325ef 100644 --- a/app/Http/Controllers/PreferencesController.php +++ b/app/Http/Controllers/PreferencesController.php @@ -1,4 +1,5 @@ middleware( function ($request, $next) { - app('view')->share('title', (string) trans('firefly.preferences')); + app('view')->share('title', (string)trans('firefly.preferences')); app('view')->share('mainTitleIcon', 'fa-gear'); return $next($request); @@ -62,12 +65,12 @@ class PreferencesController extends Controller /** * Show overview of preferences. * - * @param AccountRepositoryInterface $repository + * @param AccountRepositoryInterface $repository * * @return Factory|View * @throws FireflyException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function index(AccountRepositoryInterface $repository) { @@ -104,7 +107,7 @@ class PreferencesController extends Controller $slackUrl = app('preferences')->get('slack_webhook_url', '')->data; $customFiscalYear = app('preferences')->get('customFiscalYear', 0)->data; $fiscalYearStartStr = app('preferences')->get('fiscalYearStart', '01-01')->data; - $fiscalYearStart = date('Y') . '-' . $fiscalYearStartStr; + $fiscalYearStart = date('Y').'-'.$fiscalYearStartStr; $tjOptionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data; // notification preferences (single value for each): @@ -124,7 +127,7 @@ class PreferencesController extends Controller Log::error($e->getMessage()); $locales = []; } - $locales = ['equal' => (string) trans('firefly.equal_to_language')] + $locales; + $locales = ['equal' => (string)trans('firefly.equal_to_language')] + $locales; // an important fallback is that the frontPageAccount array gets refilled automatically // when it turns up empty. if (0 === count($frontPageAccounts->data)) { @@ -155,12 +158,12 @@ class PreferencesController extends Controller /** * Store new preferences. * - * @param Request $request + * @param Request $request * * @return RedirectResponse|Redirector * @throws FireflyException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function postIndex(Request $request) { @@ -168,7 +171,7 @@ class PreferencesController extends Controller $frontPageAccounts = []; if (is_array($request->get('frontPageAccounts')) && count($request->get('frontPageAccounts')) > 0) { foreach ($request->get('frontPageAccounts') as $id) { - $frontPageAccounts[] = (int) $id; + $frontPageAccounts[] = (int)$id; } app('preferences')->set('frontPageAccounts', $frontPageAccounts); } @@ -194,7 +197,7 @@ class PreferencesController extends Controller // slack URL: - $url = (string) $request->get('slackUrl'); + $url = (string)$request->get('slackUrl'); if (str_starts_with($url, 'https://hooks.slack.com/services/')) { app('preferences')->set('slack_webhook_url', $url); } @@ -203,8 +206,8 @@ class PreferencesController extends Controller } // custom fiscal year - $customFiscalYear = 1 === (int) $request->get('customFiscalYear'); - $string = strtotime((string) $request->get('fiscalYearStart')); + $customFiscalYear = 1 === (int)$request->get('customFiscalYear'); + $string = strtotime((string)$request->get('fiscalYearStart')); if (false !== $string) { $fiscalYearStart = date('m-d', $string); app('preferences')->set('customFiscalYear', $customFiscalYear); @@ -214,7 +217,7 @@ class PreferencesController extends Controller // save page size: app('preferences')->set('listPageSize', 50); - $listPageSize = (int) $request->get('listPageSize'); + $listPageSize = (int)$request->get('listPageSize'); if ($listPageSize > 0 && $listPageSize < 1337) { app('preferences')->set('listPageSize', $listPageSize); } @@ -256,7 +259,7 @@ class PreferencesController extends Controller ]; app('preferences')->set('transaction_journal_optional_fields', $optionalTj); - session()->flash('success', (string) trans('firefly.saved_preferences')); + session()->flash('success', (string)trans('firefly.saved_preferences')); app('preferences')->mark(); return redirect(route('preferences.index')); diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 7f381d2513..7b536464b1 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -1,4 +1,5 @@ middleware( static function ($request, $next) { - app('view')->share('title', (string) trans('firefly.profile')); + app('view')->share('title', (string)trans('firefly.profile')); app('view')->share('mainTitleIcon', 'fa-user'); return $next($request); @@ -94,62 +97,17 @@ class ProfileController extends Controller $this->middleware(IsDemoUser::class)->except(['index']); } - /** - * Change your email address. - * - * @param Request $request - * - * @return Factory|RedirectResponse|Redirector|View - */ - public function changeEmail(Request $request) - { - if (!$this->internalAuth || !$this->internalIdentity) { - $request->session()->flash('error', trans('firefly.external_user_mgt_disabled')); - - return redirect(route('profile.index')); - } - - $title = auth()->user()->email; - $email = auth()->user()->email; - $subTitle = (string) trans('firefly.change_your_email'); - $subTitleIcon = 'fa-envelope'; - - return view('profile.change-email', compact('title', 'subTitle', 'subTitleIcon', 'email')); - } - - /** - * Change your password. - * - * @param Request $request - * - * @return Factory|RedirectResponse|Redirector|View - */ - public function changePassword(Request $request) - { - if (!$this->internalAuth || !$this->internalIdentity) { - $request->session()->flash('error', trans('firefly.external_user_mgt_disabled')); - - return redirect(route('profile.index')); - } - - $title = auth()->user()->email; - $subTitle = (string) trans('firefly.change_your_password'); - $subTitleIcon = 'fa-key'; - - return view('profile.change-password', compact('title', 'subTitle', 'subTitleIcon')); - } - /** * View that generates a 2FA code for the user. * - * @param Request $request + * @param Request $request * * @return Factory|View * @throws IncompatibleWithGoogleAuthenticatorException * @throws InvalidCharactersException * @throws SecretKeyTooShortException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function code(Request $request) { @@ -200,8 +158,8 @@ class ProfileController extends Controller /** * Screen to confirm email change. * - * @param UserRepositoryInterface $repository - * @param string $token + * @param UserRepositoryInterface $repository + * @param string $token * * @return RedirectResponse|Redirector * @@ -229,7 +187,7 @@ class ProfileController extends Controller $repository->unblockUser($user); // return to login. - session()->flash('success', (string) trans('firefly.login_with_new_email')); + session()->flash('success', (string)trans('firefly.login_with_new_email')); return redirect(route('login')); } @@ -237,7 +195,7 @@ class ProfileController extends Controller /** * Delete your account view. * - * @param Request $request + * @param Request $request * * @return Application|RedirectResponse|Redirector */ @@ -249,7 +207,7 @@ class ProfileController extends Controller return redirect(route('profile.index')); } $title = auth()->user()->email; - $subTitle = (string) trans('firefly.delete_account'); + $subTitle = (string)trans('firefly.delete_account'); $subTitleIcon = 'fa-trash'; return view('profile.delete-account', compact('title', 'subTitle', 'subTitleIcon')); @@ -278,8 +236,8 @@ class ProfileController extends Controller $repository->setMFACode($user, null); app('preferences')->mark(); - session()->flash('success', (string) trans('firefly.pref_two_factor_auth_disabled')); - session()->flash('info', (string) trans('firefly.pref_two_factor_auth_remove_it')); + session()->flash('success', (string)trans('firefly.pref_two_factor_auth_disabled')); + session()->flash('info', (string)trans('firefly.pref_two_factor_auth_remove_it')); return redirect(route('profile.index')); } @@ -308,7 +266,7 @@ class ProfileController extends Controller // If FF3 already has a secret, just set the two factor auth enabled to 1, // and let the user continue with the existing secret. - session()->flash('info', (string) trans('firefly.2fa_already_enabled')); + session()->flash('info', (string)trans('firefly.2fa_already_enabled')); return redirect(route('profile.index')); } @@ -318,8 +276,8 @@ class ProfileController extends Controller * * @return Factory|View * @throws FireflyException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function index() { @@ -337,7 +295,7 @@ class ProfileController extends Controller if (0 === $count) { /** @var ClientRepository $repository */ $repository = app(ClientRepository::class); - $repository->createPersonalAccessClient(null, config('app.name') . ' Personal Access Client', 'http://localhost'); + $repository->createPersonalAccessClient(null, config('app.name').' Personal Access Client', 'http://localhost'); } $accessToken = app('preferences')->get('access_token'); @@ -358,7 +316,7 @@ class ProfileController extends Controller public function logoutOtherSessions() { if (!$this->internalAuth) { - session()->flash('info', (string) trans('firefly.external_auth_disabled')); + session()->flash('info', (string)trans('firefly.external_auth_disabled')); return redirect(route('profile.index')); } @@ -367,7 +325,7 @@ class ProfileController extends Controller } /** - * @param Request $request + * @param Request $request * * @return Factory|View * @throws FireflyException @@ -398,8 +356,8 @@ class ProfileController extends Controller /** * Submit the change email form. * - * @param EmailFormRequest $request - * @param UserRepositoryInterface $repository + * @param EmailFormRequest $request + * @param UserRepositoryInterface $repository * * @return $this|RedirectResponse|Redirector */ @@ -416,7 +374,7 @@ class ProfileController extends Controller $newEmail = $request->convertString('email'); $oldEmail = $user->email; if ($newEmail === $user->email) { - session()->flash('error', (string) trans('firefly.email_not_changed')); + session()->flash('error', (string)trans('firefly.email_not_changed')); return redirect(route('profile.change-email'))->withInput(); } @@ -426,7 +384,7 @@ class ProfileController extends Controller Auth::guard()->logout(); $request->session()->invalidate(); - session()->flash('success', (string) trans('firefly.email_changed')); + session()->flash('success', (string)trans('firefly.email_changed')); return redirect(route('index')); } @@ -439,16 +397,39 @@ class ProfileController extends Controller // force user logout. Auth::guard()->logout(); $request->session()->invalidate(); - session()->flash('success', (string) trans('firefly.email_changed')); + session()->flash('success', (string)trans('firefly.email_changed')); return redirect(route('index')); } + /** + * Change your email address. + * + * @param Request $request + * + * @return Factory|RedirectResponse|Redirector|View + */ + public function changeEmail(Request $request) + { + if (!$this->internalAuth || !$this->internalIdentity) { + $request->session()->flash('error', trans('firefly.external_user_mgt_disabled')); + + return redirect(route('profile.index')); + } + + $title = auth()->user()->email; + $email = auth()->user()->email; + $subTitle = (string)trans('firefly.change_your_email'); + $subTitleIcon = 'fa-envelope'; + + return view('profile.change-email', compact('title', 'subTitle', 'subTitleIcon', 'email')); + } + /** * Submit change password form. * - * @param ProfileFormRequest $request - * @param UserRepositoryInterface $repository + * @param ProfileFormRequest $request + * @param UserRepositoryInterface $repository * * @return RedirectResponse|Redirector */ @@ -474,20 +455,42 @@ class ProfileController extends Controller } $repository->changePassword($user, $request->get('new_password')); - session()->flash('success', (string) trans('firefly.password_changed')); + session()->flash('success', (string)trans('firefly.password_changed')); return redirect(route('profile.index')); } + /** + * Change your password. + * + * @param Request $request + * + * @return Factory|RedirectResponse|Redirector|View + */ + public function changePassword(Request $request) + { + if (!$this->internalAuth || !$this->internalIdentity) { + $request->session()->flash('error', trans('firefly.external_user_mgt_disabled')); + + return redirect(route('profile.index')); + } + + $title = auth()->user()->email; + $subTitle = (string)trans('firefly.change_your_password'); + $subTitleIcon = 'fa-key'; + + return view('profile.change-password', compact('title', 'subTitle', 'subTitleIcon')); + } + /** * Submit 2FA for the first time. * - * @param TokenFormRequest $request + * @param TokenFormRequest $request * * @return RedirectResponse|Redirector * @throws FireflyException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function postCode(TokenFormRequest $request) { @@ -508,7 +511,7 @@ class ProfileController extends Controller Preferences::delete('temp-mfa-secret'); Preferences::delete('temp-mfa-codes'); - session()->flash('success', (string) trans('firefly.saved_preferences')); + session()->flash('success', (string)trans('firefly.saved_preferences')); app('preferences')->mark(); // also save the code so replay attack is prevented. @@ -532,11 +535,11 @@ class ProfileController extends Controller /** * TODO duplicate code. * - * @param string $mfaCode + * @param string $mfaCode * * @throws FireflyException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ private function addToMFAHistory(string $mfaCode): void { @@ -577,8 +580,8 @@ class ProfileController extends Controller /** * Submit delete account. * - * @param UserRepositoryInterface $repository - * @param DeleteAccountFormRequest $request + * @param UserRepositoryInterface $repository + * @param DeleteAccountFormRequest $request * * @return RedirectResponse|Redirector */ @@ -591,7 +594,7 @@ class ProfileController extends Controller } if (!Hash::check($request->get('password'), auth()->user()->password)) { - session()->flash('error', (string) trans('firefly.invalid_password')); + session()->flash('error', (string)trans('firefly.invalid_password')); return redirect(route('profile.delete-account')); } @@ -607,7 +610,7 @@ class ProfileController extends Controller } /** - * @param Request $request + * @param Request $request * * @return Application|RedirectResponse|Redirector * @throws AuthenticationException @@ -615,7 +618,7 @@ class ProfileController extends Controller public function postLogoutOtherSessions(Request $request) { if (!$this->internalAuth) { - session()->flash('info', (string) trans('firefly.external_auth_disabled')); + session()->flash('info', (string)trans('firefly.external_auth_disabled')); return redirect(route('profile.index')); } @@ -625,11 +628,11 @@ class ProfileController extends Controller ]; if (Auth::once($creds)) { Auth::logoutOtherDevices($request->get('password')); - session()->flash('info', (string) trans('firefly.other_sessions_logged_out')); + session()->flash('info', (string)trans('firefly.other_sessions_logged_out')); return redirect(route('profile.index')); } - session()->flash('error', (string) trans('auth.failed')); + session()->flash('error', (string)trans('auth.failed')); return redirect(route('profile.index')); } @@ -637,7 +640,7 @@ class ProfileController extends Controller /** * Regenerate access token. * - * @param Request $request + * @param Request $request * * @return RedirectResponse|Redirector * @throws FireflyException @@ -654,7 +657,7 @@ class ProfileController extends Controller $user = auth()->user(); $token = $user->generateAccessToken(); app('preferences')->set('access_token', $token); - session()->flash('success', (string) trans('firefly.token_regenerated')); + session()->flash('success', (string)trans('firefly.token_regenerated')); return redirect(route('profile.index')); } @@ -662,9 +665,9 @@ class ProfileController extends Controller /** * Undo change of user email address. * - * @param UserRepositoryInterface $repository - * @param string $token - * @param string $hash + * @param UserRepositoryInterface $repository + * @param string $token + * @param string $hash * * @return RedirectResponse|Redirector * @@ -694,7 +697,7 @@ class ProfileController extends Controller /** @var string $match */ $match = null; foreach ($set as $entry) { - $hashed = hash('sha256', sprintf('%s%s', (string) config('app.key'), $entry->data)); + $hashed = hash('sha256', sprintf('%s%s', (string)config('app.key'), $entry->data)); if ($hashed === $hash) { $match = $entry->data; break; @@ -709,7 +712,7 @@ class ProfileController extends Controller $repository->unblockUser($user); // return to login. - session()->flash('success', (string) trans('firefly.login_with_old_email')); + session()->flash('success', (string)trans('firefly.login_with_old_email')); return redirect(route('login')); } diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index 8251d633f4..ae8721a359 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -1,4 +1,5 @@ middleware( function ($request, $next) { - app('view')->share('title', (string) trans('firefly.reports')); + app('view')->share('title', (string)trans('firefly.reports')); app('view')->share('mainTitleIcon', 'fa-bar-chart'); app('view')->share('subTitleIcon', 'fa-calendar'); $this->helper = app(ReportHelperInterface::class); @@ -77,9 +80,9 @@ class ReportController extends Controller /** * Show audit report. * - * @param Collection $accounts - * @param Carbon $start - * @param Carbon $end + * @param Collection $accounts + * @param Carbon $start + * @param Carbon $end * * @return Factory|View|string * @@ -88,7 +91,7 @@ class ReportController extends Controller public function auditReport(Collection $accounts, Carbon $start, Carbon $end) { if ($end < $start) { - return view('error')->with('message', (string) trans('firefly.end_after_start_date')); + return view('error')->with('message', (string)trans('firefly.end_after_start_date')); } $this->repository->cleanupBudgets(); @@ -112,10 +115,10 @@ class ReportController extends Controller /** * Show budget report. * - * @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 Factory|View|string * @@ -124,7 +127,7 @@ class ReportController extends Controller public function budgetReport(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end) { if ($end < $start) { - return view('error')->with('message', (string) trans('firefly.end_after_start_date')); + return view('error')->with('message', (string)trans('firefly.end_after_start_date')); } $this->repository->cleanupBudgets(); @@ -149,10 +152,10 @@ class ReportController extends Controller /** * Show category report. * - * @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 Factory|View|string * @@ -161,7 +164,7 @@ class ReportController extends Controller public function categoryReport(Collection $accounts, Collection $categories, Carbon $start, Carbon $end) { if ($end < $start) { - return view('error')->with('message', (string) trans('firefly.end_after_start_date')); + return view('error')->with('message', (string)trans('firefly.end_after_start_date')); } $this->repository->cleanupBudgets(); @@ -186,9 +189,9 @@ class ReportController extends Controller /** * Show default report. * - * @param Collection $accounts - * @param Carbon $start - * @param Carbon $end + * @param Collection $accounts + * @param Carbon $start + * @param Carbon $end * * @return Factory|View|string * @@ -197,7 +200,7 @@ class ReportController extends Controller public function defaultReport(Collection $accounts, Carbon $start, Carbon $end) { if ($end < $start) { - return view('error')->with('message', (string) trans('firefly.end_after_start_date')); + return view('error')->with('message', (string)trans('firefly.end_after_start_date')); } $this->repository->cleanupBudgets(); @@ -222,10 +225,10 @@ class ReportController extends Controller /** * Show account report. * - * @param Collection $accounts - * @param Collection $expense - * @param Carbon $start - * @param Carbon $end + * @param Collection $accounts + * @param Collection $expense + * @param Carbon $start + * @param Carbon $end * * @return string * @throws FireflyException @@ -242,8 +245,10 @@ class ReportController extends Controller 'subTitle', trans( 'firefly.report_double', - ['start' => $start->isoFormat($this->monthAndDayFormat), - 'end' => $end->isoFormat($this->monthAndDayFormat)] + [ + 'start' => $start->isoFormat($this->monthAndDayFormat), + 'end' => $end->isoFormat($this->monthAndDayFormat), + ] ) ); @@ -257,12 +262,12 @@ class ReportController extends Controller /** * Show index. * - * @param AccountRepositoryInterface $repository + * @param AccountRepositoryInterface $repository * * @return Factory|View * @throws FireflyException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function index(AccountRepositoryInterface $repository) { @@ -301,7 +306,7 @@ class ReportController extends Controller /** * Show options for reports. * - * @param string $reportType + * @param string $reportType * * @return JsonResponse * @@ -322,7 +327,7 @@ class ReportController extends Controller /** * Process the submit of report. * - * @param ReportFormRequest $request + * @param ReportFormRequest $request * * @return RedirectResponse|Redirector * @@ -343,37 +348,37 @@ class ReportController extends Controller if (0 === $request->getAccountList()->count()) { Log::debug('Account count is zero'); - session()->flash('error', (string) trans('firefly.select_at_least_one_account')); + session()->flash('error', (string)trans('firefly.select_at_least_one_account')); return redirect(route('reports.index')); } if ('category' === $reportType && 0 === $request->getCategoryList()->count()) { - session()->flash('error', (string) trans('firefly.select_at_least_one_category')); + session()->flash('error', (string)trans('firefly.select_at_least_one_category')); return redirect(route('reports.index')); } if ('budget' === $reportType && 0 === $request->getBudgetList()->count()) { - session()->flash('error', (string) trans('firefly.select_at_least_one_budget')); + session()->flash('error', (string)trans('firefly.select_at_least_one_budget')); return redirect(route('reports.index')); } if ('tag' === $reportType && 0 === $request->getTagList()->count()) { - session()->flash('error', (string) trans('firefly.select_at_least_one_tag')); + session()->flash('error', (string)trans('firefly.select_at_least_one_tag')); return redirect(route('reports.index')); } if ('double' === $reportType && 0 === $request->getDoubleList()->count()) { - session()->flash('error', (string) trans('firefly.select_at_least_one_expense')); + session()->flash('error', (string)trans('firefly.select_at_least_one_expense')); return redirect(route('reports.index')); } if ($request->getEndDate() < $request->getStartDate()) { - return view('error')->with('message', (string) trans('firefly.end_after_start_date')); + return view('error')->with('message', (string)trans('firefly.end_after_start_date')); } $url = match ($reportType) { @@ -391,10 +396,10 @@ class ReportController extends Controller /** * Get a tag report. * - * @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 Factory|View|string * @throws FireflyException @@ -402,7 +407,7 @@ class ReportController extends Controller public function tagReport(Collection $accounts, Collection $tags, Carbon $start, Carbon $end) { if ($end < $start) { - return view('error')->with('message', (string) trans('firefly.end_after_start_date')); + return view('error')->with('message', (string)trans('firefly.end_after_start_date')); } $this->repository->cleanupBudgets(); diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index 579c0f150b..03030e264f 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -1,4 +1,5 @@ middleware( static function ($request, $next) { app('view')->share('mainTitleIcon', 'fa-search'); - app('view')->share('title', (string) trans('firefly.search')); + app('view')->share('title', (string)trans('firefly.search')); return $next($request); } @@ -57,8 +58,8 @@ class SearchController extends Controller /** * Do the search. * - * @param Request $request - * @param SearchInterface $searcher + * @param Request $request + * @param SearchInterface $searcher * * @return Factory|View */ @@ -69,9 +70,9 @@ class SearchController extends Controller if (is_array($request->get('search'))) { $fullQuery = ''; } - $fullQuery = (string) $fullQuery; - $page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page'); - $ruleId = (int) $request->get('rule'); + $fullQuery = (string)$fullQuery; + $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page'); + $ruleId = (int)$request->get('rule'); $ruleChanged = false; // find rule, check if query is different, offer to update. @@ -90,7 +91,7 @@ class SearchController extends Controller $query = $searcher->getWordsAsString(); $operators = $searcher->getOperators(); $invalidOperators = $searcher->getInvalidOperators(); - $subTitle = (string) trans('breadcrumbs.search_result', ['query' => $fullQuery]); + $subTitle = (string)trans('breadcrumbs.search_result', ['query' => $fullQuery]); return view('search.index', compact('query', 'operators', 'page', 'rule', 'fullQuery', 'subTitle', 'ruleId', 'ruleChanged', 'invalidOperators')); } @@ -98,15 +99,15 @@ class SearchController extends Controller /** * JSON request that does the work. * - * @param Request $request - * @param SearchInterface $searcher + * @param Request $request + * @param SearchInterface $searcher * * @return JsonResponse */ public function search(Request $request, SearchInterface $searcher): JsonResponse { - $fullQuery = (string) $request->get('query'); - $page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page'); + $fullQuery = (string)$request->get('query'); + $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page'); $searcher->parseQuery($fullQuery); @@ -115,7 +116,7 @@ class SearchController extends Controller $hasPages = $groups->hasPages(); $searchTime = round($searcher->searchTime(), 3); // in seconds $parameters = ['search' => $fullQuery]; - $url = route('search.index') . '?' . http_build_query($parameters); + $url = route('search.index').'?'.http_build_query($parameters); $groups->setPath($url); try { diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index 6651f92317..ce12403dc1 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -1,4 +1,5 @@ middleware( function ($request, $next) { - app('view')->share('title', (string) trans('firefly.tags')); + app('view')->share('title', (string)trans('firefly.tags')); app('view')->share('mainTitleIcon', 'fa-tag'); $this->attachmentsHelper = app(AttachmentHelperInterface::class); @@ -74,7 +77,7 @@ class TagController extends Controller */ public function create(Request $request) { - $subTitle = (string) trans('firefly.new_tag'); + $subTitle = (string)trans('firefly.new_tag'); $subTitleIcon = 'fa-tag'; // location info: @@ -100,13 +103,13 @@ class TagController extends Controller /** * Delete a tag. * - * @param Tag $tag + * @param Tag $tag * * @return Factory|View */ public function delete(Tag $tag) { - $subTitle = (string) trans('breadcrumbs.delete_tag', ['tag' => $tag->tag]); + $subTitle = (string)trans('breadcrumbs.delete_tag', ['tag' => $tag->tag]); // put previous url in session $this->rememberPreviousUrl('tags.delete.url'); @@ -114,34 +117,16 @@ class TagController extends Controller return view('tags.delete', compact('tag', 'subTitle')); } - /** - * Destroy a tag. - * - * @param Tag $tag - * - * @return RedirectResponse - */ - public function destroy(Tag $tag): RedirectResponse - { - $tagName = $tag->tag; - $this->repository->destroy($tag); - - session()->flash('success', (string) trans('firefly.deleted_tag', ['tag' => $tagName])); - app('preferences')->mark(); - - return redirect($this->getPreviousUrl('tags.delete.url')); - } - /** * Edit a tag. * - * @param Tag $tag + * @param Tag $tag * * @return Factory|View */ public function edit(Tag $tag) { - $subTitle = (string) trans('firefly.edit_tag', ['tag' => $tag->tag]); + $subTitle = (string)trans('firefly.edit_tag', ['tag' => $tag->tag]); $subTitleIcon = 'fa-tag'; $location = $this->repository->getLocation($tag); @@ -170,7 +155,7 @@ class TagController extends Controller /** * Edit a tag. * - * @param TagRepositoryInterface $repository + * @param TagRepositoryInterface $repository * * @return Factory|View */ @@ -202,51 +187,72 @@ class TagController extends Controller { $tags = $request->get('tags'); if (null === $tags || !is_array($tags)) { - session()->flash('info', (string) trans('firefly.select_tags_to_delete')); + session()->flash('info', (string)trans('firefly.select_tags_to_delete')); return redirect(route('tags.index')); } $count = 0; foreach ($tags as $tagId) { - $tagId = (int) $tagId; + $tagId = (int)$tagId; $tag = $this->repository->find($tagId); if (null !== $tag) { $this->repository->destroy($tag); $count++; } } - session()->flash('success', (string) trans_choice('firefly.deleted_x_tags', $count)); + session()->flash('success', (string)trans_choice('firefly.deleted_x_tags', $count)); return redirect(route('tags.index')); } + /** + * Destroy a tag. + * + * @param Tag $tag + * + * @return RedirectResponse + */ + public function destroy(Tag $tag): RedirectResponse + { + $tagName = $tag->tag; + $this->repository->destroy($tag); + + session()->flash('success', (string)trans('firefly.deleted_tag', ['tag' => $tagName])); + app('preferences')->mark(); + + return redirect($this->getPreviousUrl('tags.delete.url')); + } + /** * Show a single tag. * - * @param Request $request - * @param Tag $tag - * @param Carbon|null $start - * @param Carbon|null $end + * @param Request $request + * @param Tag $tag + * @param Carbon|null $start + * @param Carbon|null $end * * @return Factory|View * @throws FireflyException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function show(Request $request, Tag $tag, Carbon $start = null, Carbon $end = null) { // default values: $subTitleIcon = 'fa-tag'; - $page = (int) $request->get('page'); - $pageSize = (int) app('preferences')->get('listPageSize', 50)->data; + $page = (int)$request->get('page'); + $pageSize = (int)app('preferences')->get('listPageSize', 50)->data; $start = $start ?? session('start'); $end = $end ?? session('end'); $location = $this->repository->getLocation($tag); $attachments = $this->repository->getAttachments($tag); $subTitle = trans( 'firefly.journals_in_period_for_tag', - ['tag' => $tag->tag, 'start' => $start->isoFormat($this->monthAndDayFormat), - 'end' => $end->isoFormat($this->monthAndDayFormat),] + [ + 'tag' => $tag->tag, + 'start' => $start->isoFormat($this->monthAndDayFormat), + 'end' => $end->isoFormat($this->monthAndDayFormat), + ] ); $startPeriod = $this->repository->firstUseDate($tag); @@ -270,22 +276,22 @@ class TagController extends Controller /** * Show a single tag over all time. * - * @param Request $request - * @param Tag $tag + * @param Request $request + * @param Tag $tag * * @return Factory|View * @throws FireflyException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function showAll(Request $request, Tag $tag) { // default values: $subTitleIcon = 'fa-tag'; - $page = (int) $request->get('page'); - $pageSize = (int) app('preferences')->get('listPageSize', 50)->data; + $page = (int)$request->get('page'); + $pageSize = (int)app('preferences')->get('listPageSize', 50)->data; $periods = []; - $subTitle = (string) trans('firefly.all_journals_for_tag', ['tag' => $tag->tag]); + $subTitle = (string)trans('firefly.all_journals_for_tag', ['tag' => $tag->tag]); $start = $this->repository->firstUseDate($tag) ?? today(config('app.timezone')); $end = $this->repository->lastUseDate($tag) ?? today(config('app.timezone')); $attachments = $this->repository->getAttachments($tag); @@ -305,7 +311,7 @@ class TagController extends Controller /** * Store a tag. * - * @param TagFormRequest $request + * @param TagFormRequest $request * * @return RedirectResponse */ @@ -317,7 +323,7 @@ class TagController extends Controller $result = $this->repository->store($data); Log::debug('Data after storage', $result->toArray()); - session()->flash('success', (string) trans('firefly.created_tag', ['tag' => $data['tag']])); + session()->flash('success', (string)trans('firefly.created_tag', ['tag' => $data['tag']])); app('preferences')->mark(); // store attachment(s): @@ -327,14 +333,14 @@ class TagController extends Controller $this->attachmentsHelper->saveAttachmentsForModel($result, $files); } if (null !== $files && auth()->user()->hasRole('demo')) { - session()->flash('info', (string) trans('firefly.no_att_demo_user')); + session()->flash('info', (string)trans('firefly.no_att_demo_user')); } if (count($this->attachmentsHelper->getMessages()->get('attachments')) > 0) { $request->session()->flash('info', $this->attachmentsHelper->getMessages()->get('attachments')); } $redirect = redirect($this->getPreviousUrl('tags.create.url')); - if (1 === (int) $request->get('create_another')) { + if (1 === (int)$request->get('create_another')) { session()->put('tags.create.fromStore', true); $redirect = redirect(route('tags.create'))->withInput(); @@ -346,8 +352,8 @@ class TagController extends Controller /** * Update a tag. * - * @param TagFormRequest $request - * @param Tag $tag + * @param TagFormRequest $request + * @param Tag $tag * * @return RedirectResponse */ @@ -356,7 +362,7 @@ class TagController extends Controller $data = $request->collectTagData(); $tag = $this->repository->update($tag, $data); - session()->flash('success', (string) trans('firefly.updated_tag', ['tag' => $data['tag']])); + session()->flash('success', (string)trans('firefly.updated_tag', ['tag' => $data['tag']])); app('preferences')->mark(); // store new attachment(s): @@ -366,14 +372,14 @@ class TagController extends Controller $this->attachmentsHelper->saveAttachmentsForModel($tag, $files); } if (null !== $files && auth()->user()->hasRole('demo')) { - session()->flash('info', (string) trans('firefly.no_att_demo_user')); + session()->flash('info', (string)trans('firefly.no_att_demo_user')); } if (count($this->attachmentsHelper->getMessages()->get('attachments')) > 0) { $request->session()->flash('info', $this->attachmentsHelper->getMessages()->get('attachments')); } $redirect = redirect($this->getPreviousUrl('tags.edit.url')); - if (1 === (int) $request->get('return_to_edit')) { + if (1 === (int)$request->get('return_to_edit')) { session()->put('tags.edit.fromUpdate', true); $redirect = redirect(route('tags.edit', [$tag->id]))->withInput(['return_to_edit' => 1]); diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 78a4ea778d..9b91bcd373 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -1,4 +1,5 @@ check()) { - $userId = (int) $value; + $userId = (int)$value; $user = self::find($userId); if (null !== $user) { return $user; @@ -361,27 +361,6 @@ class User extends Authenticatable return $this->hasMany(GroupMembership::class)->with(['userGroup', 'userRole']); } - /** - * @param string $role - * - * @return bool - */ - public function hasRole(string $role): bool - { - return $this->roles()->where('name', $role)->count() === 1; - } - - /** - * @codeCoverageIgnore - * Link to roles. - * - * @return BelongsToMany - */ - public function roles(): BelongsToMany - { - return $this->belongsToMany(Role::class); - } - /** * @codeCoverageIgnore * Link to object groups. @@ -426,6 +405,81 @@ class User extends Authenticatable return $this->hasMany(Recurrence::class); } + /** + * Get the notification routing information for the given driver. + * + * @param string $driver + * @param Notification|null $notification + * @return mixed + */ + public function routeNotificationFor($driver, $notification = null) + { + if (method_exists($this, $method = 'routeNotificationFor'.Str::studly($driver))) { + return $this->{$method}($notification); + } + $email = $this->email; + // see if user has alternative email address: + $pref = app('preferences')->getForUser($this, 'remote_guard_alt_email'); + if (null !== $pref) { + $email = $pref->data; + } + // if user is demo user, send to owner: + if ($this->hasRole('demo')) { + $email = config('firefly.site_owner'); + } + + return match ($driver) { + 'database' => $this->notifications(), + 'mail' => $email, + default => null, + }; + } + + /** + * @param string $role + * + * @return bool + */ + public function hasRole(string $role): bool + { + return $this->roles()->where('name', $role)->count() === 1; + } + + /** + * @codeCoverageIgnore + * Link to roles. + * + * @return BelongsToMany + */ + public function roles(): BelongsToMany + { + return $this->belongsToMany(Role::class); + } + + /** + * Route notifications for the Slack channel. + * + * @param Notification $notification + * @return string + */ + public function routeNotificationForSlack(Notification $notification): string + { + // this check does not validate if the user is owner, Should be done by notification itself. + if ($notification instanceof TestNotification) { + return app('fireflyconfig')->get('slack_webhook_url', '')->data; + } + if ($notification instanceof UserRegistration) { + return app('fireflyconfig')->get('slack_webhook_url', '')->data; + } + if ($notification instanceof VersionCheckResult) { + return app('fireflyconfig')->get('slack_webhook_url', '')->data; + } + if ($notification instanceof UserInvitation) { + return app('fireflyconfig')->get('slack_webhook_url', '')->data; + } + return app('preferences')->getForUser($this, 'slack_webhook_url', '')->data; + } + /** * @codeCoverageIgnore * Link to rule groups. @@ -452,7 +506,7 @@ class User extends Authenticatable * @codeCoverageIgnore * Send the password reset notification. * - * @param string $token + * @param string $token */ public function sendPasswordResetNotification($token): void { @@ -461,9 +515,11 @@ class User extends Authenticatable event(new RequestedNewPassword($this, $token, $ipAddress)); } + // start LDAP related code + /** * Set the models LDAP domain. - * @param string $domain + * @param string $domain * * @return void * @deprecated @@ -476,7 +532,7 @@ class User extends Authenticatable /** * Set the models LDAP GUID. - * @param string $guid + * @param string $guid * * @return void * @deprecated @@ -486,8 +542,6 @@ class User extends Authenticatable $this->{$this->getLdapGuidColumn()} = $guid; } - // start LDAP related code - /** * @codeCoverageIgnore * Link to tags. @@ -552,58 +606,4 @@ class User extends Authenticatable { return $this->hasMany(Webhook::class); } - - /** - * Get the notification routing information for the given driver. - * - * @param string $driver - * @param Notification|null $notification - * @return mixed - */ - public function routeNotificationFor($driver, $notification = null) - { - if (method_exists($this, $method = 'routeNotificationFor' . Str::studly($driver))) { - return $this->{$method}($notification); - } - $email = $this->email; - // see if user has alternative email address: - $pref = app('preferences')->getForUser($this, 'remote_guard_alt_email'); - if (null !== $pref) { - $email = $pref->data; - } - // if user is demo user, send to owner: - if ($this->hasRole('demo')) { - $email = config('firefly.site_owner'); - } - - return match ($driver) { - 'database' => $this->notifications(), - 'mail' => $email, - default => null, - }; - } - - /** - * Route notifications for the Slack channel. - * - * @param Notification $notification - * @return string - */ - public function routeNotificationForSlack(Notification $notification): string - { - // this check does not validate if the user is owner, Should be done by notification itself. - if ($notification instanceof TestNotification) { - return app('fireflyconfig')->get('slack_webhook_url', '')->data; - } - if ($notification instanceof UserRegistration) { - return app('fireflyconfig')->get('slack_webhook_url', '')->data; - } - if ($notification instanceof VersionCheckResult) { - return app('fireflyconfig')->get('slack_webhook_url', '')->data; - } - if ($notification instanceof UserInvitation) { - return app('fireflyconfig')->get('slack_webhook_url', '')->data; - } - return app('preferences')->getForUser($this, 'slack_webhook_url', '')->data; - } } diff --git a/composer.lock b/composer.lock index 1b0cb26dab..0d3e9795af 100644 --- a/composer.lock +++ b/composer.lock @@ -9368,16 +9368,16 @@ }, { "name": "nunomaduro/larastan", - "version": "2.3.1", + "version": "2.3.2", "source": { "type": "git", "url": "https://github.com/nunomaduro/larastan.git", - "reference": "2217d0725884fd68f029fe22919edd3f910683d3" + "reference": "f5103aaa9ebe050689b7c4f7870563bb2de33f92" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/larastan/zipball/2217d0725884fd68f029fe22919edd3f910683d3", - "reference": "2217d0725884fd68f029fe22919edd3f910683d3", + "url": "https://api.github.com/repos/nunomaduro/larastan/zipball/f5103aaa9ebe050689b7c4f7870563bb2de33f92", + "reference": "f5103aaa9ebe050689b7c4f7870563bb2de33f92", "shasum": "" }, "require": { @@ -9441,7 +9441,7 @@ ], "support": { "issues": "https://github.com/nunomaduro/larastan/issues", - "source": "https://github.com/nunomaduro/larastan/tree/2.3.1" + "source": "https://github.com/nunomaduro/larastan/tree/2.3.2" }, "funding": [ { @@ -9461,7 +9461,7 @@ "type": "patreon" } ], - "time": "2022-12-23T14:56:31+00:00" + "time": "2022-12-29T10:58:10+00:00" }, { "name": "phar-io/manifest",