From e829d795893edad1572280638b2d189c82bb9292 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 18 Sep 2021 10:21:29 +0200 Subject: [PATCH] Various code cleanup. --- app/Factory/TransactionJournalFactory.php | 15 +++--- .../Report/Audit/MonthReportGenerator.php | 4 +- .../Events/UpdatedAccountEventHandler.php | 1 - app/Handlers/Events/UserEventHandler.php | 12 ++--- .../Events/VersionCheckEventHandler.php | 1 - app/Helpers/Fiscal/FiscalHelper.php | 1 + app/Helpers/Report/NetWorth.php | 1 + .../Controllers/Account/CreateController.php | 1 + .../Controllers/Account/IndexController.php | 1 + app/Http/Controllers/Admin/HomeController.php | 1 + .../Controllers/Admin/UpdateController.php | 2 - app/Http/Controllers/Auth/LoginController.php | 2 +- .../Controllers/Auth/RegisterController.php | 2 +- .../Controllers/Bill/CreateController.php | 2 - app/Http/Controllers/Bill/EditController.php | 2 - app/Http/Controllers/Bill/IndexController.php | 3 +- app/Http/Controllers/Bill/ShowController.php | 2 +- .../Budget/AvailableBudgetController.php | 2 +- .../Controllers/Budget/IndexController.php | 1 + .../Controllers/Budget/ShowController.php | 3 ++ .../Controllers/Category/IndexController.php | 1 + .../Category/NoCategoryController.php | 2 + .../Controllers/Category/ShowController.php | 2 + .../Controllers/Chart/AccountController.php | 10 ++++ app/Http/Controllers/Chart/BillController.php | 2 + .../Controllers/Chart/BudgetController.php | 9 +++- .../Controllers/Chart/CategoryController.php | 17 ++++-- .../Chart/ExpenseReportController.php | 4 +- .../Controllers/Chart/PiggyBankController.php | 5 +- .../Controllers/Chart/ReportController.php | 2 + .../Chart/TransactionController.php | 4 ++ app/Http/Controllers/CurrencyController.php | 5 +- .../Controllers/Export/IndexController.php | 2 - app/Http/Controllers/HelpController.php | 1 + app/Http/Controllers/HomeController.php | 5 -- app/Http/Controllers/JavascriptController.php | 2 + .../Json/AutoCompleteController.php | 4 -- app/Http/Controllers/Json/BoxController.php | 2 + app/Http/Controllers/Json/IntroController.php | 2 + .../Controllers/Json/ReconcileController.php | 3 +- app/Http/Controllers/NewUserController.php | 1 + .../ObjectGroup/IndexController.php | 2 - .../Controllers/Popup/ReportController.php | 28 +++------- .../Controllers/PreferencesController.php | 3 +- app/Http/Controllers/ProfileController.php | 7 ++- .../Controllers/Report/AccountController.php | 2 +- .../Controllers/Report/BudgetController.php | 1 + .../Controllers/Report/CategoryController.php | 4 +- .../Report/OperationsController.php | 3 ++ app/Http/Controllers/ReportController.php | 54 ++++++------------- app/Http/Controllers/Rule/IndexController.php | 2 - app/Http/Controllers/TagController.php | 2 +- .../Transaction/CreateController.php | 2 +- app/Http/Middleware/InstallationId.php | 1 - app/Http/Middleware/TrustProxies.php | 1 - app/Jobs/CreateRecurringTransactions.php | 2 + app/Models/GroupMembership.php | 20 +++---- app/Models/TransactionJournal.php | 1 - app/Models/UserGroup.php | 14 ++--- app/Models/UserRole.php | 14 ++--- .../Account/AccountRepository.php | 2 + app/Repositories/Bill/BillRepository.php | 2 + .../Budget/AvailableBudgetRepository.php | 1 - .../Category/CategoryRepository.php | 1 + .../Currency/CurrencyRepository.php | 1 + .../Journal/JournalCLIRepository.php | 2 + .../Journal/JournalRepository.php | 2 + .../ObjectGroup/CreatesObjectGroups.php | 1 - app/Repositories/User/UserRepository.php | 1 + app/Rules/IsValidBulkClause.php | 2 + .../FireflyIIIOrg/Update/UpdateRequest.php | 1 - .../Internal/Destroy/BillDestroyService.php | 1 - .../Internal/Destroy/BudgetDestroyService.php | 1 - .../Destroy/CategoryDestroyService.php | 1 - .../Destroy/CurrencyDestroyService.php | 1 - .../Destroy/RecurrenceDestroyService.php | 1 - .../Internal/Support/AccountServiceTrait.php | 1 - .../Internal/Support/BillServiceTrait.php | 1 - .../Support/CreditRecalculateService.php | 4 +- .../Internal/Update/AccountUpdateService.php | 1 - .../Internal/Update/GroupUpdateService.php | 1 + app/Support/Amount.php | 4 ++ .../Authentication/RemoteUserGuard.php | 3 +- app/Support/CacheProperties.php | 1 - app/Support/Cronjobs/AbstractCronjob.php | 2 - app/Support/Http/Controllers/AugumentData.php | 1 + .../Http/Controllers/ChartGeneration.php | 3 +- .../Http/Controllers/GetConfigurationData.php | 2 +- .../Http/Controllers/PeriodOverview.php | 6 +++ .../Http/Controllers/RequestInformation.php | 1 + .../Http/Controllers/RuleManagement.php | 1 - app/Support/ParseDateString.php | 41 ++++++-------- app/Support/Preferences.php | 3 +- app/Support/Request/ConvertsDataTypes.php | 1 - app/Support/Search/OperatorQuerySearch.php | 1 - app/Support/Steam.php | 10 +++- app/TransactionRules/Actions/ClearBudget.php | 1 - .../Actions/ClearCategory.php | 1 - app/TransactionRules/Actions/ClearNotes.php | 1 - .../Actions/SetDestinationAccount.php | 1 - .../Engine/SearchRuleEngine.php | 1 + app/Transformers/AccountTransformer.php | 2 + app/Transformers/AttachmentTransformer.php | 4 +- app/Transformers/PiggyBankTransformer.php | 1 - .../TransactionGroupTransformer.php | 2 +- app/Validation/FireflyValidator.php | 1 - app/Validation/TransactionValidation.php | 14 ++--- 107 files changed, 225 insertions(+), 220 deletions(-) diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.php index 3c893a9839..8c624acfeb 100644 --- a/app/Factory/TransactionJournalFactory.php +++ b/app/Factory/TransactionJournalFactory.php @@ -95,8 +95,9 @@ class TransactionJournalFactory * @param array $data * * @return Collection - * @throws FireflyException * @throws DuplicateTransactionException + * @throws FireflyException + * @throws JsonException */ public function create(array $data): Collection { @@ -388,15 +389,11 @@ class TransactionJournalFactory private function getCurrencyByAccount(string $type, ?TransactionCurrency $currency, Account $source, Account $destination): TransactionCurrency { Log::debug('Now ingetCurrencyByAccount()'); - switch ($type) { - default: - case TransactionType::WITHDRAWAL: - case TransactionType::TRANSFER: - return $this->getCurrency($currency, $source); - case TransactionType::DEPOSIT: - return $this->getCurrency($currency, $destination); - } + return match ($type) { + default => $this->getCurrency($currency, $source), + TransactionType::DEPOSIT => $this->getCurrency($currency, $destination), + }; } /** diff --git a/app/Generator/Report/Audit/MonthReportGenerator.php b/app/Generator/Report/Audit/MonthReportGenerator.php index 55ac3508a1..d12efb5eb9 100644 --- a/app/Generator/Report/Audit/MonthReportGenerator.php +++ b/app/Generator/Report/Audit/MonthReportGenerator.php @@ -48,7 +48,6 @@ class MonthReportGenerator implements ReportGeneratorInterface * Generates the report. * * @return string - * @throws FireflyException * @codeCoverageIgnore */ public function generate(): string @@ -195,7 +194,8 @@ class MonthReportGenerator implements ReportGeneratorInterface * @param Carbon $date * * @return array - * + * @throws FireflyException + * @throws \JsonException */ #[ArrayShape(['journals' => "array", 'currency' => "mixed", 'exists' => "bool", 'end' => "string", 'endBalance' => "mixed", 'dayBefore' => "string", 'dayBeforeBalance' => "mixed"])] public function getAuditReport(Account $account, Carbon $date): array diff --git a/app/Handlers/Events/UpdatedAccountEventHandler.php b/app/Handlers/Events/UpdatedAccountEventHandler.php index ec070538ff..096ab5f99c 100644 --- a/app/Handlers/Events/UpdatedAccountEventHandler.php +++ b/app/Handlers/Events/UpdatedAccountEventHandler.php @@ -25,7 +25,6 @@ declare(strict_types=1); namespace FireflyIII\Handlers\Events; -use FireflyIII\Events\StoredAccount; use FireflyIII\Events\UpdatedAccount; use FireflyIII\Services\Internal\Support\CreditRecalculateService; diff --git a/app/Handlers/Events/UserEventHandler.php b/app/Handlers/Events/UserEventHandler.php index 5662c34328..cdd587ddd9 100644 --- a/app/Handlers/Events/UserEventHandler.php +++ b/app/Handlers/Events/UserEventHandler.php @@ -114,7 +114,7 @@ class UserEventHandler * @param Login $event * * @return bool - * @throws \FireflyIII\Exceptions\FireflyException + * @throws FireflyException */ public function demoUserBackToEnglish(Login $event): bool { @@ -136,7 +136,7 @@ class UserEventHandler /** * @param DetectedNewIPAddress $event * - * @throws \FireflyIII\Exceptions\FireflyException + * @throws FireflyException */ public function notifyNewIPAddress(DetectedNewIPAddress $event): void { @@ -178,7 +178,7 @@ class UserEventHandler * @param UserChangedEmail $event * * @return bool - * @throws \FireflyIII\Exceptions\FireflyException + * @throws FireflyException */ public function sendEmailChangeConfirmMail(UserChangedEmail $event): bool { @@ -204,7 +204,7 @@ class UserEventHandler * @param UserChangedEmail $event * * @return bool - * @throws \FireflyIII\Exceptions\FireflyException + * @throws FireflyException */ public function sendEmailChangeUndoMail(UserChangedEmail $event): bool { @@ -286,7 +286,7 @@ class UserEventHandler * @param RegisteredUser $event * * @return bool - * @throws \FireflyIII\Exceptions\FireflyException + * @throws FireflyException */ public function sendRegistrationMail(RegisteredUser $event): bool { @@ -319,7 +319,7 @@ class UserEventHandler /** * @param Login $event * - * @throws \FireflyIII\Exceptions\FireflyException + * @throws FireflyException */ public function storeUserIPAddress(Login $event): void { diff --git a/app/Handlers/Events/VersionCheckEventHandler.php b/app/Handlers/Events/VersionCheckEventHandler.php index 2fd9f6558f..40307cf453 100644 --- a/app/Handlers/Events/VersionCheckEventHandler.php +++ b/app/Handlers/Events/VersionCheckEventHandler.php @@ -29,7 +29,6 @@ use FireflyIII\Exceptions\FireflyException; use FireflyIII\Helpers\Update\UpdateTrait; use FireflyIII\Models\Configuration; use FireflyIII\Repositories\User\UserRepositoryInterface; -use FireflyIII\User; use Log; /** diff --git a/app/Helpers/Fiscal/FiscalHelper.php b/app/Helpers/Fiscal/FiscalHelper.php index 15a92d3c83..ea52ce1074 100644 --- a/app/Helpers/Fiscal/FiscalHelper.php +++ b/app/Helpers/Fiscal/FiscalHelper.php @@ -67,6 +67,7 @@ class FiscalHelper implements FiscalHelperInterface * @param Carbon $date * * @return Carbon date object + * @throws \FireflyIII\Exceptions\FireflyException */ public function startOfFiscalYear(Carbon $date): Carbon { diff --git a/app/Helpers/Report/NetWorth.php b/app/Helpers/Report/NetWorth.php index 10f62cfc15..0fda556332 100644 --- a/app/Helpers/Report/NetWorth.php +++ b/app/Helpers/Report/NetWorth.php @@ -62,6 +62,7 @@ class NetWorth implements NetWorthInterface * @param Carbon $date * * @return array + * @throws \JsonException */ public function getNetWorthByCurrency(Collection $accounts, Carbon $date): array { diff --git a/app/Http/Controllers/Account/CreateController.php b/app/Http/Controllers/Account/CreateController.php index a01febc004..1a5a3c5f96 100644 --- a/app/Http/Controllers/Account/CreateController.php +++ b/app/Http/Controllers/Account/CreateController.php @@ -135,6 +135,7 @@ class CreateController extends Controller * @param AccountFormRequest $request * * @return RedirectResponse|Redirector + * @throws \FireflyIII\Exceptions\FireflyException */ public function store(AccountFormRequest $request) { diff --git a/app/Http/Controllers/Account/IndexController.php b/app/Http/Controllers/Account/IndexController.php index 2d008188bc..11566bfe0f 100644 --- a/app/Http/Controllers/Account/IndexController.php +++ b/app/Http/Controllers/Account/IndexController.php @@ -72,6 +72,7 @@ class IndexController extends Controller * @param string $objectType * * @return Factory|View + * @throws \FireflyIII\Exceptions\FireflyException */ public function inactive(Request $request, string $objectType) { diff --git a/app/Http/Controllers/Admin/HomeController.php b/app/Http/Controllers/Admin/HomeController.php index c4da989f2c..718d112b1f 100644 --- a/app/Http/Controllers/Admin/HomeController.php +++ b/app/Http/Controllers/Admin/HomeController.php @@ -53,6 +53,7 @@ class HomeController extends Controller * Index of the admin. * * @return Factory|View + * @throws \FireflyIII\Exceptions\FireflyException */ public function index() { diff --git a/app/Http/Controllers/Admin/UpdateController.php b/app/Http/Controllers/Admin/UpdateController.php index 13a21a6988..5e509db1c9 100644 --- a/app/Http/Controllers/Admin/UpdateController.php +++ b/app/Http/Controllers/Admin/UpdateController.php @@ -31,8 +31,6 @@ use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Routing\Redirector; use Illuminate\View\View; -use Psr\Container\ContainerExceptionInterface; -use Psr\Container\NotFoundExceptionInterface; /** * Class HomeController. diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 5ef0774785..92fcc56271 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -194,7 +194,7 @@ class LoginController extends Controller * * @param Request $request * - * @return Factory|Response|View + * @return Factory|\Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\View|\Illuminate\Routing\Redirector|RedirectResponse * @throws FireflyException */ public function showLoginForm(Request $request) diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index c41172d317..c5b3ce425d 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -78,7 +78,7 @@ class RegisterController extends Controller * * @param Request $request * - * @return Factory|RedirectResponse|Redirector|View + * @return \Illuminate\Contracts\Foundation\Application|Redirector|RedirectResponse * @throws FireflyException * @throws ValidationException */ diff --git a/app/Http/Controllers/Bill/CreateController.php b/app/Http/Controllers/Bill/CreateController.php index 17d1dcde7a..8015319b45 100644 --- a/app/Http/Controllers/Bill/CreateController.php +++ b/app/Http/Controllers/Bill/CreateController.php @@ -29,11 +29,9 @@ use FireflyIII\Helpers\Attachments\AttachmentHelperInterface; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Requests\BillStoreRequest; use FireflyIII\Repositories\Bill\BillRepositoryInterface; -use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\View\Factory; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\View\View; use Log; /** diff --git a/app/Http/Controllers/Bill/EditController.php b/app/Http/Controllers/Bill/EditController.php index f713d87dde..7959115862 100644 --- a/app/Http/Controllers/Bill/EditController.php +++ b/app/Http/Controllers/Bill/EditController.php @@ -29,11 +29,9 @@ use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Requests\BillUpdateRequest; use FireflyIII\Models\Bill; use FireflyIII\Repositories\Bill\BillRepositoryInterface; -use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\View\Factory; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\View\View; /** * Class EditController diff --git a/app/Http/Controllers/Bill/IndexController.php b/app/Http/Controllers/Bill/IndexController.php index ba627833e1..f87f80baca 100644 --- a/app/Http/Controllers/Bill/IndexController.php +++ b/app/Http/Controllers/Bill/IndexController.php @@ -24,10 +24,8 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Bill; -use Carbon\Carbon; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Models\Bill; -use FireflyIII\Models\TransactionCurrency; use FireflyIII\Repositories\Bill\BillRepositoryInterface; use FireflyIII\Repositories\ObjectGroup\OrganisesObjectGroups; use FireflyIII\Transformers\BillTransformer; @@ -145,6 +143,7 @@ class IndexController extends Controller * @param array $bills * * @return array + * @throws \FireflyIII\Exceptions\FireflyException */ private function getSums(array $bills): array { diff --git a/app/Http/Controllers/Bill/ShowController.php b/app/Http/Controllers/Bill/ShowController.php index 6a871b05a3..87b3638957 100644 --- a/app/Http/Controllers/Bill/ShowController.php +++ b/app/Http/Controllers/Bill/ShowController.php @@ -24,7 +24,6 @@ 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; @@ -124,6 +123,7 @@ class ShowController extends Controller * @param Bill $bill * * @return Factory|View + * @throws FireflyException */ public function show(Request $request, Bill $bill) { diff --git a/app/Http/Controllers/Budget/AvailableBudgetController.php b/app/Http/Controllers/Budget/AvailableBudgetController.php index 323f0d3d6a..b2f82e9036 100644 --- a/app/Http/Controllers/Budget/AvailableBudgetController.php +++ b/app/Http/Controllers/Budget/AvailableBudgetController.php @@ -133,7 +133,7 @@ class AvailableBudgetController extends Controller } /** - * @param AvailableBudget $availableBudget + * @param Request $request * * @return RedirectResponse|Redirector */ diff --git a/app/Http/Controllers/Budget/IndexController.php b/app/Http/Controllers/Budget/IndexController.php index f478cb9e3f..9f1caa1de7 100644 --- a/app/Http/Controllers/Budget/IndexController.php +++ b/app/Http/Controllers/Budget/IndexController.php @@ -90,6 +90,7 @@ class IndexController extends Controller * @param Carbon|null $end * * @return Factory|View + * @throws \FireflyIII\Exceptions\FireflyException */ public function index(Request $request, Carbon $start = null, Carbon $end = null) { diff --git a/app/Http/Controllers/Budget/ShowController.php b/app/Http/Controllers/Budget/ShowController.php index f7f8583f28..6716256a10 100644 --- a/app/Http/Controllers/Budget/ShowController.php +++ b/app/Http/Controllers/Budget/ShowController.php @@ -78,6 +78,7 @@ class ShowController extends Controller * @param Carbon|null $end * * @return Factory|View + * @throws FireflyException */ public function noBudget(Request $request, Carbon $start = null, Carbon $end = null) { @@ -113,6 +114,7 @@ class ShowController extends Controller * @param Request $request * * @return Factory|View + * @throws FireflyException */ public function noBudgetAll(Request $request) { @@ -141,6 +143,7 @@ class ShowController extends Controller * @param Budget $budget * * @return Factory|View + * @throws FireflyException */ public function show(Request $request, Budget $budget) { diff --git a/app/Http/Controllers/Category/IndexController.php b/app/Http/Controllers/Category/IndexController.php index 9b75383272..fb93dd652d 100644 --- a/app/Http/Controllers/Category/IndexController.php +++ b/app/Http/Controllers/Category/IndexController.php @@ -66,6 +66,7 @@ class IndexController extends Controller * @param Request $request * * @return Factory|View + * @throws \FireflyIII\Exceptions\FireflyException */ public function index(Request $request) { diff --git a/app/Http/Controllers/Category/NoCategoryController.php b/app/Http/Controllers/Category/NoCategoryController.php index 9ae41cebb2..4ec98fbe81 100644 --- a/app/Http/Controllers/Category/NoCategoryController.php +++ b/app/Http/Controllers/Category/NoCategoryController.php @@ -74,6 +74,7 @@ class NoCategoryController extends Controller * @param Carbon|null $end * * @return Factory|View + * @throws \FireflyIII\Exceptions\FireflyException */ public function show(Request $request, Carbon $start = null, Carbon $end = null) { @@ -111,6 +112,7 @@ class NoCategoryController extends Controller * @param Request $request * * @return Factory|View + * @throws \FireflyIII\Exceptions\FireflyException */ public function showAll(Request $request) { diff --git a/app/Http/Controllers/Category/ShowController.php b/app/Http/Controllers/Category/ShowController.php index 67c21af5b4..5a530d19cc 100644 --- a/app/Http/Controllers/Category/ShowController.php +++ b/app/Http/Controllers/Category/ShowController.php @@ -76,6 +76,7 @@ class ShowController extends Controller * @param Carbon|null $end * * @return Factory|View + * @throws \FireflyIII\Exceptions\FireflyException */ public function show(Request $request, Category $category, Carbon $start = null, Carbon $end = null) { @@ -115,6 +116,7 @@ class ShowController extends Controller * @param Category $category * * @return Factory|View + * @throws \FireflyIII\Exceptions\FireflyException */ public function showAll(Request $request, Category $category) { diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php index cc0b950288..68f98a29aa 100644 --- a/app/Http/Controllers/Chart/AccountController.php +++ b/app/Http/Controllers/Chart/AccountController.php @@ -83,6 +83,7 @@ class AccountController extends Controller * This chart is (multi) currency aware. * * @return JsonResponse + * @throws \JsonException */ public function expenseAccounts(): JsonResponse { @@ -194,6 +195,7 @@ class AccountController extends Controller * @param Carbon $end * * @return JsonResponse + * @throws \JsonException */ public function expenseBudget(Account $account, Carbon $start, Carbon $end): JsonResponse { @@ -268,6 +270,7 @@ class AccountController extends Controller * @param Carbon $end * * @return JsonResponse + * @throws \JsonException */ public function expenseCategory(Account $account, Carbon $start, Carbon $end): JsonResponse { @@ -322,6 +325,7 @@ class AccountController extends Controller * @param AccountRepositoryInterface $repository * * @return JsonResponse + * @throws \FireflyIII\Exceptions\FireflyException */ public function frontpage(AccountRepositoryInterface $repository): JsonResponse { @@ -364,6 +368,7 @@ class AccountController extends Controller * @param Carbon $end * * @return JsonResponse + * @throws \JsonException */ public function incomeCategory(Account $account, Carbon $start, Carbon $end): JsonResponse { @@ -421,6 +426,8 @@ class AccountController extends Controller * @param Carbon $end * * @return JsonResponse + * @throws \FireflyIII\Exceptions\FireflyException + * @throws \JsonException */ public function period(Account $account, Carbon $start, Carbon $end): JsonResponse { @@ -458,6 +465,8 @@ class AccountController extends Controller * @param TransactionCurrency $currency * * @return array + * @throws \FireflyIII\Exceptions\FireflyException + * @throws \JsonException */ private function periodByCurrency(Carbon $start, Carbon $end, Account $account, TransactionCurrency $currency): array { @@ -528,6 +537,7 @@ class AccountController extends Controller * This chart is multi-currency aware. * * @return JsonResponse + * @throws \JsonException */ public function revenueAccounts(): JsonResponse { diff --git a/app/Http/Controllers/Chart/BillController.php b/app/Http/Controllers/Chart/BillController.php index 9b28269dc3..8fe9467b4f 100644 --- a/app/Http/Controllers/Chart/BillController.php +++ b/app/Http/Controllers/Chart/BillController.php @@ -57,6 +57,7 @@ class BillController extends Controller * @param BillRepositoryInterface $repository * * @return JsonResponse + * @throws \JsonException */ public function frontpage(BillRepositoryInterface $repository): JsonResponse { @@ -102,6 +103,7 @@ class BillController extends Controller * @param Bill $bill * * @return JsonResponse + * @throws \JsonException */ public function single(Bill $bill): JsonResponse { diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php index 77ac926f9a..400e137710 100644 --- a/app/Http/Controllers/Chart/BudgetController.php +++ b/app/Http/Controllers/Chart/BudgetController.php @@ -84,6 +84,7 @@ class BudgetController extends Controller * @param Budget $budget * * @return JsonResponse + * @throws \JsonException */ public function budget(Budget $budget): JsonResponse { @@ -152,6 +153,7 @@ class BudgetController extends Controller * @return JsonResponse * * @throws FireflyException + * @throws \JsonException */ public function budgetLimit(Budget $budget, BudgetLimit $budgetLimit): JsonResponse { @@ -202,6 +204,7 @@ class BudgetController extends Controller * @param BudgetLimit|null $budgetLimit * * @return JsonResponse + * @throws \JsonException */ public function expenseAsset(Budget $budget, ?BudgetLimit $budgetLimit = null): JsonResponse { @@ -270,6 +273,7 @@ class BudgetController extends Controller * @param BudgetLimit|null $budgetLimit * * @return JsonResponse + * @throws \JsonException */ public function expenseCategory(Budget $budget, ?BudgetLimit $budgetLimit = null): JsonResponse { @@ -334,6 +338,7 @@ class BudgetController extends Controller * @param BudgetLimit|null $budgetLimit * * @return JsonResponse + * @throws \JsonException */ public function expenseExpense(Budget $budget, ?BudgetLimit $budgetLimit = null): JsonResponse { @@ -397,7 +402,7 @@ class BudgetController extends Controller * Shows a budget list with spent/left/overspent. * * @return JsonResponse - * + * @throws \JsonException */ public function frontpage(): JsonResponse { @@ -435,6 +440,7 @@ class BudgetController extends Controller * @param Carbon $end * * @return JsonResponse + * @throws \JsonException */ public function period(Budget $budget, TransactionCurrency $currency, Collection $accounts, Carbon $start, Carbon $end): JsonResponse { @@ -510,6 +516,7 @@ class BudgetController extends Controller * @param Carbon $end * * @return JsonResponse + * @throws \JsonException */ public function periodNoBudget(TransactionCurrency $currency, Collection $accounts, Carbon $start, Carbon $end): JsonResponse { diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php index f8fd2e6f59..7e1cf1239f 100644 --- a/app/Http/Controllers/Chart/CategoryController.php +++ b/app/Http/Controllers/Chart/CategoryController.php @@ -63,11 +63,13 @@ class CategoryController extends Controller /** * Show an overview for a category for all time, per month/week/year. -* See reference nr. 59 + * See reference nr. 59 * * @param Category $category * * @return JsonResponse + * @throws \FireflyIII\Exceptions\FireflyException + * @throws \JsonException */ public function all(Category $category): JsonResponse { @@ -111,9 +113,10 @@ class CategoryController extends Controller /** * Shows the category chart on the front page. -* See reference nr. 60 + * See reference nr. 60 * * @return JsonResponse + * @throws \JsonException */ public function frontPage(): JsonResponse { @@ -138,7 +141,7 @@ class CategoryController extends Controller /** * Chart report. -* See reference nr. 61 + * See reference nr. 61 * * @param Category $category * @param Collection $accounts @@ -146,6 +149,7 @@ class CategoryController extends Controller * @param Carbon $end * * @return JsonResponse + * @throws \JsonException */ public function reportPeriod(Category $category, Collection $accounts, Carbon $start, Carbon $end): JsonResponse { @@ -254,13 +258,14 @@ class CategoryController extends Controller /** * Chart for period for transactions without a category. -* See reference nr. 62 + * See reference nr. 62 * * @param Collection $accounts * @param Carbon $start * @param Carbon $end * * @return JsonResponse + * @throws \JsonException */ public function reportPeriodNoCategory(Collection $accounts, Carbon $start, Carbon $end): JsonResponse { @@ -281,12 +286,14 @@ class CategoryController extends Controller /** * Chart for a specific period. -* See reference nr. 63 + * See reference nr. 63 * * @param Category $category * @param Carbon $date * * @return JsonResponse + * @throws \FireflyIII\Exceptions\FireflyException + * @throws \JsonException */ public function specificPeriod(Category $category, Carbon $date): JsonResponse { diff --git a/app/Http/Controllers/Chart/ExpenseReportController.php b/app/Http/Controllers/Chart/ExpenseReportController.php index 12e450d3c0..dd1541143a 100644 --- a/app/Http/Controllers/Chart/ExpenseReportController.php +++ b/app/Http/Controllers/Chart/ExpenseReportController.php @@ -69,7 +69,7 @@ class ExpenseReportController extends Controller /** * Main chart that shows income and expense for a combination of expense/revenue accounts. * -* See reference nr. 58 + * See reference nr. 58 * * @param Collection $accounts * @param Collection $expense @@ -77,7 +77,7 @@ class ExpenseReportController extends Controller * @param Carbon $end * * @return JsonResponse - * + * @throws \JsonException */ public function mainChart(Collection $accounts, Collection $expense, Carbon $start, Carbon $end): JsonResponse { diff --git a/app/Http/Controllers/Chart/PiggyBankController.php b/app/Http/Controllers/Chart/PiggyBankController.php index be6ba88848..a7d1684d90 100644 --- a/app/Http/Controllers/Chart/PiggyBankController.php +++ b/app/Http/Controllers/Chart/PiggyBankController.php @@ -31,7 +31,6 @@ use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface; use FireflyIII\Support\CacheProperties; use FireflyIII\Support\Http\Controllers\DateCalculation; use Illuminate\Http\JsonResponse; -use Illuminate\Support\Collection; /** * Class PiggyBankController. @@ -58,13 +57,13 @@ class PiggyBankController extends Controller /** * Shows the piggy bank history. * -* See reference nr. 53 + * See reference nr. 53 * * @param PiggyBankRepositoryInterface $repository * @param PiggyBank $piggyBank * * @return JsonResponse - * + * @throws \JsonException */ public function history(PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank): JsonResponse { diff --git a/app/Http/Controllers/Chart/ReportController.php b/app/Http/Controllers/Chart/ReportController.php index 304d5ea347..31efe7921a 100644 --- a/app/Http/Controllers/Chart/ReportController.php +++ b/app/Http/Controllers/Chart/ReportController.php @@ -68,6 +68,7 @@ class ReportController extends Controller * @param Carbon $end * * @return JsonResponse + * @throws \JsonException */ public function netWorth(Collection $accounts, Carbon $start, Carbon $end): JsonResponse { @@ -142,6 +143,7 @@ class ReportController extends Controller * @param Carbon $end * * @return JsonResponse + * @throws \JsonException */ public function operations(Collection $accounts, Carbon $start, Carbon $end): JsonResponse { diff --git a/app/Http/Controllers/Chart/TransactionController.php b/app/Http/Controllers/Chart/TransactionController.php index c57fcc2be7..27c5daea39 100644 --- a/app/Http/Controllers/Chart/TransactionController.php +++ b/app/Http/Controllers/Chart/TransactionController.php @@ -56,6 +56,7 @@ class TransactionController extends Controller * @param Carbon $end * * @return JsonResponse + * @throws \JsonException */ public function budgets(Carbon $start, Carbon $end) { @@ -100,6 +101,7 @@ class TransactionController extends Controller * * @return JsonResponse * @throws FireflyException + * @throws \JsonException */ public function categories(string $objectType, Carbon $start, Carbon $end) { @@ -158,6 +160,7 @@ class TransactionController extends Controller * * @return JsonResponse * @throws FireflyException + * @throws \JsonException */ public function destinationAccounts(string $objectType, Carbon $start, Carbon $end) { @@ -215,6 +218,7 @@ class TransactionController extends Controller * * @return JsonResponse * @throws FireflyException + * @throws \JsonException */ public function sourceAccounts(string $objectType, Carbon $start, Carbon $end) { diff --git a/app/Http/Controllers/CurrencyController.php b/app/Http/Controllers/CurrencyController.php index 3b04b612b9..22cd0a8cba 100644 --- a/app/Http/Controllers/CurrencyController.php +++ b/app/Http/Controllers/CurrencyController.php @@ -99,10 +99,10 @@ class CurrencyController extends Controller /** * Make currency the default currency. * - * @param Request $request - * @param TransactionCurrency $currency + * @param Request $request * * @return RedirectResponse|Redirector + * @throws FireflyException */ public function defaultCurrency(Request $request) { @@ -328,6 +328,7 @@ class CurrencyController extends Controller * @param Request $request * * @return Factory|View + * @throws FireflyException */ public function index(Request $request) { diff --git a/app/Http/Controllers/Export/IndexController.php b/app/Http/Controllers/Export/IndexController.php index 8e8b201e0e..04d7d56322 100644 --- a/app/Http/Controllers/Export/IndexController.php +++ b/app/Http/Controllers/Export/IndexController.php @@ -67,9 +67,7 @@ class IndexController extends Controller /** * @return LaravelResponse - * @throws CannotInsertRecord * @throws FireflyException - * @throws Exception */ public function export(): LaravelResponse { diff --git a/app/Http/Controllers/HelpController.php b/app/Http/Controllers/HelpController.php index f14958df16..ecd2205c86 100644 --- a/app/Http/Controllers/HelpController.php +++ b/app/Http/Controllers/HelpController.php @@ -35,6 +35,7 @@ class HelpController extends Controller * @param string $route * * @return JsonResponse + * @throws \FireflyIII\Exceptions\FireflyException */ public function show(string $route): JsonResponse { diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index cc5f6c3bdf..1a402722c1 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -28,17 +28,12 @@ use FireflyIII\Events\RequestedVersionCheckStatus; use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Http\Middleware\Installer; use FireflyIII\Models\AccountType; -use FireflyIII\Models\GroupMembership; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Bill\BillRepositoryInterface; use FireflyIII\User; -use Illuminate\Contracts\View\Factory; use Illuminate\Http\JsonResponse; -use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Routing\Redirector; use Illuminate\Support\Collection; -use Illuminate\View\View; use Log; /** diff --git a/app/Http/Controllers/JavascriptController.php b/app/Http/Controllers/JavascriptController.php index 33b15b8fcf..c457ba4042 100644 --- a/app/Http/Controllers/JavascriptController.php +++ b/app/Http/Controllers/JavascriptController.php @@ -46,6 +46,7 @@ class JavascriptController extends Controller * @param CurrencyRepositoryInterface $currencyRepository * * @return Response + * @throws \FireflyIII\Exceptions\FireflyException */ public function accounts(AccountRepositoryInterface $repository, CurrencyRepositoryInterface $currencyRepository): Response { @@ -128,6 +129,7 @@ class JavascriptController extends Controller * @param CurrencyRepositoryInterface $currencyRepository * * @return Response + * @throws \FireflyIII\Exceptions\FireflyException */ public function variables(Request $request, AccountRepositoryInterface $repository, CurrencyRepositoryInterface $currencyRepository): Response { diff --git a/app/Http/Controllers/Json/AutoCompleteController.php b/app/Http/Controllers/Json/AutoCompleteController.php index 98d6fa09a4..86bd5603b2 100644 --- a/app/Http/Controllers/Json/AutoCompleteController.php +++ b/app/Http/Controllers/Json/AutoCompleteController.php @@ -23,10 +23,6 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Json; use FireflyIII\Http\Controllers\Controller; -use FireflyIII\Repositories\Journal\JournalRepositoryInterface; -use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface; -use Illuminate\Http\JsonResponse; -use Illuminate\Http\Request; /** * Class AutoCompleteController. diff --git a/app/Http/Controllers/Json/BoxController.php b/app/Http/Controllers/Json/BoxController.php index 03c6c9b020..ad12df6ad3 100644 --- a/app/Http/Controllers/Json/BoxController.php +++ b/app/Http/Controllers/Json/BoxController.php @@ -51,6 +51,7 @@ class BoxController extends Controller * 2) if the user has no available amount set this period: spent per day * * @return JsonResponse + * @throws \JsonException */ public function available(): JsonResponse { @@ -129,6 +130,7 @@ class BoxController extends Controller * @param CurrencyRepositoryInterface $repository * * @return JsonResponse + * @throws \JsonException */ public function balance(CurrencyRepositoryInterface $repository): JsonResponse { diff --git a/app/Http/Controllers/Json/IntroController.php b/app/Http/Controllers/Json/IntroController.php index 18c259a3d5..d7164428c8 100644 --- a/app/Http/Controllers/Json/IntroController.php +++ b/app/Http/Controllers/Json/IntroController.php @@ -103,6 +103,7 @@ class IntroController extends Controller * @param string|null $specialPage * * @return JsonResponse + * @throws \FireflyIII\Exceptions\FireflyException */ public function postEnable(string $route, string $specialPage = null): JsonResponse { @@ -126,6 +127,7 @@ class IntroController extends Controller * @param string|null $specialPage * * @return JsonResponse + * @throws \FireflyIII\Exceptions\FireflyException */ public function postFinished(string $route, string $specialPage = null): JsonResponse { diff --git a/app/Http/Controllers/Json/ReconcileController.php b/app/Http/Controllers/Json/ReconcileController.php index 66ea1b5256..2b328a7d62 100644 --- a/app/Http/Controllers/Json/ReconcileController.php +++ b/app/Http/Controllers/Json/ReconcileController.php @@ -215,7 +215,8 @@ class ReconcileController extends Controller * @param Carbon $end * * @return JsonResponse - * + * @throws \FireflyIII\Exceptions\FireflyException + * @throws \JsonException */ public function transactions(Account $account, Carbon $start, Carbon $end) { diff --git a/app/Http/Controllers/NewUserController.php b/app/Http/Controllers/NewUserController.php index 9b6d005cce..8aa942ec82 100644 --- a/app/Http/Controllers/NewUserController.php +++ b/app/Http/Controllers/NewUserController.php @@ -86,6 +86,7 @@ class NewUserController extends Controller * @param CurrencyRepositoryInterface $currencyRepository * * @return RedirectResponse|Redirector + * @throws \FireflyIII\Exceptions\FireflyException */ public function submit(NewUserFormRequest $request, CurrencyRepositoryInterface $currencyRepository) { diff --git a/app/Http/Controllers/ObjectGroup/IndexController.php b/app/Http/Controllers/ObjectGroup/IndexController.php index 0d159d4754..6bc9805282 100644 --- a/app/Http/Controllers/ObjectGroup/IndexController.php +++ b/app/Http/Controllers/ObjectGroup/IndexController.php @@ -27,11 +27,9 @@ namespace FireflyIII\Http\Controllers\ObjectGroup; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Models\ObjectGroup; use FireflyIII\Repositories\ObjectGroup\ObjectGroupRepositoryInterface; -use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\View\Factory; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; -use Illuminate\View\View; use Log; /** diff --git a/app/Http/Controllers/Popup/ReportController.php b/app/Http/Controllers/Popup/ReportController.php index b6089d1976..1b4d64d685 100644 --- a/app/Http/Controllers/Popup/ReportController.php +++ b/app/Http/Controllers/Popup/ReportController.php @@ -51,26 +51,14 @@ class ReportController extends Controller app('view')->share('start', $attributes['startDate']); app('view')->share('end', $attributes['endDate']); - switch ($attributes['location']) { - default: - $html = sprintf('Firefly III cannot handle "%s"-popups.', $attributes['location']); - break; - case 'budget-spent-amount': - $html = $this->budgetSpentAmount($attributes); - break; - case 'expense-entry': - $html = $this->expenseEntry($attributes); - break; - case 'income-entry': - $html = $this->incomeEntry($attributes); - break; - case 'category-entry': - $html = $this->categoryEntry($attributes); - break; - case 'budget-entry': - $html = $this->budgetEntry($attributes); - break; - } + $html = match ($attributes['location']) { + default => sprintf('Firefly III cannot handle "%s"-popups.', $attributes['location']), + 'budget-spent-amount' => $this->budgetSpentAmount($attributes), + 'expense-entry' => $this->expenseEntry($attributes), + 'income-entry' => $this->incomeEntry($attributes), + 'category-entry' => $this->categoryEntry($attributes), + 'budget-entry' => $this->budgetEntry($attributes), + }; return response()->json(['html' => $html]); } diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php index be5de919b9..9cc2850941 100644 --- a/app/Http/Controllers/PreferencesController.php +++ b/app/Http/Controllers/PreferencesController.php @@ -64,6 +64,7 @@ class PreferencesController extends Controller * @param AccountRepositoryInterface $repository * * @return Factory|View + * @throws \FireflyIII\Exceptions\FireflyException */ public function index(AccountRepositoryInterface $repository) { @@ -144,7 +145,7 @@ class PreferencesController extends Controller * @param Request $request * * @return RedirectResponse|Redirector - * + * @throws \FireflyIII\Exceptions\FireflyException */ public function postIndex(Request $request) { diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 890708eb06..469138d1e0 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -389,7 +389,10 @@ class ProfileController extends Controller } /** + * @param Request $request + * * @return Factory|View + * @throws FireflyException */ public function newBackupCodes(Request $request) { @@ -506,6 +509,7 @@ class ProfileController extends Controller * @param TokenFormRequest $request * * @return RedirectResponse|Redirector + * @throws FireflyException */ public function postCode(TokenFormRequest $request) { @@ -657,9 +661,10 @@ class ProfileController extends Controller } /** -* See reference nr. 64 + * See reference nr. 64 * * @param string $mfaCode + * @throws FireflyException */ private function addToMFAHistory(string $mfaCode): void { diff --git a/app/Http/Controllers/Report/AccountController.php b/app/Http/Controllers/Report/AccountController.php index 2bd37602a3..0f8b992b97 100644 --- a/app/Http/Controllers/Report/AccountController.php +++ b/app/Http/Controllers/Report/AccountController.php @@ -44,7 +44,7 @@ class AccountController extends Controller * @param Carbon $end * * @return mixed|string - * + * @throws \JsonException */ public function general(Collection $accounts, Carbon $start, Carbon $end) { diff --git a/app/Http/Controllers/Report/BudgetController.php b/app/Http/Controllers/Report/BudgetController.php index b0c17a6ef5..eadfe8866f 100644 --- a/app/Http/Controllers/Report/BudgetController.php +++ b/app/Http/Controllers/Report/BudgetController.php @@ -307,6 +307,7 @@ class BudgetController extends Controller * @param Carbon $end * * @return mixed|string + * @throws \JsonException */ public function period(Collection $accounts, Carbon $start, Carbon $end) { diff --git a/app/Http/Controllers/Report/CategoryController.php b/app/Http/Controllers/Report/CategoryController.php index 17b2b7e0f9..c8a0fce6c4 100644 --- a/app/Http/Controllers/Report/CategoryController.php +++ b/app/Http/Controllers/Report/CategoryController.php @@ -488,6 +488,7 @@ class CategoryController extends Controller * @param Carbon $end * * @return mixed|string + * @throws \JsonException */ public function expenses(Collection $accounts, Carbon $start, Carbon $end) { @@ -568,6 +569,7 @@ class CategoryController extends Controller * @param Carbon $end * * @return string + * @throws \JsonException */ public function income(Collection $accounts, Carbon $start, Carbon $end): string { @@ -646,7 +648,7 @@ class CategoryController extends Controller * @param Carbon $end * * @return mixed|string - * + * @throws \JsonException */ public function operations(Collection $accounts, Carbon $start, Carbon $end) { diff --git a/app/Http/Controllers/Report/OperationsController.php b/app/Http/Controllers/Report/OperationsController.php index 2863f049df..63e5b3bdd9 100644 --- a/app/Http/Controllers/Report/OperationsController.php +++ b/app/Http/Controllers/Report/OperationsController.php @@ -66,6 +66,7 @@ class OperationsController extends Controller * @param Carbon $end * * @return mixed|string + * @throws \JsonException */ public function expenses(Collection $accounts, Carbon $start, Carbon $end) { @@ -101,6 +102,7 @@ class OperationsController extends Controller * @param Carbon $end * * @return string + * @throws \JsonException */ public function income(Collection $accounts, Carbon $start, Carbon $end): string { @@ -136,6 +138,7 @@ class OperationsController extends Controller * @param Carbon $end * * @return mixed|string + * @throws \JsonException */ public function operations(Collection $accounts, Carbon $start, Carbon $end) { diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index ad67bb0ede..79c97dbec1 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -260,6 +260,7 @@ class ReportController extends Controller * @param AccountRepositoryInterface $repository * * @return Factory|View + * @throws FireflyException */ public function index(AccountRepositoryInterface $repository) { @@ -305,23 +306,13 @@ class ReportController extends Controller */ public function options(string $reportType) { - switch ($reportType) { - default: - $result = $this->noReportOptions(); - break; - case 'category': - $result = $this->categoryReportOptions(); - break; - case 'budget': - $result = $this->budgetReportOptions(); - break; - case 'tag': - $result = $this->tagReportOptions(); - break; - case 'double': - $result = $this->doubleReportOptions(); - break; - } + $result = match ($reportType) { + default => $this->noReportOptions(), + 'category' => $this->categoryReportOptions(), + 'budget' => $this->budgetReportOptions(), + 'tag' => $this->tagReportOptions(), + 'double' => $this->doubleReportOptions(), + }; return response()->json(['html' => $result]); } @@ -383,27 +374,14 @@ class ReportController extends Controller return prefixView('error')->with('message', (string)trans('firefly.end_after_start_date')); } - switch ($reportType) { - default: - case 'default': - $uri = route('reports.report.default', [$accounts, $start, $end]); - break; - case 'category': - $uri = route('reports.report.category', [$accounts, $categories, $start, $end]); - break; - case 'audit': - $uri = route('reports.report.audit', [$accounts, $start, $end]); - break; - case 'budget': - $uri = route('reports.report.budget', [$accounts, $budgets, $start, $end]); - break; - case 'tag': - $uri = route('reports.report.tag', [$accounts, $tags, $start, $end]); - break; - case 'double': - $uri = route('reports.report.double', [$accounts, $double, $start, $end]); - break; - } + $uri = match ($reportType) { + default => route('reports.report.default', [$accounts, $start, $end]), + 'category' => route('reports.report.category', [$accounts, $categories, $start, $end]), + 'audit' => route('reports.report.audit', [$accounts, $start, $end]), + 'budget' => route('reports.report.budget', [$accounts, $budgets, $start, $end]), + 'tag' => route('reports.report.tag', [$accounts, $tags, $start, $end]), + 'double' => route('reports.report.double', [$accounts, $double, $start, $end]), + }; return redirect($uri); } diff --git a/app/Http/Controllers/Rule/IndexController.php b/app/Http/Controllers/Rule/IndexController.php index b680cbb134..3826c02cbc 100644 --- a/app/Http/Controllers/Rule/IndexController.php +++ b/app/Http/Controllers/Rule/IndexController.php @@ -22,14 +22,12 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Rule; -use FireflyIII\Exceptions\FireflyException; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Models\Rule; use FireflyIII\Models\RuleGroup; use FireflyIII\Repositories\Rule\RuleRepositoryInterface; use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface; use FireflyIII\Support\Http\Controllers\RuleManagement; -use FireflyIII\User; use Illuminate\Contracts\View\Factory; use Illuminate\Http\JsonResponse; use Illuminate\Http\RedirectResponse; diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index 50d03d9407..8dbba9e584 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -272,7 +272,7 @@ class TagController extends Controller * @param Tag $tag * * @return Factory|View - * + * @throws FireflyException */ public function showAll(Request $request, Tag $tag) { diff --git a/app/Http/Controllers/Transaction/CreateController.php b/app/Http/Controllers/Transaction/CreateController.php index 3ed7ff63c7..ec36340853 100644 --- a/app/Http/Controllers/Transaction/CreateController.php +++ b/app/Http/Controllers/Transaction/CreateController.php @@ -31,7 +31,6 @@ use FireflyIII\Services\Internal\Update\GroupCloneService; use Illuminate\Contracts\View\Factory; use Illuminate\Http\RedirectResponse; use Illuminate\Routing\Redirector; -use Illuminate\View\View; /** * Class CreateController @@ -88,6 +87,7 @@ class CreateController extends Controller * @param string|null $objectType * * @return Factory|\Illuminate\Contracts\View\View + * @throws \FireflyIII\Exceptions\FireflyException */ public function create(?string $objectType) { diff --git a/app/Http/Middleware/InstallationId.php b/app/Http/Middleware/InstallationId.php index 10985827d6..7a741e9ea6 100644 --- a/app/Http/Middleware/InstallationId.php +++ b/app/Http/Middleware/InstallationId.php @@ -24,7 +24,6 @@ declare(strict_types=1); namespace FireflyIII\Http\Middleware; use Closure; -use FireflyIII\Exceptions\FireflyException; use FireflyIII\Support\System\GeneratesInstallationId; use Illuminate\Http\Request; diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php index 27c60f65b1..77bc9e6256 100644 --- a/app/Http/Middleware/TrustProxies.php +++ b/app/Http/Middleware/TrustProxies.php @@ -24,7 +24,6 @@ namespace FireflyIII\Http\Middleware; use Fideloper\Proxy\TrustProxies as Middleware; use Illuminate\Contracts\Config\Repository; -use Illuminate\Http\Request; /** * Class TrustProxies diff --git a/app/Jobs/CreateRecurringTransactions.php b/app/Jobs/CreateRecurringTransactions.php index 86254f57eb..081cd65162 100644 --- a/app/Jobs/CreateRecurringTransactions.php +++ b/app/Jobs/CreateRecurringTransactions.php @@ -328,6 +328,8 @@ class CreateRecurringTransactions implements ShouldQueue * @param array $occurrences * * @return Collection + * @throws DuplicateTransactionException + * @throws FireflyException */ private function handleOccurrences(Recurrence $recurrence, RecurrenceRepetition $repetition, array $occurrences): Collection { diff --git a/app/Models/GroupMembership.php b/app/Models/GroupMembership.php index 93ab42b00d..1af5447862 100644 --- a/app/Models/GroupMembership.php +++ b/app/Models/GroupMembership.php @@ -34,16 +34,16 @@ use Illuminate\Support\Carbon; /** * Class GroupMembership * - * @property int $id - * @property Carbon|null $created_at - * @property Carbon|null $updated_at - * @property string|null $deleted_at - * @property int $user_id - * @property int $user_group_id - * @property int $user_role_id - * @property-read User $user - * @property-read \FireflyIII\Models\UserGroup $userGroup - * @property-read \FireflyIII\Models\UserRole $userRole + * @property int $id + * @property Carbon|null $created_at + * @property Carbon|null $updated_at + * @property string|null $deleted_at + * @property int $user_id + * @property int $user_group_id + * @property int $user_role_id + * @property-read User $user + * @property-read UserGroup $userGroup + * @property-read UserRole $userRole * @method static Builder|GroupMembership newModelQuery() * @method static Builder|GroupMembership newQuery() * @method static Builder|GroupMembership query() diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php index 70963b2ad4..f89805655a 100644 --- a/app/Models/TransactionJournal.php +++ b/app/Models/TransactionJournal.php @@ -156,7 +156,6 @@ class TransactionJournal extends Model * @param string $value * * @return TransactionJournal - * @throws FireflyException * @throws NotFoundHttpException */ public static function routeBinder(string $value): TransactionJournal diff --git a/app/Models/UserGroup.php b/app/Models/UserGroup.php index f5d247c6f8..4ebc662242 100644 --- a/app/Models/UserGroup.php +++ b/app/Models/UserGroup.php @@ -34,13 +34,13 @@ use Illuminate\Support\Carbon; /** * Class UserGroup * - * @property int $id - * @property Carbon|null $created_at - * @property Carbon|null $updated_at - * @property string|null $deleted_at - * @property string $title - * @property-read Collection|\FireflyIII\Models\GroupMembership[] $groupMemberships - * @property-read int|null $group_memberships_count + * @property int $id + * @property Carbon|null $created_at + * @property Carbon|null $updated_at + * @property string|null $deleted_at + * @property string $title + * @property-read Collection|GroupMembership[] $groupMemberships + * @property-read int|null $group_memberships_count * @method static Builder|UserGroup newModelQuery() * @method static Builder|UserGroup newQuery() * @method static Builder|UserGroup query() diff --git a/app/Models/UserRole.php b/app/Models/UserRole.php index b8e49ad67b..ca51556d1c 100644 --- a/app/Models/UserRole.php +++ b/app/Models/UserRole.php @@ -34,13 +34,13 @@ use Illuminate\Support\Carbon; /** * Class UserRole * - * @property int $id - * @property Carbon|null $created_at - * @property Carbon|null $updated_at - * @property string|null $deleted_at - * @property string $title - * @property-read Collection|\FireflyIII\Models\GroupMembership[] $groupMemberships - * @property-read int|null $group_memberships_count + * @property int $id + * @property Carbon|null $created_at + * @property Carbon|null $updated_at + * @property string|null $deleted_at + * @property string $title + * @property-read Collection|GroupMembership[] $groupMemberships + * @property-read int|null $group_memberships_count * @method static Builder|UserRole newModelQuery() * @method static Builder|UserRole newQuery() * @method static Builder|UserRole query() diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index 096545ff0d..4cbd918fbe 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -730,6 +730,8 @@ class AccountRepository implements AccountRepositoryInterface * @param array $data * * @return Account + * @throws FireflyException + * @throws \JsonException */ public function update(Account $account, array $data): Account { diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php index 725a241203..482448deda 100644 --- a/app/Repositories/Bill/BillRepository.php +++ b/app/Repositories/Bill/BillRepository.php @@ -623,6 +623,7 @@ class BillRepository implements BillRepositoryInterface * @param Carbon $date * * @return Carbon + * @throws \JsonException */ public function nextDateMatch(Bill $bill, Carbon $date): Carbon { @@ -651,6 +652,7 @@ class BillRepository implements BillRepositoryInterface * @param Carbon $date * * @return Carbon + * @throws \JsonException */ public function nextExpectedMatch(Bill $bill, Carbon $date): Carbon { diff --git a/app/Repositories/Budget/AvailableBudgetRepository.php b/app/Repositories/Budget/AvailableBudgetRepository.php index 25afeb262d..690e9ca75b 100644 --- a/app/Repositories/Budget/AvailableBudgetRepository.php +++ b/app/Repositories/Budget/AvailableBudgetRepository.php @@ -30,7 +30,6 @@ use FireflyIII\Models\TransactionCurrency; use FireflyIII\User; use Illuminate\Database\Eloquent\Builder; use Illuminate\Support\Collection; -use Log; /** * diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.php index e90246c5c6..30bec9642b 100644 --- a/app/Repositories/Category/CategoryRepository.php +++ b/app/Repositories/Category/CategoryRepository.php @@ -309,6 +309,7 @@ class CategoryRepository implements CategoryRepositoryInterface * @param array $data * * @return Category + * @throws Exception */ public function update(Category $category, array $data): Category { diff --git a/app/Repositories/Currency/CurrencyRepository.php b/app/Repositories/Currency/CurrencyRepository.php index ea30208170..456008442b 100644 --- a/app/Repositories/Currency/CurrencyRepository.php +++ b/app/Repositories/Currency/CurrencyRepository.php @@ -65,6 +65,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface * @param TransactionCurrency $currency * * @return bool + * @throws FireflyException */ public function currencyInUse(TransactionCurrency $currency): bool { diff --git a/app/Repositories/Journal/JournalCLIRepository.php b/app/Repositories/Journal/JournalCLIRepository.php index 53d7294f09..fd1dd5aa29 100644 --- a/app/Repositories/Journal/JournalCLIRepository.php +++ b/app/Repositories/Journal/JournalCLIRepository.php @@ -117,6 +117,7 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface * @param string $field * * @return null|Carbon + * @throws \JsonException */ public function getMetaDate(TransactionJournal $journal, string $field): ?Carbon { @@ -160,6 +161,7 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface * @param string $field * * @return null|string + * @throws \JsonException */ public function getMetaField(TransactionJournal $journal, string $field): ?string { diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php index 8bb0e7c0a2..539c63ef59 100644 --- a/app/Repositories/Journal/JournalRepository.php +++ b/app/Repositories/Journal/JournalRepository.php @@ -129,6 +129,7 @@ class JournalRepository implements JournalRepositoryInterface * @param TransactionJournal $journal * * @return string + * @throws \JsonException */ public function getJournalTotal(TransactionJournal $journal): string { @@ -185,6 +186,7 @@ class JournalRepository implements JournalRepositoryInterface * @param string $field * * @return null|Carbon + * @throws \JsonException */ public function getMetaDateById(int $journalId, string $field): ?Carbon { diff --git a/app/Repositories/ObjectGroup/CreatesObjectGroups.php b/app/Repositories/ObjectGroup/CreatesObjectGroups.php index 2a25e58ab8..69fadd48d0 100644 --- a/app/Repositories/ObjectGroup/CreatesObjectGroups.php +++ b/app/Repositories/ObjectGroup/CreatesObjectGroups.php @@ -25,7 +25,6 @@ declare(strict_types=1); namespace FireflyIII\Repositories\ObjectGroup; use FireflyIII\Models\ObjectGroup; -use FireflyIII\User; /** * Trait CreatesObjectGroups diff --git a/app/Repositories/User/UserRepository.php b/app/Repositories/User/UserRepository.php index 7eb42fe1e6..45232e4af8 100644 --- a/app/Repositories/User/UserRepository.php +++ b/app/Repositories/User/UserRepository.php @@ -348,6 +348,7 @@ class UserRepository implements UserRepositoryInterface * @param array $data * * @return User + * @throws FireflyException */ public function update(User $user, array $data): User { diff --git a/app/Rules/IsValidBulkClause.php b/app/Rules/IsValidBulkClause.php index d10b78c0dd..b01201c6c9 100644 --- a/app/Rules/IsValidBulkClause.php +++ b/app/Rules/IsValidBulkClause.php @@ -71,6 +71,8 @@ class IsValidBulkClause implements Rule /** * Does basic rule based validation. * + * @param string $value + * * @return bool */ private function basicValidation(string $value): bool diff --git a/app/Services/FireflyIIIOrg/Update/UpdateRequest.php b/app/Services/FireflyIIIOrg/Update/UpdateRequest.php index f5d1a9a27f..7aed47deb5 100644 --- a/app/Services/FireflyIIIOrg/Update/UpdateRequest.php +++ b/app/Services/FireflyIIIOrg/Update/UpdateRequest.php @@ -25,7 +25,6 @@ declare(strict_types=1); namespace FireflyIII\Services\FireflyIIIOrg\Update; use Carbon\Carbon; -use Exception; use GuzzleHttp\Client; use GuzzleHttp\Exception\GuzzleException; use JsonException; diff --git a/app/Services/Internal/Destroy/BillDestroyService.php b/app/Services/Internal/Destroy/BillDestroyService.php index e9719679bb..bc97716159 100644 --- a/app/Services/Internal/Destroy/BillDestroyService.php +++ b/app/Services/Internal/Destroy/BillDestroyService.php @@ -25,7 +25,6 @@ namespace FireflyIII\Services\Internal\Destroy; use Exception; use FireflyIII\Models\Bill; -use Log; /** * @codeCoverageIgnore diff --git a/app/Services/Internal/Destroy/BudgetDestroyService.php b/app/Services/Internal/Destroy/BudgetDestroyService.php index aa8c4190d8..f1335cd7c1 100644 --- a/app/Services/Internal/Destroy/BudgetDestroyService.php +++ b/app/Services/Internal/Destroy/BudgetDestroyService.php @@ -26,7 +26,6 @@ namespace FireflyIII\Services\Internal\Destroy; use DB; use Exception; use FireflyIII\Models\Budget; -use Log; /** * Class BudgetDestroyService diff --git a/app/Services/Internal/Destroy/CategoryDestroyService.php b/app/Services/Internal/Destroy/CategoryDestroyService.php index e93240f104..adb3f92f2c 100644 --- a/app/Services/Internal/Destroy/CategoryDestroyService.php +++ b/app/Services/Internal/Destroy/CategoryDestroyService.php @@ -26,7 +26,6 @@ namespace FireflyIII\Services\Internal\Destroy; use DB; use Exception; use FireflyIII\Models\Category; -use Log; /** * Class CategoryDestroyService diff --git a/app/Services/Internal/Destroy/CurrencyDestroyService.php b/app/Services/Internal/Destroy/CurrencyDestroyService.php index 53bf9026ff..a655c82919 100644 --- a/app/Services/Internal/Destroy/CurrencyDestroyService.php +++ b/app/Services/Internal/Destroy/CurrencyDestroyService.php @@ -25,7 +25,6 @@ namespace FireflyIII\Services\Internal\Destroy; use Exception; use FireflyIII\Models\TransactionCurrency; -use Log; /** * Class CurrencyDestroyService diff --git a/app/Services/Internal/Destroy/RecurrenceDestroyService.php b/app/Services/Internal/Destroy/RecurrenceDestroyService.php index efa7d95f46..5a4ac788c5 100644 --- a/app/Services/Internal/Destroy/RecurrenceDestroyService.php +++ b/app/Services/Internal/Destroy/RecurrenceDestroyService.php @@ -26,7 +26,6 @@ namespace FireflyIII\Services\Internal\Destroy; use Exception; use FireflyIII\Models\Recurrence; use FireflyIII\Models\RecurrenceTransaction; -use Log; /** * @codeCoverageIgnore diff --git a/app/Services/Internal/Support/AccountServiceTrait.php b/app/Services/Internal/Support/AccountServiceTrait.php index 3305501129..5fdd24e19e 100644 --- a/app/Services/Internal/Support/AccountServiceTrait.php +++ b/app/Services/Internal/Support/AccountServiceTrait.php @@ -39,7 +39,6 @@ use FireflyIII\Models\TransactionGroup; use FireflyIII\Models\TransactionJournal; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Services\Internal\Destroy\TransactionGroupDestroyService; -use JsonException; use Log; use Validator; diff --git a/app/Services/Internal/Support/BillServiceTrait.php b/app/Services/Internal/Support/BillServiceTrait.php index 9df0a307dc..65c232481c 100644 --- a/app/Services/Internal/Support/BillServiceTrait.php +++ b/app/Services/Internal/Support/BillServiceTrait.php @@ -27,7 +27,6 @@ use Exception; use FireflyIII\Models\Bill; use FireflyIII\Models\Note; use FireflyIII\Models\RuleAction; -use Illuminate\Support\Collection; use Log; /** diff --git a/app/Services/Internal/Support/CreditRecalculateService.php b/app/Services/Internal/Support/CreditRecalculateService.php index 7c50885384..300fda53ae 100644 --- a/app/Services/Internal/Support/CreditRecalculateService.php +++ b/app/Services/Internal/Support/CreditRecalculateService.php @@ -262,7 +262,7 @@ class CreditRecalculateService // if it's a credit, we don't care, because sending more money // to a credit-liability doesn't increase the amount (yet) if ( - in_array($type, [TransactionType::WITHDRAWAL]) + $type === TransactionType::WITHDRAWAL && (int)$account->id === (int)$transaction->account_id && 1 === bccomp($transaction->amount, '0') && 'credit' === $direction @@ -274,7 +274,7 @@ class CreditRecalculateService // likewise deposit into a credit debt does not change the amount if ( - in_array($type, [TransactionType::DEPOSIT]) + $type === TransactionType::DEPOSIT && (int)$account->id === (int)$transaction->account_id && -1 === bccomp($transaction->amount, '0') && 'credit' === $direction diff --git a/app/Services/Internal/Update/AccountUpdateService.php b/app/Services/Internal/Update/AccountUpdateService.php index e9341d8f7b..7c45a6a5d7 100644 --- a/app/Services/Internal/Update/AccountUpdateService.php +++ b/app/Services/Internal/Update/AccountUpdateService.php @@ -79,7 +79,6 @@ class AccountUpdateService * * @return Account * @throws FireflyException - * @throws JsonException */ public function update(Account $account, array $data): Account { diff --git a/app/Services/Internal/Update/GroupUpdateService.php b/app/Services/Internal/Update/GroupUpdateService.php index d15c4c5984..7b0a196827 100644 --- a/app/Services/Internal/Update/GroupUpdateService.php +++ b/app/Services/Internal/Update/GroupUpdateService.php @@ -122,6 +122,7 @@ class GroupUpdateService * @param array $transactions * * @return array + * @throws DuplicateTransactionException * @throws FireflyException */ private function updateTransactions(TransactionGroup $transactionGroup, array $transactions): array diff --git a/app/Support/Amount.php b/app/Support/Amount.php index 83096f79f2..7bea63e335 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -109,6 +109,8 @@ class Amount /** * @return string + * @throws \FireflyIII\Exceptions\FireflyException + * @throws \JsonException */ public function getCurrencyCode(): string { @@ -145,6 +147,8 @@ class Amount * @param User $user * * @return TransactionCurrency + * @throws \FireflyIII\Exceptions\FireflyException + * @throws \JsonException */ public function getDefaultCurrencyByUser(User $user): TransactionCurrency { diff --git a/app/Support/Authentication/RemoteUserGuard.php b/app/Support/Authentication/RemoteUserGuard.php index 61fda41a26..e5cd72cdc9 100644 --- a/app/Support/Authentication/RemoteUserGuard.php +++ b/app/Support/Authentication/RemoteUserGuard.php @@ -44,8 +44,7 @@ class RemoteUserGuard implements Guard * Create a new authentication guard. * * @param UserProvider $provider - * - * @return void + * @param Application $app */ // @phpstan-ignore-next-line public function __construct(UserProvider $provider, Application $app) // @phpstan-ignore-line diff --git a/app/Support/CacheProperties.php b/app/Support/CacheProperties.php index 7eb90f8927..0d95c386a5 100644 --- a/app/Support/CacheProperties.php +++ b/app/Support/CacheProperties.php @@ -74,7 +74,6 @@ class CacheProperties /** * @return bool - * @throws JsonException */ public function has(): bool { diff --git a/app/Support/Cronjobs/AbstractCronjob.php b/app/Support/Cronjobs/AbstractCronjob.php index 19a5ae44a2..45cdce0a98 100644 --- a/app/Support/Cronjobs/AbstractCronjob.php +++ b/app/Support/Cronjobs/AbstractCronjob.php @@ -24,8 +24,6 @@ declare(strict_types=1); namespace FireflyIII\Support\Cronjobs; use Carbon\Carbon; -use Exception; -use FireflyIII\Exceptions\FireflyException; /** * Class AbstractCronjob diff --git a/app/Support/Http/Controllers/AugumentData.php b/app/Support/Http/Controllers/AugumentData.php index 19c28683a4..7ef49e57cf 100644 --- a/app/Support/Http/Controllers/AugumentData.php +++ b/app/Support/Http/Controllers/AugumentData.php @@ -190,6 +190,7 @@ trait AugumentData * @param Carbon $end * * @return Collection + * @throws \JsonException */ protected function getLimits(Budget $budget, Carbon $start, Carbon $end): Collection // get data + augment with info { diff --git a/app/Support/Http/Controllers/ChartGeneration.php b/app/Support/Http/Controllers/ChartGeneration.php index d217867765..373aee5b73 100644 --- a/app/Support/Http/Controllers/ChartGeneration.php +++ b/app/Support/Http/Controllers/ChartGeneration.php @@ -45,7 +45,8 @@ trait ChartGeneration * @param Carbon $end * * @return array - * + * @throws \FireflyIII\Exceptions\FireflyException + * @throws \JsonException */ protected function accountBalanceChart(Collection $accounts, Carbon $start, Carbon $end): array // chart helper method. { diff --git a/app/Support/Http/Controllers/GetConfigurationData.php b/app/Support/Http/Controllers/GetConfigurationData.php index eb3d3bb1f2..5493ae41ee 100644 --- a/app/Support/Http/Controllers/GetConfigurationData.php +++ b/app/Support/Http/Controllers/GetConfigurationData.php @@ -85,7 +85,7 @@ trait GetConfigurationData * Get config for date range. * * @return array - * + * @throws \FireflyIII\Exceptions\FireflyException */ protected function getDateRangeConfig(): array // get configuration + get preferences. { diff --git a/app/Support/Http/Controllers/PeriodOverview.php b/app/Support/Http/Controllers/PeriodOverview.php index 90dfed5d71..da65f3bfa4 100644 --- a/app/Support/Http/Controllers/PeriodOverview.php +++ b/app/Support/Http/Controllers/PeriodOverview.php @@ -78,6 +78,7 @@ trait PeriodOverview * * @return array * @throws FireflyException + * @throws \JsonException */ protected function getAccountPeriodOverview(Account $account, Carbon $start, Carbon $end): array { @@ -269,6 +270,7 @@ trait PeriodOverview * * @return array * @throws FireflyException + * @throws \JsonException */ protected function getCategoryPeriodOverview(Category $category, Carbon $start, Carbon $end): array { @@ -347,6 +349,7 @@ trait PeriodOverview * * @return array * @throws FireflyException + * @throws \JsonException */ protected function getNoBudgetPeriodOverview(Carbon $start, Carbon $end): array { @@ -400,6 +403,7 @@ trait PeriodOverview * * @return array * @throws FireflyException + * @throws \JsonException */ protected function getNoCategoryPeriodOverview(Carbon $theDate): array { @@ -480,6 +484,7 @@ trait PeriodOverview * * @return array * @throws FireflyException + * @throws \JsonException */ protected function getTagPeriodOverview(Tag $tag, Carbon $start, Carbon $end): array // period overview for tags. { @@ -554,6 +559,7 @@ trait PeriodOverview * * @return array * @throws FireflyException + * @throws \JsonException */ protected function getTransactionPeriodOverview(string $transactionType, Carbon $start, Carbon $end): array { diff --git a/app/Support/Http/Controllers/RequestInformation.php b/app/Support/Http/Controllers/RequestInformation.php index 99ee491d86..280893eb71 100644 --- a/app/Support/Http/Controllers/RequestInformation.php +++ b/app/Support/Http/Controllers/RequestInformation.php @@ -162,6 +162,7 @@ trait RequestInformation * Returns if user has seen demo. * * @return bool + * @throws \FireflyIII\Exceptions\FireflyException */ final protected function hasSeenDemo(): bool // get request info + get preference { diff --git a/app/Support/Http/Controllers/RuleManagement.php b/app/Support/Http/Controllers/RuleManagement.php index 417ca46140..01ab4e63ff 100644 --- a/app/Support/Http/Controllers/RuleManagement.php +++ b/app/Support/Http/Controllers/RuleManagement.php @@ -23,7 +23,6 @@ declare(strict_types=1); namespace FireflyIII\Support\Http\Controllers; -use FireflyIII\Repositories\Rule\RuleRepositoryInterface; use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface; use FireflyIII\Support\Search\OperatorQuerySearch; use Illuminate\Http\Request; diff --git a/app/Support/ParseDateString.php b/app/Support/ParseDateString.php index 3fd64fe68c..3fe2b018fb 100644 --- a/app/Support/ParseDateString.php +++ b/app/Support/ParseDateString.php @@ -51,6 +51,7 @@ class ParseDateString * @param string $date * * @return Carbon + * @throws FireflyException */ public function parseDate(string $date): Carbon { @@ -265,31 +266,20 @@ class ParseDateString protected function parseKeyword(string $keyword): Carbon { $today = Carbon::today()->startOfDay(); - switch ($keyword) { - default: - case 'today': - return $today; - case 'yesterday': - return $today->subDay(); - case 'tomorrow': - return $today->addDay(); - case 'start of this week': - return $today->startOfWeek(); - case 'end of this week': - return $today->endOfWeek(); - case 'start of this month': - return $today->startOfMonth(); - case 'end of this month': - return $today->endOfMonth(); - case 'start of this quarter': - return $today->startOfQuarter(); - case 'end of this quarter': - return $today->endOfQuarter(); - case 'start of this year': - return $today->startOfYear(); - case 'end of this year': - return $today->endOfYear(); - } + + return match ($keyword) { + default => $today, + 'yesterday' => $today->subDay(), + 'tomorrow' => $today->addDay(), + 'start of this week' => $today->startOfWeek(), + 'end of this week' => $today->endOfWeek(), + 'start of this month' => $today->startOfMonth(), + 'end of this month' => $today->endOfMonth(), + 'start of this quarter' => $today->startOfQuarter(), + 'end of this quarter' => $today->endOfQuarter(), + 'start of this year' => $today->startOfYear(), + 'end of this year' => $today->endOfYear(), + }; } /** @@ -371,7 +361,6 @@ class ParseDateString ], ]; - /** @var string $part */ foreach ($parts as $part) { Log::debug(sprintf('Now parsing part "%s"', $part)); $part = trim($part); diff --git a/app/Support/Preferences.php b/app/Support/Preferences.php index dabd433bd7..de81c8e269 100644 --- a/app/Support/Preferences.php +++ b/app/Support/Preferences.php @@ -28,7 +28,6 @@ use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\Preference; use FireflyIII\User; use Illuminate\Support\Collection; -use Log; use PDOException; use Session; @@ -107,6 +106,7 @@ class Preferences * @param mixed $default * * @return Preference|null + * @throws FireflyException */ public function getFresh(string $name, $default = null): ?Preference { @@ -207,6 +207,7 @@ class Preferences /** * @return string + * @throws FireflyException */ public function lastActivity(): string { diff --git a/app/Support/Request/ConvertsDataTypes.php b/app/Support/Request/ConvertsDataTypes.php index 108413f963..880d8ed6f2 100644 --- a/app/Support/Request/ConvertsDataTypes.php +++ b/app/Support/Request/ConvertsDataTypes.php @@ -25,7 +25,6 @@ namespace FireflyIII\Support\Request; use Carbon\Carbon; use Carbon\Exceptions\InvalidFormatException; -use Exception; use Log; /** diff --git a/app/Support/Search/OperatorQuerySearch.php b/app/Support/Search/OperatorQuerySearch.php index 6a11e6a14a..002f96cb8e 100644 --- a/app/Support/Search/OperatorQuerySearch.php +++ b/app/Support/Search/OperatorQuerySearch.php @@ -166,7 +166,6 @@ class OperatorQuerySearch implements SearchInterface /** * @inheritDoc - * @throws FireflyException */ public function searchTransactions(): LengthAwarePaginator { diff --git a/app/Support/Steam.php b/app/Support/Steam.php index 62a0108b63..c912b1a556 100644 --- a/app/Support/Steam.php +++ b/app/Support/Steam.php @@ -49,7 +49,6 @@ class Steam * @param TransactionCurrency|null $currency * * @return string - * @throws FireflyException * @throws JsonException */ public function balance(Account $account, Carbon $date, ?TransactionCurrency $currency = null): string @@ -97,6 +96,7 @@ class Steam * @param Carbon $date * * @return string + * @throws JsonException */ public function balanceIgnoreVirtual(Account $account, Carbon $date): string { @@ -164,6 +164,8 @@ class Steam * @param TransactionCurrency|null $currency * * @return array + * @throws FireflyException + * @throws JsonException */ public function balanceInRange(Account $account, Carbon $start, Carbon $end, ?TransactionCurrency $currency = null): array { @@ -246,6 +248,7 @@ class Steam * @param Carbon $date * * @return array + * @throws JsonException */ public function balancePerCurrency(Account $account, Carbon $date): array { @@ -279,6 +282,8 @@ class Steam * @param Carbon $date * * @return array + * @throws FireflyException + * @throws JsonException */ public function balancesByAccounts(Collection $accounts, Carbon $date): array { @@ -311,6 +316,7 @@ class Steam * @param Carbon $date * * @return array + * @throws JsonException */ public function balancesPerCurrencyByAccounts(Collection $accounts, Carbon $date): array { @@ -444,6 +450,7 @@ class Steam * Get user's language. * * @return string + * @throws FireflyException */ public function getLanguage(): string // get preference { @@ -454,6 +461,7 @@ class Steam * Get user's locale. * * @return string + * @throws FireflyException */ public function getLocale(): string // get preference { diff --git a/app/TransactionRules/Actions/ClearBudget.php b/app/TransactionRules/Actions/ClearBudget.php index 0890a7ff59..c13996bbcd 100644 --- a/app/TransactionRules/Actions/ClearBudget.php +++ b/app/TransactionRules/Actions/ClearBudget.php @@ -23,7 +23,6 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; use DB; -use FireflyIII\Models\RuleAction; use Log; /** diff --git a/app/TransactionRules/Actions/ClearCategory.php b/app/TransactionRules/Actions/ClearCategory.php index 4650c09196..d32dc222db 100644 --- a/app/TransactionRules/Actions/ClearCategory.php +++ b/app/TransactionRules/Actions/ClearCategory.php @@ -23,7 +23,6 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; use DB; -use FireflyIII\Models\RuleAction; use Log; /** diff --git a/app/TransactionRules/Actions/ClearNotes.php b/app/TransactionRules/Actions/ClearNotes.php index 171803f074..d30466cd61 100644 --- a/app/TransactionRules/Actions/ClearNotes.php +++ b/app/TransactionRules/Actions/ClearNotes.php @@ -23,7 +23,6 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; use DB; -use FireflyIII\Models\RuleAction; use FireflyIII\Models\TransactionJournal; use Log; diff --git a/app/TransactionRules/Actions/SetDestinationAccount.php b/app/TransactionRules/Actions/SetDestinationAccount.php index fe87c4b8a1..bcb1a776a5 100644 --- a/app/TransactionRules/Actions/SetDestinationAccount.php +++ b/app/TransactionRules/Actions/SetDestinationAccount.php @@ -24,7 +24,6 @@ namespace FireflyIII\TransactionRules\Actions; use DB; use FireflyIII\Models\Account; -use FireflyIII\Models\AccountType; use FireflyIII\Models\RuleAction; use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionJournal; diff --git a/app/TransactionRules/Engine/SearchRuleEngine.php b/app/TransactionRules/Engine/SearchRuleEngine.php index 45febf39a1..0604f46076 100644 --- a/app/TransactionRules/Engine/SearchRuleEngine.php +++ b/app/TransactionRules/Engine/SearchRuleEngine.php @@ -527,6 +527,7 @@ class SearchRuleEngine implements RuleEngineInterface * @param RuleGroup $group * * @return bool + * @throws FireflyException */ private function fireGroup(RuleGroup $group): bool { diff --git a/app/Transformers/AccountTransformer.php b/app/Transformers/AccountTransformer.php index 466d657e88..438f066229 100644 --- a/app/Transformers/AccountTransformer.php +++ b/app/Transformers/AccountTransformer.php @@ -51,6 +51,8 @@ class AccountTransformer extends AbstractTransformer * @param Account $account * * @return array + * @throws \FireflyIII\Exceptions\FireflyException + * @throws \JsonException */ public function transform(Account $account): array { diff --git a/app/Transformers/AttachmentTransformer.php b/app/Transformers/AttachmentTransformer.php index d1aef15bfa..2d579f01cb 100644 --- a/app/Transformers/AttachmentTransformer.php +++ b/app/Transformers/AttachmentTransformer.php @@ -61,8 +61,8 @@ class AttachmentTransformer extends AbstractTransformer 'attachable_type' => str_replace('FireflyIII\\Models\\', '', $attachment->attachable_type), 'md5' => $attachment->md5, 'filename' => $attachment->filename, - 'download_uri' => route('api.v1.attachments.download', [$attachment->id]), - 'upload_uri' => route('api.v1.attachments.upload', [$attachment->id]), + 'download_url' => route('api.v1.attachments.download', [$attachment->id]), + 'upload_url' => route('api.v1.attachments.upload', [$attachment->id]), 'title' => $attachment->title, 'notes' => $this->repository->getNoteText($attachment), 'mime' => $attachment->mime, diff --git a/app/Transformers/PiggyBankTransformer.php b/app/Transformers/PiggyBankTransformer.php index b1bc03a70b..1116f3b63c 100644 --- a/app/Transformers/PiggyBankTransformer.php +++ b/app/Transformers/PiggyBankTransformer.php @@ -22,7 +22,6 @@ declare(strict_types=1); namespace FireflyIII\Transformers; -use FireflyIII\Models\Account; use FireflyIII\Models\ObjectGroup; use FireflyIII\Models\PiggyBank; use FireflyIII\Repositories\Account\AccountRepositoryInterface; diff --git a/app/Transformers/TransactionGroupTransformer.php b/app/Transformers/TransactionGroupTransformer.php index 60795e2e8d..6d88969a3a 100644 --- a/app/Transformers/TransactionGroupTransformer.php +++ b/app/Transformers/TransactionGroupTransformer.php @@ -351,7 +351,7 @@ class TransactionGroupTransformer extends AbstractTransformer $bill = $this->getBill($journal->bill); if (null !== $foreignAmount && null !== $foreignCurrency) { - $foreignAmount = number_format((float)$foreignAmount, $foreignCurrency['decimal_places'], '.', ''); + $foreignAmount = number_format((float)$foreignAmount, $foreignCurrency->decimal_places ?? 0, '.', ''); } $longitude = null; diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php index a20be34865..a8febacce8 100644 --- a/app/Validation/FireflyValidator.php +++ b/app/Validation/FireflyValidator.php @@ -117,7 +117,6 @@ class FireflyValidator extends Validator * @param mixed $value * * @return bool - * @throws FireflyException */ public function validateIban($attribute, $value): bool { diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.php index 34009ab076..14f7ce6912 100644 --- a/app/Validation/TransactionValidation.php +++ b/app/Validation/TransactionValidation.php @@ -518,15 +518,11 @@ trait TransactionValidation */ private function compareAccountData(string $type, array $comparison): bool { - switch ($type) { - default: - case 'withdrawal': - return $this->compareAccountDataWithdrawal($comparison); - case 'deposit': - return $this->compareAccountDataDeposit($comparison); - case 'transfer': - return $this->compareAccountDataTransfer($comparison); - } + return match ($type) { + default => $this->compareAccountDataWithdrawal($comparison), + 'deposit' => $this->compareAccountDataDeposit($comparison), + 'transfer' => $this->compareAccountDataTransfer($comparison), + }; } /**