From 38691d6fdfbd505619e25f7fb325278e4b686e7a Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 9 Nov 2025 09:06:11 +0100 Subject: [PATCH 01/12] Fix code quality with rector [skip ci] --- .../Autocomplete/AccountController.php | 5 +++-- .../Autocomplete/BillController.php | 5 +++-- .../Autocomplete/BudgetController.php | 5 +++-- .../Autocomplete/CategoryController.php | 5 +++-- .../Autocomplete/CurrencyController.php | 3 ++- .../Autocomplete/ObjectGroupController.php | 3 ++- .../Autocomplete/PiggyBankController.php | 3 ++- .../Autocomplete/RecurrenceController.php | 3 ++- .../Autocomplete/RuleController.php | 3 ++- .../Autocomplete/RuleGroupController.php | 3 ++- .../Autocomplete/TagController.php | 3 ++- .../Autocomplete/TransactionController.php | 3 ++- .../TransactionTypeController.php | 3 ++- .../Controllers/Chart/AccountController.php | 3 ++- .../Controllers/Chart/BalanceController.php | 3 ++- .../V1/Controllers/Chart/BudgetController.php | 11 +++++----- .../Controllers/Chart/CategoryController.php | 5 +++-- app/Api/V1/Controllers/Controller.php | 9 ++++---- .../Data/Bulk/TransactionController.php | 3 ++- .../V1/Controllers/Data/DestroyController.php | 5 +++-- .../Data/Export/ExportController.php | 3 ++- .../V1/Controllers/Data/PurgeController.php | 3 ++- .../DestroyController.php | 3 ++- .../CurrencyExchangeRate/IndexController.php | 3 ++- .../CurrencyExchangeRate/ShowController.php | 3 ++- .../CurrencyExchangeRate/StoreController.php | 3 ++- .../CurrencyExchangeRate/UpdateController.php | 3 ++- app/User.php | 21 ++++++++----------- 28 files changed, 76 insertions(+), 52 deletions(-) diff --git a/app/Api/V1/Controllers/Autocomplete/AccountController.php b/app/Api/V1/Controllers/Autocomplete/AccountController.php index 01502a60e9..1dc73a3c76 100644 --- a/app/Api/V1/Controllers/Autocomplete/AccountController.php +++ b/app/Api/V1/Controllers/Autocomplete/AccountController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Autocomplete; +use Illuminate\Http\Request; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest; use FireflyIII\Enums\AccountTypeEnum; @@ -60,7 +61,7 @@ class AccountController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->validateUserGroup($request); $this->repository = app(AccountRepositoryInterface::class); $this->repository->setUser($this->user); @@ -138,7 +139,7 @@ class AccountController extends Controller // custom order. usort( $return, - static function (array $left, array $right) { + static function (array $left, array $right): int { $order = [AccountTypeEnum::ASSET->value, AccountTypeEnum::REVENUE->value, AccountTypeEnum::EXPENSE->value]; $posA = (int)array_search($left['type'], $order, true); $posB = (int)array_search($right['type'], $order, true); diff --git a/app/Api/V1/Controllers/Autocomplete/BillController.php b/app/Api/V1/Controllers/Autocomplete/BillController.php index 4c0da6fc4c..edc428d319 100644 --- a/app/Api/V1/Controllers/Autocomplete/BillController.php +++ b/app/Api/V1/Controllers/Autocomplete/BillController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Autocomplete; +use Illuminate\Http\Request; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest; use FireflyIII\Enums\UserRoleEnum; @@ -46,7 +47,7 @@ class BillController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->validateUserGroup($request); $this->repository = app(BillRepositoryInterface::class); $this->repository->setUser($this->user); @@ -65,7 +66,7 @@ class BillController extends Controller { $result = $this->repository->searchBill($request->attributes->get('query'), $request->attributes->get('limit')); $filtered = $result->map( - static fn (Bill $item) => [ + static fn (Bill $item): array => [ 'id' => (string) $item->id, 'name' => $item->name, 'active' => $item->active, diff --git a/app/Api/V1/Controllers/Autocomplete/BudgetController.php b/app/Api/V1/Controllers/Autocomplete/BudgetController.php index 4a096bff1e..c38b268494 100644 --- a/app/Api/V1/Controllers/Autocomplete/BudgetController.php +++ b/app/Api/V1/Controllers/Autocomplete/BudgetController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Autocomplete; +use Illuminate\Http\Request; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest; use FireflyIII\Enums\UserRoleEnum; @@ -46,7 +47,7 @@ class BudgetController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->validateUserGroup($request); $this->repository = app(BudgetRepositoryInterface::class); $this->repository->setUser($this->user); @@ -65,7 +66,7 @@ class BudgetController extends Controller { $result = $this->repository->searchBudget($request->attributes->get('query'), $request->attributes->get('limit')); $filtered = $result->map( - static fn (Budget $item) => [ + static fn (Budget $item): array => [ 'id' => (string) $item->id, 'name' => $item->name, 'active' => $item->active, diff --git a/app/Api/V1/Controllers/Autocomplete/CategoryController.php b/app/Api/V1/Controllers/Autocomplete/CategoryController.php index 34a963b5ea..09ef038b21 100644 --- a/app/Api/V1/Controllers/Autocomplete/CategoryController.php +++ b/app/Api/V1/Controllers/Autocomplete/CategoryController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Autocomplete; +use Illuminate\Http\Request; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest; use FireflyIII\Enums\UserRoleEnum; @@ -46,7 +47,7 @@ class CategoryController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->validateUserGroup($request); $this->repository = app(CategoryRepositoryInterface::class); $this->repository->setUser($this->user); @@ -65,7 +66,7 @@ class CategoryController extends Controller { $result = $this->repository->searchCategory($request->attributes->get('query'), $request->attributes->get('limit')); $filtered = $result->map( - static fn (Category $item) => [ + static fn (Category $item): array => [ '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 1528e17c18..3259306e79 100644 --- a/app/Api/V1/Controllers/Autocomplete/CurrencyController.php +++ b/app/Api/V1/Controllers/Autocomplete/CurrencyController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Autocomplete; +use Illuminate\Http\Request; use Deprecated; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest; @@ -48,7 +49,7 @@ class CurrencyController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->validateUserGroup($request); $this->repository = app(CurrencyRepositoryInterface::class); $this->repository->setUser($this->user); diff --git a/app/Api/V1/Controllers/Autocomplete/ObjectGroupController.php b/app/Api/V1/Controllers/Autocomplete/ObjectGroupController.php index 38a2ce56be..c9de397ed8 100644 --- a/app/Api/V1/Controllers/Autocomplete/ObjectGroupController.php +++ b/app/Api/V1/Controllers/Autocomplete/ObjectGroupController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Autocomplete; +use Illuminate\Http\Request; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest; use FireflyIII\Enums\UserRoleEnum; @@ -46,7 +47,7 @@ class ObjectGroupController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->validateUserGroup($request); $this->repository = app(ObjectGroupRepositoryInterface::class); $this->repository->setUser($this->user); diff --git a/app/Api/V1/Controllers/Autocomplete/PiggyBankController.php b/app/Api/V1/Controllers/Autocomplete/PiggyBankController.php index f31a990cf0..327c92c8ae 100644 --- a/app/Api/V1/Controllers/Autocomplete/PiggyBankController.php +++ b/app/Api/V1/Controllers/Autocomplete/PiggyBankController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Autocomplete; +use Illuminate\Http\Request; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest; use FireflyIII\Enums\UserRoleEnum; @@ -50,7 +51,7 @@ class PiggyBankController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->validateUserGroup($request); $this->piggyRepository = app(PiggyBankRepositoryInterface::class); $this->accountRepository = app(AccountRepositoryInterface::class); diff --git a/app/Api/V1/Controllers/Autocomplete/RecurrenceController.php b/app/Api/V1/Controllers/Autocomplete/RecurrenceController.php index e757d098c1..2882b51a1f 100644 --- a/app/Api/V1/Controllers/Autocomplete/RecurrenceController.php +++ b/app/Api/V1/Controllers/Autocomplete/RecurrenceController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Autocomplete; +use Illuminate\Http\Request; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest; use FireflyIII\Enums\UserRoleEnum; @@ -46,7 +47,7 @@ class RecurrenceController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->validateUserGroup($request); $this->repository = app(RecurringRepositoryInterface::class); $this->repository->setUser($this->user); diff --git a/app/Api/V1/Controllers/Autocomplete/RuleController.php b/app/Api/V1/Controllers/Autocomplete/RuleController.php index 1ff0271607..79514e9a80 100644 --- a/app/Api/V1/Controllers/Autocomplete/RuleController.php +++ b/app/Api/V1/Controllers/Autocomplete/RuleController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Autocomplete; +use Illuminate\Http\Request; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest; use FireflyIII\Enums\UserRoleEnum; @@ -46,7 +47,7 @@ class RuleController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->validateUserGroup($request); $this->repository = app(RuleRepositoryInterface::class); $this->repository->setUser($this->user); diff --git a/app/Api/V1/Controllers/Autocomplete/RuleGroupController.php b/app/Api/V1/Controllers/Autocomplete/RuleGroupController.php index 70c66be5ee..b2cee766c9 100644 --- a/app/Api/V1/Controllers/Autocomplete/RuleGroupController.php +++ b/app/Api/V1/Controllers/Autocomplete/RuleGroupController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Autocomplete; +use Illuminate\Http\Request; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest; use FireflyIII\Enums\UserRoleEnum; @@ -46,7 +47,7 @@ class RuleGroupController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->validateUserGroup($request); $this->repository = app(RuleGroupRepositoryInterface::class); $this->repository->setUser($this->user); diff --git a/app/Api/V1/Controllers/Autocomplete/TagController.php b/app/Api/V1/Controllers/Autocomplete/TagController.php index d797931319..83305b5e32 100644 --- a/app/Api/V1/Controllers/Autocomplete/TagController.php +++ b/app/Api/V1/Controllers/Autocomplete/TagController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Autocomplete; +use Illuminate\Http\Request; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest; use FireflyIII\Enums\UserRoleEnum; @@ -46,7 +47,7 @@ class TagController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->validateUserGroup($request); $this->repository = app(TagRepositoryInterface::class); $this->repository->setUser($this->user); diff --git a/app/Api/V1/Controllers/Autocomplete/TransactionController.php b/app/Api/V1/Controllers/Autocomplete/TransactionController.php index cf8302fdf2..91d6956cc7 100644 --- a/app/Api/V1/Controllers/Autocomplete/TransactionController.php +++ b/app/Api/V1/Controllers/Autocomplete/TransactionController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Autocomplete; +use Illuminate\Http\Request; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest; use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteTransactionApiRequest; @@ -51,7 +52,7 @@ class TransactionController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->validateUserGroup($request); $this->repository = app(JournalRepositoryInterface::class); $this->groupRepository = app(TransactionGroupRepositoryInterface::class); diff --git a/app/Api/V1/Controllers/Autocomplete/TransactionTypeController.php b/app/Api/V1/Controllers/Autocomplete/TransactionTypeController.php index bdfad0d9d9..535d094b4d 100644 --- a/app/Api/V1/Controllers/Autocomplete/TransactionTypeController.php +++ b/app/Api/V1/Controllers/Autocomplete/TransactionTypeController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Autocomplete; +use Illuminate\Http\Request; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteApiRequest; use FireflyIII\Enums\UserRoleEnum; @@ -46,7 +47,7 @@ class TransactionTypeController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->validateUserGroup($request); $this->repository = app(TransactionTypeRepositoryInterface::class); diff --git a/app/Api/V1/Controllers/Chart/AccountController.php b/app/Api/V1/Controllers/Chart/AccountController.php index f321965777..c097ec0372 100644 --- a/app/Api/V1/Controllers/Chart/AccountController.php +++ b/app/Api/V1/Controllers/Chart/AccountController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Chart; +use Illuminate\Http\Request; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Chart\ChartRequest; use FireflyIII\Enums\UserRoleEnum; @@ -59,7 +60,7 @@ class AccountController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->repository = app(AccountRepositoryInterface::class); $this->validateUserGroup($request); $this->repository->setUserGroup($this->userGroup); diff --git a/app/Api/V1/Controllers/Chart/BalanceController.php b/app/Api/V1/Controllers/Chart/BalanceController.php index cd3d967dc6..1014c15cd2 100644 --- a/app/Api/V1/Controllers/Chart/BalanceController.php +++ b/app/Api/V1/Controllers/Chart/BalanceController.php @@ -25,6 +25,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Chart; +use Illuminate\Http\Request; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Chart\ChartRequest; use FireflyIII\Enums\TransactionTypeEnum; @@ -56,7 +57,7 @@ class BalanceController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->validateUserGroup($request); $this->repository = app(AccountRepositoryInterface::class); $this->collector = app(GroupCollectorInterface::class); diff --git a/app/Api/V1/Controllers/Chart/BudgetController.php b/app/Api/V1/Controllers/Chart/BudgetController.php index 090b90f65a..c63d7d32fa 100644 --- a/app/Api/V1/Controllers/Chart/BudgetController.php +++ b/app/Api/V1/Controllers/Chart/BudgetController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Chart; +use Illuminate\Http\Request; use Carbon\Carbon; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\DateRangeRequest; @@ -61,7 +62,7 @@ class BudgetController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->validateUserGroup($request); $this->repository = app(BudgetRepositoryInterface::class); $this->blRepository = app(BudgetLimitRepositoryInterface::class); @@ -140,14 +141,14 @@ class BudgetController extends Controller } // convert data if necessary. - if (true === $this->convertToPrimary && $currencyId !== $this->primaryCurrency->id) { + if ($this->convertToPrimary && $currencyId !== $this->primaryCurrency->id) { $currencies[$currencyId] ??= Amount::getTransactionCurrencyById($currencyId); $row['pc_budgeted'] = $converter->convert($currencies[$currencyId], $this->primaryCurrency, $start, $row['budgeted']); $row['pc_spent'] = $converter->convert($currencies[$currencyId], $this->primaryCurrency, $start, $row['spent']); $row['pc_left'] = $converter->convert($currencies[$currencyId], $this->primaryCurrency, $start, $row['left']); $row['pc_overspent'] = $converter->convert($currencies[$currencyId], $this->primaryCurrency, $start, $row['overspent']); } - if (true === $this->convertToPrimary && $currencyId === $this->primaryCurrency->id) { + if ($this->convertToPrimary && $currencyId === $this->primaryCurrency->id) { $row['pc_budgeted'] = $row['budgeted']; $row['pc_spent'] = $row['spent']; $row['pc_left'] = $row['left']; @@ -265,7 +266,7 @@ class BudgetController extends Controller /** @var BudgetLimit $current */ foreach ($limits as $current) { - if (true === $this->convertToPrimary) { + if ($this->convertToPrimary) { if ($current->transaction_currency_id === $this->primaryCurrency->id) { // simply add it. $amount = bcadd($amount, (string)$current->amount); @@ -283,7 +284,7 @@ class BudgetController extends Controller $limit = $current; } } - if (null !== $limit && true === $this->convertToPrimary) { + if (null !== $limit && $this->convertToPrimary) { // convert and add all amounts. $limit->amount = app('steam')->positive($amount); Log::debug(sprintf('Final amount in limit with converted amount %s', $limit->amount)); diff --git a/app/Api/V1/Controllers/Chart/CategoryController.php b/app/Api/V1/Controllers/Chart/CategoryController.php index a85fc89fa3..31df558fc6 100644 --- a/app/Api/V1/Controllers/Chart/CategoryController.php +++ b/app/Api/V1/Controllers/Chart/CategoryController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Chart; +use Illuminate\Http\Request; use Carbon\Carbon; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\DateRangeRequest; @@ -58,7 +59,7 @@ class CategoryController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->validateUserGroup($request); $this->accountRepos = app(AccountRepositoryInterface::class); $this->currencyRepos = app(CurrencyRepositoryInterface::class); @@ -181,7 +182,7 @@ class CategoryController extends Controller $return = array_values($return); // order by amount - usort($return, static fn (array $a, array $b) => ((float)$a['entries']['spent'] + (float)$a['entries']['earned']) < ((float)$b['entries']['spent'] + (float)$b['entries']['earned']) ? 1 : -1); + usort($return, static fn (array $a, array $b): int => ((float)$a['entries']['spent'] + (float)$a['entries']['earned']) < ((float)$b['entries']['spent'] + (float)$b['entries']['earned']) ? 1 : -1); return response()->json($this->clean($return)); } diff --git a/app/Api/V1/Controllers/Controller.php b/app/Api/V1/Controllers/Controller.php index c9169673b5..8c6cff0d16 100644 --- a/app/Api/V1/Controllers/Controller.php +++ b/app/Api/V1/Controllers/Controller.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers; +use Deprecated; use Carbon\Carbon; use Carbon\Exceptions\InvalidFormatException; use FireflyIII\Exceptions\BadHttpHeaderException; @@ -100,10 +101,10 @@ abstract class Controller extends BaseController ); } - /** - * @deprecated use Request classes - * Method to grab all parameters from the URL - */ + #[Deprecated(message: <<<'TXT' + use Request classes + Method to grab all parameters from the URL + TXT)] private function getParameters(): ParameterBag { $bag = new ParameterBag(); diff --git a/app/Api/V1/Controllers/Data/Bulk/TransactionController.php b/app/Api/V1/Controllers/Data/Bulk/TransactionController.php index 7f00225c70..d896f60fe8 100644 --- a/app/Api/V1/Controllers/Data/Bulk/TransactionController.php +++ b/app/Api/V1/Controllers/Data/Bulk/TransactionController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Data\Bulk; +use Illuminate\Http\Request; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Data\Bulk\TransactionRequest; use FireflyIII\Enums\UserRoleEnum; @@ -51,7 +52,7 @@ class TransactionController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->validateUserGroup($request); $this->repository = app(AccountRepositoryInterface::class); $this->repository->setUserGroup($this->userGroup); diff --git a/app/Api/V1/Controllers/Data/DestroyController.php b/app/Api/V1/Controllers/Data/DestroyController.php index 86180cf44c..85ac99ae94 100644 --- a/app/Api/V1/Controllers/Data/DestroyController.php +++ b/app/Api/V1/Controllers/Data/DestroyController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Data; +use Illuminate\Http\Request; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Data\DestroyRequest; use FireflyIII\Enums\AccountTypeEnum; @@ -63,7 +64,7 @@ class DestroyController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->validateUserGroup($request); return $next($request); @@ -185,7 +186,7 @@ class DestroyController extends Controller /** @var Account $account */ foreach ($collection as $account) { $count = $account->transactions()->count(); - if (true === $this->unused && 0 === $count) { + if ($this->unused && 0 === $count) { Log::info(sprintf('Deleted unused account #%d "%s"', $account->id, $account->name)); Log::channel('audit')->info(sprintf('Deleted unused account #%d "%s"', $account->id, $account->name)); $service->destroy($account, null); diff --git a/app/Api/V1/Controllers/Data/Export/ExportController.php b/app/Api/V1/Controllers/Data/Export/ExportController.php index 7e78ca920e..0f055c4428 100644 --- a/app/Api/V1/Controllers/Data/Export/ExportController.php +++ b/app/Api/V1/Controllers/Data/Export/ExportController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Data\Export; +use Illuminate\Http\Request; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Data\Export\ExportRequest; use FireflyIII\Enums\UserRoleEnum; @@ -49,7 +50,7 @@ class ExportController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->validateUserGroup($request); $this->exporter = app(ExportDataGenerator::class); $this->exporter->setUserGroup($this->userGroup); diff --git a/app/Api/V1/Controllers/Data/PurgeController.php b/app/Api/V1/Controllers/Data/PurgeController.php index cea88fa0e6..700b0da352 100644 --- a/app/Api/V1/Controllers/Data/PurgeController.php +++ b/app/Api/V1/Controllers/Data/PurgeController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Data; +use Illuminate\Http\Request; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Enums\UserRoleEnum; use FireflyIII\Models\Account; @@ -51,7 +52,7 @@ class PurgeController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->validateUserGroup($request); return $next($request); diff --git a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/DestroyController.php b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/DestroyController.php index 27ce2e6330..807ff96f31 100644 --- a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/DestroyController.php +++ b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/DestroyController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Models\CurrencyExchangeRate; +use Illuminate\Http\Request; use Carbon\Carbon; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Models\CurrencyExchangeRate\DestroyRequest; @@ -47,7 +48,7 @@ class DestroyController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->repository = app(ExchangeRateRepositoryInterface::class); $this->repository->setUserGroup($this->validateUserGroup($request)); diff --git a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/IndexController.php b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/IndexController.php index cebd3a8277..f5bdd92d87 100644 --- a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/IndexController.php +++ b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/IndexController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Models\CurrencyExchangeRate; +use Illuminate\Http\Request; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Enums\UserRoleEnum; use FireflyIII\Repositories\ExchangeRate\ExchangeRateRepositoryInterface; @@ -47,7 +48,7 @@ class IndexController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->repository = app(ExchangeRateRepositoryInterface::class); $this->repository->setUserGroup($this->validateUserGroup($request)); diff --git a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/ShowController.php b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/ShowController.php index 22a9756ab7..ac6e94100a 100644 --- a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/ShowController.php +++ b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/ShowController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Models\CurrencyExchangeRate; +use Illuminate\Http\Request; use Carbon\Carbon; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Enums\UserRoleEnum; @@ -51,7 +52,7 @@ class ShowController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->repository = app(ExchangeRateRepositoryInterface::class); $this->repository->setUserGroup($this->validateUserGroup($request)); diff --git a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/StoreController.php b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/StoreController.php index 45da4ff67e..2b9bd95dbd 100644 --- a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/StoreController.php +++ b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/StoreController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Models\CurrencyExchangeRate; +use Illuminate\Http\Request; use Carbon\Carbon; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Models\CurrencyExchangeRate\StoreByCurrenciesRequest; @@ -52,7 +53,7 @@ class StoreController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->repository = app(ExchangeRateRepositoryInterface::class); $this->repository->setUserGroup($this->validateUserGroup($request)); diff --git a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/UpdateController.php b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/UpdateController.php index 19a34d1b5e..c5fc27d76b 100644 --- a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/UpdateController.php +++ b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/UpdateController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Models\CurrencyExchangeRate; +use Illuminate\Http\Request; use Carbon\Carbon; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Models\CurrencyExchangeRate\UpdateRequest; @@ -48,7 +49,7 @@ class UpdateController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { $this->repository = app(ExchangeRateRepositoryInterface::class); $this->repository->setUserGroup($this->validateUserGroup($request)); diff --git a/app/User.php b/app/User.php index 445ef22f77..82c3f99bf5 100644 --- a/app/User.php +++ b/app/User.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII; +use Illuminate\Support\Facades\Log; use Deprecated; use Exception; use FireflyIII\Enums\UserRoleEnum; @@ -198,11 +199,9 @@ class User extends Authenticatable /** * Get the database column name of the domain. - * - * @return string */ #[Deprecated] - public function getLdapDomainColumn() + public function getLdapDomainColumn(): string { return 'domain'; } @@ -220,11 +219,9 @@ class User extends Authenticatable /** * Get the models LDAP GUID database column name. - * - * @return string */ #[Deprecated] - public function getLdapGuidColumn() + public function getLdapGuidColumn(): string { return 'objectguid'; } @@ -247,12 +244,12 @@ class User extends Authenticatable */ private function hasAnyRoleInGroup(UserGroup $userGroup, array $roles): bool { - app('log')->debug(sprintf('in hasAnyRoleInGroup(%s)', implode(', ', $roles))); + Log::debug(sprintf('in hasAnyRoleInGroup(%s)', implode(', ', $roles))); /** @var Collection $dbRoles */ $dbRoles = UserRole::whereIn('title', $roles)->get(); if (0 === $dbRoles->count()) { - app('log')->error(sprintf('Could not find role(s): %s. Probably migration mishap.', implode(', ', $roles))); + Log::error(sprintf('Could not find role(s): %s. Probably migration mishap.', implode(', ', $roles))); return false; } @@ -261,7 +258,7 @@ class User extends Authenticatable $groupMemberships = $this->groupMemberships()->whereIn('user_role_id', $dbRolesIds)->where('user_group_id', $userGroup->id)->get(); if (0 === $groupMemberships->count()) { - app('log')->error(sprintf( + Log::error(sprintf( 'User #%d "%s" does not have roles %s in user group #%d "%s"', $this->id, $this->email, @@ -273,7 +270,7 @@ class User extends Authenticatable return false; } foreach ($groupMemberships as $membership) { - app('log')->debug(sprintf( + Log::debug(sprintf( 'User #%d "%s" has role "%s" in user group #%d "%s"', $this->id, $this->email, @@ -282,12 +279,12 @@ class User extends Authenticatable $userGroup->title )); if (in_array($membership->userRole->title, $dbRolesTitles, true)) { - app('log')->debug(sprintf('Return true, found role "%s"', $membership->userRole->title)); + Log::debug(sprintf('Return true, found role "%s"', $membership->userRole->title)); return true; } } - app('log')->error(sprintf( + Log::error(sprintf( 'User #%d "%s" does not have roles %s in user group #%d "%s"', $this->id, $this->email, From d2610be790e4134883f58567e31a52fc1e0a08d2 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 9 Nov 2025 09:07:14 +0100 Subject: [PATCH 02/12] Fix code quality with rector [skip ci] --- .../Models/Transaction/StoreController.php | 3 +- .../TransactionCurrency/ListController.php | 12 +-- .../Controllers/Search/AccountController.php | 15 ++- .../Controllers/Summary/BasicController.php | 8 +- app/Api/V1/Requests/AggregateFormRequest.php | 8 +- app/Api/V1/Requests/Chart/ChartRequest.php | 2 +- .../Data/Bulk/MoveTransactionsRequest.php | 2 +- .../Requests/Data/Bulk/TransactionRequest.php | 2 +- app/Api/V1/Requests/DateRangeRequest.php | 2 +- app/Api/V1/Requests/DateRequest.php | 2 +- .../Requests/Generic/ObjectTypeApiRequest.php | 4 +- app/Api/V1/Requests/Generic/QueryRequest.php | 2 +- .../Models/Account/AccountTypeApiRequest.php | 2 +- .../Models/Account/AccountTypesApiRequest.php | 2 +- .../Requests/Models/Account/ShowRequest.php | 1 - .../Requests/Models/Account/UpdateRequest.php | 2 +- .../Models/Attachment/StoreRequest.php | 2 +- .../Models/Attachment/UpdateRequest.php | 2 +- .../Models/AvailableBudget/Request.php | 2 +- .../V1/Requests/Models/Bill/StoreRequest.php | 2 +- .../V1/Requests/Models/Bill/UpdateRequest.php | 2 +- .../Requests/Models/Budget/StoreRequest.php | 2 +- .../Requests/Models/Budget/UpdateRequest.php | 2 +- .../Models/BudgetLimit/StoreRequest.php | 2 +- .../Models/BudgetLimit/UpdateRequest.php | 2 +- .../StoreByCurrenciesRequest.php | 2 +- .../StoreByDateRequest.php | 2 +- .../Models/PiggyBank/StoreRequest.php | 2 +- .../Models/Recurrence/StoreRequest.php | 2 +- .../Models/Recurrence/UpdateRequest.php | 2 +- .../V1/Requests/Models/Rule/StoreRequest.php | 6 +- .../V1/Requests/Models/Rule/UpdateRequest.php | 6 +- .../Models/Transaction/StoreRequest.php | 2 +- .../Models/Transaction/UpdateRequest.php | 2 +- .../CurrencyCodeRequest.php | 2 +- .../Models/TransactionLink/StoreRequest.php | 2 +- .../Models/TransactionLink/UpdateRequest.php | 2 +- .../Requests/Models/Webhook/CreateRequest.php | 2 +- .../Requests/Models/Webhook/UpdateRequest.php | 2 +- app/Api/V1/Requests/PaginationRequest.php | 4 +- .../V1/Requests/System/UserUpdateRequest.php | 2 +- .../Commands/Correction/CorrectsAmounts.php | 2 +- .../Correction/CorrectsCurrencies.php | 2 +- .../Correction/CorrectsGroupInformation.php | 4 +- .../Commands/Correction/CorrectsIbans.php | 33 +++---- .../CorrectsPrimaryCurrencyAmounts.php | 2 +- .../Correction/CorrectsTransactionTypes.php | 6 +- .../Correction/CorrectsUnevenAmount.php | 12 +-- .../Commands/Correction/RestoresOAuthKeys.php | 2 +- app/Console/Commands/Export/ExportsData.php | 4 +- .../Commands/System/CreatesDatabase.php | 2 +- .../Commands/System/ForcesDecimalSize.php | 4 +- app/Console/Commands/Tools/ApplyRules.php | 2 +- .../Upgrade/UpgradesLiabilitiesEight.php | 6 +- .../Commands/Upgrade/UpgradesTagLocations.php | 2 +- .../Commands/Upgrade/UpgradesToGroups.php | 4 +- .../UpgradesVariousCurrencyInformation.php | 1 - .../Commands/Upgrade/UpgradesWebhooks.php | 4 +- app/Events/RequestedReportOnJournals.php | 4 +- app/Exceptions/GracefulNotFoundHandler.php | 2 +- app/Exceptions/Handler.php | 2 +- app/Exceptions/IntervalException.php | 6 +- app/Factory/AccountFactory.php | 4 +- app/Factory/AttachmentFactory.php | 4 +- app/Factory/TagFactory.php | 2 +- app/Factory/TransactionFactory.php | 13 +-- app/Factory/TransactionJournalFactory.php | 9 +- .../Report/Account/MonthReportGenerator.php | 2 +- .../Report/Audit/MonthReportGenerator.php | 2 +- .../Report/Budget/MonthReportGenerator.php | 12 +-- .../Report/Category/MonthReportGenerator.php | 15 +-- .../Report/Standard/MonthReportGenerator.php | 8 +- .../Standard/MultiYearReportGenerator.php | 8 +- .../Report/Standard/YearReportGenerator.php | 8 +- .../Report/Tag/MonthReportGenerator.php | 2 +- .../Webhook/StandardMessageGenerator.php | 6 +- app/Handlers/Events/UserEventHandler.php | 2 +- app/Handlers/Events/WebhookEventHandler.php | 2 +- app/Handlers/Observer/TransactionObserver.php | 16 ++- app/Helpers/Attachments/AttachmentHelper.php | 6 +- .../Extensions/AttachmentCollection.php | 21 ++-- .../Collector/Extensions/MetaCollection.php | 51 +++++----- app/Helpers/Collector/GroupCollector.php | 5 +- app/Helpers/Fiscal/FiscalHelper.php | 8 +- app/Helpers/Report/NetWorth.php | 4 - app/Helpers/Report/ReportHelper.php | 9 +- .../Controllers/Account/CreateController.php | 4 +- .../Controllers/Account/DeleteController.php | 8 +- .../Controllers/Account/EditController.php | 4 +- .../Controllers/Account/IndexController.php | 22 ++--- .../Account/ReconcileController.php | 28 ++---- .../Controllers/Account/ShowController.php | 43 +------- .../Admin/ConfigurationController.php | 4 +- app/Http/Controllers/Admin/HomeController.php | 4 +- app/Http/Controllers/Admin/LinkController.php | 24 +++-- .../Admin/NotificationController.php | 20 +--- .../Controllers/Admin/UpdateController.php | 8 +- app/Http/Controllers/Admin/UserController.php | 36 +++---- app/Http/Controllers/AttachmentController.php | 22 ++--- .../Auth/ForgotPasswordController.php | 6 +- app/Http/Controllers/Auth/LoginController.php | 25 ++--- .../Controllers/Auth/RegisterController.php | 18 ++-- .../Auth/ResetPasswordController.php | 5 +- .../Controllers/Auth/TwoFactorController.php | 15 +-- .../Controllers/Bill/CreateController.php | 8 +- .../Controllers/Bill/DeleteController.php | 8 +- app/Http/Controllers/Bill/EditController.php | 6 +- app/Http/Controllers/Bill/IndexController.php | 11 ++- app/Http/Controllers/Bill/ShowController.php | 8 +- .../Budget/BudgetLimitController.php | 24 +++-- .../Controllers/Budget/CreateController.php | 4 +- .../Controllers/Budget/DeleteController.php | 8 +- .../Controllers/Budget/EditController.php | 4 +- .../Controllers/Budget/IndexController.php | 22 +---- .../Controllers/Budget/ShowController.php | 16 +-- .../Controllers/Category/CreateController.php | 4 +- .../Controllers/Category/DeleteController.php | 8 +- .../Controllers/Category/EditController.php | 8 +- .../Controllers/Category/IndexController.php | 4 +- .../Category/NoCategoryController.php | 8 +- .../Controllers/Category/ShowController.php | 8 +- .../Controllers/Chart/AccountController.php | 2 +- app/Http/Controllers/Chart/BillController.php | 2 +- .../Controllers/Chart/ReportController.php | 2 +- app/Http/Controllers/DebugController.php | 98 ++++++------------- .../ExchangeRates/IndexController.php | 2 +- .../Controllers/Export/IndexController.php | 2 +- app/Http/Controllers/HomeController.php | 4 +- app/Http/Controllers/Json/BoxController.php | 2 +- .../Controllers/Json/FrontpageController.php | 9 +- app/Http/Controllers/Json/IntroController.php | 17 ++-- .../Controllers/Json/ReconcileController.php | 22 ++--- .../Controllers/Json/RecurrenceController.php | 9 +- app/Http/Controllers/Json/RuleController.php | 13 +-- app/Http/Controllers/NewUserController.php | 8 +- .../ObjectGroup/DeleteController.php | 6 +- .../ObjectGroup/EditController.php | 8 +- .../ObjectGroup/IndexController.php | 10 +- .../PiggyBank/AmountController.php | 18 ++-- .../PiggyBank/CreateController.php | 6 +- .../PiggyBank/DeleteController.php | 4 +- .../Controllers/PiggyBank/EditController.php | 8 +- .../Controllers/PiggyBank/IndexController.php | 7 +- .../Controllers/PiggyBank/ShowController.php | 4 +- .../Controllers/PreferencesController.php | 38 +------ .../Controllers/Profile/MfaController.php | 13 ++- app/Http/Controllers/ProfileController.php | 31 +++--- .../Recurring/CreateController.php | 12 +-- .../Recurring/DeleteController.php | 8 +- .../Controllers/Recurring/EditController.php | 14 +-- .../Controllers/Recurring/IndexController.php | 4 +- .../Controllers/Recurring/ShowController.php | 4 +- .../Recurring/TriggerController.php | 5 +- .../Controllers/Report/AccountController.php | 7 +- .../Controllers/Report/BalanceController.php | 7 +- .../Controllers/Report/BillController.php | 7 +- .../Controllers/Report/BudgetController.php | 31 +++--- .../Controllers/Report/CategoryController.php | 41 ++++---- .../Controllers/Report/DoubleController.php | 25 ++--- .../Report/OperationsController.php | 19 ++-- app/Http/Controllers/Report/TagController.php | 29 +++--- app/Http/Controllers/ReportController.php | 10 +- .../Controllers/Rule/CreateController.php | 14 ++- .../Controllers/Rule/DeleteController.php | 4 +- app/Http/Controllers/Rule/EditController.php | 9 +- app/Http/Controllers/Rule/IndexController.php | 4 +- .../Controllers/Rule/SelectController.php | 11 ++- .../RuleGroup/CreateController.php | 4 +- .../RuleGroup/DeleteController.php | 8 +- .../Controllers/RuleGroup/EditController.php | 4 +- .../RuleGroup/ExecutionController.php | 4 +- app/Http/Controllers/SearchController.php | 11 ++- .../Controllers/System/CronController.php | 5 +- .../Controllers/System/InstallController.php | 27 +++-- app/Http/Controllers/TagController.php | 30 +++--- .../Transaction/BulkController.php | 17 ++-- .../Transaction/ConvertController.php | 19 +--- .../Transaction/CreateController.php | 5 +- .../Transaction/DeleteController.php | 15 ++- .../Transaction/EditController.php | 4 +- .../Transaction/IndexController.php | 8 +- .../Transaction/LinkController.php | 25 ++--- .../Transaction/MassController.php | 21 ++-- .../Transaction/ShowController.php | 4 +- .../TransactionCurrency/CreateController.php | 8 +- .../TransactionCurrency/DeleteController.php | 7 +- .../TransactionCurrency/EditController.php | 7 +- .../TransactionCurrency/IndexController.php | 6 +- .../UserGroup/CreateController.php | 5 +- .../Controllers/UserGroup/EditController.php | 5 +- .../Controllers/UserGroup/IndexController.php | 5 +- .../Controllers/Webhooks/CreateController.php | 4 +- .../Controllers/Webhooks/DeleteController.php | 4 +- .../Controllers/Webhooks/EditController.php | 4 +- .../Controllers/Webhooks/IndexController.php | 2 +- .../Controllers/Webhooks/ShowController.php | 4 +- app/Http/Middleware/Authenticate.php | 27 +++-- app/Http/Middleware/Binder.php | 17 +--- app/Http/Middleware/IsDemoUser.php | 3 +- app/Http/Middleware/Range.php | 2 +- app/Http/Requests/AccountFormRequest.php | 2 +- app/Http/Requests/AttachmentFormRequest.php | 2 +- app/Http/Requests/BillStoreRequest.php | 2 +- app/Http/Requests/BillUpdateRequest.php | 2 +- app/Http/Requests/BudgetFormStoreRequest.php | 2 +- app/Http/Requests/BudgetFormUpdateRequest.php | 2 +- app/Http/Requests/BudgetIncomeRequest.php | 2 +- app/Http/Requests/BulkEditJournalRequest.php | 2 +- app/Http/Requests/CategoryFormRequest.php | 2 +- app/Http/Requests/ConfigurationRequest.php | 2 +- app/Http/Requests/CurrencyFormRequest.php | 2 +- .../Requests/DeleteAccountFormRequest.php | 2 +- app/Http/Requests/EmailFormRequest.php | 2 +- .../Requests/ExistingTokenFormRequest.php | 2 +- app/Http/Requests/InviteUserFormRequest.php | 2 +- app/Http/Requests/JournalLinkRequest.php | 2 +- app/Http/Requests/LinkTypeFormRequest.php | 2 +- .../Requests/MassDeleteJournalRequest.php | 2 +- app/Http/Requests/MassEditJournalRequest.php | 2 +- app/Http/Requests/NewUserFormRequest.php | 2 +- app/Http/Requests/ObjectGroupFormRequest.php | 2 +- app/Http/Requests/PiggyBankStoreRequest.php | 2 +- app/Http/Requests/PiggyBankUpdateRequest.php | 2 +- app/Http/Requests/ProfileFormRequest.php | 2 +- .../Requests/ReconciliationStoreRequest.php | 4 +- app/Http/Requests/RecurrenceFormRequest.php | 8 +- app/Http/Requests/ReportFormRequest.php | 20 ++-- app/Http/Requests/RuleFormRequest.php | 2 +- app/Http/Requests/RuleGroupFormRequest.php | 2 +- .../Requests/SelectTransactionsRequest.php | 2 +- app/Http/Requests/TagFormRequest.php | 2 +- app/Http/Requests/TestRuleFormRequest.php | 2 +- app/Http/Requests/TokenFormRequest.php | 2 +- .../Requests/TriggerRecurrenceRequest.php | 2 +- app/Http/Requests/UserFormRequest.php | 2 +- app/Http/Requests/UserRegistrationRequest.php | 2 +- app/Jobs/CreateRecurringTransactions.php | 7 +- app/Jobs/DownloadExchangeRates.php | 3 +- app/Jobs/SendWebhookMessage.php | 4 +- app/Jobs/WarnAboutBills.php | 12 +-- app/Mail/NewIPAddressWarningMail.php | 3 +- app/Models/Account.php | 10 +- app/Models/AccountMeta.php | 2 +- app/Models/Attachment.php | 2 +- app/Models/AuditLogEntry.php | 4 +- app/Models/AutoBudget.php | 6 +- app/Models/AvailableBudget.php | 12 +-- app/Models/Bill.php | 10 +- app/Models/Budget.php | 2 +- app/Models/BudgetLimit.php | 6 +- app/Models/Configuration.php | 2 +- app/Models/CurrencyExchangeRate.php | 8 +- app/Models/GroupMembership.php | 2 +- app/Models/Location.php | 2 +- app/Models/Note.php | 2 +- app/Models/ObjectGroup.php | 2 +- app/Models/PeriodStatistic.php | 2 +- app/Models/PiggyBank.php | 6 +- app/Models/PiggyBankEvent.php | 4 +- app/Models/PiggyBankRepetition.php | 4 +- app/Models/Recurrence.php | 2 +- app/Models/RecurrenceMeta.php | 2 +- 262 files changed, 873 insertions(+), 1186 deletions(-) diff --git a/app/Api/V1/Controllers/Models/Transaction/StoreController.php b/app/Api/V1/Controllers/Models/Transaction/StoreController.php index 6a7e603d5d..afea0e1dae 100644 --- a/app/Api/V1/Controllers/Models/Transaction/StoreController.php +++ b/app/Api/V1/Controllers/Models/Transaction/StoreController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Controllers\Models\Transaction; +use Illuminate\Http\Request; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Models\Transaction\StoreRequest; use FireflyIII\Enums\UserRoleEnum; @@ -61,7 +62,7 @@ class StoreController extends Controller { parent::__construct(); $this->middleware( - function ($request, $next) { + function (Request $request, $next) { /** @var User $admin */ $admin = auth()->user(); $userGroup = $this->validateUserGroup($request); diff --git a/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.php b/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.php index 3864806bb5..bb98322c9b 100644 --- a/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.php +++ b/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.php @@ -90,7 +90,7 @@ class ListController extends Controller // filter list on currency preference: $collection = $unfiltered->filter( - static function (Account $account) use ($currency, $accountRepository) { + static function (Account $account) use ($currency, $accountRepository): bool { $currencyId = (int) $accountRepository->getMetaValue($account, 'currency_id'); return $currencyId === $currency->id; @@ -178,7 +178,7 @@ class ListController extends Controller // filter and paginate list: $collection = $unfiltered->filter( - static fn (Bill $bill) => $bill->transaction_currency_id === $currency->id + static fn (Bill $bill): bool => $bill->transaction_currency_id === $currency->id ); $count = $collection->count(); $bills = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize); @@ -261,8 +261,8 @@ class ListController extends Controller // filter selection $collection = $unfiltered->filter( - static function (Recurrence $recurrence) use ($currency) { // @phpstan-ignore-line - if (array_any($recurrence->recurrenceTransactions, fn ($transaction) => $transaction->transaction_currency_id === $currency->id || $transaction->foreign_currency_id === $currency->id)) { + static function (Recurrence $recurrence) use ($currency): ?Recurrence { // @phpstan-ignore-line + if (array_any($recurrence->recurrenceTransactions, fn ($transaction): bool => $transaction->transaction_currency_id === $currency->id || $transaction->foreign_currency_id === $currency->id)) { return $recurrence; } @@ -310,8 +310,8 @@ class ListController extends Controller $unfiltered = $ruleRepos->getAll(); $collection = $unfiltered->filter( - static function (Rule $rule) use ($currency) { // @phpstan-ignore-line - if (array_any($rule->ruleTriggers, fn ($trigger) => 'currency_is' === $trigger->trigger_type && $currency->name === $trigger->trigger_value)) { + static function (Rule $rule) use ($currency): ?Rule { // @phpstan-ignore-line + if (array_any($rule->ruleTriggers, fn ($trigger): bool => 'currency_is' === $trigger->trigger_type && $currency->name === $trigger->trigger_value)) { return $rule; } diff --git a/app/Api/V1/Controllers/Search/AccountController.php b/app/Api/V1/Controllers/Search/AccountController.php index cfcad8642a..caaa0c879b 100644 --- a/app/Api/V1/Controllers/Search/AccountController.php +++ b/app/Api/V1/Controllers/Search/AccountController.php @@ -45,18 +45,17 @@ class AccountController extends Controller { use AccountFilter; - private array $validFields; + private array $validFields = [ + AccountSearch::SEARCH_ALL, + AccountSearch::SEARCH_ID, + AccountSearch::SEARCH_NAME, + AccountSearch::SEARCH_IBAN, + AccountSearch::SEARCH_NUMBER, + ]; public function __construct() { parent::__construct(); - $this->validFields = [ - AccountSearch::SEARCH_ALL, - AccountSearch::SEARCH_ID, - AccountSearch::SEARCH_NAME, - AccountSearch::SEARCH_IBAN, - AccountSearch::SEARCH_NUMBER, - ]; } /** diff --git a/app/Api/V1/Controllers/Summary/BasicController.php b/app/Api/V1/Controllers/Summary/BasicController.php index 86b65b9e34..730bfd3c6e 100644 --- a/app/Api/V1/Controllers/Summary/BasicController.php +++ b/app/Api/V1/Controllers/Summary/BasicController.php @@ -591,7 +591,7 @@ class BasicController extends Controller // filter list on preference of being included. $filtered = $allAccounts->filter( - function (Account $account) { + function (Account $account): bool { $includeNetWorth = $this->accountRepository->getMetaValue($account, 'include_net_worth'); return null === $includeNetWorth || '1' === $includeNetWorth; @@ -652,10 +652,6 @@ class BasicController extends Controller return true; } // start and end in the past? use $end - if ($start->lessThanOrEqualTo($date) && $end->lessThanOrEqualTo($date)) { - return true; - } - - return false; + return $start->lessThanOrEqualTo($date) && $end->lessThanOrEqualTo($date); } } diff --git a/app/Api/V1/Requests/AggregateFormRequest.php b/app/Api/V1/Requests/AggregateFormRequest.php index 8aa3cecffb..99891a4c98 100644 --- a/app/Api/V1/Requests/AggregateFormRequest.php +++ b/app/Api/V1/Requests/AggregateFormRequest.php @@ -23,10 +23,11 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests; +use Override; +use Illuminate\Contracts\Validation\Validator; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; use RuntimeException; abstract class AggregateFormRequest extends ApiRequest @@ -39,6 +40,7 @@ abstract class AggregateFormRequest extends ApiRequest /** @return array */ abstract protected function getRequests(): array; + #[Override] public function initialize(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null): void { parent::initialize($query, $request, $attributes, $cookies, $files, $server, $content); @@ -76,7 +78,7 @@ abstract class AggregateFormRequest extends ApiRequest // check all subrequests for rules and combine them return array_reduce( $this->requests, - static fn (array $rules, FormRequest $request) => $rules + static fn (array $rules, FormRequest $request): array => $rules + ( method_exists($request, 'rules') ? $request->rules() @@ -91,7 +93,7 @@ abstract class AggregateFormRequest extends ApiRequest // register all subrequests' validators foreach ($this->requests as $request) { if (method_exists($request, 'withValidator')) { - Log::debug(sprintf('Process withValidator from class %s', get_class($request))); + Log::debug(sprintf('Process withValidator from class %s', $request::class)); $request->withValidator($validator); } } diff --git a/app/Api/V1/Requests/Chart/ChartRequest.php b/app/Api/V1/Requests/Chart/ChartRequest.php index bf43fe47c2..83b666943d 100644 --- a/app/Api/V1/Requests/Chart/ChartRequest.php +++ b/app/Api/V1/Requests/Chart/ChartRequest.php @@ -24,13 +24,13 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Chart; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Enums\UserRoleEnum; use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class ChartRequest diff --git a/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php b/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php index 3ada80f591..8731e354aa 100644 --- a/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php +++ b/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php @@ -24,12 +24,12 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Data\Bulk; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class MoveTransactionsRequest diff --git a/app/Api/V1/Requests/Data/Bulk/TransactionRequest.php b/app/Api/V1/Requests/Data/Bulk/TransactionRequest.php index 902967a9c2..4be7ceb07d 100644 --- a/app/Api/V1/Requests/Data/Bulk/TransactionRequest.php +++ b/app/Api/V1/Requests/Data/Bulk/TransactionRequest.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Data\Bulk; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Enums\ClauseType; use FireflyIII\Rules\IsValidBulkClause; use FireflyIII\Support\Request\ChecksLogin; @@ -31,7 +32,6 @@ use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Validation\Api\Data\Bulk\ValidatesBulkTransactionQuery; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; use JsonException; use function Safe\json_decode; diff --git a/app/Api/V1/Requests/DateRangeRequest.php b/app/Api/V1/Requests/DateRangeRequest.php index 19614e640b..afaddc5bc1 100644 --- a/app/Api/V1/Requests/DateRangeRequest.php +++ b/app/Api/V1/Requests/DateRangeRequest.php @@ -23,7 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests; -use Illuminate\Validation\Validator; +use Illuminate\Contracts\Validation\Validator; class DateRangeRequest extends ApiRequest { diff --git a/app/Api/V1/Requests/DateRequest.php b/app/Api/V1/Requests/DateRequest.php index b73970786d..8344164845 100644 --- a/app/Api/V1/Requests/DateRequest.php +++ b/app/Api/V1/Requests/DateRequest.php @@ -23,8 +23,8 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests; +use Illuminate\Contracts\Validation\Validator; use Carbon\Carbon; -use Illuminate\Validation\Validator; class DateRequest extends ApiRequest { diff --git a/app/Api/V1/Requests/Generic/ObjectTypeApiRequest.php b/app/Api/V1/Requests/Generic/ObjectTypeApiRequest.php index 7fb642d72d..2e8a793747 100644 --- a/app/Api/V1/Requests/Generic/ObjectTypeApiRequest.php +++ b/app/Api/V1/Requests/Generic/ObjectTypeApiRequest.php @@ -23,6 +23,8 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Generic; +use Override; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Api\V1\Requests\ApiRequest; use FireflyIII\Models\Account; use FireflyIII\Models\Transaction; @@ -30,7 +32,6 @@ use FireflyIII\Rules\Account\IsValidAccountTypeList; use FireflyIII\Rules\TransactionType\IsValidTransactionTypeList; use FireflyIII\Support\Http\Api\AccountFilter; use FireflyIII\Support\Http\Api\TransactionFilter; -use Illuminate\Validation\Validator; use RuntimeException; class ObjectTypeApiRequest extends ApiRequest @@ -40,6 +41,7 @@ class ObjectTypeApiRequest extends ApiRequest private ?string $objectType = null; + #[Override] public function handleConfig(array $config): void { parent::handleConfig($config); diff --git a/app/Api/V1/Requests/Generic/QueryRequest.php b/app/Api/V1/Requests/Generic/QueryRequest.php index 10051fc0a8..0b01399e33 100644 --- a/app/Api/V1/Requests/Generic/QueryRequest.php +++ b/app/Api/V1/Requests/Generic/QueryRequest.php @@ -23,10 +23,10 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Generic; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Api\V1\Requests\ApiRequest; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; -use Illuminate\Validation\Validator; class QueryRequest extends ApiRequest { diff --git a/app/Api/V1/Requests/Models/Account/AccountTypeApiRequest.php b/app/Api/V1/Requests/Models/Account/AccountTypeApiRequest.php index e1e6bc686f..3261423b11 100644 --- a/app/Api/V1/Requests/Models/Account/AccountTypeApiRequest.php +++ b/app/Api/V1/Requests/Models/Account/AccountTypeApiRequest.php @@ -23,9 +23,9 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\Account; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Api\V1\Requests\ApiRequest; use FireflyIII\Support\Http\Api\AccountFilter; -use Illuminate\Validation\Validator; class AccountTypeApiRequest extends ApiRequest { diff --git a/app/Api/V1/Requests/Models/Account/AccountTypesApiRequest.php b/app/Api/V1/Requests/Models/Account/AccountTypesApiRequest.php index 5662ad207f..03710a9bf3 100644 --- a/app/Api/V1/Requests/Models/Account/AccountTypesApiRequest.php +++ b/app/Api/V1/Requests/Models/Account/AccountTypesApiRequest.php @@ -23,10 +23,10 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\Account; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Api\V1\Requests\ApiRequest; use FireflyIII\Rules\Account\IsValidAccountTypeList; use FireflyIII\Support\Http\Api\AccountFilter; -use Illuminate\Validation\Validator; class AccountTypesApiRequest extends ApiRequest { diff --git a/app/Api/V1/Requests/Models/Account/ShowRequest.php b/app/Api/V1/Requests/Models/Account/ShowRequest.php index b9abe7957b..5f3b11a29b 100644 --- a/app/Api/V1/Requests/Models/Account/ShowRequest.php +++ b/app/Api/V1/Requests/Models/Account/ShowRequest.php @@ -26,7 +26,6 @@ namespace FireflyIII\Api\V1\Requests\Models\Account; use FireflyIII\Api\V1\Requests\AggregateFormRequest; use FireflyIII\Api\V1\Requests\DateRangeRequest; use FireflyIII\Api\V1\Requests\DateRequest; -use FireflyIII\Api\V1\Requests\Generic\ObjectTypeApiRequest; use FireflyIII\Api\V1\Requests\PaginationRequest; use FireflyIII\Models\Account; diff --git a/app/Api/V1/Requests/Models/Account/UpdateRequest.php b/app/Api/V1/Requests/Models/Account/UpdateRequest.php index dbe30eab1b..5fb31b6fc8 100644 --- a/app/Api/V1/Requests/Models/Account/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Account/UpdateRequest.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\Account; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Models\Account; use FireflyIII\Models\Location; use FireflyIII\Repositories\Account\AccountRepositoryInterface; @@ -35,7 +36,6 @@ use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class UpdateRequest diff --git a/app/Api/V1/Requests/Models/Attachment/StoreRequest.php b/app/Api/V1/Requests/Models/Attachment/StoreRequest.php index 2c8f572843..5c4cc9bcc7 100644 --- a/app/Api/V1/Requests/Models/Attachment/StoreRequest.php +++ b/app/Api/V1/Requests/Models/Attachment/StoreRequest.php @@ -58,7 +58,7 @@ class StoreRequest extends FormRequest { $models = config('firefly.valid_attachment_models'); $models = array_map( - static fn (string $className) => str_replace('FireflyIII\Models\\', '', $className), + static fn (string $className): string => str_replace('FireflyIII\Models\\', '', $className), $models ); $models = implode(',', $models); diff --git a/app/Api/V1/Requests/Models/Attachment/UpdateRequest.php b/app/Api/V1/Requests/Models/Attachment/UpdateRequest.php index c84cd6a9d9..236a884419 100644 --- a/app/Api/V1/Requests/Models/Attachment/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Attachment/UpdateRequest.php @@ -60,7 +60,7 @@ class UpdateRequest extends FormRequest { $models = config('firefly.valid_attachment_models'); $models = array_map( - static fn (string $className) => str_replace('FireflyIII\Models\\', '', $className), + static fn (string $className): string => str_replace('FireflyIII\Models\\', '', $className), $models ); $models = implode(',', $models); diff --git a/app/Api/V1/Requests/Models/AvailableBudget/Request.php b/app/Api/V1/Requests/Models/AvailableBudget/Request.php index c2ddea145c..93b3f732b0 100644 --- a/app/Api/V1/Requests/Models/AvailableBudget/Request.php +++ b/app/Api/V1/Requests/Models/AvailableBudget/Request.php @@ -24,13 +24,13 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\AvailableBudget; +use Illuminate\Contracts\Validation\Validator; use Carbon\Carbon; use FireflyIII\Rules\IsValidPositiveAmount; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class Request diff --git a/app/Api/V1/Requests/Models/Bill/StoreRequest.php b/app/Api/V1/Requests/Models/Bill/StoreRequest.php index 393ff54ca3..7784ea6891 100644 --- a/app/Api/V1/Requests/Models/Bill/StoreRequest.php +++ b/app/Api/V1/Requests/Models/Bill/StoreRequest.php @@ -24,13 +24,13 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\Bill; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Rules\IsBoolean; use FireflyIII\Rules\IsValidPositiveAmount; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; use TypeError; use ValueError; diff --git a/app/Api/V1/Requests/Models/Bill/UpdateRequest.php b/app/Api/V1/Requests/Models/Bill/UpdateRequest.php index 8b16cce5e3..149f5ad4b7 100644 --- a/app/Api/V1/Requests/Models/Bill/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Bill/UpdateRequest.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\Bill; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Models\Bill; use FireflyIII\Rules\IsBoolean; use FireflyIII\Rules\IsValidPositiveAmount; @@ -31,7 +32,6 @@ use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class UpdateRequest diff --git a/app/Api/V1/Requests/Models/Budget/StoreRequest.php b/app/Api/V1/Requests/Models/Budget/StoreRequest.php index 9d3a9bc883..27fc63e405 100644 --- a/app/Api/V1/Requests/Models/Budget/StoreRequest.php +++ b/app/Api/V1/Requests/Models/Budget/StoreRequest.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\Budget; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Rules\IsBoolean; use FireflyIII\Rules\IsValidPositiveAmount; use FireflyIII\Support\Request\ChecksLogin; @@ -31,7 +32,6 @@ use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Validation\AutoBudget\ValidatesAutoBudgetRequest; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class StoreRequest diff --git a/app/Api/V1/Requests/Models/Budget/UpdateRequest.php b/app/Api/V1/Requests/Models/Budget/UpdateRequest.php index d028906aa4..1048aeb3d1 100644 --- a/app/Api/V1/Requests/Models/Budget/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Budget/UpdateRequest.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\Budget; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Models\Budget; use FireflyIII\Rules\IsBoolean; use FireflyIII\Rules\IsValidPositiveAmount; @@ -32,7 +33,6 @@ use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Validation\AutoBudget\ValidatesAutoBudgetRequest; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class UpdateRequest diff --git a/app/Api/V1/Requests/Models/BudgetLimit/StoreRequest.php b/app/Api/V1/Requests/Models/BudgetLimit/StoreRequest.php index 1a705223de..914df7dcf2 100644 --- a/app/Api/V1/Requests/Models/BudgetLimit/StoreRequest.php +++ b/app/Api/V1/Requests/Models/BudgetLimit/StoreRequest.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\BudgetLimit; +use Illuminate\Contracts\Validation\Validator; use Carbon\Carbon; use FireflyIII\Factory\TransactionCurrencyFactory; use FireflyIII\Rules\IsBoolean; @@ -33,7 +34,6 @@ use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class StoreRequest diff --git a/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php b/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php index f4ecfa9ac4..0448048c7e 100644 --- a/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\BudgetLimit; +use Illuminate\Contracts\Validation\Validator; use Carbon\Carbon; use FireflyIII\Rules\IsBoolean; use FireflyIII\Rules\IsValidPositiveAmount; @@ -31,7 +32,6 @@ use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class UpdateRequest diff --git a/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByCurrenciesRequest.php b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByCurrenciesRequest.php index b7a8d00159..14fe7f25a0 100644 --- a/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByCurrenciesRequest.php +++ b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByCurrenciesRequest.php @@ -24,12 +24,12 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\CurrencyExchangeRate; +use Illuminate\Contracts\Validation\Validator; use Carbon\Carbon; use Carbon\Exceptions\InvalidFormatException; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; -use Illuminate\Validation\Validator; class StoreByCurrenciesRequest extends FormRequest { diff --git a/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php index de5dbe94c9..c3ec816361 100644 --- a/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php +++ b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php @@ -24,13 +24,13 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\CurrencyExchangeRate; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\TransactionCurrency; use FireflyIII\Support\Facades\Amount; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; -use Illuminate\Validation\Validator; class StoreByDateRequest extends FormRequest { diff --git a/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php b/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php index 81acd25bd7..a791f741a4 100644 --- a/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php +++ b/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\PiggyBank; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Models\TransactionCurrency; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Rules\IsValidZeroOrMoreAmount; @@ -32,7 +33,6 @@ use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class StoreRequest diff --git a/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php b/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php index 387f28f930..b9f736f74f 100644 --- a/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php +++ b/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\Recurrence; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Rules\BelongsUser; use FireflyIII\Rules\IsBoolean; use FireflyIII\Rules\IsValidPositiveAmount; @@ -35,7 +36,6 @@ use FireflyIII\Validation\RecurrenceValidation; use FireflyIII\Validation\TransactionValidation; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class StoreRequest diff --git a/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php b/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php index ea5cbd0f9a..f16c521590 100644 --- a/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\Recurrence; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Models\Recurrence; use FireflyIII\Rules\BelongsUser; use FireflyIII\Rules\IsBoolean; @@ -36,7 +37,6 @@ use FireflyIII\Validation\RecurrenceValidation; use FireflyIII\Validation\TransactionValidation; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class UpdateRequest diff --git a/app/Api/V1/Requests/Models/Rule/StoreRequest.php b/app/Api/V1/Requests/Models/Rule/StoreRequest.php index dd65d648a0..1a9bdc1df9 100644 --- a/app/Api/V1/Requests/Models/Rule/StoreRequest.php +++ b/app/Api/V1/Requests/Models/Rule/StoreRequest.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\Rule; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Rules\IsBoolean; use FireflyIII\Rules\IsValidActionExpression; use FireflyIII\Support\Request\ChecksLogin; @@ -31,7 +32,6 @@ use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\GetRuleConfiguration; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class StoreRequest @@ -202,7 +202,7 @@ class StoreRequest extends FormRequest $inactiveIndex = $index; } } - if (true === $allInactive) { + if ($allInactive) { $validator->errors()->add(sprintf('triggers.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_trigger')); } } @@ -231,7 +231,7 @@ class StoreRequest extends FormRequest $inactiveIndex = $index; } } - if (true === $allInactive) { + if ($allInactive) { $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/UpdateRequest.php b/app/Api/V1/Requests/Models/Rule/UpdateRequest.php index 13a8a97676..e51f81b3fe 100644 --- a/app/Api/V1/Requests/Models/Rule/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Rule/UpdateRequest.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\Rule; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Models\Rule; use FireflyIII\Rules\IsBoolean; use FireflyIII\Rules\IsValidActionExpression; @@ -32,7 +33,6 @@ use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\GetRuleConfiguration; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class UpdateRequest @@ -207,7 +207,7 @@ class UpdateRequest extends FormRequest $inactiveIndex = $index; } } - if (true === $allInactive) { + if ($allInactive) { $validator->errors()->add(sprintf('triggers.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_trigger')); } } @@ -248,7 +248,7 @@ class UpdateRequest extends FormRequest $inactiveIndex = $index; } } - if (true === $allInactive) { + if ($allInactive) { $validator->errors()->add(sprintf('actions.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_action')); } } diff --git a/app/Api/V1/Requests/Models/Transaction/StoreRequest.php b/app/Api/V1/Requests/Models/Transaction/StoreRequest.php index 2b54cb977c..22fc2030b8 100644 --- a/app/Api/V1/Requests/Models/Transaction/StoreRequest.php +++ b/app/Api/V1/Requests/Models/Transaction/StoreRequest.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\Transaction; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Models\Location; use FireflyIII\Rules\BelongsUser; use FireflyIII\Rules\IsBoolean; @@ -39,7 +40,6 @@ use FireflyIII\Validation\GroupValidation; use FireflyIII\Validation\TransactionValidation; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class StoreRequest diff --git a/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php b/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php index af1b57cb29..1578b4ba12 100644 --- a/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\Transaction; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\TransactionGroup; use FireflyIII\Rules\BelongsUser; @@ -37,7 +38,6 @@ use FireflyIII\Validation\GroupValidation; use FireflyIII\Validation\TransactionValidation; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class UpdateRequest diff --git a/app/Api/V1/Requests/Models/TransactionCurrency/CurrencyCodeRequest.php b/app/Api/V1/Requests/Models/TransactionCurrency/CurrencyCodeRequest.php index 72a2c6bc59..833ce92b1e 100644 --- a/app/Api/V1/Requests/Models/TransactionCurrency/CurrencyCodeRequest.php +++ b/app/Api/V1/Requests/Models/TransactionCurrency/CurrencyCodeRequest.php @@ -23,8 +23,8 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\TransactionCurrency; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Api\V1\Requests\ApiRequest; -use Illuminate\Validation\Validator; class CurrencyCodeRequest extends ApiRequest { diff --git a/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php b/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php index 638bda8306..b93334289d 100644 --- a/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php +++ b/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\TransactionLink; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface; use FireflyIII\Support\Request\ChecksLogin; @@ -31,7 +32,6 @@ use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\User; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class StoreRequest diff --git a/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php b/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php index 0ab51bccd0..ce62f5a87c 100644 --- a/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\TransactionLink; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Models\TransactionJournalLink; use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface; @@ -31,7 +32,6 @@ use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class UpdateRequest diff --git a/app/Api/V1/Requests/Models/Webhook/CreateRequest.php b/app/Api/V1/Requests/Models/Webhook/CreateRequest.php index 73318823ca..a0b66b50a2 100644 --- a/app/Api/V1/Requests/Models/Webhook/CreateRequest.php +++ b/app/Api/V1/Requests/Models/Webhook/CreateRequest.php @@ -52,7 +52,7 @@ class CreateRequest extends FormRequest $responses = $this->get('responses', []); $deliveries = $this->get('deliveries', []); - if (0 === count($triggers) || 0 === count($responses) || 0 === count($deliveries)) { + if (in_array(0, [count($triggers), count($responses), count($deliveries)], true)) { throw new FireflyException('Unexpectedly got no responses, triggers or deliveries.'); } diff --git a/app/Api/V1/Requests/Models/Webhook/UpdateRequest.php b/app/Api/V1/Requests/Models/Webhook/UpdateRequest.php index aa37a0b4ed..07dcf74b0c 100644 --- a/app/Api/V1/Requests/Models/Webhook/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Webhook/UpdateRequest.php @@ -53,7 +53,7 @@ class UpdateRequest extends FormRequest $responses = $this->get('responses', []); $deliveries = $this->get('deliveries', []); - if (0 === count($triggers) || 0 === count($responses) || 0 === count($deliveries)) { + if (in_array(0, [count($triggers), count($responses), count($deliveries)], true)) { throw new FireflyException('Unexpectedly got no responses, triggers or deliveries.'); } diff --git a/app/Api/V1/Requests/PaginationRequest.php b/app/Api/V1/Requests/PaginationRequest.php index d9a59c1969..1dad0ca20f 100644 --- a/app/Api/V1/Requests/PaginationRequest.php +++ b/app/Api/V1/Requests/PaginationRequest.php @@ -23,16 +23,18 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests; +use Override; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Rules\IsValidSortInstruction; use FireflyIII\Support\Facades\Preferences; use FireflyIII\User; -use Illuminate\Validation\Validator; use RuntimeException; class PaginationRequest extends ApiRequest { private ?string $sortClass = null; + #[Override] public function handleConfig(array $config): void { parent::handleConfig($config); diff --git a/app/Api/V1/Requests/System/UserUpdateRequest.php b/app/Api/V1/Requests/System/UserUpdateRequest.php index 553f8e54e4..d22090ba0b 100644 --- a/app/Api/V1/Requests/System/UserUpdateRequest.php +++ b/app/Api/V1/Requests/System/UserUpdateRequest.php @@ -24,13 +24,13 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\System; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Rules\IsBoolean; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\User; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class UserUpdateRequest diff --git a/app/Console/Commands/Correction/CorrectsAmounts.php b/app/Console/Commands/Correction/CorrectsAmounts.php index 328196817f..85243b437e 100644 --- a/app/Console/Commands/Correction/CorrectsAmounts.php +++ b/app/Console/Commands/Correction/CorrectsAmounts.php @@ -220,7 +220,7 @@ class CorrectsAmounts extends Command /** @var RuleTrigger $item */ foreach ($set as $item) { $result = $this->fixRuleTrigger($item); - if (true === $result) { + if ($result) { ++$fixed; } } diff --git a/app/Console/Commands/Correction/CorrectsCurrencies.php b/app/Console/Commands/Correction/CorrectsCurrencies.php index 1ded27400b..d1ee224081 100644 --- a/app/Console/Commands/Correction/CorrectsCurrencies.php +++ b/app/Console/Commands/Correction/CorrectsCurrencies.php @@ -115,7 +115,7 @@ class CorrectsCurrencies extends Command $found = array_values( array_filter( $found, - static fn (int $currencyId) => 0 !== $currencyId + static fn (int $currencyId): bool => 0 !== $currencyId ) ); diff --git a/app/Console/Commands/Correction/CorrectsGroupInformation.php b/app/Console/Commands/Correction/CorrectsGroupInformation.php index c55a3f0029..cba18e475b 100644 --- a/app/Console/Commands/Correction/CorrectsGroupInformation.php +++ b/app/Console/Commands/Correction/CorrectsGroupInformation.php @@ -55,10 +55,8 @@ class CorrectsGroupInformation extends Command /** * Execute the console command. - * - * @return int */ - public function handle() + public function handle(): int { // objects: accounts, attachments, available budgets, bills, budgets, categories, currency_exchange_rates // recurrences, rule groups, rules, tags, transaction groups, transaction journals, webhooks diff --git a/app/Console/Commands/Correction/CorrectsIbans.php b/app/Console/Commands/Correction/CorrectsIbans.php index 93062e1c8c..3b41d44bf5 100644 --- a/app/Console/Commands/Correction/CorrectsIbans.php +++ b/app/Console/Commands/Correction/CorrectsIbans.php @@ -93,25 +93,20 @@ class CorrectsIbans extends Command if (in_array($type, [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value], true)) { $type = 'liabilities'; } - if (array_key_exists($iban, $set[$userId])) { - // iban already in use! two exceptions exist: - if ( - !(AccountTypeEnum::EXPENSE->value === $set[$userId][$iban] && AccountTypeEnum::REVENUE->value === $type) // allowed combination - && !(AccountTypeEnum::REVENUE->value === $set[$userId][$iban] && AccountTypeEnum::EXPENSE->value === $type) // also allowed combination. - ) { - $this->friendlyWarning( - sprintf( - 'IBAN "%s" is used more than once and will be removed from %s #%d ("%s")', - $iban, - $account->accountType->type, - $account->id, - $account->name - ) - ); - $account->iban = null; - $account->save(); - ++$this->count; - } + // iban already in use! two exceptions exist: + if (array_key_exists($iban, $set[$userId]) && (!AccountTypeEnum::EXPENSE->value === $set[$userId][$iban] && AccountTypeEnum::REVENUE->value === $type && !(AccountTypeEnum::REVENUE->value === $set[$userId][$iban] && AccountTypeEnum::EXPENSE->value === $type))) { + $this->friendlyWarning( + sprintf( + 'IBAN "%s" is used more than once and will be removed from %s #%d ("%s")', + $iban, + $account->accountType->type, + $account->id, + $account->name + ) + ); + $account->iban = null; + $account->save(); + ++$this->count; } if (!array_key_exists($iban, $set[$userId])) { diff --git a/app/Console/Commands/Correction/CorrectsPrimaryCurrencyAmounts.php b/app/Console/Commands/Correction/CorrectsPrimaryCurrencyAmounts.php index 563cd6c08f..bfb7ed2007 100644 --- a/app/Console/Commands/Correction/CorrectsPrimaryCurrencyAmounts.php +++ b/app/Console/Commands/Correction/CorrectsPrimaryCurrencyAmounts.php @@ -130,7 +130,7 @@ class CorrectsPrimaryCurrencyAmounts extends Command $repository->setUserGroup($userGroup); $set = $repository->getPiggyBanks(); $set = $set->filter( - static fn (PiggyBank $piggyBank) => $currency->id !== $piggyBank->transaction_currency_id + static fn (PiggyBank $piggyBank): bool => $currency->id !== $piggyBank->transaction_currency_id ); foreach ($set as $piggyBank) { $piggyBank->encrypted = false; diff --git a/app/Console/Commands/Correction/CorrectsTransactionTypes.php b/app/Console/Commands/Correction/CorrectsTransactionTypes.php index 3663917ef5..18d99038ed 100644 --- a/app/Console/Commands/Correction/CorrectsTransactionTypes.php +++ b/app/Console/Commands/Correction/CorrectsTransactionTypes.php @@ -53,7 +53,7 @@ class CorrectsTransactionTypes extends Command /** @var TransactionJournal $journal */ foreach ($journals as $journal) { $fixed = $this->fixJournal($journal); - if (true === $fixed) { + if ($fixed) { ++$count; } } @@ -115,7 +115,7 @@ class CorrectsTransactionTypes extends Command private function getSourceAccount(TransactionJournal $journal): Account { $collection = $journal->transactions->filter( - static fn (Transaction $transaction) => $transaction->amount < 0 + static fn (Transaction $transaction): bool => $transaction->amount < 0 ); if (0 === $collection->count()) { throw new FireflyException(sprintf('300001: Journal #%d has no source transaction.', $journal->id)); @@ -142,7 +142,7 @@ class CorrectsTransactionTypes extends Command private function getDestinationAccount(TransactionJournal $journal): Account { $collection = $journal->transactions->filter( - static fn (Transaction $transaction) => $transaction->amount > 0 + static fn (Transaction $transaction): bool => $transaction->amount > 0 ); if (0 === $collection->count()) { throw new FireflyException(sprintf('300004: Journal #%d has no destination transaction.', $journal->id)); diff --git a/app/Console/Commands/Correction/CorrectsUnevenAmount.php b/app/Console/Commands/Correction/CorrectsUnevenAmount.php index 4f6519951c..491f6dde2b 100644 --- a/app/Console/Commands/Correction/CorrectsUnevenAmount.php +++ b/app/Console/Commands/Correction/CorrectsUnevenAmount.php @@ -251,27 +251,19 @@ class CorrectsUnevenAmount extends Command /** @var Transaction $source */ $source = $journal->transactions()->where('amount', '<', 0)->first(); - // safety catch on NULL should not be necessary, we just had that catch. // source amount = dest foreign amount // source currency = dest foreign currency // dest amount = source foreign currency // dest currency = source foreign currency - // Log::debug(sprintf('[a] %s', bccomp(app('steam')->positive($source->amount), app('steam')->positive($destination->foreign_amount)))); // Log::debug(sprintf('[b] %s', bccomp(app('steam')->positive($destination->amount), app('steam')->positive($source->foreign_amount)))); // Log::debug(sprintf('[c] %s', var_export($source->transaction_currency_id === $destination->foreign_currency_id,true))); // Log::debug(sprintf('[d] %s', var_export((int) $destination->transaction_currency_id ===(int) $source->foreign_currency_id, true))); - - if (0 === bccomp(Steam::positive($source->amount), Steam::positive($destination->foreign_amount)) + return 0 === bccomp(Steam::positive($source->amount), Steam::positive($destination->foreign_amount)) && $source->transaction_currency_id === $destination->foreign_currency_id && 0 === bccomp(Steam::positive($destination->amount), Steam::positive($source->foreign_amount)) - && (int) $destination->transaction_currency_id === (int) $source->foreign_currency_id - ) { - return true; - } - - return false; + && (int) $destination->transaction_currency_id === (int) $source->foreign_currency_id; } private function matchCurrencies(): void diff --git a/app/Console/Commands/Correction/RestoresOAuthKeys.php b/app/Console/Commands/Correction/RestoresOAuthKeys.php index 599f127395..a85fba2bf8 100644 --- a/app/Console/Commands/Correction/RestoresOAuthKeys.php +++ b/app/Console/Commands/Correction/RestoresOAuthKeys.php @@ -56,7 +56,7 @@ class RestoresOAuthKeys extends Command } if ($this->keysInDatabase() && !$this->keysOnDrive()) { $result = $this->restoreKeysFromDB(); - if (true === $result) { + if ($result) { $this->friendlyInfo('Restored OAuth keys from database.'); return; diff --git a/app/Console/Commands/Export/ExportsData.php b/app/Console/Commands/Export/ExportsData.php index 90a8c9602b..2a9b55292c 100644 --- a/app/Console/Commands/Export/ExportsData.php +++ b/app/Console/Commands/Export/ExportsData.php @@ -206,7 +206,7 @@ class ExportsData extends Command $error = true; } - if (true === $error && 'start' === $field) { + if ($error && 'start' === $field) { $journal = $this->journalRepository->firstNull(); $date = $journal instanceof TransactionJournal ? $journal->date : today(config('app.timezone'))->subYear(); $date->startOfDay(); @@ -214,7 +214,7 @@ class ExportsData extends Command return $date; } // field can only be 'end' at this point, so no need to include it in the check. - if (true === $error) { + if ($error) { $date = today(config('app.timezone')); $date->endOfDay(); diff --git a/app/Console/Commands/System/CreatesDatabase.php b/app/Console/Commands/System/CreatesDatabase.php index 1e88f7209f..685aaf101d 100644 --- a/app/Console/Commands/System/CreatesDatabase.php +++ b/app/Console/Commands/System/CreatesDatabase.php @@ -86,7 +86,7 @@ class CreatesDatabase extends Command $pdo->exec(sprintf('CREATE DATABASE `%s` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;', env('DB_DATABASE'))); $this->friendlyInfo(sprintf('Created database "%s"', env('DB_DATABASE'))); } - if (true === $exists) { + if ($exists) { $this->friendlyInfo(sprintf('Database "%s" exists.', env('DB_DATABASE'))); } diff --git a/app/Console/Commands/System/ForcesDecimalSize.php b/app/Console/Commands/System/ForcesDecimalSize.php index 4cbbe5546c..e3a644e2bc 100644 --- a/app/Console/Commands/System/ForcesDecimalSize.php +++ b/app/Console/Commands/System/ForcesDecimalSize.php @@ -132,11 +132,11 @@ class ForcesDecimalSize extends Command { // if sqlite, add function? if ('sqlite' === (string) config('database.default')) { - DB::connection()->getPdo()->sqliteCreateFunction('REGEXP', static function ($pattern, $value) { + DB::connection()->getPdo()->sqliteCreateFunction('REGEXP', static function ($pattern, $value): int { mb_regex_encoding('UTF-8'); $pattern = trim($pattern, '"'); - return (false !== mb_ereg($pattern, (string) $value)) ? 1 : 0; + return (mb_ereg($pattern, (string) $value)) ? 1 : 0; }); } diff --git a/app/Console/Commands/Tools/ApplyRules.php b/app/Console/Commands/Tools/ApplyRules.php index 0b07299ab1..555f3b39a0 100644 --- a/app/Console/Commands/Tools/ApplyRules.php +++ b/app/Console/Commands/Tools/ApplyRules.php @@ -314,7 +314,7 @@ class ApplyRules extends Command foreach ($rules as $rule) { // if in rule selection, or group in selection or all rules, it's included. $test = $this->includeRule($rule, $group); - if (true === $test) { + if ($test) { Log::debug(sprintf('Will include rule #%d "%s"', $rule->id, $rule->title)); $rulesToApply->push($rule); } diff --git a/app/Console/Commands/Upgrade/UpgradesLiabilitiesEight.php b/app/Console/Commands/Upgrade/UpgradesLiabilitiesEight.php index 26ecde2584..611aa7d08b 100644 --- a/app/Console/Commands/Upgrade/UpgradesLiabilitiesEight.php +++ b/app/Console/Commands/Upgrade/UpgradesLiabilitiesEight.php @@ -136,11 +136,7 @@ class UpgradesLiabilitiesEight extends Command if (null === $liabilityJournal) { return false; } - if (!$openingJournal->date->isSameDay($liabilityJournal->date)) { - return false; - } - - return true; + return (bool) $openingJournal->date->isSameDay($liabilityJournal->date); } private function deleteCreditTransaction(Account $account): void diff --git a/app/Console/Commands/Upgrade/UpgradesTagLocations.php b/app/Console/Commands/Upgrade/UpgradesTagLocations.php index c891de9982..1bba349b76 100644 --- a/app/Console/Commands/Upgrade/UpgradesTagLocations.php +++ b/app/Console/Commands/Upgrade/UpgradesTagLocations.php @@ -77,7 +77,7 @@ class UpgradesTagLocations extends Command private function hasLocationDetails(Tag $tag): bool { - return null !== $tag->latitude && null !== $tag->longitude && null !== $tag->zoomLevel; + return !in_array(null, [$tag->latitude, $tag->longitude, $tag->zoomLevel], true); } private function migrateLocationDetails(Tag $tag): void diff --git a/app/Console/Commands/Upgrade/UpgradesToGroups.php b/app/Console/Commands/Upgrade/UpgradesToGroups.php index c5db2427ca..b1411a7b25 100644 --- a/app/Console/Commands/Upgrade/UpgradesToGroups.php +++ b/app/Console/Commands/Upgrade/UpgradesToGroups.php @@ -180,7 +180,7 @@ class UpgradesToGroups extends Command private function getDestinationTransactions(TransactionJournal $journal): Collection { return $journal->transactions->filter( - static fn (Transaction $transaction) => $transaction->amount > 0 + static fn (Transaction $transaction): bool => $transaction->amount > 0 ); } @@ -278,7 +278,7 @@ class UpgradesToGroups extends Command private function findOpposingTransaction(TransactionJournal $journal, Transaction $transaction): ?Transaction { $set = $journal->transactions->filter( - static function (Transaction $subject) use ($transaction) { + static function (Transaction $subject) use ($transaction): bool { $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))); diff --git a/app/Console/Commands/Upgrade/UpgradesVariousCurrencyInformation.php b/app/Console/Commands/Upgrade/UpgradesVariousCurrencyInformation.php index 2b47161771..f0e669797d 100644 --- a/app/Console/Commands/Upgrade/UpgradesVariousCurrencyInformation.php +++ b/app/Console/Commands/Upgrade/UpgradesVariousCurrencyInformation.php @@ -211,7 +211,6 @@ class UpgradesVariousCurrencyInformation extends Command break; } - /** @var null|Transaction */ return $lead; } diff --git a/app/Console/Commands/Upgrade/UpgradesWebhooks.php b/app/Console/Commands/Upgrade/UpgradesWebhooks.php index e917b09596..bd4773a3f9 100644 --- a/app/Console/Commands/Upgrade/UpgradesWebhooks.php +++ b/app/Console/Commands/Upgrade/UpgradesWebhooks.php @@ -84,7 +84,7 @@ class UpgradesWebhooks extends Command $delivery = WebhookDelivery::tryFrom((int)$webhook->delivery); $response = WebhookResponse::tryFrom((int)$webhook->response); $trigger = WebhookTrigger::tryFrom((int)$webhook->trigger); - if (null === $delivery || null === $response || null === $trigger) { + if (in_array(null, [$delivery, $response, $trigger], true)) { $this->friendlyError(sprintf('[a] Webhook #%d has an invalid delivery, response or trigger value. Will not upgrade.', $webhook->id)); return; @@ -92,7 +92,7 @@ class UpgradesWebhooks extends Command $deliveryModel = WebhookDeliveryModel::where('key', $delivery->value)->first(); $responseModel = WebhookResponseModel::where('key', $response->value)->first(); $triggerModel = WebhookTriggerModel::where('key', $trigger->value)->first(); - if (null === $deliveryModel || null === $responseModel || null === $triggerModel) { + if (in_array(null, [$deliveryModel, $responseModel, $triggerModel], true)) { $this->friendlyError(sprintf('[b] Webhook #%d has an invalid delivery, response or trigger model. Will not upgrade.', $webhook->id)); return; diff --git a/app/Events/RequestedReportOnJournals.php b/app/Events/RequestedReportOnJournals.php index 27df251eb3..94bd7e2e6a 100644 --- a/app/Events/RequestedReportOnJournals.php +++ b/app/Events/RequestedReportOnJournals.php @@ -50,10 +50,8 @@ class RequestedReportOnJournals /** * Get the channels the event should broadcast on. - * - * @return PrivateChannel */ - public function broadcastOn() + public function broadcastOn(): PrivateChannel { return new PrivateChannel('channel-name'); } diff --git a/app/Exceptions/GracefulNotFoundHandler.php b/app/Exceptions/GracefulNotFoundHandler.php index 6f905adb22..0251bf4f1b 100644 --- a/app/Exceptions/GracefulNotFoundHandler.php +++ b/app/Exceptions/GracefulNotFoundHandler.php @@ -194,7 +194,7 @@ class GracefulNotFoundHandler extends ExceptionHandler $user = auth()->user(); $route = $request->route(); $param = $route->parameter('transactionGroup'); - $groupId = !is_object($param) ? (int) $param : 0; + $groupId = is_object($param) ? 0 : (int) $param; /** @var null|TransactionGroup $group */ $group = $user->transactionGroups()->withTrashed()->find($groupId); diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 8db203a421..5322b93e08 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -274,7 +274,7 @@ class Handler extends ExceptionHandler { return null !== Arr::first( $this->dontReport, - static fn ($type) => $e instanceof $type + static fn ($type): bool => $e instanceof $type ); } diff --git a/app/Exceptions/IntervalException.php b/app/Exceptions/IntervalException.php index 4b6396ad19..046e9cdef7 100644 --- a/app/Exceptions/IntervalException.php +++ b/app/Exceptions/IntervalException.php @@ -33,8 +33,8 @@ use Throwable; */ final class IntervalException extends Exception { - public array $availableIntervals; - public Periodicity $periodicity; + public array $availableIntervals = []; + public Periodicity $periodicity = Periodicity::Monthly; /** @var mixed */ protected $message = 'The periodicity %s is unknown. Choose one of available periodicity: %s'; @@ -42,8 +42,6 @@ final class IntervalException extends Exception public function __construct(string $message = '', int $code = 0, ?Throwable $previous = null) { parent::__construct($message, $code, $previous); - $this->availableIntervals = []; - $this->periodicity = Periodicity::Monthly; } public static function unavailable( diff --git a/app/Factory/AccountFactory.php b/app/Factory/AccountFactory.php index 22df6a483e..699d02c186 100644 --- a/app/Factory/AccountFactory.php +++ b/app/Factory/AccountFactory.php @@ -130,7 +130,7 @@ class AccountFactory protected function getAccountType(array $data): ?AccountType { $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; + $accountTypeName = $data['account_type_name'] ?? null; $result = null; // find by name or ID if ($accountTypeId > 0) { @@ -174,7 +174,7 @@ class AccountFactory $this->accountRepository->resetAccountOrder(); // create it: - $virtualBalance = array_key_exists('virtual_balance', $data) ? $data['virtual_balance'] : null; + $virtualBalance = $data['virtual_balance'] ?? null; $active = array_key_exists('active', $data) ? $data['active'] : true; $databaseData = [ 'user_id' => $this->user->id, diff --git a/app/Factory/AttachmentFactory.php b/app/Factory/AttachmentFactory.php index 74e8643886..64f7d245f8 100644 --- a/app/Factory/AttachmentFactory.php +++ b/app/Factory/AttachmentFactory.php @@ -44,8 +44,8 @@ class AttachmentFactory public function create(array $data): ?Attachment { // append if necessary. - $model = !str_contains((string) $data['attachable_type'], 'FireflyIII') ? sprintf('FireflyIII\Models\%s', $data['attachable_type']) - : $data['attachable_type']; + $model = str_contains((string) $data['attachable_type'], 'FireflyIII') ? $data['attachable_type'] + : sprintf('FireflyIII\Models\%s', $data['attachable_type']); // get journal instead of transaction. if (Transaction::class === $model) { diff --git a/app/Factory/TagFactory.php b/app/Factory/TagFactory.php index 8c49cf53d4..e53dde916a 100644 --- a/app/Factory/TagFactory.php +++ b/app/Factory/TagFactory.php @@ -89,7 +89,7 @@ class TagFactory /** @var null|Tag $tag */ $tag = Tag::create($array); - if (null !== $tag && null !== $latitude && null !== $longitude) { + if (!in_array(null, [$tag, $latitude, $longitude], true)) { // create location object. $location = new Location(); $location->latitude = $latitude; diff --git a/app/Factory/TransactionFactory.php b/app/Factory/TransactionFactory.php index 1f53d562f7..354dc53418 100644 --- a/app/Factory/TransactionFactory.php +++ b/app/Factory/TransactionFactory.php @@ -41,20 +41,11 @@ use Illuminate\Support\Facades\Log; class TransactionFactory { private Account $account; - private array $accountInformation; + private array $accountInformation = []; private TransactionCurrency $currency; private ?TransactionCurrency $foreignCurrency = null; private TransactionJournal $journal; - private bool $reconciled; - - /** - * Constructor. - */ - public function __construct() - { - $this->reconciled = false; - $this->accountInformation = []; - } + private bool $reconciled = false; /** * Create transaction with negative amount (for source accounts). diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.php index cd47828c9d..8e7a28b281 100644 --- a/app/Factory/TransactionJournalFactory.php +++ b/app/Factory/TransactionJournalFactory.php @@ -71,7 +71,7 @@ class TransactionJournalFactory private AccountValidator $accountValidator; private BillRepositoryInterface $billRepository; private CurrencyRepositoryInterface $currencyRepository; - private bool $errorOnHash; + private bool $errorOnHash = false; private array $fields; private PiggyBankEventFactory $piggyEventFactory; private PiggyBankRepositoryInterface $piggyRepository; @@ -86,7 +86,6 @@ class TransactionJournalFactory */ public function __construct() { - $this->errorOnHash = false; $this->fields = config('firefly.journal_meta_fields'); $this->currencyRepository = app(CurrencyRepositoryInterface::class); $this->typeRepository = app(TransactionTypeRepositoryInterface::class); @@ -237,7 +236,7 @@ class TransactionJournalFactory Log::debug('Done with getAccount(2x)'); // there is a safety catch here. If either account is NULL, they will be replaced with the cash account. - if (null === $destinationAccount) { + if (!$destinationAccount instanceof Account) { Log::warning('Destination account is NULL, will replace with cash account.'); $destinationAccount = $this->accountRepository->getCashAccount(); } @@ -615,7 +614,7 @@ class TransactionJournalFactory private function storeLocation(TransactionJournal $journal, NullArrayObject $data): void { - if (null !== $data['longitude'] && null !== $data['latitude'] && null !== $data['zoom_level']) { + if (!in_array(null, [$data['longitude'], $data['latitude'], $data['zoom_level']], true)) { $location = new Location(); $location->longitude = $data['longitude']; $location->latitude = $data['latitude']; @@ -628,7 +627,7 @@ class TransactionJournalFactory public function setErrorOnHash(bool $errorOnHash): void { $this->errorOnHash = $errorOnHash; - if (true === $errorOnHash) { + if ($errorOnHash) { Log::info('Will trigger duplication alert for this journal.'); } } diff --git a/app/Generator/Report/Account/MonthReportGenerator.php b/app/Generator/Report/Account/MonthReportGenerator.php index bb9e5c8246..64cc958681 100644 --- a/app/Generator/Report/Account/MonthReportGenerator.php +++ b/app/Generator/Report/Account/MonthReportGenerator.php @@ -53,7 +53,7 @@ class MonthReportGenerator implements ReportGeneratorInterface $preferredPeriod = $this->preferredPeriod(); try { - $result = view('reports.double.report', compact('accountIds', 'reportType', 'doubleIds', 'preferredPeriod')) + $result = view('reports.double.report', ['accountIds' => $accountIds, 'reportType' => $reportType, 'doubleIds' => $doubleIds, 'preferredPeriod' => $preferredPeriod]) ->with('start', $this->start)->with('end', $this->end) ->with('doubles', $this->expense) ->render() diff --git a/app/Generator/Report/Audit/MonthReportGenerator.php b/app/Generator/Report/Audit/MonthReportGenerator.php index e62d609d9d..ffc3fe6c24 100644 --- a/app/Generator/Report/Audit/MonthReportGenerator.php +++ b/app/Generator/Report/Audit/MonthReportGenerator.php @@ -100,7 +100,7 @@ class MonthReportGenerator implements ReportGeneratorInterface ]; try { - $result = view('reports.audit.report', compact('reportType', 'accountIds', 'auditData', 'hideable', 'defaultShow')) + $result = view('reports.audit.report', ['reportType' => $reportType, 'accountIds' => $accountIds, 'auditData' => $auditData, 'hideable' => $hideable, 'defaultShow' => $defaultShow]) ->with('start', $this->start)->with('end', $this->end)->with('accounts', $this->accounts) ->render() ; diff --git a/app/Generator/Report/Budget/MonthReportGenerator.php b/app/Generator/Report/Budget/MonthReportGenerator.php index 5ed587a6df..a11697616a 100644 --- a/app/Generator/Report/Budget/MonthReportGenerator.php +++ b/app/Generator/Report/Budget/MonthReportGenerator.php @@ -41,17 +41,9 @@ class MonthReportGenerator implements ReportGeneratorInterface private Collection $accounts; private Collection $budgets; private Carbon $end; - private array $expenses; + private array $expenses = []; private Carbon $start; - /** - * MonthReportGenerator constructor. - */ - public function __construct() - { - $this->expenses = []; - } - /** * Generates the report. * @@ -65,7 +57,7 @@ class MonthReportGenerator implements ReportGeneratorInterface try { $result = view( 'reports.budget.month', - compact('accountIds', 'budgetIds') + ['accountIds' => $accountIds, 'budgetIds' => $budgetIds] ) ->with('start', $this->start)->with('end', $this->end) ->with('budgets', $this->budgets) diff --git a/app/Generator/Report/Category/MonthReportGenerator.php b/app/Generator/Report/Category/MonthReportGenerator.php index 8511c426d8..2360b93abd 100644 --- a/app/Generator/Report/Category/MonthReportGenerator.php +++ b/app/Generator/Report/Category/MonthReportGenerator.php @@ -41,19 +41,10 @@ class MonthReportGenerator implements ReportGeneratorInterface private Collection $accounts; private Collection $categories; private Carbon $end; - private array $expenses; - private array $income; + private array $expenses = []; + private array $income = []; private Carbon $start; - /** - * MonthReportGenerator constructor. - */ - public function __construct() - { - $this->income = []; - $this->expenses = []; - } - /** * Generates the report. * @@ -67,7 +58,7 @@ class MonthReportGenerator implements ReportGeneratorInterface // render! try { - return view('reports.category.month', compact('accountIds', 'categoryIds', 'reportType')) + return view('reports.category.month', ['accountIds' => $accountIds, 'categoryIds' => $categoryIds, 'reportType' => $reportType]) ->with('start', $this->start)->with('end', $this->end) ->with('categories', $this->categories) ->with('accounts', $this->accounts) diff --git a/app/Generator/Report/Standard/MonthReportGenerator.php b/app/Generator/Report/Standard/MonthReportGenerator.php index e7cd581f61..f8ad0b4f82 100644 --- a/app/Generator/Report/Standard/MonthReportGenerator.php +++ b/app/Generator/Report/Standard/MonthReportGenerator.php @@ -36,13 +36,13 @@ use Illuminate\Support\Facades\Log; class MonthReportGenerator implements ReportGeneratorInterface { /** @var Collection The accounts involved in the report. */ - private $accounts; + private ?Collection $accounts = null; /** @var Carbon The end date. */ - private $end; + private ?Carbon $end = null; /** @var Carbon The start date. */ - private $start; + private ?Carbon $start = null; /** * Generates the report. @@ -55,7 +55,7 @@ class MonthReportGenerator implements ReportGeneratorInterface $reportType = 'default'; try { - return view('reports.default.month', compact('accountIds', 'reportType'))->with('start', $this->start)->with('end', $this->end)->render(); + return view('reports.default.month', ['accountIds' => $accountIds, 'reportType' => $reportType])->with('start', $this->start)->with('end', $this->end)->render(); } catch (Throwable $e) { Log::error(sprintf('Cannot render reports.default.month: %s', $e->getMessage())); Log::error($e->getTraceAsString()); diff --git a/app/Generator/Report/Standard/MultiYearReportGenerator.php b/app/Generator/Report/Standard/MultiYearReportGenerator.php index 7802931a2d..dc49d75e7c 100644 --- a/app/Generator/Report/Standard/MultiYearReportGenerator.php +++ b/app/Generator/Report/Standard/MultiYearReportGenerator.php @@ -36,13 +36,13 @@ use Illuminate\Support\Facades\Log; class MultiYearReportGenerator implements ReportGeneratorInterface { /** @var Collection The accounts involved. */ - private $accounts; + private ?Collection $accounts = null; /** @var Carbon The end date. */ - private $end; + private ?Carbon $end = null; /** @var Carbon The start date. */ - private $start; + private ?Carbon $start = null; /** * Generates the report. @@ -58,7 +58,7 @@ class MultiYearReportGenerator implements ReportGeneratorInterface try { return view( 'reports.default.multi-year', - compact('accountIds', 'reportType') + ['accountIds' => $accountIds, 'reportType' => $reportType] )->with('start', $this->start)->with('end', $this->end)->render(); } catch (Throwable $e) { Log::error(sprintf('Cannot render reports.default.multi-year: %s', $e->getMessage())); diff --git a/app/Generator/Report/Standard/YearReportGenerator.php b/app/Generator/Report/Standard/YearReportGenerator.php index b705cdda61..995d49d335 100644 --- a/app/Generator/Report/Standard/YearReportGenerator.php +++ b/app/Generator/Report/Standard/YearReportGenerator.php @@ -36,13 +36,13 @@ use Illuminate\Support\Facades\Log; class YearReportGenerator implements ReportGeneratorInterface { /** @var Collection The accounts involved. */ - private $accounts; + private ?Collection $accounts = null; /** @var Carbon The end date. */ - private $end; + private ?Carbon $end = null; /** @var Carbon The start date. */ - private $start; + private ?Carbon $start = null; /** * Generates the report. @@ -58,7 +58,7 @@ class YearReportGenerator implements ReportGeneratorInterface try { $result = view( 'reports.default.year', - compact('accountIds', 'reportType') + ['accountIds' => $accountIds, 'reportType' => $reportType] )->with('start', $this->start)->with('end', $this->end)->render(); } catch (Throwable $e) { Log::error(sprintf('Cannot render reports.account.report: %s', $e->getMessage())); diff --git a/app/Generator/Report/Tag/MonthReportGenerator.php b/app/Generator/Report/Tag/MonthReportGenerator.php index 26d454e336..b7b6aad3a0 100644 --- a/app/Generator/Report/Tag/MonthReportGenerator.php +++ b/app/Generator/Report/Tag/MonthReportGenerator.php @@ -65,7 +65,7 @@ class MonthReportGenerator implements ReportGeneratorInterface try { $result = view( 'reports.tag.month', - compact('accountIds', 'reportType', 'tagIds') + ['accountIds' => $accountIds, 'reportType' => $reportType, 'tagIds' => $tagIds] )->with('start', $this->start)->with('end', $this->end)->with('tags', $this->tags)->with('accounts', $this->accounts)->render(); } catch (Throwable $e) { Log::error(sprintf('Cannot render reports.tag.month: %s', $e->getMessage())); diff --git a/app/Generator/Webhook/StandardMessageGenerator.php b/app/Generator/Webhook/StandardMessageGenerator.php index cd8ab1cdb9..d23a93cf3a 100644 --- a/app/Generator/Webhook/StandardMessageGenerator.php +++ b/app/Generator/Webhook/StandardMessageGenerator.php @@ -130,7 +130,7 @@ class StandardMessageGenerator implements MessageGeneratorInterface /** @var WebhookResponseModel $response */ $response = $webhook->webhookResponses()->first(); - $triggers = $this->getTriggerTitles($webhook->webhookTriggers()->get()); + $this->getTriggerTitles($webhook->webhookTriggers()->get()); $basicMessage = [ 'uuid' => $uuid->toString(), 'user_id' => 0, @@ -171,7 +171,7 @@ class StandardMessageGenerator implements MessageGeneratorInterface break; } - $responseTitle = $this->getRelevantResponse($triggers, $response, $class); + $responseTitle = $this->getRelevantResponse($response, $class); switch ($responseTitle) { default: @@ -298,7 +298,7 @@ class StandardMessageGenerator implements MessageGeneratorInterface $this->webhooks = $webhooks; } - private function getRelevantResponse(array $triggers, WebhookResponseModel $response, string $class): string + private function getRelevantResponse(WebhookResponseModel $response, string $class): string { // return none if none. if (WebhookResponse::NONE->name === $response->title) { diff --git a/app/Handlers/Events/UserEventHandler.php b/app/Handlers/Events/UserEventHandler.php index a872b0abef..398298fc6d 100644 --- a/app/Handlers/Events/UserEventHandler.php +++ b/app/Handlers/Events/UserEventHandler.php @@ -133,7 +133,7 @@ class UserEventHandler $group = null; // create a new group. - while (true === $groupExists) { // @phpstan-ignore-line + while ($groupExists) { // @phpstan-ignore-line $groupExists = UserGroup::where('title', $groupTitle)->count() > 0; if (false === $groupExists) { $group = UserGroup::create(['title' => $groupTitle]); diff --git a/app/Handlers/Events/WebhookEventHandler.php b/app/Handlers/Events/WebhookEventHandler.php index bab7d51363..04e575039e 100644 --- a/app/Handlers/Events/WebhookEventHandler.php +++ b/app/Handlers/Events/WebhookEventHandler.php @@ -49,7 +49,7 @@ class WebhookEventHandler $messages = WebhookMessage::where('webhook_messages.sent', false) ->get(['webhook_messages.*']) ->filter( - static fn (WebhookMessage $message) => $message->webhookAttempts()->count() <= 2 + static fn (WebhookMessage $message): bool => $message->webhookAttempts()->count() <= 2 )->splice(0, 5) ; Log::debug(sprintf('Found %d webhook message(s) ready to be send.', $messages->count())); diff --git a/app/Handlers/Observer/TransactionObserver.php b/app/Handlers/Observer/TransactionObserver.php index e040fae67a..dc34b29e61 100644 --- a/app/Handlers/Observer/TransactionObserver.php +++ b/app/Handlers/Observer/TransactionObserver.php @@ -39,11 +39,9 @@ class TransactionObserver public function created(Transaction $transaction): void { Log::debug('Observe "created" of a transaction.'); - if (true === config('firefly.feature_flags.running_balance_column')) { - if (1 === bccomp($transaction->amount, '0') && true === self::$recalculate) { - Log::debug('Trigger recalculateForJournal'); - AccountBalanceCalculator::recalculateForJournal($transaction->transactionJournal); - } + if (true === config('firefly.feature_flags.running_balance_column') && (1 === bccomp($transaction->amount, '0') && self::$recalculate)) { + Log::debug('Trigger recalculateForJournal'); + AccountBalanceCalculator::recalculateForJournal($transaction->transactionJournal); } $this->updatePrimaryCurrencyAmount($transaction); } @@ -84,11 +82,9 @@ class TransactionObserver public function updated(Transaction $transaction): void { // Log::debug('Observe "updated" of a transaction.'); - if (true === config('firefly.feature_flags.running_balance_column') && true === self::$recalculate) { - if (1 === bccomp($transaction->amount, '0')) { - Log::debug('Trigger recalculateForJournal'); - AccountBalanceCalculator::recalculateForJournal($transaction->transactionJournal); - } + if (true === config('firefly.feature_flags.running_balance_column') && self::$recalculate && 1 === bccomp($transaction->amount, '0')) { + Log::debug('Trigger recalculateForJournal'); + AccountBalanceCalculator::recalculateForJournal($transaction->transactionJournal); } $this->updatePrimaryCurrencyAmount($transaction); } diff --git a/app/Helpers/Attachments/AttachmentHelper.php b/app/Helpers/Attachments/AttachmentHelper.php index c4d79ed8d2..0a770a0560 100644 --- a/app/Helpers/Attachments/AttachmentHelper.php +++ b/app/Helpers/Attachments/AttachmentHelper.php @@ -229,7 +229,7 @@ class AttachmentHelper implements AttachmentHelperInterface Log::debug('Now in processFile()'); $validation = $this->validateUpload($file, $model); $attachment = null; - if (false !== $validation) { + if ($validation) { $user = $model->user; // ignore lines about polymorphic calls. if ($model instanceof PiggyBank) { @@ -289,11 +289,11 @@ class AttachmentHelper implements AttachmentHelperInterface } // can't seem to reach this point. - if (true === $result && !$this->validSize($file)) { + if ($result && !$this->validSize($file)) { $result = false; } - if (true === $result && $this->hasFile($file, $model)) { + if ($result && $this->hasFile($file, $model)) { return false; } diff --git a/app/Helpers/Collector/Extensions/AttachmentCollection.php b/app/Helpers/Collector/Extensions/AttachmentCollection.php index d549c47121..80e016a880 100644 --- a/app/Helpers/Collector/Extensions/AttachmentCollection.php +++ b/app/Helpers/Collector/Extensions/AttachmentCollection.php @@ -27,7 +27,6 @@ namespace FireflyIII\Helpers\Collector\Extensions; use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Models\Attachment; use FireflyIII\Models\TransactionJournal; -use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder as EloquentBuilder; use Illuminate\Support\Facades\Log; @@ -55,7 +54,7 @@ trait AttachmentCollection strtolower((string) $attachment['title']), strtolower($name) ); - if (true === $result) { + if ($result) { return true; } } @@ -135,7 +134,7 @@ trait AttachmentCollection strtolower((string) $attachment['title']), strtolower($name) ); - if (true === $result) { + if ($result) { return true; } } @@ -169,7 +168,7 @@ trait AttachmentCollection strtolower((string) $attachment['title']), strtolower($name) ); - if (true === $result) { + if ($result) { return true; } } @@ -203,7 +202,7 @@ trait AttachmentCollection strtolower((string) $attachment['title']), strtolower($name) ); - if (true === $result) { + if ($result) { return true; } } @@ -229,7 +228,7 @@ trait AttachmentCollection strtolower((string) $attachment['title']), strtolower($name) ); - if (true === $result) { + if ($result) { return true; } } @@ -252,7 +251,7 @@ trait AttachmentCollection /** @var array $attachment */ foreach ($transaction['attachments'] as $attachment) { $result = $attachment['filename'] === $name || $attachment['title'] === $name; - if (true === $result) { + if ($result) { return true; } } @@ -275,7 +274,7 @@ trait AttachmentCollection /** @var array $attachment */ foreach ($transaction['attachments'] as $attachment) { $result = $attachment['filename'] !== $name && $attachment['title'] !== $name; - if (true === $result) { + if ($result) { return true; } } @@ -301,7 +300,7 @@ trait AttachmentCollection strtolower((string) $attachment['title']), strtolower($name) ); - if (true === $result) { + if ($result) { return true; } } @@ -514,10 +513,10 @@ trait AttachmentCollection Log::debug('Add filter on no attachments.'); $this->joinAttachmentTables(); - $this->query->where(static function (Builder $q1): void { // @phpstan-ignore-line + $this->query->where(static function (EloquentBuilder $q1): void { // @phpstan-ignore-line $q1 ->whereNull('attachments.attachable_id') - ->orWhere(static function (Builder $q2): void { + ->orWhere(static function (EloquentBuilder $q2): void { $q2 ->whereNotNull('attachments.attachable_id') ->whereNotNull('attachments.deleted_at') diff --git a/app/Helpers/Collector/Extensions/MetaCollection.php b/app/Helpers/Collector/Extensions/MetaCollection.php index 11a15ef799..4c001e60c4 100644 --- a/app/Helpers/Collector/Extensions/MetaCollection.php +++ b/app/Helpers/Collector/Extensions/MetaCollection.php @@ -31,7 +31,6 @@ use FireflyIII\Models\Budget; use FireflyIII\Models\Category; use FireflyIII\Models\Tag; use FireflyIII\Models\TransactionJournal; -use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder as EloquentBuilder; use Illuminate\Database\Query\JoinClause; use Illuminate\Support\Collection; @@ -170,7 +169,7 @@ trait MetaCollection { $this->joinMetaDataTables(); $this->query->where('journal_meta.name', '=', 'external_id'); - $this->query->where('journal_meta.data', '!=', sprintf('%s', json_encode($externalId))); + $this->query->where('journal_meta.data', '!=', json_encode($externalId)); $this->query->whereNull('journal_meta.deleted_at'); return $this; @@ -214,7 +213,7 @@ trait MetaCollection { $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.data', '!=', json_encode($recurringId)); return $this; } @@ -511,7 +510,7 @@ trait MetaCollection public function notesDoNotContain(string $value): GroupCollectorInterface { $this->withNotes(); - $this->query->where(static function (Builder $q) use ($value): void { // @phpstan-ignore-line + $this->query->where(static function (EloquentBuilder $q) use ($value): void { // @phpstan-ignore-line $q->whereNull('notes.text'); $q->orWhereNotLike('notes.text', sprintf('%%%s%%', $value)); }); @@ -522,7 +521,7 @@ trait MetaCollection public function notesDontEndWith(string $value): GroupCollectorInterface { $this->withNotes(); - $this->query->where(static function (Builder $q) use ($value): void { // @phpstan-ignore-line + $this->query->where(static function (EloquentBuilder $q) use ($value): void { // @phpstan-ignore-line $q->whereNull('notes.text'); $q->orWhereNotLike('notes.text', sprintf('%%%s', $value)); }); @@ -533,7 +532,7 @@ trait MetaCollection public function notesDontStartWith(string $value): GroupCollectorInterface { $this->withNotes(); - $this->query->where(static function (Builder $q) use ($value): void { // @phpstan-ignore-line + $this->query->where(static function (EloquentBuilder $q) use ($value): void { // @phpstan-ignore-line $q->whereNull('notes.text'); $q->orWhereNotLike('notes.text', sprintf('%s%%', $value)); }); @@ -552,7 +551,7 @@ trait MetaCollection public function notesExactly(string $value): GroupCollectorInterface { $this->withNotes(); - $this->query->where('notes.text', '=', sprintf('%s', $value)); + $this->query->where('notes.text', '=', $value); return $this; } @@ -560,9 +559,9 @@ trait MetaCollection public function notesExactlyNot(string $value): GroupCollectorInterface { $this->withNotes(); - $this->query->where(static function (Builder $q) use ($value): void { // @phpstan-ignore-line + $this->query->where(static function (EloquentBuilder $q) use ($value): void { // @phpstan-ignore-line $q->whereNull('notes.text'); - $q->orWhere('notes.text', '!=', sprintf('%s', $value)); + $q->orWhere('notes.text', '!=', $value); }); return $this; @@ -587,7 +586,7 @@ trait MetaCollection // this method adds a "postFilter" to the collector. $list = $tags->pluck('tag')->toArray(); - $list = array_map('strtolower', $list); + $list = array_map(strtolower(...), $list); $filter = static function (array $object) use ($list): bool|array { $includedJournals = []; $return = $object; @@ -622,7 +621,7 @@ trait MetaCollection // found at least the expected tags. $result = $foundTagCount >= $expectedTagCount; - if (true === $result) { + if ($result) { return $return; } @@ -707,7 +706,7 @@ trait MetaCollection { $this->joinMetaDataTables(); $this->query->where('journal_meta.name', '=', 'external_id'); - $this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($externalId))); + $this->query->where('journal_meta.data', '=', json_encode($externalId)); $this->query->whereNull('journal_meta.deleted_at'); return $this; @@ -730,7 +729,7 @@ trait MetaCollection $this->joinMetaDataTables(); $this->query->where('journal_meta.name', '=', 'internal_reference'); - $this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($internalReference))); + $this->query->where('journal_meta.data', '=', json_encode($internalReference)); $this->query->whereNull('journal_meta.deleted_at'); return $this; @@ -740,7 +739,7 @@ trait MetaCollection { $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.data', '=', json_encode($recurringId)); $this->query->whereNull('journal_meta.deleted_at'); return $this; @@ -750,7 +749,7 @@ trait MetaCollection { $this->joinMetaDataTables(); $this->query->where('journal_meta.name', '=', 'sepa_ct_id'); - $this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($sepaCT))); + $this->query->where('journal_meta.data', '=', json_encode($sepaCT)); $this->query->whereNull('journal_meta.deleted_at'); return $this; @@ -781,7 +780,7 @@ trait MetaCollection // this method adds a "postFilter" to the collector. $list = $tags->pluck('tag')->toArray(); - $list = array_map('strtolower', $list); + $list = array_map(strtolower(...), $list); $filter = static function (array $object) use ($list): bool { Log::debug(sprintf('Now in setTags(%s) filter', implode(', ', $list))); foreach ($object['transactions'] as $transaction) { @@ -812,7 +811,7 @@ trait MetaCollection // this method adds a "postFilter" to the collector. $list = $tags->pluck('tag')->toArray(); - $list = array_map('strtolower', $list); + $list = array_map(strtolower(...), $list); $filter = static function (array $object) use ($list): bool { Log::debug(sprintf('Now in setWithoutSpecificTags(%s) filter', implode(', ', $list))); foreach ($object['transactions'] as $transaction) { @@ -933,15 +932,15 @@ trait MetaCollection { $this->joinMetaDataTables(); // TODO not sure if this will work properly. - $this->query->where(static function (Builder $q1): void { // @phpstan-ignore-line - $q1->where(static function (Builder $q2): void { + $this->query->where(static function (EloquentBuilder $q1): void { // @phpstan-ignore-line + $q1->where(static function (EloquentBuilder $q2): void { $q2->where('journal_meta.name', '=', 'external_id'); $q2->whereNull('journal_meta.data'); $q2->whereNull('journal_meta.deleted_at'); - })->orWhere(static function (Builder $q3): void { + })->orWhere(static function (EloquentBuilder $q3): void { $q3->where('journal_meta.name', '!=', 'external_id'); $q3->whereNull('journal_meta.deleted_at'); - })->orWhere(static function (Builder $q4): void { + })->orWhere(static function (EloquentBuilder $q4): void { $q4->whereNull('journal_meta.name'); $q4->whereNull('journal_meta.deleted_at'); }); @@ -954,15 +953,15 @@ trait MetaCollection { $this->joinMetaDataTables(); // TODO not sure if this will work properly. - $this->query->where(static function (Builder $q1): void { // @phpstan-ignore-line - $q1->where(static function (Builder $q2): void { + $this->query->where(static function (EloquentBuilder $q1): void { // @phpstan-ignore-line + $q1->where(static function (EloquentBuilder $q2): void { $q2->where('journal_meta.name', '=', 'external_url'); $q2->whereNull('journal_meta.data'); $q2->whereNull('journal_meta.deleted_at'); - })->orWhere(static function (Builder $q3): void { + })->orWhere(static function (EloquentBuilder $q3): void { $q3->where('journal_meta.name', '!=', 'external_url'); $q3->whereNull('journal_meta.deleted_at'); - })->orWhere(static function (Builder $q4): void { + })->orWhere(static function (EloquentBuilder $q4): void { $q4->whereNull('journal_meta.name'); $q4->whereNull('journal_meta.deleted_at'); }); @@ -974,7 +973,7 @@ trait MetaCollection public function withoutNotes(): GroupCollectorInterface { $this->withNotes(); - $this->query->where(static function (Builder $q): void { // @phpstan-ignore-line + $this->query->where(static function (EloquentBuilder $q): void { // @phpstan-ignore-line $q->whereNull('notes.text'); $q->orWhere('notes.text', ''); }); diff --git a/app/Helpers/Collector/GroupCollector.php b/app/Helpers/Collector/GroupCollector.php index 5c265da4b5..b684a4b6df 100644 --- a/app/Helpers/Collector/GroupCollector.php +++ b/app/Helpers/Collector/GroupCollector.php @@ -371,7 +371,7 @@ class GroupCollector implements GroupCollectorInterface { if (0 !== count($journalIds)) { // make all integers. - $integerIDs = array_map('intval', $journalIds); + $integerIDs = array_map(intval(...), $journalIds); $this->query->whereNotIn('transaction_journals.id', $integerIDs); } @@ -779,7 +779,6 @@ class GroupCollector implements GroupCollectorInterface { $currentCollection = $collection; $countFilters = count($this->postFilters); - $countCollection = count($currentCollection); if (0 === $countFilters) { return $currentCollection; } @@ -947,7 +946,7 @@ class GroupCollector implements GroupCollectorInterface { if (0 !== count($journalIds)) { // make all integers. - $integerIDs = array_map('intval', $journalIds); + $integerIDs = array_map(intval(...), $journalIds); Log::debug(sprintf('GroupCollector: setJournalIds: %s', implode(', ', $integerIDs))); $this->query->whereIn('transaction_journals.id', $integerIDs); diff --git a/app/Helpers/Fiscal/FiscalHelper.php b/app/Helpers/Fiscal/FiscalHelper.php index 1503e4e437..b8b5910f2f 100644 --- a/app/Helpers/Fiscal/FiscalHelper.php +++ b/app/Helpers/Fiscal/FiscalHelper.php @@ -27,15 +27,13 @@ use Carbon\Carbon; use FireflyIII\Support\Facades\Preferences; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; -use Illuminate\Support\Facades\Log; /** * Class FiscalHelper. */ class FiscalHelper implements FiscalHelperInterface { - /** @var bool */ - protected $useCustomFiscalYear; + protected bool $useCustomFiscalYear; /** * FiscalHelper constructor. @@ -52,7 +50,7 @@ class FiscalHelper implements FiscalHelperInterface { // Log::debug(sprintf('Now in endOfFiscalYear(%s).', $date->format('Y-m-d'))); $endDate = $this->startOfFiscalYear($date); - if (true === $this->useCustomFiscalYear) { + if ($this->useCustomFiscalYear) { // add 1 year and sub 1 day $endDate->addYear(); $endDate->subDay(); @@ -75,7 +73,7 @@ class FiscalHelper implements FiscalHelperInterface { // get start mm-dd. Then create a start date in the year passed. $startDate = clone $date; - if (true === $this->useCustomFiscalYear) { + if ($this->useCustomFiscalYear) { $prefStartStr = Preferences::get('fiscalYearStart', '01-01')->data; if (is_array($prefStartStr)) { $prefStartStr = '01-01'; diff --git a/app/Helpers/Report/NetWorth.php b/app/Helpers/Report/NetWorth.php index b45659415c..9308f63c52 100644 --- a/app/Helpers/Report/NetWorth.php +++ b/app/Helpers/Report/NetWorth.php @@ -46,8 +46,6 @@ use Illuminate\Support\Facades\Log; class NetWorth implements NetWorthInterface { private AccountRepositoryInterface $accountRepository; - private User $user; // @phpstan-ignore-line - private ?UserGroup $userGroup = null; /** * This method collects the user's net worth in ALL the user's currencies @@ -117,13 +115,11 @@ class NetWorth implements NetWorthInterface if (!$user instanceof User) { return; } - $this->user = $user; $this->setUserGroup($user->userGroup); } public function setUserGroup(UserGroup $userGroup): void { - $this->userGroup = $userGroup; $this->accountRepository = app(AccountRepositoryInterface::class); $this->accountRepository->setUserGroup($userGroup); diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php index 3fce549ae0..7c1d4cc113 100644 --- a/app/Helpers/Report/ReportHelper.php +++ b/app/Helpers/Report/ReportHelper.php @@ -36,15 +36,14 @@ use Illuminate\Support\Collection; */ class ReportHelper implements ReportHelperInterface { - /** @var BudgetRepositoryInterface The budget repository */ - protected $budgetRepository; - /** * ReportHelper constructor. */ - public function __construct(BudgetRepositoryInterface $budgetRepository) + public function __construct( + /** @var BudgetRepositoryInterface The budget repository */ + protected BudgetRepositoryInterface $budgetRepository + ) { - $this->budgetRepository = $budgetRepository; } /** diff --git a/app/Http/Controllers/Account/CreateController.php b/app/Http/Controllers/Account/CreateController.php index f246ec119a..65994d0f82 100644 --- a/app/Http/Controllers/Account/CreateController.php +++ b/app/Http/Controllers/Account/CreateController.php @@ -75,7 +75,7 @@ class CreateController extends Controller * * @return Factory|View */ - public function create(Request $request, string $objectType) + public function create(Request $request, string $objectType): Factory|\Illuminate\Contracts\View\View { $subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType)); $subTitle = (string) trans(sprintf('firefly.make_new_%s_account', $objectType)); @@ -124,7 +124,7 @@ class CreateController extends Controller return view( 'accounts.create', - compact('subTitleIcon', 'liabilityDirections', 'showNetWorth', 'locations', 'objectType', 'interestPeriods', 'subTitle', 'roles', 'liabilityTypes') + ['subTitleIcon' => $subTitleIcon, 'liabilityDirections' => $liabilityDirections, 'showNetWorth' => $showNetWorth, 'locations' => $locations, 'objectType' => $objectType, 'interestPeriods' => $interestPeriods, 'subTitle' => $subTitle, 'roles' => $roles, 'liabilityTypes' => $liabilityTypes] ); } diff --git a/app/Http/Controllers/Account/DeleteController.php b/app/Http/Controllers/Account/DeleteController.php index 0763718cd1..d2370eab4b 100644 --- a/app/Http/Controllers/Account/DeleteController.php +++ b/app/Http/Controllers/Account/DeleteController.php @@ -66,7 +66,7 @@ class DeleteController extends Controller * * @return Factory|Redirector|RedirectResponse|View */ - public function delete(Account $account) + public function delete(Account $account): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View { if (!$this->isEditableAccount($account)) { return $this->redirectAccountToAccount($account); @@ -81,15 +81,13 @@ class DeleteController extends Controller // put previous url in session $this->rememberPreviousUrl('accounts.delete.url'); - return view('accounts.delete', compact('account', 'subTitle', 'accountList', 'objectType')); + return view('accounts.delete', ['account' => $account, 'subTitle' => $subTitle, 'accountList' => $accountList, 'objectType' => $objectType]); } /** * Delete the account. - * - * @return Redirector|RedirectResponse */ - public function destroy(Request $request, Account $account) + public function destroy(Request $request, Account $account): Redirector|RedirectResponse { if (!$this->isEditableAccount($account)) { return $this->redirectAccountToAccount($account); diff --git a/app/Http/Controllers/Account/EditController.php b/app/Http/Controllers/Account/EditController.php index 041b34a8f9..98b6c99ccb 100644 --- a/app/Http/Controllers/Account/EditController.php +++ b/app/Http/Controllers/Account/EditController.php @@ -76,7 +76,7 @@ class EditController extends Controller * * @return Factory|Redirector|RedirectResponse|View */ - public function edit(Request $request, Account $account, AccountRepositoryInterface $repository) + public function edit(Request $request, Account $account, AccountRepositoryInterface $repository): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View { if (!$this->isEditableAccount($account)) { return $this->redirectAccountToAccount($account); @@ -163,7 +163,7 @@ class EditController extends Controller $request->session()->flash('preFilled', $preFilled); - return view('accounts.edit', compact('account', 'currency', 'canEditCurrency', 'showNetWorth', 'subTitle', 'subTitleIcon', 'locations', 'liabilityDirections', 'objectType', 'roles', 'preFilled', 'liabilityTypes', 'interestPeriods')); + return view('accounts.edit', ['account' => $account, 'currency' => $currency, 'canEditCurrency' => $canEditCurrency, 'showNetWorth' => $showNetWorth, 'subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon, 'locations' => $locations, 'liabilityDirections' => $liabilityDirections, 'objectType' => $objectType, 'roles' => $roles, 'preFilled' => $preFilled, 'liabilityTypes' => $liabilityTypes, 'interestPeriods' => $interestPeriods]); } /** diff --git a/app/Http/Controllers/Account/IndexController.php b/app/Http/Controllers/Account/IndexController.php index 41ee6981b3..564dc3401e 100644 --- a/app/Http/Controllers/Account/IndexController.php +++ b/app/Http/Controllers/Account/IndexController.php @@ -72,7 +72,7 @@ class IndexController extends Controller * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function inactive(Request $request, string $objectType) + public function inactive(Request $request, string $objectType): Factory|\Illuminate\Contracts\View\View { $inactivePage = true; $subTitle = (string) trans(sprintf('firefly.%s_accounts_inactive', $objectType)); @@ -120,7 +120,7 @@ class IndexController extends Controller $accounts = new LengthAwarePaginator($accounts, $total, $pageSize, $page); $accounts->setPath(route('accounts.inactive.index', [$objectType])); - return view('accounts.index', compact('objectType', 'inactivePage', 'subTitleIcon', 'subTitle', 'page', 'accounts')); + return view('accounts.index', ['objectType' => $objectType, 'inactivePage' => $inactivePage, 'subTitleIcon' => $subTitleIcon, 'subTitle' => $subTitle, 'page' => $page, 'accounts' => $accounts]); } private function subtract(array $startBalances, array $endBalances): array @@ -141,9 +141,9 @@ class IndexController extends Controller * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function index(Request $request, string $objectType) + public function index(Request $request, string $objectType): Factory|\Illuminate\Contracts\View\View { - app('log')->debug(sprintf('Now at %s', __METHOD__)); + Log::debug(sprintf('Now at %s', __METHOD__)); $subTitle = (string) trans(sprintf('firefly.%s_accounts', $objectType)); $subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType)); $types = config(sprintf('firefly.accountTypesByIdentifier.%s', $objectType)); @@ -157,7 +157,7 @@ class IndexController extends Controller $accounts = $collection->slice(($page - 1) * $pageSize, $pageSize); $inactiveCount = $this->repository->getInactiveAccountsByType($types)->count(); - app('log')->debug(sprintf('Count of collection: %d, count of accounts: %d', $total, $accounts->count())); + Log::debug(sprintf('Count of collection: %d, count of accounts: %d', $total, $accounts->count())); unset($collection); @@ -187,9 +187,7 @@ class IndexController extends Controller $account->differences = $this->subtract($account->startBalances, $account->endBalances); $account->lastActivityDate = $this->isInArrayDate($activities, $account->id); $account->interest = Steam::bcround($interest, 4); - $account->interestPeriod = (string) trans( - sprintf('firefly.interest_calc_%s', $this->repository->getMetaValue($account, 'interest_period')) - ); + $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->location = $this->repository->getLocation($account); $account->liability_direction = $this->repository->getMetaValue($account, 'liability_direction'); @@ -201,15 +199,15 @@ class IndexController extends Controller } ); // make paginator: - app('log')->debug(sprintf('Count of accounts before LAP: %d', $accounts->count())); + Log::debug(sprintf('Count of accounts before LAP: %d', $accounts->count())); /** @var LengthAwarePaginator $accounts */ $accounts = new LengthAwarePaginator($accounts, $total, $pageSize, $page); $accounts->setPath(route('accounts.index', [$objectType])); - app('log')->debug(sprintf('Count of accounts after LAP (1): %d', $accounts->count())); - app('log')->debug(sprintf('Count of accounts after LAP (2): %d', $accounts->getCollection()->count())); + Log::debug(sprintf('Count of accounts after LAP (1): %d', $accounts->count())); + Log::debug(sprintf('Count of accounts after LAP (2): %d', $accounts->getCollection()->count())); - return view('accounts.index', compact('objectType', 'inactiveCount', 'subTitleIcon', 'subTitle', 'page', 'accounts')); + return view('accounts.index', ['objectType' => $objectType, 'inactiveCount' => $inactiveCount, 'subTitleIcon' => $subTitleIcon, 'subTitle' => $subTitle, 'page' => $page, 'accounts' => $accounts]); } } diff --git a/app/Http/Controllers/Account/ReconcileController.php b/app/Http/Controllers/Account/ReconcileController.php index c78696f776..ff99abb88a 100644 --- a/app/Http/Controllers/Account/ReconcileController.php +++ b/app/Http/Controllers/Account/ReconcileController.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Account; +use Illuminate\Support\Facades\Log; use Carbon\Carbon; use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Enums\TransactionTypeEnum; @@ -40,7 +41,6 @@ use Illuminate\Contracts\View\Factory; use Illuminate\Http\RedirectResponse; use Illuminate\Routing\Redirector; use Illuminate\Support\Collection; -use Illuminate\Support\Facades\Log; use Illuminate\View\View; /** @@ -78,7 +78,7 @@ class ReconcileController extends Controller * * @throws FireflyException * */ - public function reconcile(Account $account, ?Carbon $start = null, ?Carbon $end = null) + public function reconcile(Account $account, ?Carbon $start = null, ?Carbon $end = null): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View { if (!$this->isEditableAccount($account)) { return $this->redirectAccountToAccount($account); @@ -139,44 +139,30 @@ class ReconcileController extends Controller return view( 'accounts.reconcile.index', - compact( - 'account', - 'currency', - 'objectType', - 'subTitleIcon', - 'start', - 'end', - 'subTitle', - 'startBalance', - 'endBalance', - 'transactionsUrl', - 'overviewUrl', - 'indexUrl' - ) + ['account' => $account, 'currency' => $currency, 'objectType' => $objectType, 'subTitleIcon' => $subTitleIcon, 'start' => $start, 'end' => $end, 'subTitle' => $subTitle, 'startBalance' => $startBalance, 'endBalance' => $endBalance, 'transactionsUrl' => $transactionsUrl, 'overviewUrl' => $overviewUrl, 'indexUrl' => $indexUrl] ); } /** * Submit a new reconciliation. * - * @return Redirector|RedirectResponse * * @throws DuplicateTransactionException */ - public function submit(ReconciliationStoreRequest $request, Account $account, Carbon $start, Carbon $end) + public function submit(ReconciliationStoreRequest $request, Account $account, Carbon $start, Carbon $end): Redirector|RedirectResponse { if (!$this->isEditableAccount($account)) { return $this->redirectAccountToAccount($account); } - app('log')->debug('In ReconcileController::submit()'); + Log::debug('In ReconcileController::submit()'); $data = $request->getAll(); /** @var string $journalId */ foreach ($data['journals'] as $journalId) { $this->repository->reconcileById((int) $journalId); } - app('log')->debug('Reconciled all transactions.'); + Log::debug('Reconciled all transactions.'); // switch dates if necessary if ($end->lt($start)) { @@ -188,7 +174,7 @@ class ReconcileController extends Controller if ('create' === $data['reconcile']) { $result = $this->createReconciliation($account, $start, $end, $data['difference']); } - app('log')->debug('End of routine.'); + Log::debug('End of routine.'); app('preferences')->mark(); if ('' === $result) { session()->flash('success', (string) trans('firefly.reconciliation_stored')); diff --git a/app/Http/Controllers/Account/ShowController.php b/app/Http/Controllers/Account/ShowController.php index bcb0ba6a0e..dfbb046410 100644 --- a/app/Http/Controllers/Account/ShowController.php +++ b/app/Http/Controllers/Account/ShowController.php @@ -84,7 +84,7 @@ class ShowController extends Controller * @throws FireflyException * @throws NotFoundExceptionInterface */ - public function show(Request $request, Account $account, ?Carbon $start = null, ?Carbon $end = null) + public function show(Request $request, Account $account, ?Carbon $start = null, ?Carbon $end = null): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View { if (0 === $account->id) { throw new NotFoundHttpException(); @@ -175,23 +175,7 @@ class ShowController extends Controller return view( 'accounts.show', - compact( - 'account', - 'showAll', - 'objectType', - 'currency', - 'today', - 'periods', - 'subTitleIcon', - 'groups', - 'attachments', - 'subTitle', - 'start', - 'end', - 'chartUrl', - 'location', - 'balances' - ) + ['account' => $account, 'showAll' => $showAll, 'objectType' => $objectType, 'currency' => $currency, 'today' => $today, 'periods' => $periods, 'subTitleIcon' => $subTitleIcon, 'groups' => $groups, 'attachments' => $attachments, 'subTitle' => $subTitle, 'start' => $start, 'end' => $end, 'chartUrl' => $chartUrl, 'location' => $location, 'balances' => $balances] ); } @@ -203,7 +187,7 @@ class ShowController extends Controller * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function showAll(Request $request, Account $account) + public function showAll(Request $request, Account $account): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View { if (!$this->isEditableAccount($account)) { return $this->redirectAccountToAccount($account); @@ -214,7 +198,7 @@ class ShowController extends Controller $objectType = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type)); $end = today(config('app.timezone')); $today = today(config('app.timezone')); - $accountCurrency = $this->repository->getAccountCurrency($account); + $this->repository->getAccountCurrency($account); $start = $this->repository->oldestJournalDate($account) ?? today(config('app.timezone'))->startOfMonth(); $subTitleIcon = config('firefly.subIconsByIdentifier.'.$account->accountType->type); $page = (int) $request->get('page'); @@ -247,24 +231,7 @@ class ShowController extends Controller return view( 'accounts.show', - compact( - 'account', - 'showAll', - 'location', - 'objectType', - 'isLiability', - 'attachments', - 'currency', - 'today', - 'chartUrl', - 'periods', - 'subTitleIcon', - 'groups', - 'subTitle', - 'start', - 'end', - 'balances' - ) + ['account' => $account, 'showAll' => $showAll, 'location' => $location, 'objectType' => $objectType, 'isLiability' => $isLiability, 'attachments' => $attachments, 'currency' => $currency, 'today' => $today, 'chartUrl' => $chartUrl, 'periods' => $periods, 'subTitleIcon' => $subTitleIcon, 'groups' => $groups, 'subTitle' => $subTitle, 'start' => $start, 'end' => $end, 'balances' => $balances] ); } } diff --git a/app/Http/Controllers/Admin/ConfigurationController.php b/app/Http/Controllers/Admin/ConfigurationController.php index 33afca23c0..541549fade 100644 --- a/app/Http/Controllers/Admin/ConfigurationController.php +++ b/app/Http/Controllers/Admin/ConfigurationController.php @@ -60,7 +60,7 @@ class ConfigurationController extends Controller * * @return Factory|View */ - public function index() + public function index(): Factory|\Illuminate\Contracts\View\View { $subTitle = (string) trans('firefly.instance_configuration'); $subTitleIcon = 'fa-wrench'; @@ -75,7 +75,7 @@ class ConfigurationController extends Controller return view( 'settings.configuration.index', - compact('subTitle', 'subTitleIcon', 'singleUserMode', 'isDemoSite', 'siteOwner') + ['subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon, 'singleUserMode' => $singleUserMode, 'isDemoSite' => $isDemoSite, 'siteOwner' => $siteOwner] ); } diff --git a/app/Http/Controllers/Admin/HomeController.php b/app/Http/Controllers/Admin/HomeController.php index bd14a9d51b..8915a44f06 100644 --- a/app/Http/Controllers/Admin/HomeController.php +++ b/app/Http/Controllers/Admin/HomeController.php @@ -53,7 +53,7 @@ class HomeController extends Controller * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function index() + public function index(): Factory|\Illuminate\Contracts\View\View { Log::channel('audit')->info('User visits admin index.'); $title = (string) trans('firefly.system_settings'); @@ -64,6 +64,6 @@ class HomeController extends Controller $email = $pref->data; } - return view('settings.index', compact('title', 'mainTitleIcon', 'email')); + return view('settings.index', ['title' => $title, 'mainTitleIcon' => $mainTitleIcon, 'email' => $email]); } } diff --git a/app/Http/Controllers/Admin/LinkController.php b/app/Http/Controllers/Admin/LinkController.php index 88d87ac3a1..06c66deeb1 100644 --- a/app/Http/Controllers/Admin/LinkController.php +++ b/app/Http/Controllers/Admin/LinkController.php @@ -66,7 +66,7 @@ class LinkController extends Controller * * @return Factory|View */ - public function create() + public function create(): Factory|\Illuminate\Contracts\View\View { Log::channel('audit')->info('User visits link index.'); @@ -78,7 +78,7 @@ class LinkController extends Controller $this->rememberPreviousUrl('link-types.create.url'); } - return view('settings.link.create', compact('subTitle', 'subTitleIcon')); + return view('settings.link.create', ['subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon]); } /** @@ -86,7 +86,7 @@ class LinkController extends Controller * * @return Factory|Redirector|RedirectResponse|View */ - public function delete(Request $request, LinkType $linkType) + public function delete(Request $request, LinkType $linkType): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View { if (false === $linkType->editable) { $request->session()->flash('error', (string) trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)])); @@ -111,15 +111,13 @@ class LinkController extends Controller // put previous url in session $this->rememberPreviousUrl('link-types.delete.url'); - return view('settings.link.delete', compact('linkType', 'subTitle', 'moveTo', 'count')); + return view('settings.link.delete', ['linkType' => $linkType, 'subTitle' => $subTitle, 'moveTo' => $moveTo, 'count' => $count]); } /** * Actually destroy the link. - * - * @return Redirector|RedirectResponse */ - public function destroy(Request $request, LinkType $linkType) + public function destroy(Request $request, LinkType $linkType): Redirector|RedirectResponse { Log::channel('audit')->info(sprintf('User destroyed link type #%d', $linkType->id)); $name = $linkType->name; @@ -137,7 +135,7 @@ class LinkController extends Controller * * @return Factory|Redirector|RedirectResponse|View */ - public function edit(Request $request, LinkType $linkType) + public function edit(Request $request, LinkType $linkType): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View { if (false === $linkType->editable) { $request->session()->flash('error', (string) trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)])); @@ -155,7 +153,7 @@ class LinkController extends Controller } $request->session()->forget('link-types.edit.fromUpdate'); - return view('settings.link.edit', compact('subTitle', 'subTitleIcon', 'linkType')); + return view('settings.link.edit', ['subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon, 'linkType' => $linkType]); } /** @@ -163,7 +161,7 @@ class LinkController extends Controller * * @return Factory|View */ - public function index() + public function index(): Factory|\Illuminate\Contracts\View\View { $subTitle = (string) trans('firefly.journal_link_configuration'); $subTitleIcon = 'fa-link'; @@ -176,7 +174,7 @@ class LinkController extends Controller } ); - return view('settings.link.index', compact('subTitle', 'subTitleIcon', 'linkTypes')); + return view('settings.link.index', ['subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon, 'linkTypes' => $linkTypes]); } /** @@ -184,7 +182,7 @@ class LinkController extends Controller * * @return Factory|View */ - public function show(LinkType $linkType) + public function show(LinkType $linkType): Factory|\Illuminate\Contracts\View\View { $subTitle = (string) trans('firefly.overview_for_link', ['name' => $linkType->name]); $subTitleIcon = 'fa-link'; @@ -192,7 +190,7 @@ class LinkController extends Controller Log::channel('audit')->info(sprintf('User viewing link type #%d', $linkType->id)); - return view('settings.link.show', compact('subTitle', 'subTitleIcon', 'linkType', 'links')); + return view('settings.link.show', ['subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon, 'linkType' => $linkType, 'links' => $links]); } /** diff --git a/app/Http/Controllers/Admin/NotificationController.php b/app/Http/Controllers/Admin/NotificationController.php index 233dc7f66a..f2e268cf87 100644 --- a/app/Http/Controllers/Admin/NotificationController.php +++ b/app/Http/Controllers/Admin/NotificationController.php @@ -74,23 +74,7 @@ class NotificationController extends Controller return view( 'settings.notifications.index', - compact( - 'title', - 'subTitle', - 'forcedAvailability', - 'mainTitleIcon', - 'subTitleIcon', - 'channels', - 'slackUrl', - 'notifications', - 'pushoverAppToken', - 'pushoverUserToken', - 'ntfyServer', - 'ntfyTopic', - 'ntfyAuth', - 'ntfyUser', - 'ntfyPass' - ) + ['title' => $title, 'subTitle' => $subTitle, 'forcedAvailability' => $forcedAvailability, 'mainTitleIcon' => $mainTitleIcon, 'subTitleIcon' => $subTitleIcon, 'channels' => $channels, 'slackUrl' => $slackUrl, 'notifications' => $notifications, 'pushoverAppToken' => $pushoverAppToken, 'pushoverUserToken' => $pushoverUserToken, 'ntfyServer' => $ntfyServer, 'ntfyTopic' => $ntfyTopic, 'ntfyAuth' => $ntfyAuth, 'ntfyUser' => $ntfyUser, 'ntfyPass' => $ntfyPass] ); } @@ -142,7 +126,7 @@ class NotificationController extends Controller case 'pushover': case 'ntfy': $owner = new OwnerNotifiable(); - app('log')->debug(sprintf('Now in testNotification("%s") controller.', $channel)); + Log::debug(sprintf('Now in testNotification("%s") controller.', $channel)); event(new OwnerTestNotificationChannel($channel, $owner)); session()->flash('success', (string) trans('firefly.notification_test_executed', ['channel' => $channel])); } diff --git a/app/Http/Controllers/Admin/UpdateController.php b/app/Http/Controllers/Admin/UpdateController.php index 90729abe56..a205534ef0 100644 --- a/app/Http/Controllers/Admin/UpdateController.php +++ b/app/Http/Controllers/Admin/UpdateController.php @@ -63,7 +63,7 @@ class UpdateController extends Controller * * @return Factory|View */ - public function index() + public function index(): Factory|\Illuminate\Contracts\View\View { $subTitle = (string) trans('firefly.update_check_title'); $subTitleIcon = 'fa-star'; @@ -83,15 +83,13 @@ class UpdateController extends Controller 'alpha' => (string) trans('firefly.update_channel_alpha'), ]; - return view('settings.update.index', compact('subTitle', 'subTitleIcon', 'selected', 'options', 'channelSelected', 'channelOptions')); + return view('settings.update.index', ['subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon, 'selected' => $selected, 'options' => $options, 'channelSelected' => $channelSelected, 'channelOptions' => $channelOptions]); } /** * Post new settings. - * - * @return Redirector|RedirectResponse */ - public function post(Request $request) + public function post(Request $request): Redirector|RedirectResponse { $checkForUpdates = (int) $request->get('check_for_updates'); $channel = $request->get('update_channel'); diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 736ae8edf7..dbebe2ba5d 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Admin; +use Illuminate\Support\Facades\Log; use FireflyIII\Events\Admin\InvitationCreated; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Http\Controllers\Controller; @@ -72,7 +73,7 @@ class UserController extends Controller /** * @return Application|Factory|Redirector|RedirectResponse|View */ - public function delete(User $user) + public function delete(User $user): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View { if ($this->externalIdentity) { request()->session()->flash('error', trans('firefly.external_user_mgt_disabled')); @@ -82,19 +83,19 @@ class UserController extends Controller $subTitle = (string) trans('firefly.delete_user', ['email' => $user->email]); - return view('settings.users.delete', compact('user', 'subTitle')); + return view('settings.users.delete', ['user' => $user, 'subTitle' => $subTitle]); } public function deleteInvite(InvitedUser $invitedUser): JsonResponse { - app('log')->debug('Will now delete invitation'); + Log::debug('Will now delete invitation'); if (true === $invitedUser->redeemed) { - app('log')->debug('Is already redeemed.'); + Log::debug('Is already redeemed.'); session()->flash('error', trans('firefly.invite_is_already_redeemed', ['address' => $invitedUser->email])); return response()->json(['success' => false]); } - app('log')->debug('Delete!'); + Log::debug('Delete!'); session()->flash('success', trans('firefly.invite_is_deleted', ['address' => $invitedUser->email])); $this->repository->deleteInvite($invitedUser); @@ -103,10 +104,8 @@ class UserController extends Controller /** * Destroy a user. - * - * @return Redirector|RedirectResponse */ - public function destroy(User $user) + public function destroy(User $user): Redirector|RedirectResponse { if ($this->externalIdentity) { request()->session()->flash('error', trans('firefly.external_user_mgt_disabled')); @@ -124,7 +123,7 @@ class UserController extends Controller * * @return Factory|View */ - public function edit(User $user) + public function edit(User $user): Factory|\Illuminate\Contracts\View\View { $canEditDetails = true; if ($this->externalIdentity) { @@ -147,7 +146,7 @@ class UserController extends Controller 'email_changed' => (string) trans('firefly.block_code_email_changed'), ]; - return view('settings.users.edit', compact('user', 'canEditDetails', 'subTitle', 'subTitleIcon', 'codes', 'currentUser', 'isAdmin')); + return view('settings.users.edit', ['user' => $user, 'canEditDetails' => $canEditDetails, 'subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon, 'codes' => $codes, 'currentUser' => $currentUser, 'isAdmin' => $isAdmin]); } /** @@ -159,7 +158,7 @@ class UserController extends Controller * @throws FireflyException * @throws NotFoundExceptionInterface */ - public function index() + public function index(): Factory|\Illuminate\Contracts\View\View { $subTitle = (string) trans('firefly.user_administration'); $subTitleIcon = 'fa-users'; @@ -181,7 +180,7 @@ class UserController extends Controller } ); - return view('settings.users.index', compact('subTitle', 'subTitleIcon', 'users', 'allowInvites', 'invitedUsers')); + return view('settings.users.index', ['subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon, 'users' => $users, 'allowInvites' => $allowInvites, 'invitedUsers' => $invitedUsers]); } public function invite(InviteUserFormRequest $request): RedirectResponse @@ -201,7 +200,7 @@ class UserController extends Controller * * @return Factory|View */ - public function show(User $user) + public function show(User $user): Factory|\Illuminate\Contracts\View\View { $title = (string) trans('firefly.system_settings'); $mainTitleIcon = 'fa-hand-spock-o'; @@ -211,14 +210,7 @@ class UserController extends Controller return view( 'settings.users.show', - compact( - 'title', - 'mainTitleIcon', - 'subTitle', - 'subTitleIcon', - 'information', - 'user' - ) + ['title' => $title, 'mainTitleIcon' => $mainTitleIcon, 'subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon, 'information' => $information, 'user' => $user] ); } @@ -229,7 +221,7 @@ class UserController extends Controller */ public function update(UserFormRequest $request, User $user) { - app('log')->debug('Actually here'); + Log::debug('Actually here'); $data = $request->getUserData(); // var_dump($data); diff --git a/app/Http/Controllers/AttachmentController.php b/app/Http/Controllers/AttachmentController.php index d1cdfa9a58..534dd47cee 100644 --- a/app/Http/Controllers/AttachmentController.php +++ b/app/Http/Controllers/AttachmentController.php @@ -65,22 +65,20 @@ class AttachmentController extends Controller * * @return Factory|View */ - public function delete(Attachment $attachment) + public function delete(Attachment $attachment): Factory|\Illuminate\Contracts\View\View { $subTitle = (string) trans('firefly.delete_attachment', ['name' => $attachment->filename]); // put previous url in session $this->rememberPreviousUrl('attachments.delete.url'); - return view('attachments.delete', compact('attachment', 'subTitle')); + return view('attachments.delete', ['attachment' => $attachment, 'subTitle' => $subTitle]); } /** * Destroy attachment. - * - * @return Redirector|RedirectResponse */ - public function destroy(Request $request, Attachment $attachment) + public function destroy(Request $request, Attachment $attachment): Redirector|RedirectResponse { $name = $attachment->filename; @@ -123,7 +121,7 @@ class AttachmentController extends Controller } $message = 'Could not find the indicated attachment. The file is no longer there.'; - return view('errors.error', compact('message')); + return view('errors.error', ['message' => $message]); } /** @@ -131,7 +129,7 @@ class AttachmentController extends Controller * * @return Factory|View */ - public function edit(Request $request, Attachment $attachment) + public function edit(Request $request, Attachment $attachment): Factory|\Illuminate\Contracts\View\View { $subTitleIcon = 'fa-pencil'; $subTitle = (string) trans('firefly.edit_attachment', ['name' => $attachment->filename]); @@ -146,7 +144,7 @@ class AttachmentController extends Controller ]; $request->session()->flash('preFilled', $preFilled); - return view('attachments.edit', compact('attachment', 'subTitleIcon', 'subTitle')); + return view('attachments.edit', ['attachment' => $attachment, 'subTitleIcon' => $subTitleIcon, 'subTitle' => $subTitle]); } /** @@ -154,18 +152,18 @@ class AttachmentController extends Controller * * @return Factory|View */ - public function index() + public function index(): Factory|\Illuminate\Contracts\View\View { $set = $this->repository->get()->reverse(); $set = $set->each( - function (Attachment $attachment) { + function (Attachment $attachment): Attachment { $attachment->file_exists = $this->repository->exists($attachment); return $attachment; } ); - return view('attachments.index', compact('set')); + return view('attachments.index', ['set' => $set]); } /** @@ -226,6 +224,6 @@ class AttachmentController extends Controller $message = 'Could not find the indicated attachment. The file is no longer there.'; - return view('errors.error', compact('message')); + return view('errors.error', ['message' => $message]); } } diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index d3f996c6f4..303bad7505 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -73,7 +73,7 @@ class ForgotPasswordController extends Controller $message = sprintf('Cannot reset password when authenticating over "%s".', config('firefly.authentication_guard')); Log::error($message); - return view('errors.error', compact('message')); + return view('errors.error', ['message' => $message]); } // validate host header. @@ -138,7 +138,7 @@ class ForgotPasswordController extends Controller if ('web' !== config('firefly.authentication_guard')) { $message = sprintf('Cannot reset password when authenticating over "%s".', config('firefly.authentication_guard')); - return view('errors.error', compact('message')); + return view('errors.error', ['message' => $message]); } // is allowed to? @@ -150,6 +150,6 @@ class ForgotPasswordController extends Controller $allowRegistration = false; } - return view('auth.passwords.email')->with(compact('allowRegistration', 'pageTitle')); + return view('auth.passwords.email')->with(['allowRegistration' => $allowRegistration, 'pageTitle' => $pageTitle]); } } diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 30b0bce73f..8866f1aba5 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -68,7 +68,7 @@ class LoginController extends Controller protected string $redirectTo = RouteServiceProvider::HOME; private UserRepositoryInterface $repository; - private string $username; + private string $username = 'email'; /** * Create a new controller instance. @@ -76,7 +76,6 @@ class LoginController extends Controller public function __construct() { parent::__construct(); - $this->username = 'email'; $this->middleware('guest')->except('logout'); $this->repository = app(UserRepositoryInterface::class); } @@ -90,7 +89,7 @@ class LoginController extends Controller { $username = $request->get($this->username()); Log::channel('audit')->info(sprintf('User is trying to login using "%s"', $username)); - app('log')->debug('User is trying to login.'); + Log::debug('User is trying to login.'); try { $this->validateLogin($request); @@ -107,7 +106,7 @@ class LoginController extends Controller ->onlyInput($this->username) ; } - app('log')->debug('Login data is present.'); + Log::debug('Login data is present.'); // Copied directly from AuthenticatesUsers, but with logging added: // If the class is using the ThrottlesLogins trait, we can automatically throttle @@ -115,14 +114,14 @@ class LoginController extends Controller // the IP address of the client making these requests into this application. if ($this->hasTooManyLoginAttempts($request)) { Log::channel('audit')->warning(sprintf('Login for user "%s" was locked out.', $request->get($this->username()))); - app('log')->error(sprintf('Login for user "%s" was locked out.', $request->get($this->username()))); + Log::error(sprintf('Login for user "%s" was locked out.', $request->get($this->username()))); $this->fireLockoutEvent($request); $this->sendLockoutResponse($request); } // Copied directly from AuthenticatesUsers, but with logging added: if ($this->attemptLogin($request)) { Log::channel('audit')->info(sprintf('User "%s" has been logged in.', $request->get($this->username()))); - app('log')->debug(sprintf('Redirect after login is %s.', $this->redirectPath())); + Log::debug(sprintf('Redirect after login is %s.', $this->redirectPath())); // if you just logged in, it can't be that you have a valid 2FA cookie. @@ -132,7 +131,7 @@ class LoginController extends Controller return $this->sendLoginResponse($request); } - app('log')->warning('Login attempt failed.'); + Log::warning('Login attempt failed.'); $username = (string) $request->get($this->username()); $user = $this->repository->findByEmail($username); if (!$user instanceof User) { @@ -158,10 +157,8 @@ class LoginController extends Controller /** * Get the login username to be used by the controller. - * - * @return string */ - public function username() + public function username(): string { return $this->username; } @@ -187,10 +184,8 @@ class LoginController extends Controller /** * Log the user out of the application. - * - * @return Redirector|RedirectResponse|Response */ - public function logout(Request $request) + public function logout(Request $request): Redirector|RedirectResponse|Response { $authGuard = config('firefly.authentication_guard'); $logoutUrl = config('firefly.custom_logout_url'); @@ -227,7 +222,7 @@ class LoginController extends Controller * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function showLoginForm(Request $request) + public function showLoginForm(Request $request): Redirector|RedirectResponse|Factory|View { Log::channel('audit')->info('Show login form (1.1).'); @@ -263,6 +258,6 @@ class LoginController extends Controller } $usernameField = $this->username(); - return view('auth.login', compact('allowRegistration', 'email', 'remember', 'allowReset', 'title', 'usernameField')); + return view('auth.login', ['allowRegistration' => $allowRegistration, 'email' => $email, 'remember' => $remember, 'allowReset' => $allowReset, 'title' => $title, 'usernameField' => $usernameField]); } } diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index ea1e8619f1..314f6cab2b 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -82,7 +82,7 @@ class RegisterController extends Controller * @throws FireflyException * @throws ValidationException */ - public function register(Request $request) + public function register(Request $request): Redirector|RedirectResponse { $allowRegistration = $this->allowedToRegister(); $inviteCode = (string) $request->get('invite_code'); @@ -146,7 +146,7 @@ class RegisterController extends Controller * @throws FireflyException * @throws NotFoundExceptionInterface */ - public function showInviteForm(Request $request, string $code) + public function showInviteForm(Request $request, string $code): Factory|\Illuminate\Contracts\View\View { $isDemoSite = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site'))->data; $pageTitle = (string) trans('firefly.register_page_title'); @@ -155,20 +155,20 @@ class RegisterController extends Controller $inviteCode = $code; $validCode = $repository->validateInviteCode($inviteCode); - if (true === $allowRegistration) { + if ($allowRegistration) { $message = 'You do not need an invite code on this installation.'; - return view('errors.error', compact('message')); + return view('errors.error', ['message' => $message]); } if (false === $validCode) { $message = 'Invalid code.'; - return view('errors.error', compact('message')); + return view('errors.error', ['message' => $message]); } $email = $request->old('email'); - return view('auth.register', compact('isDemoSite', 'email', 'pageTitle', 'inviteCode')); + return view('auth.register', ['isDemoSite' => $isDemoSite, 'email' => $email, 'pageTitle' => $pageTitle, 'inviteCode' => $inviteCode]); } /** @@ -180,7 +180,7 @@ class RegisterController extends Controller * @throws FireflyException * @throws NotFoundExceptionInterface */ - public function showRegistrationForm(?Request $request = null) + public function showRegistrationForm(?Request $request = null): Factory|\Illuminate\Contracts\View\View { $isDemoSite = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site'))->data; $pageTitle = (string) trans('firefly.register_page_title'); @@ -189,11 +189,11 @@ class RegisterController extends Controller if (false === $allowRegistration) { $message = 'Registration is currently not available. If you are the administrator, you can enable this in the administration.'; - return view('errors.error', compact('message')); + return view('errors.error', ['message' => $message]); } $email = $request?->old('email'); - return view('auth.register', compact('isDemoSite', 'email', 'pageTitle')); + return view('auth.register', ['isDemoSite' => $isDemoSite, 'email' => $email, 'pageTitle' => $pageTitle]); } } diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index b52ae8e0e7..9b4f2dc7dd 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -80,7 +80,7 @@ class ResetPasswordController extends Controller if ('web' !== config('firefly.authentication_guard')) { $message = sprintf('Cannot reset password when authenticating over "%s".', config('firefly.authentication_guard')); - return view('errors.error', compact('message')); + return view('errors.error', ['message' => $message]); } $rules = [ @@ -114,7 +114,6 @@ class ResetPasswordController extends Controller * * If no token is present, display the link request form. * - * @param null $token * * @return Factory|View * @@ -127,7 +126,7 @@ class ResetPasswordController extends Controller if ('web' !== config('firefly.authentication_guard')) { $message = sprintf('Cannot reset password when authenticating over "%s".', config('firefly.authentication_guard')); - return view('errors.error', compact('message')); + return view('errors.error', ['message' => $message]); } // is allowed to register? diff --git a/app/Http/Controllers/Auth/TwoFactorController.php b/app/Http/Controllers/Auth/TwoFactorController.php index a651b7c50a..b9e956d7e1 100644 --- a/app/Http/Controllers/Auth/TwoFactorController.php +++ b/app/Http/Controllers/Auth/TwoFactorController.php @@ -47,26 +47,23 @@ class TwoFactorController extends Controller { /** * What to do if 2FA lost? - * - * @return Factory|View */ - public function lostTwoFactor() + public function lostTwoFactor(): Factory|View { /** @var User $user */ $user = auth()->user(); $siteOwner = config('firefly.site_owner'); $title = (string) trans('firefly.two_factor_forgot_title'); - return view('auth.lost-two-factor', compact('user', 'siteOwner', 'title')); + return view('auth.lost-two-factor', ['user' => $user, 'siteOwner' => $siteOwner, 'title' => $title]); } /** - * @return Redirector|RedirectResponse * * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function submitMFA(Request $request) + public function submitMFA(Request $request): Redirector|RedirectResponse { /** @var array $mfaHistory */ $mfaHistory = app('preferences')->get('mfa_history', [])->data; @@ -214,11 +211,7 @@ class TwoFactorController extends Controller if (!is_array($list)) { $list = []; } - if (in_array($mfaCode, $list, true)) { - return true; - } - - return false; + return in_array($mfaCode, $list, true); } /** diff --git a/app/Http/Controllers/Bill/CreateController.php b/app/Http/Controllers/Bill/CreateController.php index ae97eefa84..f87059d095 100644 --- a/app/Http/Controllers/Bill/CreateController.php +++ b/app/Http/Controllers/Bill/CreateController.php @@ -64,10 +64,8 @@ class CreateController extends Controller /** * Create a new bill. - * - * @return Factory|View */ - public function create(Request $request) + public function create(Request $request): Factory|View { $periods = []; @@ -84,7 +82,7 @@ class CreateController extends Controller } $request->session()->forget('bills.create.fromStore'); - return view('bills.create', compact('periods', 'subTitle')); + return view('bills.create', ['periods' => $periods, 'subTitle' => $subTitle]); } /** @@ -99,7 +97,7 @@ class CreateController extends Controller try { $bill = $this->repository->store($billData); } catch (FireflyException $e) { - app('log')->error($e->getMessage()); + Log::error($e->getMessage()); $request->session()->flash('error', (string) trans('firefly.bill_store_error')); return redirect(route('bills.create'))->withInput(); diff --git a/app/Http/Controllers/Bill/DeleteController.php b/app/Http/Controllers/Bill/DeleteController.php index 6dccb056a6..a3516bcf4a 100644 --- a/app/Http/Controllers/Bill/DeleteController.php +++ b/app/Http/Controllers/Bill/DeleteController.php @@ -65,21 +65,19 @@ class DeleteController extends Controller * * @return Factory|View */ - public function delete(Bill $bill) + public function delete(Bill $bill): Factory|\Illuminate\Contracts\View\View { // put previous url in session $this->rememberPreviousUrl('bills.delete.url'); $subTitle = (string) trans('firefly.delete_bill', ['name' => $bill->name]); - return view('bills.delete', compact('bill', 'subTitle')); + return view('bills.delete', ['bill' => $bill, 'subTitle' => $subTitle]); } /** * Destroy a bill. - * - * @return Redirector|RedirectResponse */ - public function destroy(Request $request, Bill $bill) + public function destroy(Request $request, Bill $bill): Redirector|RedirectResponse { $name = $bill->name; $this->repository->destroy($bill); diff --git a/app/Http/Controllers/Bill/EditController.php b/app/Http/Controllers/Bill/EditController.php index e9515ef071..820841215b 100644 --- a/app/Http/Controllers/Bill/EditController.php +++ b/app/Http/Controllers/Bill/EditController.php @@ -64,10 +64,8 @@ class EditController extends Controller /** * Edit a bill. - * - * @return Factory|View */ - public function edit(Request $request, Bill $bill) + public function edit(Request $request, Bill $bill): Factory|View { $periods = []; @@ -104,7 +102,7 @@ class EditController extends Controller $request->session()->flash('preFilled', $preFilled); $request->session()->forget('bills.edit.fromUpdate'); - return view('bills.edit', compact('subTitle', 'periods', 'rules', 'bill', 'preFilled')); + return view('bills.edit', ['subTitle' => $subTitle, 'periods' => $periods, 'rules' => $rules, 'bill' => $bill, 'preFilled' => $preFilled]); } /** diff --git a/app/Http/Controllers/Bill/IndexController.php b/app/Http/Controllers/Bill/IndexController.php index fcc0ebeb0d..9a1b345b18 100644 --- a/app/Http/Controllers/Bill/IndexController.php +++ b/app/Http/Controllers/Bill/IndexController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Bill; +use Illuminate\Support\Facades\Log; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Models\Bill; use FireflyIII\Repositories\Bill\BillRepositoryInterface; @@ -144,7 +145,7 @@ class IndexController extends Controller $totals = $this->getTotals($sums); $today = now()->startOfDay(); - return view('bills.index', compact('bills', 'sums', 'total', 'totals', 'today')); + return view('bills.index', ['bills' => $bills, 'sums' => $sums, 'total' => $total, 'totals' => $totals, 'today' => $today]); } private function getSums(array $bills): array @@ -202,8 +203,8 @@ class IndexController extends Controller { $avg = bcdiv(bcadd((string)$bill['amount_min'], (string)$bill['amount_max']), '2'); - app('log')->debug(sprintf('Amount per period for bill #%d "%s"', $bill['id'], $bill['name'])); - app('log')->debug(sprintf('Average is %s', $avg)); + Log::debug(sprintf('Amount per period for bill #%d "%s"', $bill['id'], $bill['name'])); + Log::debug(sprintf('Average is %s', $avg)); // calculate amount per year: $multiplies = [ 'yearly' => '1', @@ -214,7 +215,7 @@ class IndexController extends Controller 'daily' => '365.24', ]; $yearAmount = bcmul($avg, bcdiv($multiplies[$bill['repeat_freq']], (string)($bill['skip'] + 1))); - app('log')->debug(sprintf('Amount per year is %s (%s * %s / %s)', $yearAmount, $avg, $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 = [ @@ -234,7 +235,7 @@ class IndexController extends Controller ]; $perPeriod = bcdiv($yearAmount, $division[$range]); - app('log')->debug(sprintf('Amount per %s is %s (%s / %s)', $range, $perPeriod, $yearAmount, $division[$range])); + Log::debug(sprintf('Amount per %s is %s (%s / %s)', $range, $perPeriod, $yearAmount, $division[$range])); return $perPeriod; } diff --git a/app/Http/Controllers/Bill/ShowController.php b/app/Http/Controllers/Bill/ShowController.php index f102f5b5ac..33d9fa56b7 100644 --- a/app/Http/Controllers/Bill/ShowController.php +++ b/app/Http/Controllers/Bill/ShowController.php @@ -77,10 +77,8 @@ class ShowController extends Controller /** * Rescan bills for transactions. - * - * @return Redirector|RedirectResponse */ - public function rescan(Request $request, Bill $bill) + public function rescan(Request $request, Bill $bill): Redirector|RedirectResponse { $total = 0; if (false === $bill->active) { @@ -120,7 +118,7 @@ class ShowController extends Controller * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function show(Request $request, Bill $bill) + public function show(Request $request, Bill $bill): Factory|\Illuminate\Contracts\View\View { // add info about rules: $rules = $this->repository->getRulesForBill($bill); @@ -188,6 +186,6 @@ class ShowController extends Controller ); } - return view('bills.show', compact('attachments', 'groups', 'rules', 'yearAverage', 'overallAverage', 'year', 'object', 'bill', 'subTitle')); + return view('bills.show', ['attachments' => $attachments, 'groups' => $groups, 'rules' => $rules, 'yearAverage' => $yearAverage, 'overallAverage' => $overallAverage, 'year' => $year, 'object' => $object, 'bill' => $bill, 'subTitle' => $subTitle]); } } diff --git a/app/Http/Controllers/Budget/BudgetLimitController.php b/app/Http/Controllers/Budget/BudgetLimitController.php index 81087328c4..241345f2f5 100644 --- a/app/Http/Controllers/Budget/BudgetLimitController.php +++ b/app/Http/Controllers/Budget/BudgetLimitController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Budget; +use Illuminate\Support\Facades\Log; use Carbon\Carbon; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Http\Controllers\Controller; @@ -78,14 +79,14 @@ class BudgetLimitController extends Controller /** * @return Factory|View */ - public function create(Budget $budget, Carbon $start, Carbon $end) + public function create(Budget $budget, Carbon $start, Carbon $end): Factory|\Illuminate\Contracts\View\View { $collection = $this->currencyRepos->get(); $budgetLimits = $this->blRepository->getBudgetLimits($budget, $start, $end); // remove already budgeted currencies with the same date range $currencies = $collection->filter( - static function (TransactionCurrency $currency) use ($budgetLimits, $start, $end) { + static function (TransactionCurrency $currency) use ($budgetLimits, $start, $end): bool { /** @var BudgetLimit $limit */ foreach ($budgetLimits as $limit) { if ($limit->transaction_currency_id === $currency->id && $limit->start_date->isSameDay($start) && $limit->end_date->isSameDay($end) @@ -98,13 +99,10 @@ class BudgetLimitController extends Controller } ); - return view('budgets.budget-limits.create', compact('start', 'end', 'currencies', 'budget')); + return view('budgets.budget-limits.create', ['start' => $start, 'end' => $end, 'currencies' => $currencies, 'budget' => $budget]); } - /** - * @return Redirector|RedirectResponse - */ - public function delete(BudgetLimit $budgetLimit) + public function delete(BudgetLimit $budgetLimit): Redirector|RedirectResponse { $this->blRepository->destroyBudgetLimit($budgetLimit); session()->flash('success', trans('firefly.deleted_bl')); @@ -115,21 +113,21 @@ class BudgetLimitController extends Controller /** * @return Factory|View */ - public function edit(BudgetLimit $budgetLimit) + public function edit(BudgetLimit $budgetLimit): Factory|\Illuminate\Contracts\View\View { $notes = $this->blRepository->getNoteText($budgetLimit); - return view('budgets.budget-limits.edit', compact('budgetLimit', 'notes')); + return view('budgets.budget-limits.edit', ['budgetLimit' => $budgetLimit, 'notes' => $notes]); } /** * @return Factory|View */ - public function show(BudgetLimit $budgetLimit) + public function show(BudgetLimit $budgetLimit): Factory|\Illuminate\Contracts\View\View { $notes = $this->blRepository->getNoteText($budgetLimit); - return view('budgets.budget-limits.show', compact('budgetLimit', 'notes')); + return view('budgets.budget-limits.show', ['budgetLimit' => $budgetLimit, 'notes' => $notes]); } /** @@ -139,7 +137,7 @@ class BudgetLimitController extends Controller */ public function store(Request $request): JsonResponse|RedirectResponse { - app('log')->debug('Going to store new budget-limit.', $request->all()); + Log::debug('Going to store new budget-limit.', $request->all()); // first search for existing one and update it if necessary. $currency = $this->currencyRepos->find((int) $request->get('transaction_currency_id')); $budget = $this->repository->find((int) $request->get('budget_id')); @@ -161,7 +159,7 @@ class BudgetLimitController extends Controller return response()->json(); } - app('log')->debug(sprintf('Start: %s, end: %s', $start->format('Y-m-d'), $end->format('Y-m-d'))); + Log::debug(sprintf('Start: %s, end: %s', $start->format('Y-m-d'), $end->format('Y-m-d'))); $limit = $this->blRepository->find($budget, $currency, $start, $end); diff --git a/app/Http/Controllers/Budget/CreateController.php b/app/Http/Controllers/Budget/CreateController.php index 45f05ad897..2146daa4e9 100644 --- a/app/Http/Controllers/Budget/CreateController.php +++ b/app/Http/Controllers/Budget/CreateController.php @@ -67,7 +67,7 @@ class CreateController extends Controller * * @return Factory|View */ - public function create(Request $request) + public function create(Request $request): Factory|\Illuminate\Contracts\View\View { $hasOldInput = null !== $request->old('_token'); @@ -101,7 +101,7 @@ class CreateController extends Controller $request->session()->forget('budgets.create.fromStore'); $subTitle = (string) trans('firefly.create_new_budget'); - return view('budgets.create', compact('subTitle', 'autoBudgetTypes', 'autoBudgetPeriods')); + return view('budgets.create', ['subTitle' => $subTitle, 'autoBudgetTypes' => $autoBudgetTypes, 'autoBudgetPeriods' => $autoBudgetPeriods]); } /** diff --git a/app/Http/Controllers/Budget/DeleteController.php b/app/Http/Controllers/Budget/DeleteController.php index a938a06df4..7338cfa1b1 100644 --- a/app/Http/Controllers/Budget/DeleteController.php +++ b/app/Http/Controllers/Budget/DeleteController.php @@ -64,22 +64,20 @@ class DeleteController extends Controller * * @return Factory|View */ - public function delete(Budget $budget) + public function delete(Budget $budget): Factory|\Illuminate\Contracts\View\View { $subTitle = (string) trans('firefly.delete_budget', ['name' => $budget->name]); // put previous url in session $this->rememberPreviousUrl('budgets.delete.url'); - return view('budgets.delete', compact('budget', 'subTitle')); + return view('budgets.delete', ['budget' => $budget, 'subTitle' => $subTitle]); } /** * Destroys a budget. - * - * @return Redirector|RedirectResponse */ - public function destroy(Request $request, Budget $budget) + public function destroy(Request $request, Budget $budget): Redirector|RedirectResponse { $name = $budget->name; $this->repository->destroy($budget); diff --git a/app/Http/Controllers/Budget/EditController.php b/app/Http/Controllers/Budget/EditController.php index 6b0f820e20..15ca61d449 100644 --- a/app/Http/Controllers/Budget/EditController.php +++ b/app/Http/Controllers/Budget/EditController.php @@ -69,7 +69,7 @@ class EditController extends Controller * * @return Factory|View */ - public function edit(Request $request, Budget $budget) + public function edit(Request $request, Budget $budget): Factory|\Illuminate\Contracts\View\View { $subTitle = (string) trans('firefly.edit_budget', ['name' => $budget->name]); $autoBudget = $this->repository->getAutoBudget($budget); @@ -113,7 +113,7 @@ class EditController extends Controller $request->session()->forget('budgets.edit.fromUpdate'); $request->session()->flash('preFilled', $preFilled); - return view('budgets.edit', compact('budget', 'subTitle', 'autoBudgetTypes', 'autoBudgetPeriods', 'autoBudget')); + return view('budgets.edit', ['budget' => $budget, 'subTitle' => $subTitle, 'autoBudgetTypes' => $autoBudgetTypes, 'autoBudgetPeriods' => $autoBudgetPeriods, 'autoBudget' => $autoBudget]); } /** diff --git a/app/Http/Controllers/Budget/IndexController.php b/app/Http/Controllers/Budget/IndexController.php index 08631b6bd3..9f675b93a9 100644 --- a/app/Http/Controllers/Budget/IndexController.php +++ b/app/Http/Controllers/Budget/IndexController.php @@ -88,7 +88,7 @@ class IndexController extends Controller * * @throws FireflyException * */ - public function index(?Carbon $start = null, ?Carbon $end = null) + public function index(?Carbon $start = null, ?Carbon $end = null): Factory|\Illuminate\Contracts\View\View { $this->abRepository->cleanup(); Log::debug(sprintf('Start of IndexController::index("%s", "%s")', $start?->format('Y-m-d'), $end?->format('Y-m-d'))); @@ -138,23 +138,7 @@ class IndexController extends Controller return view( 'budgets.index', - compact( - 'availableBudgets', - 'budgeted', - 'spent', - 'prevLoop', - 'nextLoop', - 'budgets', - 'currencies', - 'periodTitle', - 'activeDaysPassed', - 'activeDaysLeft', - 'inactive', - 'budgets', - 'start', - 'end', - 'sums' - ) + ['availableBudgets' => $availableBudgets, 'budgeted' => $budgeted, 'spent' => $spent, 'prevLoop' => $prevLoop, 'nextLoop' => $nextLoop, 'currencies' => $currencies, 'periodTitle' => $periodTitle, 'activeDaysPassed' => $activeDaysPassed, 'activeDaysLeft' => $activeDaysLeft, 'inactive' => $inactive, 'budgets' => $budgets, 'start' => $start, 'end' => $end, 'sums' => $sums] ); } @@ -319,7 +303,7 @@ class IndexController extends Controller $budgetId = (int) $budgetId; $budget = $repository->find($budgetId); if ($budget instanceof Budget) { - app('log')->debug(sprintf('Set budget #%d ("%s") to position %d', $budget->id, $budget->name, $index + 1)); + Log::debug(sprintf('Set budget #%d ("%s") to position %d', $budget->id, $budget->name, $index + 1)); $repository->setBudgetOrder($budget, $index + 1); } } diff --git a/app/Http/Controllers/Budget/ShowController.php b/app/Http/Controllers/Budget/ShowController.php index 4c31d2927a..9215523324 100644 --- a/app/Http/Controllers/Budget/ShowController.php +++ b/app/Http/Controllers/Budget/ShowController.php @@ -81,7 +81,7 @@ class ShowController extends Controller * @throws FireflyException * @throws NotFoundExceptionInterface */ - public function noBudget(Request $request, ?Carbon $start = null, ?Carbon $end = null) + public function noBudget(Request $request, ?Carbon $start = null, ?Carbon $end = null): Factory|\Illuminate\Contracts\View\View { $start ??= session('start'); $end ??= session('end'); @@ -108,7 +108,7 @@ class ShowController extends Controller $groups = $collector->getPaginatedGroups(); $groups->setPath(route('budgets.no-budget')); - return view('budgets.no-budget', compact('groups', 'subTitle', 'periods', 'start', 'end')); + return view('budgets.no-budget', ['groups' => $groups, 'subTitle' => $subTitle, 'periods' => $periods, 'start' => $start, 'end' => $end]); } /** @@ -119,7 +119,7 @@ class ShowController extends Controller * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function noBudgetAll(Request $request) + public function noBudgetAll(Request $request): Factory|\Illuminate\Contracts\View\View { $subTitle = (string) trans('firefly.all_journals_without_budget'); $first = $this->journalRepos->firstNull(); @@ -136,7 +136,7 @@ class ShowController extends Controller $groups = $collector->getPaginatedGroups(); $groups->setPath(route('budgets.no-budget-all')); - return view('budgets.no-budget', compact('groups', 'subTitle', 'start', 'end')); + return view('budgets.no-budget', ['groups' => $groups, 'subTitle' => $subTitle, 'start' => $start, 'end' => $end]); } /** @@ -147,7 +147,7 @@ class ShowController extends Controller * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function show(Request $request, Budget $budget) + public function show(Request $request, Budget $budget): Factory|\Illuminate\Contracts\View\View { /** @var Carbon $allStart */ $allStart = session('first', today(config('app.timezone'))->startOfYear()); @@ -170,7 +170,7 @@ class ShowController extends Controller $subTitle = (string) trans('firefly.all_journals_for_budget', ['name' => $budget->name]); - return view('budgets.show', compact('limits', 'attachments', 'budget', 'repetition', 'groups', 'subTitle')); + return view('budgets.show', ['limits' => $limits, 'attachments' => $attachments, 'budget' => $budget, 'repetition' => $repetition, 'groups' => $groups, 'subTitle' => $subTitle]); } /** @@ -182,7 +182,7 @@ class ShowController extends Controller * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function showByBudgetLimit(Request $request, Budget $budget, BudgetLimit $budgetLimit) + public function showByBudgetLimit(Request $request, Budget $budget, BudgetLimit $budgetLimit): Factory|\Illuminate\Contracts\View\View { if ($budgetLimit->budget->id !== $budget->id) { throw new FireflyException('This budget limit is not part of this budget.'); @@ -220,6 +220,6 @@ class ShowController extends Controller $attachments = $this->repository->getAttachments($budget); $limits = $this->getLimits($budget, $start, $end); - return view('budgets.show', compact('limits', 'attachments', 'budget', 'budgetLimit', 'groups', 'subTitle', 'currencySymbol')); + return view('budgets.show', ['limits' => $limits, 'attachments' => $attachments, 'budget' => $budget, 'budgetLimit' => $budgetLimit, 'groups' => $groups, 'subTitle' => $subTitle, 'currencySymbol' => $currencySymbol]); } } diff --git a/app/Http/Controllers/Category/CreateController.php b/app/Http/Controllers/Category/CreateController.php index c9a0e58d1d..da68a62fe9 100644 --- a/app/Http/Controllers/Category/CreateController.php +++ b/app/Http/Controllers/Category/CreateController.php @@ -68,7 +68,7 @@ class CreateController extends Controller * * @return Factory|View */ - public function create(Request $request) + public function create(Request $request): Factory|\Illuminate\Contracts\View\View { if (true !== session('categories.create.fromStore')) { $this->rememberPreviousUrl('categories.create.url'); @@ -76,7 +76,7 @@ class CreateController extends Controller $request->session()->forget('categories.create.fromStore'); $subTitle = (string) trans('firefly.create_new_category'); - return view('categories.create', compact('subTitle')); + return view('categories.create', ['subTitle' => $subTitle]); } /** diff --git a/app/Http/Controllers/Category/DeleteController.php b/app/Http/Controllers/Category/DeleteController.php index b4968f45ee..e90b33b56c 100644 --- a/app/Http/Controllers/Category/DeleteController.php +++ b/app/Http/Controllers/Category/DeleteController.php @@ -64,22 +64,20 @@ class DeleteController extends Controller * * @return Factory|View */ - public function delete(Category $category) + public function delete(Category $category): Factory|\Illuminate\Contracts\View\View { $subTitle = (string) trans('firefly.delete_category', ['name' => $category->name]); // put previous url in session $this->rememberPreviousUrl('categories.delete.url'); - return view('categories.delete', compact('category', 'subTitle')); + return view('categories.delete', ['category' => $category, 'subTitle' => $subTitle]); } /** * Destroy a category. - * - * @return Redirector|RedirectResponse */ - public function destroy(Request $request, Category $category) + public function destroy(Request $request, Category $category): Redirector|RedirectResponse { $name = $category->name; $this->repository->destroy($category); diff --git a/app/Http/Controllers/Category/EditController.php b/app/Http/Controllers/Category/EditController.php index cdfa19a3fc..9a5ddd55dc 100644 --- a/app/Http/Controllers/Category/EditController.php +++ b/app/Http/Controllers/Category/EditController.php @@ -68,7 +68,7 @@ class EditController extends Controller * * @return Factory|View */ - public function edit(Request $request, Category $category) + public function edit(Request $request, Category $category): Factory|\Illuminate\Contracts\View\View { $subTitle = (string) trans('firefly.edit_category', ['name' => $category->name]); @@ -82,15 +82,13 @@ class EditController extends Controller 'notes' => $request->old('notes') ?? $this->repository->getNoteText($category), ]; - return view('categories.edit', compact('category', 'subTitle', 'preFilled')); + return view('categories.edit', ['category' => $category, 'subTitle' => $subTitle, 'preFilled' => $preFilled]); } /** * Update category. - * - * @return Redirector|RedirectResponse */ - public function update(CategoryFormRequest $request, Category $category) + public function update(CategoryFormRequest $request, Category $category): Redirector|RedirectResponse { $data = $request->getCategoryData(); $this->repository->update($category, $data); diff --git a/app/Http/Controllers/Category/IndexController.php b/app/Http/Controllers/Category/IndexController.php index f91870a346..15d7f70865 100644 --- a/app/Http/Controllers/Category/IndexController.php +++ b/app/Http/Controllers/Category/IndexController.php @@ -69,7 +69,7 @@ class IndexController extends Controller * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function index(Request $request) + public function index(Request $request): Factory|\Illuminate\Contracts\View\View { $page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page'); $pageSize = (int) app('preferences')->get('listPageSize', 50)->data; @@ -87,6 +87,6 @@ class IndexController extends Controller $categories = new LengthAwarePaginator($collection, $total, $pageSize, $page); $categories->setPath(route('categories.index')); - return view('categories.index', compact('categories')); + return view('categories.index', ['categories' => $categories]); } } diff --git a/app/Http/Controllers/Category/NoCategoryController.php b/app/Http/Controllers/Category/NoCategoryController.php index b2dade990d..2e4db37b00 100644 --- a/app/Http/Controllers/Category/NoCategoryController.php +++ b/app/Http/Controllers/Category/NoCategoryController.php @@ -77,7 +77,7 @@ class NoCategoryController extends Controller * @throws FireflyException * @throws NotFoundExceptionInterface */ - public function show(Request $request, ?Carbon $start = null, ?Carbon $end = null) + public function show(Request $request, ?Carbon $start = null, ?Carbon $end = null): Factory|\Illuminate\Contracts\View\View { Log::debug('Start of noCategory()'); $start ??= session('start'); @@ -104,7 +104,7 @@ class NoCategoryController extends Controller $groups = $collector->getPaginatedGroups(); $groups->setPath(route('categories.no-category', [$start->format('Y-m-d'), $end->format('Y-m-d')])); - return view('categories.no-category', compact('groups', 'subTitle', 'periods', 'start', 'end')); + return view('categories.no-category', ['groups' => $groups, 'subTitle' => $subTitle, 'periods' => $periods, 'start' => $start, 'end' => $end]); } /** @@ -115,7 +115,7 @@ class NoCategoryController extends Controller * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function showAll(Request $request) + public function showAll(Request $request): Factory|\Illuminate\Contracts\View\View { // default values: $start = null; @@ -140,6 +140,6 @@ class NoCategoryController extends Controller $groups = $collector->getPaginatedGroups(); $groups->setPath(route('categories.no-category.all')); - return view('categories.no-category', compact('groups', 'subTitle', 'periods', 'start', 'end')); + return view('categories.no-category', ['groups' => $groups, 'subTitle' => $subTitle, 'periods' => $periods, 'start' => $start, 'end' => $end]); } } diff --git a/app/Http/Controllers/Category/ShowController.php b/app/Http/Controllers/Category/ShowController.php index 57fa33fc7a..101bf3f75a 100644 --- a/app/Http/Controllers/Category/ShowController.php +++ b/app/Http/Controllers/Category/ShowController.php @@ -76,7 +76,7 @@ class ShowController extends Controller * @throws FireflyException * @throws NotFoundExceptionInterface */ - public function show(Request $request, Category $category, ?Carbon $start = null, ?Carbon $end = null) + public function show(Request $request, Category $category, ?Carbon $start = null, ?Carbon $end = null): Factory|\Illuminate\Contracts\View\View { $start ??= session('start', today(config('app.timezone'))->startOfMonth()); $end ??= session('end', today(config('app.timezone'))->endOfMonth()); @@ -109,7 +109,7 @@ class ShowController extends Controller $groups = $collector->getPaginatedGroups(); $groups->setPath($path); - return view('categories.show', compact('category', 'attachments', 'groups', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end')); + return view('categories.show', ['category' => $category, 'attachments' => $attachments, 'groups' => $groups, 'periods' => $periods, 'subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon, 'start' => $start, 'end' => $end]); } /** @@ -120,7 +120,7 @@ class ShowController extends Controller * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function showAll(Request $request, Category $category) + public function showAll(Request $request, Category $category): Factory|\Illuminate\Contracts\View\View { // default values: $subTitleIcon = 'fa-bookmark'; @@ -149,6 +149,6 @@ class ShowController extends Controller $groups = $collector->getPaginatedGroups(); $groups->setPath($path); - return view('categories.show', compact('category', 'attachments', 'groups', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end')); + return view('categories.show', ['category' => $category, 'attachments' => $attachments, 'groups' => $groups, 'periods' => $periods, 'subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon, 'start' => $start, 'end' => $end]); } } diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php index ada7f9014e..8cf2c2be9e 100644 --- a/app/Http/Controllers/Chart/AccountController.php +++ b/app/Http/Controllers/Chart/AccountController.php @@ -387,7 +387,7 @@ class AccountController extends Controller $defaultSet = $repository->getAccountsByType([AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value])->pluck('id')->toArray(); // Log::debug('Default set is ', $defaultSet); $frontpage = Preferences::get('frontpageAccounts', $defaultSet); - $frontpageArray = !is_array($frontpage->data) ? [] : $frontpage->data; + $frontpageArray = is_array($frontpage->data) ? $frontpage->data : []; Log::debug('Frontpage preference set is ', $frontpageArray); if (0 === count($frontpageArray)) { Preferences::set('frontpageAccounts', $defaultSet); diff --git a/app/Http/Controllers/Chart/BillController.php b/app/Http/Controllers/Chart/BillController.php index ceb02a444b..3ea69e293f 100644 --- a/app/Http/Controllers/Chart/BillController.php +++ b/app/Http/Controllers/Chart/BillController.php @@ -122,7 +122,7 @@ class BillController extends Controller // sort the other way around: usort( $journals, - static function (array $left, array $right) { + static function (array $left, array $right): int { if ($left['date']->gt($right['date'])) { return 1; } diff --git a/app/Http/Controllers/Chart/ReportController.php b/app/Http/Controllers/Chart/ReportController.php index 4517b002fc..5ccd3a0d10 100644 --- a/app/Http/Controllers/Chart/ReportController.php +++ b/app/Http/Controllers/Chart/ReportController.php @@ -86,7 +86,7 @@ class ReportController extends Controller /** @var AccountRepositoryInterface $accountRepository */ $accountRepository = app(AccountRepositoryInterface::class); $filtered = $accounts->filter( - static function (Account $account) use ($accountRepository) { + static function (Account $account) use ($accountRepository): bool { $includeNetWorth = $accountRepository->getMetaValue($account, 'include_net_worth'); $result = null === $includeNetWorth ? true : '1' === $includeNetWorth; if (false === $result) { diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.php index 0e6bddcd2d..e374dd2adb 100644 --- a/app/Http/Controllers/DebugController.php +++ b/app/Http/Controllers/DebugController.php @@ -96,11 +96,10 @@ class DebugController extends Controller /** * Clear log and session. * - * @return Redirector|RedirectResponse * * @throws FireflyException */ - public function flush(Request $request) + public function flush(Request $request): Redirector|RedirectResponse { Preferences::mark(); $request->session()->forget(['start', 'end', '_previous', 'viewRange', 'range', 'is_custom_range', 'temp-mfa-secret', 'temp-mfa-codes']); @@ -134,7 +133,7 @@ class DebugController extends Controller * * @throws FilesystemException */ - public function index() + public function index(): Factory|\Illuminate\Contracts\View\View { $table = $this->generateTable(); $table = str_replace(["\n", "\t", ' '], '', $table); @@ -158,7 +157,7 @@ class DebugController extends Controller $logContent = 'Truncated from this point <----|'.substr($logContent, -16384); } - return view('debug', compact('table', 'now', 'logContent')); + return view('debug', ['table' => $table, 'now' => $now, 'logContent' => $logContent]); } public function apiTest(): View @@ -174,7 +173,7 @@ class DebugController extends Controller $app = $this->getAppInfo(); $user = $this->getUserInfo(); - return (string) view('partials.debug-table', compact('system', 'docker', 'app', 'user')); + return (string) view('partials.debug-table', ['system' => $system, 'docker' => $docker, 'app' => $app, 'user' => $user]); } private function getSystemInformation(): array @@ -474,122 +473,81 @@ class DebugController extends Controller return 'asset'; case 'account': - return '1'; - - case 'start_date': - return '20241201'; - - case 'end_date': - return '20241231'; case 'attachment': - return '1'; case 'bill': - return '1'; case 'budget': - return '1'; case 'budgetLimit': - return '1'; case 'category': - return '1'; case 'currency': - return '1'; - - case 'fromCurrencyCode': - return 'EUR'; - - case 'toCurrencyCode': - return 'USD'; - - case 'accountList': - return '1,6'; - - case 'budgetList': - return '1,2'; - - case 'categoryList': - return '1,2'; - - case 'doubleList': - return '1,2'; - - case 'tagList': - return '1,2'; case 'tag': - return '1'; case 'piggyBank': - return '1'; case 'objectGroup': - return '1'; - - case 'route': - return 'accounts'; - - case 'specificPage': - return 'show'; case 'recurrence': - return '1'; case 'tj': - return '1'; - - case 'reportType': - return 'default'; case 'ruleGroup': - return '1'; case 'rule': - return '1'; case 'tagOrId': - return '1'; case 'transactionGroup': - return '1'; - - case 'journalList': - return '1,2'; - - case 'transactionType': - return 'withdrawal'; case 'journalLink': - return '1'; case 'webhook': - return '1'; case 'user': - return '1'; case 'linkType': - return '1'; case 'userGroup': return '1'; + case 'start_date': case 'date': return '20241201'; + case 'end_date': + return '20241231'; + case 'fromCurrencyCode': + return 'EUR'; + case 'toCurrencyCode': + return 'USD'; + case 'accountList': + return '1,6'; + case 'budgetList': + case 'categoryList': + case 'doubleList': + case 'tagList': + case 'journalList': + return '1,2'; + case 'route': + return 'accounts'; + case 'specificPage': + return 'show'; + case 'reportType': + return 'default'; + case 'transactionType': + return 'withdrawal'; } } /** * Flash all types of messages. - * - * @return Redirector|RedirectResponse */ - public function testFlash(Request $request) + public function testFlash(Request $request): Redirector|RedirectResponse { $request->session()->flash('success', 'This is a success message.'); $request->session()->flash('info', 'This is an info message.'); diff --git a/app/Http/Controllers/ExchangeRates/IndexController.php b/app/Http/Controllers/ExchangeRates/IndexController.php index 258052606b..e8dbf13382 100644 --- a/app/Http/Controllers/ExchangeRates/IndexController.php +++ b/app/Http/Controllers/ExchangeRates/IndexController.php @@ -59,6 +59,6 @@ class IndexController extends Controller public function rates(TransactionCurrency $from, TransactionCurrency $to): View { - return view('exchange-rates.rates', compact('from', 'to')); + return view('exchange-rates.rates', ['from' => $from, 'to' => $to]); } } diff --git a/app/Http/Controllers/Export/IndexController.php b/app/Http/Controllers/Export/IndexController.php index 3089c4ac35..68223b0fab 100644 --- a/app/Http/Controllers/Export/IndexController.php +++ b/app/Http/Controllers/Export/IndexController.php @@ -118,7 +118,7 @@ class IndexController extends Controller /** * @return Factory|View */ - public function index() + public function index(): Factory|\Illuminate\Contracts\View\View { return view('export.index'); } diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 4a29660f92..b3cff18071 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -179,7 +179,7 @@ class HomeController extends Controller $user = auth()->user(); event(new RequestedVersionCheckStatus($user)); - return view('index', compact('count', 'subTitle', 'transactions', 'billCount', 'start', 'end', 'today', 'pageTitle')); + return view('index', ['count' => $count, 'subTitle' => $subTitle, 'transactions' => $transactions, 'billCount' => $billCount, 'start' => $start, 'end' => $end, 'today' => $today, 'pageTitle' => $pageTitle]); } private function indexV2(): mixed @@ -194,6 +194,6 @@ class HomeController extends Controller $user = auth()->user(); event(new RequestedVersionCheckStatus($user)); - return view('index', compact('subTitle', 'start', 'end', 'pageTitle')); + return view('index', ['subTitle' => $subTitle, 'start' => $start, 'end' => $end, 'pageTitle' => $pageTitle]); } } diff --git a/app/Http/Controllers/Json/BoxController.php b/app/Http/Controllers/Json/BoxController.php index 04d6a6b108..a7a631a193 100644 --- a/app/Http/Controllers/Json/BoxController.php +++ b/app/Http/Controllers/Json/BoxController.php @@ -170,7 +170,7 @@ class BoxController extends Controller // filter list on preference of being included. $filtered = $allAccounts->filter( - static function (Account $account) use ($accountRepository) { + static function (Account $account) use ($accountRepository): bool { $includeNetWorth = $accountRepository->getMetaValue($account, 'include_net_worth'); $result = null === $includeNetWorth || '1' === $includeNetWorth; if (false === $result) { diff --git a/app/Http/Controllers/Json/FrontpageController.php b/app/Http/Controllers/Json/FrontpageController.php index a51499cfc2..e884ab789a 100644 --- a/app/Http/Controllers/Json/FrontpageController.php +++ b/app/Http/Controllers/Json/FrontpageController.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Json; +use Illuminate\Support\Facades\Log; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Models\PiggyBank; @@ -80,7 +81,7 @@ class FrontpageController extends Controller // sort by current percentage (lowest at the top) uasort( $info, - static fn (array $a, array $b) => $a['percentage'] <=> $b['percentage'] + static fn (array $a, array $b): int => $a['percentage'] <=> $b['percentage'] ); $html = ''; @@ -88,10 +89,10 @@ class FrontpageController extends Controller try { $convertToPrimary = $this->convertToPrimary; $primary = $this->primaryCurrency; - $html = view('json.piggy-banks', compact('info', 'convertToPrimary', 'primary'))->render(); + $html = view('json.piggy-banks', ['info' => $info, 'convertToPrimary' => $convertToPrimary, 'primary' => $primary])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Cannot render json.piggy-banks: %s', $e->getMessage())); - app('log')->error($e->getTraceAsString()); + Log::error(sprintf('Cannot render json.piggy-banks: %s', $e->getMessage())); + Log::error($e->getTraceAsString()); $html = 'Could not render view.'; throw new FireflyException($html, 0, $e); diff --git a/app/Http/Controllers/Json/IntroController.php b/app/Http/Controllers/Json/IntroController.php index 7a55bca8c1..9025051314 100644 --- a/app/Http/Controllers/Json/IntroController.php +++ b/app/Http/Controllers/Json/IntroController.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Json; +use Illuminate\Support\Facades\Log; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Support\Http\Controllers\GetConfigurationData; use Illuminate\Http\JsonResponse; @@ -39,12 +40,12 @@ class IntroController extends Controller */ public function getIntroSteps(string $route, ?string $specificPage = null): JsonResponse { - app('log')->debug(sprintf('getIntroSteps for route "%s" and page "%s"', $route, $specificPage)); + Log::debug(sprintf('getIntroSteps for route "%s" and page "%s"', $route, $specificPage)); $specificPage ??= ''; $steps = $this->getBasicSteps($route); $specificSteps = $this->getSpecificSteps($route, $specificPage); if (0 === count($specificSteps)) { - app('log')->debug(sprintf('No specific steps for route "%s" and page "%s"', $route, $specificPage)); + Log::debug(sprintf('No specific steps for route "%s" and page "%s"', $route, $specificPage)); return response()->json($steps); } @@ -70,7 +71,7 @@ class IntroController extends Controller public function hasOutroStep(string $route): bool { $routeKey = str_replace('.', '_', $route); - app('log')->debug(sprintf('Has outro step for route %s', $routeKey)); + Log::debug(sprintf('Has outro step for route %s', $routeKey)); $elements = config(sprintf('intro.%s', $routeKey)); if (!is_array($elements)) { return false; @@ -78,9 +79,9 @@ class IntroController extends Controller $hasStep = array_key_exists('outro', $elements); - app('log')->debug('Elements is array', $elements); - app('log')->debug('Keys is', array_keys($elements)); - app('log')->debug(sprintf('Keys has "outro": %s', var_export($hasStep, true))); + Log::debug('Elements is array', $elements); + Log::debug('Keys is', array_keys($elements)); + Log::debug(sprintf('Keys has "outro": %s', var_export($hasStep, true))); return $hasStep; } @@ -96,7 +97,7 @@ class IntroController extends Controller if ('' !== $specialPage) { $key = sprintf('%s_%s', $key, $specialPage); } - app('log')->debug(sprintf('Going to mark the following route as NOT done: %s with special "%s" (%s)', $route, $specialPage, $key)); + Log::debug(sprintf('Going to mark the following route as NOT done: %s with special "%s" (%s)', $route, $specialPage, $key)); app('preferences')->set($key, false); app('preferences')->mark(); @@ -113,7 +114,7 @@ class IntroController extends Controller if ('' !== $specialPage) { $key = sprintf('%s_%s', $key, $specialPage); } - app('log')->debug(sprintf('Going to mark the following route as done: %s with special "%s" (%s)', $route, $specialPage, $key)); + Log::debug(sprintf('Going to mark the following route as done: %s with special "%s" (%s)', $route, $specialPage, $key)); app('preferences')->set($key, true); return response()->json(['result' => sprintf('Reported demo watched for route "%s" (%s): %s.', $route, $specialPage, $key)]); diff --git a/app/Http/Controllers/Json/ReconcileController.php b/app/Http/Controllers/Json/ReconcileController.php index ed85b21885..4dd4c2274c 100644 --- a/app/Http/Controllers/Json/ReconcileController.php +++ b/app/Http/Controllers/Json/ReconcileController.php @@ -118,7 +118,7 @@ class ReconcileController extends Controller foreach ($journals as $journal) { $amount = $this->processJournal($account, $accountCurrency, $journal, $amount); } - app('log')->debug(sprintf('Final amount is %s', $amount)); + Log::debug(sprintf('Final amount is %s', $amount)); /** @var array $journal */ foreach ($clearedJournals as $journal) { @@ -136,10 +136,10 @@ class ReconcileController extends Controller $reconSum = bcadd(bcadd($startBalance ?? '0', $amount), $clearedAmount); try { - $view = view('accounts.reconcile.overview', compact('account', 'start', 'diffCompare', 'difference', 'end', 'clearedAmount', 'startBalance', 'endBalance', 'amount', 'route', 'countCleared', 'reconSum', 'selectedIds'))->render(); + $view = view('accounts.reconcile.overview', ['account' => $account, 'start' => $start, 'diffCompare' => $diffCompare, 'difference' => $difference, 'end' => $end, 'clearedAmount' => $clearedAmount, 'startBalance' => $startBalance, 'endBalance' => $endBalance, 'amount' => $amount, 'route' => $route, 'countCleared' => $countCleared, 'reconSum' => $reconSum, 'selectedIds' => $selectedIds])->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('View error: %s', $e->getMessage())); - app('log')->error($e->getTraceAsString()); + Log::debug(sprintf('View error: %s', $e->getMessage())); + Log::error($e->getTraceAsString()); $view = sprintf('Could not render accounts.reconcile.overview: %s', $e->getMessage()); throw new FireflyException($view, 0, $e); @@ -153,7 +153,7 @@ class ReconcileController extends Controller private function processJournal(Account $account, TransactionCurrency $currency, array $journal, string $amount): string { $toAdd = '0'; - app('log')->debug(sprintf('User submitted %s #%d: "%s"', $journal['transaction_type_type'], $journal['transaction_journal_id'], $journal['description'])); + Log::debug(sprintf('User submitted %s #%d: "%s"', $journal['transaction_type_type'], $journal['transaction_journal_id'], $journal['description'])); // not much magic below we need to cover using tests. @@ -174,9 +174,9 @@ class ReconcileController extends Controller } } - app('log')->debug(sprintf('Going to add %s to %s', $toAdd, $amount)); + Log::debug(sprintf('Going to add %s to %s', $toAdd, $amount)); $amount = bcadd($amount, (string) $toAdd); - app('log')->debug(sprintf('Result is %s', $amount)); + Log::debug(sprintf('Result is %s', $amount)); return $amount; } @@ -239,11 +239,11 @@ class ReconcileController extends Controller try { $html = view( 'accounts.reconcile.transactions', - compact('account', 'journals', 'currency', 'start', 'end', 'selectionStart', 'selectionEnd') + ['account' => $account, 'journals' => $journals, 'currency' => $currency, 'start' => $start, 'end' => $end, 'selectionStart' => $selectionStart, 'selectionEnd' => $selectionEnd] )->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Could not render: %s', $e->getMessage())); - app('log')->error($e->getTraceAsString()); + Log::debug(sprintf('Could not render: %s', $e->getMessage())); + Log::error($e->getTraceAsString()); $html = sprintf('Could not render accounts.reconcile.transactions: %s', $e->getMessage()); throw new FireflyException($html, 0, $e); @@ -277,7 +277,7 @@ class ReconcileController extends Controller $inverse = true; } - if (true === $inverse) { + if ($inverse) { $journal['amount'] = app('steam')->positive($journal['amount']); if (null !== $journal['foreign_amount']) { $journal['foreign_amount'] = app('steam')->positive($journal['foreign_amount']); diff --git a/app/Http/Controllers/Json/RecurrenceController.php b/app/Http/Controllers/Json/RecurrenceController.php index 6c07685f34..8b18a8abef 100644 --- a/app/Http/Controllers/Json/RecurrenceController.php +++ b/app/Http/Controllers/Json/RecurrenceController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Json; +use Illuminate\Support\Facades\Log; use Carbon\Carbon; use Carbon\Exceptions\InvalidFormatException; use FireflyIII\Exceptions\FireflyException; @@ -168,12 +169,12 @@ class RecurrenceController extends Controller $preSelected = (string) $request->get('pre_select'); $locale = app('steam')->getLocale(); - app('log')->debug(sprintf('date = %s, today = %s. date > today? %s', $date->toAtomString(), $today->toAtomString(), var_export($date > $today, true))); - app('log')->debug(sprintf('past = true? %s', var_export('true' === (string) $request->get('past'), true))); + 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))); $result = []; if ($date > $today || 'true' === (string) $request->get('past')) { - app('log')->debug('Will fill dropdown.'); + 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)); @@ -200,7 +201,7 @@ class RecurrenceController extends Controller ], ]; } - app('log')->debug('Dropdown is', $result); + Log::debug('Dropdown is', $result); return response()->json($result); } diff --git a/app/Http/Controllers/Json/RuleController.php b/app/Http/Controllers/Json/RuleController.php index 1826cd0a80..ed927db543 100644 --- a/app/Http/Controllers/Json/RuleController.php +++ b/app/Http/Controllers/Json/RuleController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Json; +use Illuminate\Support\Facades\Log; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Http\Controllers\Controller; use Illuminate\Http\JsonResponse; @@ -50,10 +51,10 @@ class RuleController extends Controller } try { - $view = view('rules.partials.action', compact('actions', 'count'))->render(); + $view = view('rules.partials.action', ['actions' => $actions, 'count' => $count])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Cannot render rules.partials.action: %s', $e->getMessage())); - app('log')->error($e->getTraceAsString()); + Log::error(sprintf('Cannot render rules.partials.action: %s', $e->getMessage())); + Log::error($e->getTraceAsString()); $view = 'Could not render view.'; throw new FireflyException($view, 0, $e); @@ -80,10 +81,10 @@ class RuleController extends Controller asort($triggers); try { - $view = view('rules.partials.trigger', compact('triggers', 'count'))->render(); + $view = view('rules.partials.trigger', ['triggers' => $triggers, 'count' => $count])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Cannot render rules.partials.trigger: %s', $e->getMessage())); - app('log')->error($e->getTraceAsString()); + Log::error(sprintf('Cannot render rules.partials.trigger: %s', $e->getMessage())); + Log::error($e->getTraceAsString()); $view = 'Could not render view.'; throw new FireflyException($view, 0, $e); diff --git a/app/Http/Controllers/NewUserController.php b/app/Http/Controllers/NewUserController.php index 5bfbc6815e..0c914d965a 100644 --- a/app/Http/Controllers/NewUserController.php +++ b/app/Http/Controllers/NewUserController.php @@ -64,7 +64,7 @@ class NewUserController extends Controller * * @return Factory|Redirector|RedirectResponse|View */ - public function index() + public function index(): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View { app('view')->share('title', (string) trans('firefly.welcome')); app('view')->share('mainTitleIcon', 'fa-fire'); @@ -78,15 +78,13 @@ class NewUserController extends Controller return redirect(route('index')); } - return view('new-user.index', compact('languages')); + return view('new-user.index', ['languages' => $languages]); } /** * Store his new settings. - * - * @return Redirector|RedirectResponse */ - public function submit(NewUserFormRequest $request, CurrencyRepositoryInterface $currencyRepository) + public function submit(NewUserFormRequest $request, CurrencyRepositoryInterface $currencyRepository): Redirector|RedirectResponse { $language = $request->convertString('language'); if (!array_key_exists($language, config('firefly.languages'))) { diff --git a/app/Http/Controllers/ObjectGroup/DeleteController.php b/app/Http/Controllers/ObjectGroup/DeleteController.php index 4a6c97181c..52c4b61466 100644 --- a/app/Http/Controllers/ObjectGroup/DeleteController.php +++ b/app/Http/Controllers/ObjectGroup/DeleteController.php @@ -59,10 +59,8 @@ class DeleteController extends Controller /** * Delete a piggy bank. - * - * @return Factory|View */ - public function delete(ObjectGroup $objectGroup) + public function delete(ObjectGroup $objectGroup): Factory|View { $subTitle = (string) trans('firefly.delete_object_group', ['title' => $objectGroup->title]); $piggyBanks = $objectGroup->piggyBanks()->count(); @@ -70,7 +68,7 @@ class DeleteController extends Controller // put previous url in session $this->rememberPreviousUrl('object-groups.delete.url'); - return view('object-groups.delete', compact('objectGroup', 'subTitle', 'piggyBanks')); + return view('object-groups.delete', ['objectGroup' => $objectGroup, 'subTitle' => $subTitle, 'piggyBanks' => $piggyBanks]); } /** diff --git a/app/Http/Controllers/ObjectGroup/EditController.php b/app/Http/Controllers/ObjectGroup/EditController.php index 62be1e1edb..c3a3355eb6 100644 --- a/app/Http/Controllers/ObjectGroup/EditController.php +++ b/app/Http/Controllers/ObjectGroup/EditController.php @@ -62,10 +62,8 @@ class EditController extends Controller /** * Edit an object group. - * - * @return Factory|View */ - public function edit(ObjectGroup $objectGroup) + public function edit(ObjectGroup $objectGroup): Factory|View { $subTitle = (string) trans('firefly.edit_object_group', ['title' => $objectGroup->title]); $subTitleIcon = 'fa-pencil'; @@ -75,7 +73,7 @@ class EditController extends Controller } session()->forget('object-groups.edit.fromUpdate'); - return view('object-groups.edit', compact('subTitle', 'subTitleIcon', 'objectGroup')); + return view('object-groups.edit', ['subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon, 'objectGroup' => $objectGroup]); } /** @@ -83,7 +81,7 @@ class EditController extends Controller * * @return Application|Redirector|RedirectResponse */ - public function update(ObjectGroupFormRequest $request, ObjectGroup $objectGroup) + public function update(ObjectGroupFormRequest $request, ObjectGroup $objectGroup): Redirector|RedirectResponse { $data = $request->getObjectGroupData(); $piggyBank = $this->repository->update($objectGroup, $data); diff --git a/app/Http/Controllers/ObjectGroup/IndexController.php b/app/Http/Controllers/ObjectGroup/IndexController.php index 91fc370f35..756d23c16a 100644 --- a/app/Http/Controllers/ObjectGroup/IndexController.php +++ b/app/Http/Controllers/ObjectGroup/IndexController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\ObjectGroup; +use Illuminate\Support\Facades\Log; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Models\ObjectGroup; use FireflyIII\Repositories\ObjectGroup\ObjectGroupRepositoryInterface; @@ -58,17 +59,14 @@ class IndexController extends Controller ); } - /** - * @return Factory|View - */ - public function index() + public function index(): Factory|View { $this->repository->deleteEmpty(); $this->repository->resetOrder(); $subTitle = (string) trans('firefly.object_groups_index'); $objectGroups = $this->repository->get(); - return view('object-groups.index', compact('subTitle', 'objectGroups')); + return view('object-groups.index', ['subTitle' => $subTitle, 'objectGroups' => $objectGroups]); } /** @@ -76,7 +74,7 @@ class IndexController extends Controller */ public function setOrder(Request $request, ObjectGroup $objectGroup) { - app('log')->debug(sprintf('Found object group #%d "%s"', $objectGroup->id, $objectGroup->title)); + Log::debug(sprintf('Found object group #%d "%s"', $objectGroup->id, $objectGroup->title)); $newOrder = (int) $request->get('order'); $this->repository->setOrder($objectGroup, $newOrder); diff --git a/app/Http/Controllers/PiggyBank/AmountController.php b/app/Http/Controllers/PiggyBank/AmountController.php index 4cdec6201f..011ba2a445 100644 --- a/app/Http/Controllers/PiggyBank/AmountController.php +++ b/app/Http/Controllers/PiggyBank/AmountController.php @@ -66,7 +66,7 @@ class AmountController extends Controller * * @return Factory|View */ - public function add(PiggyBank $piggyBank) + public function add(PiggyBank $piggyBank): Factory|\Illuminate\Contracts\View\View { /** @var Carbon $date */ $date = session('end', today(config('app.timezone'))); @@ -98,7 +98,7 @@ class AmountController extends Controller } $total = (float) $total; // intentional float. - return view('piggy-banks.add', compact('piggyBank', 'accounts', 'total')); + return view('piggy-banks.add', ['piggyBank' => $piggyBank, 'accounts' => $accounts, 'total' => $total]); } /** @@ -106,7 +106,7 @@ class AmountController extends Controller * * @return Factory|View */ - public function addMobile(PiggyBank $piggyBank) + public function addMobile(PiggyBank $piggyBank): Factory|\Illuminate\Contracts\View\View { /** @var Carbon $date */ $date = session('end', today(config('app.timezone'))); @@ -127,7 +127,7 @@ class AmountController extends Controller $total = bcadd($total, $leftOnAccount); } - return view('piggy-banks.add-mobile', compact('piggyBank', 'total', 'accounts')); + return view('piggy-banks.add-mobile', ['piggyBank' => $piggyBank, 'total' => $total, 'accounts' => $accounts]); } /** @@ -171,7 +171,7 @@ class AmountController extends Controller return redirect(route('piggy-banks.index')); } - app('log')->error(sprintf('Cannot add %s because canAddAmount returned false.', $total)); + Log::error(sprintf('Cannot add %s because canAddAmount returned false.', $total)); session()->flash( 'error', (string) trans( @@ -237,7 +237,7 @@ class AmountController extends Controller * * @return Factory|View */ - public function remove(PiggyBank $piggyBank) + public function remove(PiggyBank $piggyBank): Factory|\Illuminate\Contracts\View\View { $accounts = []; foreach ($piggyBank->accounts as $account) { @@ -247,7 +247,7 @@ class AmountController extends Controller ]; } - return view('piggy-banks.remove', compact('piggyBank', 'accounts')); + return view('piggy-banks.remove', ['piggyBank' => $piggyBank, 'accounts' => $accounts]); } /** @@ -255,7 +255,7 @@ class AmountController extends Controller * * @return Factory|View */ - public function removeMobile(PiggyBank $piggyBank) + public function removeMobile(PiggyBank $piggyBank): Factory|\Illuminate\Contracts\View\View { $accounts = []; foreach ($piggyBank->accounts as $account) { @@ -265,6 +265,6 @@ class AmountController extends Controller ]; } - return view('piggy-banks.remove-mobile', compact('piggyBank', 'accounts')); + return view('piggy-banks.remove-mobile', ['piggyBank' => $piggyBank, 'accounts' => $accounts]); } } diff --git a/app/Http/Controllers/PiggyBank/CreateController.php b/app/Http/Controllers/PiggyBank/CreateController.php index 0edd81cbcc..d58962bf84 100644 --- a/app/Http/Controllers/PiggyBank/CreateController.php +++ b/app/Http/Controllers/PiggyBank/CreateController.php @@ -69,11 +69,11 @@ class CreateController extends Controller * * @return Factory|View */ - public function create(Request $request) + public function create(Request $request): Factory|\Illuminate\Contracts\View\View { $subTitle = (string) trans('firefly.new_piggy_bank'); $subTitleIcon = 'fa-plus'; - $hasOldInput = null !== $request->old('_token'); + $request->old('_token'); $preFilled = $request->old(); // put previous url in session if not redirect from store (not "create another"). @@ -82,7 +82,7 @@ class CreateController extends Controller } session()->forget('piggy-banks.create.fromStore'); - return view('piggy-banks.create', compact('subTitle', 'subTitleIcon', 'preFilled')); + return view('piggy-banks.create', ['subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon, 'preFilled' => $preFilled]); } /** diff --git a/app/Http/Controllers/PiggyBank/DeleteController.php b/app/Http/Controllers/PiggyBank/DeleteController.php index 2ac0855b85..f267db4a5e 100644 --- a/app/Http/Controllers/PiggyBank/DeleteController.php +++ b/app/Http/Controllers/PiggyBank/DeleteController.php @@ -62,14 +62,14 @@ class DeleteController extends Controller * * @return Factory|View */ - public function delete(PiggyBank $piggyBank) + public function delete(PiggyBank $piggyBank): Factory|\Illuminate\Contracts\View\View { $subTitle = (string) trans('firefly.delete_piggy_bank', ['name' => $piggyBank->name]); // put previous url in session $this->rememberPreviousUrl('piggy-banks.delete.url'); - return view('piggy-banks.delete', compact('piggyBank', 'subTitle')); + return view('piggy-banks.delete', ['piggyBank' => $piggyBank, 'subTitle' => $subTitle]); } /** diff --git a/app/Http/Controllers/PiggyBank/EditController.php b/app/Http/Controllers/PiggyBank/EditController.php index 200d5acc6d..4140e68da7 100644 --- a/app/Http/Controllers/PiggyBank/EditController.php +++ b/app/Http/Controllers/PiggyBank/EditController.php @@ -76,7 +76,7 @@ class EditController extends Controller * * @return Factory|View */ - public function edit(PiggyBank $piggyBank) + public function edit(PiggyBank $piggyBank): Factory|\Illuminate\Contracts\View\View { $subTitle = (string) trans('firefly.update_piggy_title', ['name' => $piggyBank->name]); $subTitleIcon = 'fa-pencil'; @@ -109,15 +109,13 @@ class EditController extends Controller } session()->forget('piggy-banks.edit.fromUpdate'); - return view('piggy-banks.edit', compact('subTitle', 'subTitleIcon', 'piggyBank', 'preFilled')); + return view('piggy-banks.edit', ['subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon, 'piggyBank' => $piggyBank, 'preFilled' => $preFilled]); } /** * Update a piggy bank. - * - * @return Redirector|RedirectResponse */ - public function update(PiggyBankUpdateRequest $request, PiggyBank $piggyBank) + public function update(PiggyBankUpdateRequest $request, PiggyBank $piggyBank): Redirector|RedirectResponse { $data = $request->getPiggyBankData(); $piggyBank = $this->piggyRepos->update($piggyBank, $data); diff --git a/app/Http/Controllers/PiggyBank/IndexController.php b/app/Http/Controllers/PiggyBank/IndexController.php index 60c089fee0..76ac7477a1 100644 --- a/app/Http/Controllers/PiggyBank/IndexController.php +++ b/app/Http/Controllers/PiggyBank/IndexController.php @@ -77,14 +77,13 @@ class IndexController extends Controller * * @return Factory|View */ - public function index() + public function index(): Factory|\Illuminate\Contracts\View\View { $this->cleanupObjectGroups(); $this->piggyRepos->resetOrder(); $collection = $this->piggyRepos->getPiggyBanks(); - /** @var Carbon $end */ - $end = session('end', today(config('app.timezone'))->endOfMonth()); + session('end', today(config('app.timezone'))->endOfMonth()); // transform piggies using the transformer: // $parameters = new ParameterBag(); @@ -103,7 +102,7 @@ class IndexController extends Controller ksort($piggyBanks); - return view('piggy-banks.index', compact('piggyBanks', 'accounts')); + return view('piggy-banks.index', ['piggyBanks' => $piggyBanks, 'accounts' => $accounts]); } private function groupPiggyBanks(Collection $collection): array diff --git a/app/Http/Controllers/PiggyBank/ShowController.php b/app/Http/Controllers/PiggyBank/ShowController.php index 9a877563a4..d75769f550 100644 --- a/app/Http/Controllers/PiggyBank/ShowController.php +++ b/app/Http/Controllers/PiggyBank/ShowController.php @@ -69,7 +69,7 @@ class ShowController extends Controller * * @throws FireflyException */ - public function show(PiggyBank $piggyBank) + public function show(PiggyBank $piggyBank): Factory|\Illuminate\Contracts\View\View { /** @var Carbon $end */ $end = session('end', today(config('app.timezone'))->endOfMonth()); @@ -95,6 +95,6 @@ class ShowController extends Controller $attachments = $this->piggyRepos->getAttachments($piggyBank); - return view('piggy-banks.show', compact('piggyBank', 'events', 'subTitle', 'piggy', 'attachments')); + return view('piggy-banks.show', ['piggyBank' => $piggyBank, 'events' => $events, 'subTitle' => $subTitle, 'piggy' => $piggy, 'attachments' => $attachments]); } } diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php index f1c2ac8658..43fd16f342 100644 --- a/app/Http/Controllers/PreferencesController.php +++ b/app/Http/Controllers/PreferencesController.php @@ -77,7 +77,7 @@ class PreferencesController extends Controller * @throws FireflyException * @throws FilesystemException */ - public function index(AccountRepositoryInterface $repository) + public function index(AccountRepositoryInterface $repository): Factory|\Illuminate\Contracts\View\View { $accounts = $repository->getAccountsByType([AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value]); $isDocker = env('IS_DOCKER', false); // @phpstan-ignore-line @@ -159,7 +159,7 @@ class PreferencesController extends Controller try { $locales = json_decode(file_get_contents(resource_path(sprintf('locales/%s/locales.json', $language))), true, 512, JSON_THROW_ON_ERROR); } catch (JsonException $e) { - app('log')->error($e->getMessage()); + Log::error($e->getMessage()); $locales = []; } $locales = ['equal' => (string) trans('firefly.equal_to_language')] + $locales; @@ -182,47 +182,19 @@ class PreferencesController extends Controller $ntfyPass = ''; } - return view('preferences.index', compact( - 'language', - 'pushoverAppToken', - 'pushoverUserToken', - 'ntfyServer', - 'ntfyTopic', - 'ntfyAuth', - 'channels', - 'ntfyUser', - 'forcedAvailability', - 'ntfyPass', - 'groupedAccounts', - 'isDocker', - 'frontpageAccounts', - 'languages', - 'darkMode', - 'availableDarkModes', - 'notifications', - 'convertToPrimary', - 'slackUrl', - 'locales', - 'locale', - 'tjOptionalFields', - 'viewRange', - 'customFiscalYear', - 'listPageSize', - 'fiscalYearStart' - )); + return view('preferences.index', ['language' => $language, 'pushoverAppToken' => $pushoverAppToken, 'pushoverUserToken' => $pushoverUserToken, 'ntfyServer' => $ntfyServer, 'ntfyTopic' => $ntfyTopic, 'ntfyAuth' => $ntfyAuth, 'channels' => $channels, 'ntfyUser' => $ntfyUser, 'forcedAvailability' => $forcedAvailability, 'ntfyPass' => $ntfyPass, 'groupedAccounts' => $groupedAccounts, 'isDocker' => $isDocker, 'frontpageAccounts' => $frontpageAccounts, 'languages' => $languages, 'darkMode' => $darkMode, 'availableDarkModes' => $availableDarkModes, 'notifications' => $notifications, 'convertToPrimary' => $convertToPrimary, 'slackUrl' => $slackUrl, 'locales' => $locales, 'locale' => $locale, 'tjOptionalFields' => $tjOptionalFields, 'viewRange' => $viewRange, 'customFiscalYear' => $customFiscalYear, 'listPageSize' => $listPageSize, 'fiscalYearStart' => $fiscalYearStart]); } /** * Store new preferences. * - * @return Redirector|RedirectResponse * * @throws FireflyException * * @SuppressWarnings("PHPMD.ExcessiveMethodLength") * @SuppressWarnings("PHPMD.NPathComplexity") */ - public function postIndex(PreferencesRequest $request) + public function postIndex(PreferencesRequest $request): Redirector|RedirectResponse { // front page accounts $frontpageAccounts = []; @@ -362,7 +334,7 @@ class PreferencesController extends Controller case 'ntfy': /** @var User $user */ $user = auth()->user(); - app('log')->debug(sprintf('Now in testNotification("%s") controller.', $channel)); + Log::debug(sprintf('Now in testNotification("%s") controller.', $channel)); event(new UserTestNotificationChannel($channel, $user)); session()->flash('success', (string) trans('firefly.notification_test_executed', ['channel' => $channel])); } diff --git a/app/Http/Controllers/Profile/MfaController.php b/app/Http/Controllers/Profile/MfaController.php index 123680e2c3..0114474be4 100644 --- a/app/Http/Controllers/Profile/MfaController.php +++ b/app/Http/Controllers/Profile/MfaController.php @@ -78,7 +78,7 @@ class MfaController extends Controller ); $authGuard = config('firefly.authentication_guard'); $this->internalAuth = 'web' === $authGuard; - app('log')->debug(sprintf('ProfileController::__construct(). Authentication guard is "%s"', $authGuard)); + Log::debug(sprintf('ProfileController::__construct(). Authentication guard is "%s"', $authGuard)); $this->middleware(IsDemoUser::class)->except(['index']); @@ -132,7 +132,7 @@ class MfaController extends Controller Log::channel('audit')->info(sprintf('User "%s" has generated new backup codes.', $user->email)); event(new MFANewBackupCodes($user)); - return view('profile.mfa.backup-codes-post')->with(compact('codes')); + return view('profile.mfa.backup-codes-post')->with(['codes' => $codes]); } @@ -152,7 +152,7 @@ class MfaController extends Controller $subTitle = (string) trans('firefly.mfa_index_title'); $subTitleIcon = 'fa-calculator'; - return view('profile.mfa.disable-mfa')->with(compact('subTitle', 'subTitleIcon', 'enabledMFA')); + return view('profile.mfa.disable-mfa')->with(['subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon, 'enabledMFA' => $enabledMFA]); } /** @@ -221,19 +221,18 @@ class MfaController extends Controller app('preferences')->set('temp-mfa-secret', $secret); - return view('profile.mfa.enable-mfa', compact('image', 'secret')); + return view('profile.mfa.enable-mfa', ['image' => $image, 'secret' => $secret]); } /** * Submit 2FA for the first time. * - * @return Redirector|RedirectResponse * * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function enableMFAPost(TokenFormRequest $request) + public function enableMFAPost(TokenFormRequest $request): Redirector|RedirectResponse { if (!$this->internalAuth) { $request->session()->flash('error', trans('firefly.external_user_mgt_disabled')); @@ -340,6 +339,6 @@ class MfaController extends Controller $subTitleIcon = 'fa-calculator'; $enabledMFA = null !== auth()->user()->mfa_secret; - return view('profile.mfa.index')->with(compact('subTitle', 'subTitleIcon', 'enabledMFA')); + return view('profile.mfa.index')->with(['subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon, 'enabledMFA' => $enabledMFA]); } } diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 26e1509103..8939c61b30 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers; +use Illuminate\Support\Facades\Log; use Exception; use FireflyIII\Events\UserChangedEmail; use FireflyIII\Exceptions\FireflyException; @@ -79,7 +80,7 @@ class ProfileController extends Controller ); $authGuard = config('firefly.authentication_guard'); $this->internalAuth = 'web' === $authGuard; - app('log')->debug(sprintf('ProfileController::__construct(). Authentication guard is "%s"', $authGuard)); + Log::debug(sprintf('ProfileController::__construct(). Authentication guard is "%s"', $authGuard)); $this->middleware(IsDemoUser::class)->except(['index']); } @@ -132,7 +133,7 @@ class ProfileController extends Controller $subTitle = (string) trans('firefly.delete_account'); $subTitleIcon = 'fa-trash'; - return view('profile.delete-account', compact('title', 'subTitle', 'subTitleIcon')); + return view('profile.delete-account', ['title' => $title, 'subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon]); } /** @@ -172,7 +173,7 @@ class ProfileController extends Controller return view( 'profile.index', - compact('subTitle', 'mfaBackupCount', 'userId', 'accessToken', 'enabled2FA', 'isInternalAuth') + ['subTitle' => $subTitle, 'mfaBackupCount' => $mfaBackupCount, 'userId' => $userId, 'accessToken' => $accessToken, 'enabled2FA' => $enabled2FA, 'isInternalAuth' => $isInternalAuth] ); } @@ -247,15 +248,13 @@ class ProfileController extends Controller $subTitle = (string) trans('firefly.change_your_email'); $subTitleIcon = 'fa-envelope'; - return view('profile.change-email', compact('title', 'subTitle', 'subTitleIcon', 'email')); + return view('profile.change-email', ['title' => $title, 'subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon, 'email' => $email]); } /** * Submit change password form. - * - * @return Redirector|RedirectResponse */ - public function postChangePassword(ProfileFormRequest $request, UserRepositoryInterface $repository) + public function postChangePassword(ProfileFormRequest $request, UserRepositoryInterface $repository): Redirector|RedirectResponse { if (!$this->internalAuth) { $request->session()->flash('error', trans('firefly.external_user_mgt_disabled')); @@ -289,7 +288,7 @@ class ProfileController extends Controller * * @return Factory|Redirector|RedirectResponse|View */ - public function changePassword(Request $request) + public function changePassword(Request $request): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View { if (!$this->internalAuth) { $request->session()->flash('error', trans('firefly.external_user_mgt_disabled')); @@ -301,15 +300,13 @@ class ProfileController extends Controller $subTitle = (string) trans('firefly.change_your_password'); $subTitleIcon = 'fa-key'; - return view('profile.change-password', compact('title', 'subTitle', 'subTitleIcon')); + return view('profile.change-password', ['title' => $title, 'subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon]); } /** * Submit delete account. - * - * @return Redirector|RedirectResponse */ - public function postDeleteAccount(UserRepositoryInterface $repository, DeleteAccountFormRequest $request) + public function postDeleteAccount(UserRepositoryInterface $repository, DeleteAccountFormRequest $request): Redirector|RedirectResponse { if (!$this->internalAuth) { $request->session()->flash('error', trans('firefly.external_user_mgt_disabled')); @@ -325,7 +322,7 @@ class ProfileController extends Controller /** @var User $user */ $user = auth()->user(); - app('log')->info(sprintf('User #%d has opted to delete their account', auth()->user()->id)); + Log::info(sprintf('User #%d has opted to delete their account', auth()->user()->id)); // make repository delete user: auth()->logout(); session()->flush(); @@ -339,7 +336,7 @@ class ProfileController extends Controller * * @throws AuthenticationException */ - public function postLogoutOtherSessions(Request $request) + public function postLogoutOtherSessions(Request $request): Redirector|RedirectResponse { if (!$this->internalAuth) { session()->flash('info', (string) trans('firefly.external_auth_disabled')); @@ -364,11 +361,10 @@ class ProfileController extends Controller /** * Regenerate access token. * - * @return Redirector|RedirectResponse * * @throws Exception */ - public function regenerate(Request $request) + public function regenerate(Request $request): Redirector|RedirectResponse { if (!$this->internalAuth) { $request->session()->flash('error', trans('firefly.external_user_mgt_disabled')); @@ -388,11 +384,10 @@ class ProfileController extends Controller /** * Undo change of user email address. * - * @return Redirector|RedirectResponse * * @throws FireflyException */ - public function undoEmailChange(UserRepositoryInterface $repository, string $token, string $hash) + public function undoEmailChange(UserRepositoryInterface $repository, string $token, string $hash): Redirector|RedirectResponse { if (!$this->internalAuth) { throw new FireflyException(trans('firefly.external_user_mgt_disabled')); diff --git a/app/Http/Controllers/Recurring/CreateController.php b/app/Http/Controllers/Recurring/CreateController.php index 9faff410ee..16bf091f03 100644 --- a/app/Http/Controllers/Recurring/CreateController.php +++ b/app/Http/Controllers/Recurring/CreateController.php @@ -80,7 +80,7 @@ class CreateController extends Controller * * @return Factory|View */ - public function create(Request $request) + public function create(Request $request): Factory|\Illuminate\Contracts\View\View { $budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets()); $bills = app('expandedform')->makeSelectListWithEmpty($this->billRepository->getActiveBills()); @@ -115,16 +115,14 @@ class CreateController extends Controller return view( 'recurring.create', - compact('tomorrow', 'oldRepetitionType', 'bills', 'weekendResponses', 'preFilled', 'repetitionEnds', 'budgets') + ['tomorrow' => $tomorrow, 'oldRepetitionType' => $oldRepetitionType, 'bills' => $bills, 'weekendResponses' => $weekendResponses, 'preFilled' => $preFilled, 'repetitionEnds' => $repetitionEnds, 'budgets' => $budgets] ); } /** - * @return Factory|\Illuminate\Contracts\View\View - * * @SuppressWarnings("PHPMD.ExcessiveMethodLength") */ - public function createFromJournal(Request $request, TransactionJournal $journal) + public function createFromJournal(Request $request, TransactionJournal $journal): Factory|\Illuminate\Contracts\View\View { $budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets()); $bills = app('expandedform')->makeSelectListWithEmpty($this->billRepository->getActiveBills()); @@ -162,7 +160,7 @@ class CreateController extends Controller $bill = null !== $journal->bill ? $journal->bill->id : 0; $hasOldInput = null !== $request->old('_token'); // flash some data $preFilled = []; - if (true === $hasOldInput) { + if ($hasOldInput) { $preFilled = [ 'title' => $request->old('title'), 'transaction_description' => $request->old('description'), @@ -206,7 +204,7 @@ class CreateController extends Controller } $request->session()->flash('preFilled', $preFilled); - return view('recurring.create', compact('tomorrow', 'oldRepetitionType', 'bills', 'weekendResponses', 'preFilled', 'repetitionEnds', 'budgets')); + return view('recurring.create', ['tomorrow' => $tomorrow, 'oldRepetitionType' => $oldRepetitionType, 'bills' => $bills, 'weekendResponses' => $weekendResponses, 'preFilled' => $preFilled, 'repetitionEnds' => $repetitionEnds, 'budgets' => $budgets]); } /** diff --git a/app/Http/Controllers/Recurring/DeleteController.php b/app/Http/Controllers/Recurring/DeleteController.php index 5ddb8fff08..35d1017f00 100644 --- a/app/Http/Controllers/Recurring/DeleteController.php +++ b/app/Http/Controllers/Recurring/DeleteController.php @@ -65,7 +65,7 @@ class DeleteController extends Controller * * @return Factory|View */ - public function delete(Recurrence $recurrence) + public function delete(Recurrence $recurrence): Factory|\Illuminate\Contracts\View\View { $subTitle = (string) trans('firefly.delete_recurring', ['title' => $recurrence->title]); // put previous url in session @@ -73,15 +73,13 @@ class DeleteController extends Controller $journalsCreated = $this->repository->getTransactions($recurrence)->count(); - return view('recurring.delete', compact('recurrence', 'subTitle', 'journalsCreated')); + return view('recurring.delete', ['recurrence' => $recurrence, 'subTitle' => $subTitle, 'journalsCreated' => $journalsCreated]); } /** * Destroy the recurring transaction. - * - * @return Redirector|RedirectResponse */ - public function destroy(RecurringRepositoryInterface $repository, Request $request, Recurrence $recurrence) + public function destroy(RecurringRepositoryInterface $repository, Request $request, Recurrence $recurrence): Redirector|RedirectResponse { $repository->destroy($recurrence); $request->session()->flash('success', (string) trans('firefly.recurrence_deleted', ['title' => $recurrence->title])); diff --git a/app/Http/Controllers/Recurring/EditController.php b/app/Http/Controllers/Recurring/EditController.php index d9b39c0e7f..f0cdb8b4da 100644 --- a/app/Http/Controllers/Recurring/EditController.php +++ b/app/Http/Controllers/Recurring/EditController.php @@ -86,7 +86,7 @@ class EditController extends Controller * * @throws FireflyException */ - public function edit(Request $request, Recurrence $recurrence) + public function edit(Request $request, Recurrence $recurrence): Factory|\Illuminate\Contracts\View\View { // TODO this should be in the repository. $count = $recurrence->recurrenceTransactions()->count(); @@ -160,17 +160,7 @@ class EditController extends Controller return view( 'recurring.edit', - compact( - 'recurrence', - 'array', - 'bills', - 'weekendResponses', - 'budgets', - 'preFilled', - 'currentRepType', - 'repetitionEnd', - 'repetitionEnds' - ) + ['recurrence' => $recurrence, 'array' => $array, 'bills' => $bills, 'weekendResponses' => $weekendResponses, 'budgets' => $budgets, 'preFilled' => $preFilled, 'currentRepType' => $currentRepType, 'repetitionEnd' => $repetitionEnd, 'repetitionEnds' => $repetitionEnds] ); } diff --git a/app/Http/Controllers/Recurring/IndexController.php b/app/Http/Controllers/Recurring/IndexController.php index be4d9e527c..48d840828f 100644 --- a/app/Http/Controllers/Recurring/IndexController.php +++ b/app/Http/Controllers/Recurring/IndexController.php @@ -79,7 +79,7 @@ class IndexController extends Controller * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function index(Request $request) + public function index(Request $request): Factory|\Illuminate\Contracts\View\View { $page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page'); $pageSize = (int) app('preferences')->get('listPageSize', 50)->data; @@ -134,6 +134,6 @@ class IndexController extends Controller $this->verifyRecurringCronJob(); - return view('recurring.index', compact('paginator', 'today', 'page', 'pageSize', 'total')); + return view('recurring.index', ['paginator' => $paginator, 'today' => $today, 'page' => $page, 'pageSize' => $pageSize, 'total' => $total]); } } diff --git a/app/Http/Controllers/Recurring/ShowController.php b/app/Http/Controllers/Recurring/ShowController.php index 2d11613550..83dc4e2bf7 100644 --- a/app/Http/Controllers/Recurring/ShowController.php +++ b/app/Http/Controllers/Recurring/ShowController.php @@ -77,7 +77,7 @@ class ShowController extends Controller * * @throws FireflyException */ - public function show(Recurrence $recurrence) + public function show(Recurrence $recurrence): Factory|\Illuminate\Contracts\View\View { $repos = app(AttachmentRepositoryInterface::class); @@ -137,6 +137,6 @@ class ShowController extends Controller $subTitle = (string) trans('firefly.overview_for_recurrence', ['title' => $recurrence->title]); - return view('recurring.show', compact('recurrence', 'subTitle', 'array', 'groups', 'today')); + return view('recurring.show', ['recurrence' => $recurrence, 'subTitle' => $subTitle, 'array' => $array, 'groups' => $groups, 'today' => $today]); } } diff --git a/app/Http/Controllers/Recurring/TriggerController.php b/app/Http/Controllers/Recurring/TriggerController.php index 7719be82a8..a709f038a0 100644 --- a/app/Http/Controllers/Recurring/TriggerController.php +++ b/app/Http/Controllers/Recurring/TriggerController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Recurring; +use Illuminate\Support\Facades\Log; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Requests\TriggerRecurrenceRequest; use FireflyIII\Jobs\CreateRecurringTransactions; @@ -70,7 +71,7 @@ class TriggerController extends Controller $backupDate = $recurrence->latest_date; // fire the recurring cron job on the given date, then post-date the created transaction. - app('log')->info(sprintf('Trigger: will now fire recurring cron job task for date "%s".', $date->format('Y-m-d H:i:s'))); + Log::info(sprintf('Trigger: will now fire recurring cron job task for date "%s".', $date->format('Y-m-d H:i:s'))); /** @var CreateRecurringTransactions $job */ $job = app(CreateRecurringTransactions::class); @@ -78,7 +79,7 @@ class TriggerController extends Controller $job->setDate($date); $job->setForce(false); $job->handle(); - app('log')->debug('Done with recurrence.'); + Log::debug('Done with recurrence.'); $groups = $job->getGroups(); $this->repository->markGroupsAsNow($groups); diff --git a/app/Http/Controllers/Report/AccountController.php b/app/Http/Controllers/Report/AccountController.php index c6818cd9c6..b68d894a67 100644 --- a/app/Http/Controllers/Report/AccountController.php +++ b/app/Http/Controllers/Report/AccountController.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Report; +use Illuminate\Support\Facades\Log; use Carbon\Carbon; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Http\Controllers\Controller; @@ -58,10 +59,10 @@ class AccountController extends Controller $accountReport = $accountTasker->getAccountReport($accounts, $start, $end); try { - $result = view('reports.partials.accounts', compact('accountReport'))->render(); + $result = view('reports.partials.accounts', ['accountReport' => $accountReport])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Could not render reports.partials.accounts: %s', $e->getMessage())); - app('log')->error($e->getTraceAsString()); + Log::error(sprintf('Could not render reports.partials.accounts: %s', $e->getMessage())); + Log::error($e->getTraceAsString()); $result = 'Could not render view.'; throw new FireflyException($result, 0, $e); diff --git a/app/Http/Controllers/Report/BalanceController.php b/app/Http/Controllers/Report/BalanceController.php index 3764008f2a..def545cbdd 100644 --- a/app/Http/Controllers/Report/BalanceController.php +++ b/app/Http/Controllers/Report/BalanceController.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Report; +use Illuminate\Support\Facades\Log; use Carbon\Carbon; use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Exceptions\FireflyException; @@ -140,10 +141,10 @@ class BalanceController extends Controller } try { - $result = view('reports.partials.balance', compact('report'))->render(); + $result = view('reports.partials.balance', ['report' => $report])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Could not render reports.partials.balance: %s', $e->getMessage())); - app('log')->error($e->getTraceAsString()); + Log::error(sprintf('Could not render reports.partials.balance: %s', $e->getMessage())); + Log::error($e->getTraceAsString()); $result = 'Could not render view.'; throw new FireflyException($result, 0, $e); diff --git a/app/Http/Controllers/Report/BillController.php b/app/Http/Controllers/Report/BillController.php index 9cea9f5edd..069aebbeac 100644 --- a/app/Http/Controllers/Report/BillController.php +++ b/app/Http/Controllers/Report/BillController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Report; +use Illuminate\Support\Facades\Log; use Carbon\Carbon; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Helpers\Report\ReportHelperInterface; @@ -58,10 +59,10 @@ class BillController extends Controller $report = $helper->getBillReport($accounts, $start, $end); try { - $result = view('reports.partials.bills', compact('report'))->render(); + $result = view('reports.partials.bills', ['report' => $report])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Could not render reports.partials.budgets: %s', $e->getMessage())); - app('log')->error($e->getTraceAsString()); + Log::error(sprintf('Could not render reports.partials.budgets: %s', $e->getMessage())); + Log::error($e->getTraceAsString()); $result = 'Could not render view.'; throw new FireflyException($result, 0, $e); diff --git a/app/Http/Controllers/Report/BudgetController.php b/app/Http/Controllers/Report/BudgetController.php index 29c802bb96..7525b4f0bc 100644 --- a/app/Http/Controllers/Report/BudgetController.php +++ b/app/Http/Controllers/Report/BudgetController.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Report; +use Illuminate\Support\Facades\Log; use Carbon\Carbon; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Http\Controllers\Controller; @@ -69,7 +70,7 @@ class BudgetController extends Controller * * @throws FireflyException */ - public function accountPerBudget(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end) + public function accountPerBudget(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end): Factory|\Illuminate\Contracts\View\View { /** @var BudgetReportGenerator $generator */ $generator = app(BudgetReportGenerator::class); @@ -83,13 +84,13 @@ class BudgetController extends Controller $generator->accountPerBudget(); $report = $generator->getReport(); - return view('reports.budget.partials.account-per-budget', compact('report', 'budgets')); + return view('reports.budget.partials.account-per-budget', ['report' => $report, 'budgets' => $budgets]); } /** * @return Factory|View */ - public function accounts(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end) + public function accounts(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end): Factory|\Illuminate\Contracts\View\View { $spent = $this->opsRepository->listExpenses($start, $end, $accounts, $budgets); $report = []; @@ -135,7 +136,7 @@ class BudgetController extends Controller } } - return view('reports.budget.partials.accounts', compact('sums', 'report')); + return view('reports.budget.partials.accounts', ['sums' => $sums, 'report' => $report]); } /** @@ -177,11 +178,11 @@ class BudgetController extends Controller array_multisort($amounts, SORT_ASC, $result); try { - $result = view('reports.budget.partials.avg-expenses', compact('result'))->render(); + $result = view('reports.budget.partials.avg-expenses', ['result' => $result])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); + Log::error(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); $result = sprintf('Could not render view: %s', $e->getMessage()); - app('log')->error($e->getTraceAsString()); + Log::error($e->getTraceAsString()); throw new FireflyException($result, 0, $e); } @@ -192,7 +193,7 @@ class BudgetController extends Controller /** * @return Factory|View */ - public function budgets(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end) + public function budgets(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end): Factory|\Illuminate\Contracts\View\View { $spent = $this->opsRepository->listExpenses($start, $end, $accounts, $budgets); $sums = []; @@ -250,7 +251,7 @@ class BudgetController extends Controller } } - return view('reports.budget.partials.budgets', compact('sums', 'report')); + return view('reports.budget.partials.budgets', ['sums' => $sums, 'report' => $report]); } /** @@ -273,7 +274,7 @@ class BudgetController extends Controller $generator->general(); $report = $generator->getReport(); - return view('reports.partials.budgets', compact('report'))->render(); + return view('reports.partials.budgets', ['report' => $report])->render(); } /** @@ -339,10 +340,10 @@ class BudgetController extends Controller } try { - $result = view('reports.partials.budget-period', compact('report', 'periods'))->render(); + $result = view('reports.partials.budget-period', ['report' => $report, 'periods' => $periods])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); - app('log')->error($e->getTraceAsString()); + Log::error(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); + Log::error($e->getTraceAsString()); $result = 'Could not render view.'; throw new FireflyException($result, 0, $e); @@ -390,9 +391,9 @@ class BudgetController extends Controller array_multisort($amounts, SORT_ASC, $result); try { - $result = view('reports.budget.partials.top-expenses', compact('result'))->render(); + $result = view('reports.budget.partials.top-expenses', ['result' => $result])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); + Log::error(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); $result = sprintf('Could not render view: %s', $e->getMessage()); throw new FireflyException($result, 0, $e); diff --git a/app/Http/Controllers/Report/CategoryController.php b/app/Http/Controllers/Report/CategoryController.php index 1ae30d59e8..ae4adb23de 100644 --- a/app/Http/Controllers/Report/CategoryController.php +++ b/app/Http/Controllers/Report/CategoryController.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Report; +use Illuminate\Support\Facades\Log; use Carbon\Carbon; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Http\Controllers\Controller; @@ -67,7 +68,7 @@ class CategoryController extends Controller /** * @return Factory|View */ - public function accountPerCategory(Collection $accounts, Collection $categories, Carbon $start, Carbon $end) + public function accountPerCategory(Collection $accounts, Collection $categories, Carbon $start, Carbon $end): Factory|\Illuminate\Contracts\View\View { $spent = $this->opsRepository->listExpenses($start, $end, $accounts, $categories); $earned = $this->opsRepository->listIncome($start, $end, $accounts, $categories); @@ -151,7 +152,7 @@ class CategoryController extends Controller } } - return view('reports.category.partials.account-per-category', compact('report', 'categories')); + return view('reports.category.partials.account-per-category', ['report' => $report, 'categories' => $categories]); } /** @@ -159,7 +160,7 @@ class CategoryController extends Controller * * @SuppressWarnings("PHPMD.ExcessiveMethodLength") */ - public function accounts(Collection $accounts, Collection $categories, Carbon $start, Carbon $end) + public function accounts(Collection $accounts, Collection $categories, Carbon $start, Carbon $end): Factory|\Illuminate\Contracts\View\View { $spent = $this->opsRepository->listExpenses($start, $end, $accounts, $categories); $earned = $this->opsRepository->listIncome($start, $end, $accounts, $categories); @@ -253,7 +254,7 @@ class CategoryController extends Controller } } - return view('reports.category.partials.accounts', compact('sums', 'report')); + return view('reports.category.partials.accounts', ['sums' => $sums, 'report' => $report]); } /** @@ -295,9 +296,9 @@ class CategoryController extends Controller array_multisort($amounts, SORT_ASC, $result); try { - $result = view('reports.category.partials.avg-expenses', compact('result'))->render(); + $result = view('reports.category.partials.avg-expenses', ['result' => $result])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); + Log::error(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); $result = sprintf('Could not render view: %s', $e->getMessage()); throw new FireflyException($result, 0, $e); @@ -345,9 +346,9 @@ class CategoryController extends Controller array_multisort($amounts, SORT_DESC, $result); try { - $result = view('reports.category.partials.avg-income', compact('result'))->render(); + $result = view('reports.category.partials.avg-income', ['result' => $result])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); + Log::error(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); $result = sprintf('Could not render view: %s', $e->getMessage()); throw new FireflyException($result, 0, $e); @@ -361,7 +362,7 @@ class CategoryController extends Controller * * @SuppressWarnings("PHPMD.ExcessiveMethodLength") */ - public function categories(Collection $accounts, Collection $categories, Carbon $start, Carbon $end) + public function categories(Collection $accounts, Collection $categories, Carbon $start, Carbon $end): Factory|\Illuminate\Contracts\View\View { $spent = $this->opsRepository->listExpenses($start, $end, $accounts, $categories); $earned = $this->opsRepository->listIncome($start, $end, $accounts, $categories); @@ -461,7 +462,7 @@ class CategoryController extends Controller } } - return view('reports.category.partials.categories', compact('sums', 'report')); + return view('reports.category.partials.categories', ['sums' => $sums, 'report' => $report]); } /** @@ -527,9 +528,9 @@ class CategoryController extends Controller $report = $data; try { - $result = view('reports.partials.category-period', compact('report', 'periods'))->render(); + $result = view('reports.partials.category-period', ['report' => $report, 'periods' => $periods])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Could not render category::expenses: %s', $e->getMessage())); + Log::error(sprintf('Could not render category::expenses: %s', $e->getMessage())); $result = sprintf('An error prevented Firefly III from rendering: %s. Apologies.', $e->getMessage()); throw new FireflyException($result, 0, $e); @@ -599,9 +600,9 @@ class CategoryController extends Controller $report = $data; try { - $result = view('reports.partials.category-period', compact('report', 'periods'))->render(); + $result = view('reports.partials.category-period', ['report' => $report, 'periods' => $periods])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Could not render category::expenses: %s', $e->getMessage())); + Log::error(sprintf('Could not render category::expenses: %s', $e->getMessage())); $result = sprintf('An error prevented Firefly III from rendering: %s. Apologies.', $e->getMessage()); throw new FireflyException($result, 0, $e); @@ -638,10 +639,10 @@ class CategoryController extends Controller $report = $generator->getReport(); try { - $result = view('reports.partials.categories', compact('report'))->render(); + $result = view('reports.partials.categories', ['report' => $report])->render(); $cache->store($result); } catch (Throwable $e) { - app('log')->error(sprintf('Could not render category::expenses: %s', $e->getMessage())); + Log::error(sprintf('Could not render category::expenses: %s', $e->getMessage())); $result = sprintf('An error prevented Firefly III from rendering: %s. Apologies.', $e->getMessage()); throw new FireflyException($result, 0, $e); @@ -687,9 +688,9 @@ class CategoryController extends Controller array_multisort($amounts, SORT_ASC, $result); try { - $result = view('reports.category.partials.top-expenses', compact('result'))->render(); + $result = view('reports.category.partials.top-expenses', ['result' => $result])->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); + Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); $result = sprintf('Could not render view: %s', $e->getMessage()); throw new FireflyException($e->getMessage(), 0, $e); @@ -735,9 +736,9 @@ class CategoryController extends Controller array_multisort($amounts, SORT_DESC, $result); try { - $result = view('reports.category.partials.top-income', compact('result'))->render(); + $result = view('reports.category.partials.top-income', ['result' => $result])->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); + Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); $result = sprintf('Could not render view: %s', $e->getMessage()); throw new FireflyException($e->getMessage(), 0, $e); diff --git a/app/Http/Controllers/Report/DoubleController.php b/app/Http/Controllers/Report/DoubleController.php index ffe0545273..e2593d31b9 100644 --- a/app/Http/Controllers/Report/DoubleController.php +++ b/app/Http/Controllers/Report/DoubleController.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Report; +use Illuminate\Support\Facades\Log; use Carbon\Carbon; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Http\Controllers\Controller; @@ -102,9 +103,9 @@ class DoubleController extends Controller array_multisort($amounts, SORT_ASC, $result); try { - $result = view('reports.double.partials.avg-expenses', compact('result'))->render(); + $result = view('reports.double.partials.avg-expenses', ['result' => $result])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); + Log::error(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); $result = sprintf('Could not render view: %s', $e->getMessage()); throw new FireflyException($e->getMessage(), 0, $e); @@ -152,9 +153,9 @@ class DoubleController extends Controller array_multisort($amounts, SORT_DESC, $result); try { - $result = view('reports.double.partials.avg-income', compact('result'))->render(); + $result = view('reports.double.partials.avg-income', ['result' => $result])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); + Log::error(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); $result = sprintf('Could not render view: %s', $e->getMessage()); throw new FireflyException($e->getMessage(), 0, $e); @@ -168,7 +169,7 @@ class DoubleController extends Controller * * @SuppressWarnings("PHPMD.ExcessiveMethodLength") */ - public function operations(Collection $accounts, Collection $double, Carbon $start, Carbon $end) + public function operations(Collection $accounts, Collection $double, Carbon $start, Carbon $end): Factory|\Illuminate\Contracts\View\View { $withCounterpart = $this->accountRepository->expandWithDoubles($double); $together = $accounts->merge($withCounterpart); @@ -276,7 +277,7 @@ class DoubleController extends Controller } } - return view('reports.double.partials.accounts', compact('sums', 'report')); + return view('reports.double.partials.accounts', ['sums' => $sums, 'report' => $report]); } /** @@ -300,7 +301,7 @@ class DoubleController extends Controller /** * @return Factory|View */ - public function operationsPerAsset(Collection $accounts, Collection $double, Carbon $start, Carbon $end) + public function operationsPerAsset(Collection $accounts, Collection $double, Carbon $start, Carbon $end): Factory|\Illuminate\Contracts\View\View { $withCounterpart = $this->accountRepository->expandWithDoubles($double); $together = $accounts->merge($withCounterpart); @@ -389,7 +390,7 @@ class DoubleController extends Controller } } - return view('reports.double.partials.accounts-per-asset', compact('sums', 'report')); + return view('reports.double.partials.accounts-per-asset', ['sums' => $sums, 'report' => $report]); } /** @@ -429,9 +430,9 @@ class DoubleController extends Controller array_multisort($amounts, SORT_ASC, $result); try { - $result = view('reports.double.partials.top-expenses', compact('result'))->render(); + $result = view('reports.double.partials.top-expenses', ['result' => $result])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); + Log::error(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); $result = sprintf('Could not render view: %s', $e->getMessage()); throw new FireflyException($e->getMessage(), 0, $e); @@ -477,9 +478,9 @@ class DoubleController extends Controller array_multisort($amounts, SORT_DESC, $result); try { - $result = view('reports.double.partials.top-income', compact('result'))->render(); + $result = view('reports.double.partials.top-income', ['result' => $result])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); + Log::error(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); $result = sprintf('Could not render view: %s', $e->getMessage()); throw new FireflyException($e->getMessage(), 0, $e); diff --git a/app/Http/Controllers/Report/OperationsController.php b/app/Http/Controllers/Report/OperationsController.php index e4f10fc574..e8a19a4357 100644 --- a/app/Http/Controllers/Report/OperationsController.php +++ b/app/Http/Controllers/Report/OperationsController.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Report; +use Illuminate\Support\Facades\Log; use Carbon\Carbon; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Http\Controllers\Controller; @@ -78,10 +79,10 @@ class OperationsController extends Controller $type = 'expense-entry'; try { - $result = view('reports.partials.income-expenses', compact('report', 'type'))->render(); + $result = view('reports.partials.income-expenses', ['report' => $report, 'type' => $type])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Could not render reports.partials.income-expense: %s', $e->getMessage())); - app('log')->error($e->getTraceAsString()); + Log::error(sprintf('Could not render reports.partials.income-expense: %s', $e->getMessage())); + Log::error($e->getTraceAsString()); $result = 'Could not render view.'; throw new FireflyException($result, 0, $e); @@ -112,10 +113,10 @@ class OperationsController extends Controller $type = 'income-entry'; try { - $result = view('reports.partials.income-expenses', compact('report', 'type'))->render(); + $result = view('reports.partials.income-expenses', ['report' => $report, 'type' => $type])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Could not render reports.partials.income-expenses: %s', $e->getMessage())); - app('log')->error($e->getTraceAsString()); + Log::error(sprintf('Could not render reports.partials.income-expenses: %s', $e->getMessage())); + Log::error($e->getTraceAsString()); $result = 'Could not render view.'; throw new FireflyException($result, 0, $e); @@ -167,10 +168,10 @@ class OperationsController extends Controller } try { - $result = view('reports.partials.operations', compact('sums'))->render(); + $result = view('reports.partials.operations', ['sums' => $sums])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Could not render reports.partials.operations: %s', $e->getMessage())); - app('log')->error($e->getTraceAsString()); + Log::error(sprintf('Could not render reports.partials.operations: %s', $e->getMessage())); + Log::error($e->getTraceAsString()); $result = 'Could not render view.'; throw new FireflyException($result, 0, $e); diff --git a/app/Http/Controllers/Report/TagController.php b/app/Http/Controllers/Report/TagController.php index 4eaeb46e90..ef3f60cdcb 100644 --- a/app/Http/Controllers/Report/TagController.php +++ b/app/Http/Controllers/Report/TagController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Report; +use Illuminate\Support\Facades\Log; use Carbon\Carbon; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Http\Controllers\Controller; @@ -62,7 +63,7 @@ class TagController extends Controller * * @SuppressWarnings("PHPMD.ExcessiveMethodLength") */ - public function accountPerTag(Collection $accounts, Collection $tags, Carbon $start, Carbon $end) + public function accountPerTag(Collection $accounts, Collection $tags, Carbon $start, Carbon $end): Factory|\Illuminate\Contracts\View\View { $spent = $this->opsRepository->listExpenses($start, $end, $accounts, $tags); $earned = $this->opsRepository->listIncome($start, $end, $accounts, $tags); @@ -148,7 +149,7 @@ class TagController extends Controller } } - return view('reports.tag.partials.account-per-tag', compact('report', 'tags')); + return view('reports.tag.partials.account-per-tag', ['report' => $report, 'tags' => $tags]); } /** @@ -156,7 +157,7 @@ class TagController extends Controller * * @SuppressWarnings("PHPMD.ExcessiveMethodLength") */ - public function accounts(Collection $accounts, Collection $tags, Carbon $start, Carbon $end) + public function accounts(Collection $accounts, Collection $tags, Carbon $start, Carbon $end): Factory|\Illuminate\Contracts\View\View { $spent = $this->opsRepository->listExpenses($start, $end, $accounts, $tags); $earned = $this->opsRepository->listIncome($start, $end, $accounts, $tags); @@ -250,7 +251,7 @@ class TagController extends Controller } } - return view('reports.tag.partials.accounts', compact('sums', 'report')); + return view('reports.tag.partials.accounts', ['sums' => $sums, 'report' => $report]); } /** @@ -292,9 +293,9 @@ class TagController extends Controller array_multisort($amounts, SORT_ASC, $result); try { - $result = view('reports.tag.partials.avg-expenses', compact('result'))->render(); + $result = view('reports.tag.partials.avg-expenses', ['result' => $result])->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); + Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); $result = sprintf('Could not render view: %s', $e->getMessage()); throw new FireflyException($result, 0, $e); @@ -342,9 +343,9 @@ class TagController extends Controller array_multisort($amounts, SORT_DESC, $result); try { - $result = view('reports.tag.partials.avg-income', compact('result'))->render(); + $result = view('reports.tag.partials.avg-income', ['result' => $result])->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); + Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); $result = sprintf('Could not render view: %s', $e->getMessage()); throw new FireflyException($result, 0, $e); @@ -358,7 +359,7 @@ class TagController extends Controller * * @SuppressWarnings("PHPMD.ExcessiveMethodLength") */ - public function tags(Collection $accounts, Collection $tags, Carbon $start, Carbon $end) + public function tags(Collection $accounts, Collection $tags, Carbon $start, Carbon $end): Factory|\Illuminate\Contracts\View\View { $spent = $this->opsRepository->listExpenses($start, $end, $accounts, $tags); $earned = $this->opsRepository->listIncome($start, $end, $accounts, $tags); @@ -450,7 +451,7 @@ class TagController extends Controller } } - return view('reports.tag.partials.tags', compact('sums', 'report')); + return view('reports.tag.partials.tags', ['sums' => $sums, 'report' => $report]); } /** @@ -490,9 +491,9 @@ class TagController extends Controller array_multisort($amounts, SORT_ASC, $result); try { - $result = view('reports.tag.partials.top-expenses', compact('result'))->render(); + $result = view('reports.tag.partials.top-expenses', ['result' => $result])->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); + Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); $result = sprintf('Could not render view: %s', $e->getMessage()); throw new FireflyException($result, 0, $e); @@ -538,9 +539,9 @@ class TagController extends Controller array_multisort($amounts, SORT_DESC, $result); try { - $result = view('reports.tag.partials.top-income', compact('result'))->render(); + $result = view('reports.tag.partials.top-income', ['result' => $result])->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); + Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage())); $result = sprintf('Could not render view: %s', $e->getMessage()); throw new FireflyException($result, 0, $e); diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index 48b37d70ba..b248e31bf7 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers; +use Illuminate\Support\Facades\Log; use Carbon\Carbon; use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Exceptions\FireflyException; @@ -192,11 +193,10 @@ class ReportController extends Controller /** * Show account report. * - * @return string * * @throws FireflyException */ - public function doubleReport(Collection $accounts, Collection $expense, Carbon $start, Carbon $end) + public function doubleReport(Collection $accounts, Collection $expense, Carbon $start, Carbon $end): string { if ($end < $start) { [$start, $end] = [$end, $start]; @@ -223,7 +223,7 @@ class ReportController extends Controller * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function index(AccountRepositoryInterface $repository) + public function index(AccountRepositoryInterface $repository): Factory|\Illuminate\Contracts\View\View { /** @var Carbon $start */ $start = clone session('first', today(config('app.timezone'))); @@ -255,7 +255,7 @@ class ReportController extends Controller $accountList = implode(',', $accounts->pluck('id')->toArray()); $this->repository->cleanupBudgets(); - return view('reports.index', compact('months', 'accounts', 'start', 'accountList', 'groupedAccounts', 'customFiscalYear')); + return view('reports.index', ['months' => $months, 'accounts' => $accounts, 'start' => $start, 'accountList' => $accountList, 'groupedAccounts' => $groupedAccounts, 'customFiscalYear' => $customFiscalYear]); } /** @@ -296,7 +296,7 @@ class ReportController extends Controller $double = implode(',', $request->getDoubleList()->pluck('id')->toArray()); if (0 === $request->getAccountList()->count()) { - app('log')->debug('Account count is zero'); + Log::debug('Account count is zero'); session()->flash('error', (string) trans('firefly.select_at_least_one_account')); return redirect(route('reports.index')); diff --git a/app/Http/Controllers/Rule/CreateController.php b/app/Http/Controllers/Rule/CreateController.php index 5b95005a1b..d1f0809cc3 100644 --- a/app/Http/Controllers/Rule/CreateController.php +++ b/app/Http/Controllers/Rule/CreateController.php @@ -78,7 +78,7 @@ class CreateController extends Controller * * @throws FireflyException */ - public function create(Request $request, ?RuleGroup $ruleGroup = null) + public function create(Request $request, ?RuleGroup $ruleGroup = null): Factory|\Illuminate\Contracts\View\View { $this->createDefaultRuleGroup(); $preFilled = [ @@ -144,7 +144,7 @@ class CreateController extends Controller return view( 'rules.rule.create', - compact('subTitleIcon', 'oldTriggers', 'preFilled', 'oldActions', 'triggerCount', 'actionCount', 'ruleGroup', 'subTitle') + ['subTitleIcon' => $subTitleIcon, 'oldTriggers' => $oldTriggers, 'preFilled' => $preFilled, 'oldActions' => $oldActions, 'triggerCount' => $triggerCount, 'actionCount' => $actionCount, 'ruleGroup' => $ruleGroup, 'subTitle' => $subTitle] ); } @@ -155,7 +155,7 @@ class CreateController extends Controller * * @throws FireflyException */ - public function createFromBill(Request $request, Bill $bill) + public function createFromBill(Request $request, Bill $bill): Factory|\Illuminate\Contracts\View\View { $request->session()->flash('info', (string) trans('firefly.instructions_rule_from_bill', ['name' => e($bill->name)])); @@ -196,16 +196,14 @@ class CreateController extends Controller return view( 'rules.rule.create', - compact('subTitleIcon', 'oldTriggers', 'preFilled', 'oldActions', 'triggerCount', 'actionCount', 'subTitle') + ['subTitleIcon' => $subTitleIcon, 'oldTriggers' => $oldTriggers, 'preFilled' => $preFilled, 'oldActions' => $oldActions, 'triggerCount' => $triggerCount, 'actionCount' => $actionCount, 'subTitle' => $subTitle] ); } /** - * @return Factory|\Illuminate\Contracts\View\View - * * @throws FireflyException */ - public function createFromJournal(Request $request, TransactionJournal $journal) + public function createFromJournal(Request $request, TransactionJournal $journal): Factory|\Illuminate\Contracts\View\View { $request->session()->flash('info', (string) trans('firefly.instructions_rule_from_journal', ['name' => e($journal->description)])); @@ -245,7 +243,7 @@ class CreateController extends Controller return view( 'rules.rule.create', - compact('subTitleIcon', 'oldTriggers', 'preFilled', 'oldActions', 'triggerCount', 'actionCount', 'subTitle') + ['subTitleIcon' => $subTitleIcon, 'oldTriggers' => $oldTriggers, 'preFilled' => $preFilled, 'oldActions' => $oldActions, 'triggerCount' => $triggerCount, 'actionCount' => $actionCount, 'subTitle' => $subTitle] ); } diff --git a/app/Http/Controllers/Rule/DeleteController.php b/app/Http/Controllers/Rule/DeleteController.php index d4c6ceb05d..f9d86b7abe 100644 --- a/app/Http/Controllers/Rule/DeleteController.php +++ b/app/Http/Controllers/Rule/DeleteController.php @@ -63,14 +63,14 @@ class DeleteController extends Controller * * @return Factory|View */ - public function delete(Rule $rule) + public function delete(Rule $rule): Factory|\Illuminate\Contracts\View\View { $subTitle = (string) trans('firefly.delete_rule', ['title' => $rule->title]); // put previous url in session $this->rememberPreviousUrl('rules.delete.url'); - return view('rules.rule.delete', compact('rule', 'subTitle')); + return view('rules.rule.delete', ['rule' => $rule, 'subTitle' => $subTitle]); } /** diff --git a/app/Http/Controllers/Rule/EditController.php b/app/Http/Controllers/Rule/EditController.php index b9295d5487..cdc80c0219 100644 --- a/app/Http/Controllers/Rule/EditController.php +++ b/app/Http/Controllers/Rule/EditController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Rule; +use Illuminate\Support\Facades\Log; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Requests\RuleFormRequest; @@ -76,7 +77,7 @@ class EditController extends Controller * * @throws FireflyException */ - public function edit(Request $request, Rule $rule) + public function edit(Request $request, Rule $rule): Factory|\Illuminate\Contracts\View\View { $triggerCount = 0; $actionCount = 0; @@ -146,7 +147,7 @@ class EditController extends Controller $request->session()->flash('preFilled', $preFilled); - return view('rules.rule.edit', compact('rule', 'subTitle', 'primaryTrigger', 'oldTriggers', 'oldActions', 'triggerCount', 'actionCount')); + return view('rules.rule.edit', ['rule' => $rule, 'subTitle' => $subTitle, 'primaryTrigger' => $primaryTrigger, 'oldTriggers' => $oldTriggers, 'oldActions' => $oldActions, 'triggerCount' => $triggerCount, 'actionCount' => $actionCount]); } /** @@ -180,8 +181,8 @@ class EditController extends Controller )->render(); } catch (Throwable $e) { $message = sprintf('Throwable was thrown in getPreviousTriggers(): %s', $e->getMessage()); - app('log')->debug($message); - app('log')->error($e->getTraceAsString()); + Log::debug($message); + Log::error($e->getTraceAsString()); throw new FireflyException($message, 0, $e); } diff --git a/app/Http/Controllers/Rule/IndexController.php b/app/Http/Controllers/Rule/IndexController.php index 7273a72e56..e95c5c459c 100644 --- a/app/Http/Controllers/Rule/IndexController.php +++ b/app/Http/Controllers/Rule/IndexController.php @@ -68,13 +68,13 @@ class IndexController extends Controller * * @return Factory|View */ - public function index() + public function index(): Factory|\Illuminate\Contracts\View\View { $this->createDefaultRuleGroup(); $this->ruleGroupRepos->resetOrder(); $ruleGroups = $this->ruleGroupRepos->getAllRuleGroupsWithRules(null); - return view('rules.index', compact('ruleGroups')); + return view('rules.index', ['ruleGroups' => $ruleGroups]); } public function moveRule(Request $request, Rule $rule, RuleGroup $ruleGroup): JsonResponse diff --git a/app/Http/Controllers/Rule/SelectController.php b/app/Http/Controllers/Rule/SelectController.php index 458d866378..dc3744ce4a 100644 --- a/app/Http/Controllers/Rule/SelectController.php +++ b/app/Http/Controllers/Rule/SelectController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Rule; +use Illuminate\Support\Facades\Log; use Carbon\Carbon; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Http\Controllers\Controller; @@ -114,7 +115,7 @@ class SelectController extends Controller // does the user have shared accounts? $subTitle = (string)trans('firefly.apply_rule_selection', ['title' => $rule->title]); - return view('rules.rule.select-transactions', compact('rule', 'subTitle')); + return view('rules.rule.select-transactions', ['rule' => $rule, 'subTitle' => $subTitle]); } /** @@ -179,8 +180,8 @@ class SelectController extends Controller try { $view = view('list.journals-array-tiny', ['groups' => $collection])->render(); } catch (Throwable $exception) { - app('log')->error(sprintf('Could not render view in testTriggers(): %s', $exception->getMessage())); - app('log')->error($exception->getTraceAsString()); + Log::error(sprintf('Could not render view in testTriggers(): %s', $exception->getMessage())); + Log::error($exception->getTraceAsString()); $view = sprintf('Could not render list.journals-tiny: %s', $exception->getMessage()); throw new FireflyException($view, 0, $exception); @@ -222,8 +223,8 @@ class SelectController extends Controller $view = view('list.journals-array-tiny', ['groups' => $collection])->render(); } catch (Throwable $exception) { $message = sprintf('Could not render view in testTriggersByRule(): %s', $exception->getMessage()); - app('log')->error($message); - app('log')->error($exception->getTraceAsString()); + Log::error($message); + Log::error($exception->getTraceAsString()); throw new FireflyException($message, 0, $exception); } diff --git a/app/Http/Controllers/RuleGroup/CreateController.php b/app/Http/Controllers/RuleGroup/CreateController.php index c269849308..9f76923ce8 100644 --- a/app/Http/Controllers/RuleGroup/CreateController.php +++ b/app/Http/Controllers/RuleGroup/CreateController.php @@ -64,7 +64,7 @@ class CreateController extends Controller * * @return Factory|View */ - public function create() + public function create(): Factory|\Illuminate\Contracts\View\View { $subTitleIcon = 'fa-clone'; $subTitle = (string) trans('firefly.make_new_rule_group'); @@ -75,7 +75,7 @@ class CreateController extends Controller } session()->forget('rule-groups.create.fromStore'); - return view('rules.rule-group.create', compact('subTitleIcon', 'subTitle')); + return view('rules.rule-group.create', ['subTitleIcon' => $subTitleIcon, 'subTitle' => $subTitle]); } /** diff --git a/app/Http/Controllers/RuleGroup/DeleteController.php b/app/Http/Controllers/RuleGroup/DeleteController.php index 8d7bf2fea7..6782f5e8bb 100644 --- a/app/Http/Controllers/RuleGroup/DeleteController.php +++ b/app/Http/Controllers/RuleGroup/DeleteController.php @@ -65,22 +65,20 @@ class DeleteController extends Controller * * @return Factory|View */ - public function delete(RuleGroup $ruleGroup) + public function delete(RuleGroup $ruleGroup): Factory|\Illuminate\Contracts\View\View { $subTitle = (string) trans('firefly.delete_rule_group', ['title' => $ruleGroup->title]); // put previous url in session $this->rememberPreviousUrl('rule-groups.delete.url'); - return view('rules.rule-group.delete', compact('ruleGroup', 'subTitle')); + return view('rules.rule-group.delete', ['ruleGroup' => $ruleGroup, 'subTitle' => $subTitle]); } /** * Actually destroy the rule group. - * - * @return Redirector|RedirectResponse */ - public function destroy(Request $request, RuleGroup $ruleGroup) + public function destroy(Request $request, RuleGroup $ruleGroup): Redirector|RedirectResponse { $title = $ruleGroup->title; diff --git a/app/Http/Controllers/RuleGroup/EditController.php b/app/Http/Controllers/RuleGroup/EditController.php index ecf18bfa47..877c8ddc97 100644 --- a/app/Http/Controllers/RuleGroup/EditController.php +++ b/app/Http/Controllers/RuleGroup/EditController.php @@ -66,7 +66,7 @@ class EditController extends Controller * * @return Factory|View */ - public function edit(Request $request, RuleGroup $ruleGroup) + public function edit(Request $request, RuleGroup $ruleGroup): Factory|\Illuminate\Contracts\View\View { $subTitle = (string) trans('firefly.edit_rule_group', ['title' => $ruleGroup->title]); @@ -81,7 +81,7 @@ class EditController extends Controller session()->forget('rule-groups.edit.fromUpdate'); session()->flash('preFilled', $preFilled); - return view('rules.rule-group.edit', compact('ruleGroup', 'subTitle')); + return view('rules.rule-group.edit', ['ruleGroup' => $ruleGroup, 'subTitle' => $subTitle]); } /** diff --git a/app/Http/Controllers/RuleGroup/ExecutionController.php b/app/Http/Controllers/RuleGroup/ExecutionController.php index 14ee17209a..3cd97826cc 100644 --- a/app/Http/Controllers/RuleGroup/ExecutionController.php +++ b/app/Http/Controllers/RuleGroup/ExecutionController.php @@ -104,10 +104,10 @@ class ExecutionController extends Controller * * @return Factory|View */ - public function selectTransactions(RuleGroup $ruleGroup) + public function selectTransactions(RuleGroup $ruleGroup): Factory|\Illuminate\Contracts\View\View { $subTitle = (string) trans('firefly.apply_rule_group_selection', ['title' => $ruleGroup->title]); - return view('rules.rule-group.select-transactions', compact('ruleGroup', 'subTitle')); + return view('rules.rule-group.select-transactions', ['ruleGroup' => $ruleGroup, 'subTitle' => $subTitle]); } } diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index 39fa3cea10..67d3762f5d 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers; +use Illuminate\Support\Facades\Log; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Repositories\Rule\RuleRepositoryInterface; use FireflyIII\Support\Search\SearchInterface; @@ -59,7 +60,7 @@ class SearchController extends Controller * * @return Factory|View */ - public function index(Request $request, SearchInterface $searcher) + public function index(Request $request, SearchInterface $searcher): Factory|\Illuminate\Contracts\View\View { // search params: $fullQuery = $request->get('search'); @@ -90,7 +91,7 @@ class SearchController extends Controller $invalidOperators = $searcher->getInvalidOperators(); $subTitle = (string) trans('breadcrumbs.search_result', ['query' => $fullQuery]); - return view('search.index', compact('words', 'excludedWords', 'operators', 'page', 'rule', 'fullQuery', 'subTitle', 'ruleId', 'ruleChanged', 'invalidOperators')); + return view('search.index', ['words' => $words, 'excludedWords' => $excludedWords, 'operators' => $operators, 'page' => $page, 'rule' => $rule, 'fullQuery' => $fullQuery, 'subTitle' => $subTitle, 'ruleId' => $ruleId, 'ruleChanged' => $ruleChanged, 'invalidOperators' => $invalidOperators]); } /** @@ -118,10 +119,10 @@ class SearchController extends Controller $groups->setPath($url); try { - $html = view('search.search', compact('groups', 'hasPages', 'searchTime'))->render(); + $html = view('search.search', ['groups' => $groups, 'hasPages' => $hasPages, 'searchTime' => $searchTime])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Cannot render search.search: %s', $e->getMessage())); - app('log')->error($e->getTraceAsString()); + Log::error(sprintf('Cannot render search.search: %s', $e->getMessage())); + Log::error($e->getTraceAsString()); $html = 'Could not render view.'; throw new FireflyException($html, 0, $e); diff --git a/app/Http/Controllers/System/CronController.php b/app/Http/Controllers/System/CronController.php index 432d0d189b..7667a998b5 100644 --- a/app/Http/Controllers/System/CronController.php +++ b/app/Http/Controllers/System/CronController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\System; +use Illuminate\Support\Facades\Log; use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\Routing\ResponseFactory; use Illuminate\Http\Response; @@ -36,9 +37,9 @@ class CronController /** * @return Application|Response|ResponseFactory */ - public function cron() + public function cron(): ResponseFactory|Response { - app('log')->error('The cron endpoint has moved to GET /api/v1/cron/[token]'); + Log::error('The cron endpoint has moved to GET /api/v1/cron/[token]'); return response('The cron endpoint has moved to GET /api/v1/cron/[token]', 500); } diff --git a/app/Http/Controllers/System/InstallController.php b/app/Http/Controllers/System/InstallController.php index f07f47758b..ff2ee33a22 100644 --- a/app/Http/Controllers/System/InstallController.php +++ b/app/Http/Controllers/System/InstallController.php @@ -51,8 +51,17 @@ class InstallController extends Controller public const string BASEDIR_ERROR = 'Firefly III cannot execute the upgrade commands. It is not allowed to because of an open_basedir restriction.'; public const string FORBIDDEN_ERROR = 'Internal PHP function "proc_close" is disabled for your installation. Auto-migration is not possible.'; public const string OTHER_ERROR = 'An unknown error prevented Firefly III from executing the upgrade commands. Sorry.'; - private string $lastError; - private array $upgradeCommands; + private string $lastError = ''; + // empty on purpose. + private array $upgradeCommands = [ + // there are 5 initial commands + // Check 4 places: InstallController, Docker image, UpgradeDatabase, composer.json + 'migrate' => ['--seed' => true, '--force' => true], + 'generate-keys' => [], // an exception :( + 'firefly-iii:upgrade-database' => [], + 'firefly-iii:set-latest-version' => ['--james-is-cool' => true], + 'firefly-iii:verify-security-alerts' => [], + ]; /** * InstallController constructor. @@ -60,18 +69,6 @@ class InstallController extends Controller public function __construct() { parent::__construct(); - // empty on purpose. - $this->upgradeCommands = [ - // there are 5 initial commands - // Check 4 places: InstallController, Docker image, UpgradeDatabase, composer.json - 'migrate' => ['--seed' => true, '--force' => true], - 'generate-keys' => [], // an exception :( - 'firefly-iii:upgrade-database' => [], - 'firefly-iii:set-latest-version' => ['--james-is-cool' => true], - 'firefly-iii:verify-security-alerts' => [], - ]; - - $this->lastError = ''; } /** @@ -79,7 +76,7 @@ class InstallController extends Controller * * @return Factory|View */ - public function index() + public function index(): Factory|\Illuminate\Contracts\View\View { app('view')->share('FF_VERSION', config('firefly.version')); diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index 53372408ae..8c8e1829a2 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -76,7 +76,7 @@ class TagController extends Controller * * @return Factory|View */ - public function create(Request $request) + public function create(Request $request): Factory|\Illuminate\Contracts\View\View { $subTitle = (string) trans('firefly.new_tag'); $subTitleIcon = 'fa-tag'; @@ -88,7 +88,7 @@ class TagController extends Controller 'latitude' => $hasOldInput ? old('location_latitude') : config('firefly.default_location.latitude'), 'longitude' => $hasOldInput ? old('location_longitude') : config('firefly.default_location.longitude'), 'zoom_level' => $hasOldInput ? old('location_zoom_level') : config('firefly.default_location.zoom_level'), - 'has_location' => $hasOldInput ? 'true' === old('location_has_location') : false, + 'has_location' => $hasOldInput && 'true' === old('location_has_location'), ], ]; @@ -98,7 +98,7 @@ class TagController extends Controller } session()->forget('tags.create.fromStore'); - return view('tags.create', compact('subTitle', 'subTitleIcon', 'locations')); + return view('tags.create', ['subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon, 'locations' => $locations]); } /** @@ -106,14 +106,14 @@ class TagController extends Controller * * @return Factory|View */ - public function delete(Tag $tag) + public function delete(Tag $tag): Factory|\Illuminate\Contracts\View\View { $subTitle = (string) trans('breadcrumbs.delete_tag', ['tag' => $tag->tag]); // put previous url in session $this->rememberPreviousUrl('tags.delete.url'); - return view('tags.delete', compact('tag', 'subTitle')); + return view('tags.delete', ['tag' => $tag, 'subTitle' => $subTitle]); } /** @@ -121,7 +121,7 @@ class TagController extends Controller * * @return Factory|View */ - public function edit(Tag $tag) + public function edit(Tag $tag): Factory|\Illuminate\Contracts\View\View { $subTitle = (string) trans('firefly.edit_tag', ['tag' => $tag->tag]); $subTitleIcon = 'fa-tag'; @@ -146,7 +146,7 @@ class TagController extends Controller } session()->forget('tags.edit.fromUpdate'); - return view('tags.edit', compact('tag', 'subTitle', 'subTitleIcon', 'locations')); + return view('tags.edit', ['tag' => $tag, 'subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon, 'locations' => $locations]); } /** @@ -154,7 +154,7 @@ class TagController extends Controller * * @return Factory|View */ - public function index(TagRepositoryInterface $repository) + public function index(TagRepositoryInterface $repository): Factory|\Illuminate\Contracts\View\View { // start with the oldest tag $first = session('first', today()) ?? today(); @@ -178,7 +178,7 @@ class TagController extends Controller } $count = $repository->count(); - return view('tags.index', compact('tags', 'count')); + return view('tags.index', ['tags' => $tags, 'count' => $count]); } public function massDestroy(Request $request): RedirectResponse @@ -226,7 +226,7 @@ class TagController extends Controller * @throws FireflyException * @throws NotFoundExceptionInterface */ - public function show(Request $request, Tag $tag, ?Carbon $start = null, ?Carbon $end = null) + public function show(Request $request, Tag $tag, ?Carbon $start = null, ?Carbon $end = null): Factory|\Illuminate\Contracts\View\View { // default values: $subTitleIcon = 'fa-tag'; @@ -259,7 +259,7 @@ class TagController extends Controller $groups->setPath($path); $sums = $this->repository->sumsOfTag($tag, $start, $end); - return view('tags.show', compact('tag', 'attachments', 'sums', 'periods', 'subTitle', 'subTitleIcon', 'groups', 'start', 'end', 'location')); + return view('tags.show', ['tag' => $tag, 'attachments' => $attachments, 'sums' => $sums, 'periods' => $periods, 'subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon, 'groups' => $groups, 'start' => $start, 'end' => $end, 'location' => $location]); } /** @@ -270,7 +270,7 @@ class TagController extends Controller * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function showAll(Request $request, Tag $tag) + public function showAll(Request $request, Tag $tag): Factory|\Illuminate\Contracts\View\View { // default values: $subTitleIcon = 'fa-tag'; @@ -294,7 +294,7 @@ class TagController extends Controller $groups->setPath($path); $sums = $this->repository->sumsOfTag($tag, $start, $end); - return view('tags.show', compact('tag', 'attachments', 'sums', 'periods', 'subTitle', 'subTitleIcon', 'groups', 'start', 'end', 'location')); + return view('tags.show', ['tag' => $tag, 'attachments' => $attachments, 'sums' => $sums, 'periods' => $periods, 'subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon, 'groups' => $groups, 'start' => $start, 'end' => $end, 'location' => $location]); } /** @@ -303,10 +303,10 @@ class TagController extends Controller public function store(TagFormRequest $request): RedirectResponse { $data = $request->collectTagData(); - app('log')->debug('Data from request', $data); + Log::debug('Data from request', $data); $result = $this->repository->store($data); - app('log')->debug('Data after storage', $result->toArray()); + Log::debug('Data after storage', $result->toArray()); session()->flash('success', (string) trans('firefly.created_tag', ['tag' => $data['tag']])); app('preferences')->mark(); diff --git a/app/Http/Controllers/Transaction/BulkController.php b/app/Http/Controllers/Transaction/BulkController.php index ab5365b1f4..b0d62692c1 100644 --- a/app/Http/Controllers/Transaction/BulkController.php +++ b/app/Http/Controllers/Transaction/BulkController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Transaction; +use Illuminate\Support\Facades\Log; use FireflyIII\Events\UpdatedTransactionGroup; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Requests\BulkEditJournalRequest; @@ -70,7 +71,7 @@ class BulkController extends Controller * * @return Factory|View */ - public function edit(array $journals) + public function edit(array $journals): Factory|\Illuminate\Contracts\View\View { $subTitle = (string) trans('firefly.mass_bulk_journals'); @@ -83,7 +84,7 @@ class BulkController extends Controller $budgetRepos = app(BudgetRepositoryInterface::class); $budgetList = app('expandedform')->makeSelectListWithEmpty($budgetRepos->getActiveBudgets()); - return view('transactions.bulk.edit', compact('journals', 'subTitle', 'budgetList')); + return view('transactions.bulk.edit', ['journals' => $journals, 'subTitle' => $subTitle, 'budgetList' => $budgetList]); } /** @@ -91,7 +92,7 @@ class BulkController extends Controller * * @return Application|Redirector|RedirectResponse */ - public function update(BulkEditJournalRequest $request) + public function update(BulkEditJournalRequest $request): Redirector|RedirectResponse { $journalIds = $request->get('journals'); $journalIds = is_array($journalIds) ? $journalIds : []; @@ -130,10 +131,10 @@ class BulkController extends Controller private function updateJournalBudget(TransactionJournal $journal, bool $ignoreUpdate, int $budgetId): bool { - if (true === $ignoreUpdate) { + if ($ignoreUpdate) { return false; } - app('log')->debug(sprintf('Set budget to %d', $budgetId)); + Log::debug(sprintf('Set budget to %d', $budgetId)); $this->repository->updateBudget($journal, $budgetId); return true; @@ -142,7 +143,7 @@ class BulkController extends Controller private function updateJournalTags(TransactionJournal $journal, string $action, array $tags): bool { if ('do_replace' === $action) { - app('log')->debug(sprintf('Set tags to %s', implode(',', $tags))); + Log::debug(sprintf('Set tags to %s', implode(',', $tags))); $this->repository->updateTags($journal, $tags); } if ('do_append' === $action) { @@ -156,10 +157,10 @@ class BulkController extends Controller private function updateJournalCategory(TransactionJournal $journal, bool $ignoreUpdate, string $category): bool { - if (true === $ignoreUpdate) { + if ($ignoreUpdate) { return false; } - app('log')->debug(sprintf('Set budget to %s', $category)); + Log::debug(sprintf('Set budget to %s', $category)); $this->repository->updateCategory($journal, $category); return true; diff --git a/app/Http/Controllers/Transaction/ConvertController.php b/app/Http/Controllers/Transaction/ConvertController.php index 5b26839211..2861cfda36 100644 --- a/app/Http/Controllers/Transaction/ConvertController.php +++ b/app/Http/Controllers/Transaction/ConvertController.php @@ -87,7 +87,7 @@ class ConvertController extends Controller * * @throws Exception */ - public function index(TransactionType $destinationType, TransactionGroup $group) + public function index(TransactionType $destinationType, TransactionGroup $group): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View { if (!$this->isEditableGroup($group)) { return $this->redirectGroupToAccount($group); @@ -117,7 +117,7 @@ class ConvertController extends Controller ]; if ($sourceType->type === $destinationType->type) { // cannot convert to its own type. - app('log')->debug('This is already a transaction of the expected type..'); + Log::debug('This is already a transaction of the expected type..'); session()->flash('info', (string) trans('firefly.convert_is_already_type_'.$destinationType->type)); return redirect(route('transactions.show', [$group->id])); @@ -125,20 +125,7 @@ class ConvertController extends Controller return view( 'transactions.convert', - compact( - 'sourceType', - 'destinationType', - 'group', - 'groupTitle', - 'groupArray', - 'assets', - 'validDepositSources', - 'liabilities', - 'validWithdrawalDests', - 'preFilled', - 'subTitle', - 'subTitleIcon' - ) + ['sourceType' => $sourceType, 'destinationType' => $destinationType, 'group' => $group, 'groupTitle' => $groupTitle, 'groupArray' => $groupArray, 'assets' => $assets, 'validDepositSources' => $validDepositSources, 'liabilities' => $liabilities, 'validWithdrawalDests' => $validWithdrawalDests, 'preFilled' => $preFilled, 'subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon] ); } diff --git a/app/Http/Controllers/Transaction/CreateController.php b/app/Http/Controllers/Transaction/CreateController.php index 054a94ec23..8f7b521c31 100644 --- a/app/Http/Controllers/Transaction/CreateController.php +++ b/app/Http/Controllers/Transaction/CreateController.php @@ -100,13 +100,12 @@ class CreateController extends Controller /** * Create a new transaction group. * - * @return Factory|View * * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface * @throws UrlException */ - public function create(?string $objectType) + public function create(?string $objectType): Factory|View { Preferences::mark(); @@ -151,6 +150,6 @@ class CreateController extends Controller session()->put('preFilled', $preFilled); - return view('transactions.create', compact('subTitleIcon', 'cash', 'longitude', 'latitude', 'zoomLevel', 'objectType', 'optionalDateFields', 'subTitle', 'previousUrl', 'optionalFields', 'preFilled', 'allowedOpposingTypes', 'accountToTypes', 'sourceId', 'destinationId')); + return view('transactions.create', ['subTitleIcon' => $subTitleIcon, 'cash' => $cash, 'longitude' => $longitude, 'latitude' => $latitude, 'zoomLevel' => $zoomLevel, 'objectType' => $objectType, 'optionalDateFields' => $optionalDateFields, 'subTitle' => $subTitle, 'previousUrl' => $previousUrl, 'optionalFields' => $optionalFields, 'preFilled' => $preFilled, 'allowedOpposingTypes' => $allowedOpposingTypes, 'accountToTypes' => $accountToTypes, 'sourceId' => $sourceId, 'destinationId' => $destinationId]); } } diff --git a/app/Http/Controllers/Transaction/DeleteController.php b/app/Http/Controllers/Transaction/DeleteController.php index 89785805a9..990a1fd753 100644 --- a/app/Http/Controllers/Transaction/DeleteController.php +++ b/app/Http/Controllers/Transaction/DeleteController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Transaction; +use Illuminate\Support\Facades\Log; use FireflyIII\Events\UpdatedAccount; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Models\Account; @@ -66,16 +67,14 @@ class DeleteController extends Controller /** * Shows the form that allows a user to delete a transaction journal. - * - * @return Factory|Redirector|RedirectResponse|View */ - public function delete(TransactionGroup $group) + public function delete(TransactionGroup $group): Redirector|RedirectResponse|Factory|View { if (!$this->isEditableGroup($group)) { return $this->redirectGroupToAccount($group); } - app('log')->debug(sprintf('Start of delete view for group #%d', $group->id)); + Log::debug(sprintf('Start of delete view for group #%d', $group->id)); $journal = $group->transactionJournals->first(); if (null === $journal) { @@ -85,10 +84,10 @@ class DeleteController extends Controller $subTitle = (string) trans('firefly.delete_'.$objectType, ['description' => $group->title ?? $journal->description]); $previous = app('steam')->getSafePreviousUrl(); // put previous url in session - app('log')->debug('Will try to remember previous URL'); + Log::debug('Will try to remember previous URL'); $this->rememberPreviousUrl('transactions.delete.url'); - return view('transactions.delete', compact('group', 'journal', 'subTitle', 'objectType', 'previous')); + return view('transactions.delete', ['group' => $group, 'journal' => $journal, 'subTitle' => $subTitle, 'objectType' => $objectType, 'previous' => $previous]); } /** @@ -96,7 +95,7 @@ class DeleteController extends Controller */ public function destroy(TransactionGroup $group): Redirector|RedirectResponse { - app('log')->debug(sprintf('Now in %s(#%d).', __METHOD__, $group->id)); + Log::debug(sprintf('Now in %s(#%d).', __METHOD__, $group->id)); if (!$this->isEditableGroup($group)) { return $this->redirectGroupToAccount($group); } @@ -127,7 +126,7 @@ class DeleteController extends Controller /** @var Account $account */ foreach ($accounts as $account) { - app('log')->debug(sprintf('Now going to trigger updated account event for account #%d', $account->id)); + Log::debug(sprintf('Now going to trigger updated account event for account #%d', $account->id)); event(new UpdatedAccount($account)); } app('preferences')->mark(); diff --git a/app/Http/Controllers/Transaction/EditController.php b/app/Http/Controllers/Transaction/EditController.php index d349a9e18c..2b26986c01 100644 --- a/app/Http/Controllers/Transaction/EditController.php +++ b/app/Http/Controllers/Transaction/EditController.php @@ -74,7 +74,7 @@ class EditController extends Controller * @throws NotFoundExceptionInterface * @throws UrlException */ - public function edit(TransactionGroup $transactionGroup) + public function edit(TransactionGroup $transactionGroup): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View { app('preferences')->mark(); @@ -120,7 +120,7 @@ class EditController extends Controller $latitude = config('firefly.default_location.latitude'); $zoomLevel = config('firefly.default_location.zoom_level'); - return view('transactions.edit', compact('cash', 'allowedSourceDests', 'expectedSourceTypes', 'optionalDateFields', 'longitude', 'latitude', 'zoomLevel', 'optionalFields', 'subTitle', 'subTitleIcon', 'transactionGroup', 'allowedOpposingTypes', 'accountToTypes', 'previousUrl')); + return view('transactions.edit', ['cash' => $cash, 'allowedSourceDests' => $allowedSourceDests, 'expectedSourceTypes' => $expectedSourceTypes, 'optionalDateFields' => $optionalDateFields, 'longitude' => $longitude, 'latitude' => $latitude, 'zoomLevel' => $zoomLevel, 'optionalFields' => $optionalFields, 'subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon, 'transactionGroup' => $transactionGroup, 'allowedOpposingTypes' => $allowedOpposingTypes, 'accountToTypes' => $accountToTypes, 'previousUrl' => $previousUrl]); } public function unreconcile(TransactionJournal $journal): JsonResponse diff --git a/app/Http/Controllers/Transaction/IndexController.php b/app/Http/Controllers/Transaction/IndexController.php index efb29a1236..8c4d3a5db3 100644 --- a/app/Http/Controllers/Transaction/IndexController.php +++ b/app/Http/Controllers/Transaction/IndexController.php @@ -75,7 +75,7 @@ class IndexController extends Controller * @throws FireflyException * @throws NotFoundExceptionInterface */ - public function index(Request $request, string $objectType, ?Carbon $start = null, ?Carbon $end = null) + public function index(Request $request, string $objectType, ?Carbon $start = null, ?Carbon $end = null): Factory|\Illuminate\Contracts\View\View { if ('transfers' === $objectType) { $objectType = 'transfer'; @@ -121,7 +121,7 @@ class IndexController extends Controller $groups = $collector->getPaginatedGroups(); $groups->setPath($path); - return view('transactions.index', compact('subTitle', 'objectType', 'subTitleIcon', 'groups', 'periods', 'start', 'end')); + return view('transactions.index', ['subTitle' => $subTitle, 'objectType' => $objectType, 'subTitleIcon' => $subTitleIcon, 'groups' => $groups, 'periods' => $periods, 'start' => $start, 'end' => $end]); } /** @@ -132,7 +132,7 @@ class IndexController extends Controller * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function indexAll(Request $request, string $objectType) + public function indexAll(Request $request, string $objectType): Factory|\Illuminate\Contracts\View\View { $subTitleIcon = config('firefly.transactionIconsByType.'.$objectType); $types = config('firefly.transactionTypesByType.'.$objectType); @@ -160,6 +160,6 @@ class IndexController extends Controller $groups = $collector->getPaginatedGroups(); $groups->setPath($path); - return view('transactions.index', compact('subTitle', 'objectType', 'subTitleIcon', 'groups', 'start', 'end')); + return view('transactions.index', ['subTitle' => $subTitle, 'objectType' => $objectType, 'subTitleIcon' => $subTitleIcon, 'groups' => $groups, 'start' => $start, 'end' => $end]); } } diff --git a/app/Http/Controllers/Transaction/LinkController.php b/app/Http/Controllers/Transaction/LinkController.php index d06bc0c089..e927ff9754 100644 --- a/app/Http/Controllers/Transaction/LinkController.php +++ b/app/Http/Controllers/Transaction/LinkController.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Transaction; +use Illuminate\Support\Facades\Log; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Requests\JournalLinkRequest; use FireflyIII\Models\TransactionJournal; @@ -68,21 +69,19 @@ class LinkController extends Controller * * @return Factory|View */ - public function delete(TransactionJournalLink $link) + public function delete(TransactionJournalLink $link): Factory|\Illuminate\Contracts\View\View { $subTitleIcon = 'fa-link'; $subTitle = (string) trans('breadcrumbs.delete_journal_link'); $this->rememberPreviousUrl('journal_links.delete.url'); - return view('transactions.links.delete', compact('link', 'subTitle', 'subTitleIcon')); + return view('transactions.links.delete', ['link' => $link, 'subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon]); } /** * Actually destroy it. - * - * @return Redirector|RedirectResponse */ - public function destroy(TransactionJournalLink $link) + public function destroy(TransactionJournalLink $link): Redirector|RedirectResponse { $this->repository->destroyLink($link); @@ -95,23 +94,21 @@ class LinkController extends Controller /** * @return Factory|View */ - public function modal(TransactionJournal $journal) + public function modal(TransactionJournal $journal): Factory|\Illuminate\Contracts\View\View { $linkTypes = $this->repository->get(); - return view('transactions.links.modal', compact('journal', 'linkTypes')); + return view('transactions.links.modal', ['journal' => $journal, 'linkTypes' => $linkTypes]); } /** * Store a new link. - * - * @return Redirector|RedirectResponse */ - public function store(JournalLinkRequest $request, TransactionJournal $journal) + public function store(JournalLinkRequest $request, TransactionJournal $journal): Redirector|RedirectResponse { $linkInfo = $request->getLinkInfo(); - app('log')->debug('We are here (store)'); + Log::debug('We are here (store)'); $other = $this->journalRepository->find($linkInfo['transaction_journal_id']); if (!$other instanceof TransactionJournal) { session()->flash('error', (string) trans('firefly.invalid_link_selection')); @@ -132,7 +129,7 @@ class LinkController extends Controller return redirect(route('transactions.show', [$journal->transaction_group_id])); } - app('log')->debug(sprintf('Journal is %d, opposing is %d', $journal->id, $other->id)); + Log::debug(sprintf('Journal is %d, opposing is %d', $journal->id, $other->id)); $this->repository->storeLink($linkInfo, $other, $journal); session()->flash('success', (string) trans('firefly.journals_linked')); @@ -141,10 +138,8 @@ class LinkController extends Controller /** * Switch link from A <> B to B <> A. - * - * @return Redirector|RedirectResponse */ - public function switchLink(Request $request) + public function switchLink(Request $request): Redirector|RedirectResponse { $linkId = (int) $request->get('id'); $this->repository->switchLinkById($linkId); diff --git a/app/Http/Controllers/Transaction/MassController.php b/app/Http/Controllers/Transaction/MassController.php index 7fde459a35..b0a552097a 100644 --- a/app/Http/Controllers/Transaction/MassController.php +++ b/app/Http/Controllers/Transaction/MassController.php @@ -78,7 +78,7 @@ class MassController extends Controller // put previous url in session $this->rememberPreviousUrl('transactions.mass-delete.url'); - return view('transactions.mass.delete', compact('journals', 'subTitle')); + return view('transactions.mass.delete', ['journals' => $journals, 'subTitle' => $subTitle]); } /** @@ -86,28 +86,28 @@ class MassController extends Controller * * @return Application|Redirector|RedirectResponse */ - public function destroy(MassDeleteJournalRequest $request) + public function destroy(MassDeleteJournalRequest $request): Redirector|RedirectResponse { - app('log')->debug(sprintf('Now in %s', __METHOD__)); + Log::debug(sprintf('Now in %s', __METHOD__)); $ids = $request->get('confirm_mass_delete'); $count = 0; if (is_array($ids)) { - app('log')->debug('Array of IDs', $ids); + Log::debug('Array of IDs', $ids); /** @var string $journalId */ foreach ($ids as $journalId) { - app('log')->debug(sprintf('Searching for ID #%d', $journalId)); + Log::debug(sprintf('Searching for ID #%d', $journalId)); /** @var null|TransactionJournal $journal */ $journal = $this->repository->find((int) $journalId); if (null !== $journal && (int) $journalId === $journal->id) { $this->repository->destroyJournal($journal); ++$count; - app('log')->debug(sprintf('Deleted transaction journal #%d', $journalId)); + Log::debug(sprintf('Deleted transaction journal #%d', $journalId)); continue; } - app('log')->debug(sprintf('Could not find transaction journal #%d', $journalId)); + Log::debug(sprintf('Could not find transaction journal #%d', $journalId)); } } app('preferences')->mark(); @@ -148,17 +148,16 @@ class MassController extends Controller $this->rememberPreviousUrl('transactions.mass-edit.url'); - return view('transactions.mass.edit', compact('journals', 'subTitle', 'withdrawalSources', 'depositDestinations', 'budgets')); + return view('transactions.mass.edit', ['journals' => $journals, 'subTitle' => $subTitle, 'withdrawalSources' => $withdrawalSources, 'depositDestinations' => $depositDestinations, 'budgets' => $budgets]); } /** * Mass update of journals. * - * @return Redirector|RedirectResponse * * @throws FireflyException */ - public function update(MassEditJournalRequest $request) + public function update(MassEditJournalRequest $request): Redirector|RedirectResponse { $journalIds = $request->get('journals'); if (!is_array($journalIds)) { @@ -211,7 +210,7 @@ class MassController extends Controller 'amount' => $this->getStringFromRequest($request, $journal->id, 'amount'), 'foreign_amount' => $this->getStringFromRequest($request, $journal->id, 'foreign_amount'), ]; - app('log')->debug(sprintf('Will update journal #%d with data.', $journal->id), $data); + Log::debug(sprintf('Will update journal #%d with data.', $journal->id), $data); // call service to update. $service->setData($data); diff --git a/app/Http/Controllers/Transaction/ShowController.php b/app/Http/Controllers/Transaction/ShowController.php index 7c2fff6105..fe77236857 100644 --- a/app/Http/Controllers/Transaction/ShowController.php +++ b/app/Http/Controllers/Transaction/ShowController.php @@ -82,7 +82,7 @@ class ShowController extends Controller * * @throws FireflyException */ - public function show(TransactionGroup $transactionGroup) + public function show(TransactionGroup $transactionGroup): Factory|\Illuminate\Contracts\View\View { /** @var User $admin */ $admin = auth()->user(); @@ -146,7 +146,7 @@ class ShowController extends Controller $attachments = $this->repository->getAttachments($transactionGroup); $links = $this->repository->getLinks($transactionGroup); - return view('transactions.show', compact('transactionGroup', 'amounts', 'first', 'type', 'logEntries', 'groupLogEntries', 'subTitle', 'splits', 'selectedGroup', 'groupArray', 'events', 'attachments', 'links', 'accounts')); + return view('transactions.show', ['transactionGroup' => $transactionGroup, 'amounts' => $amounts, 'first' => $first, 'type' => $type, 'logEntries' => $logEntries, 'groupLogEntries' => $groupLogEntries, 'subTitle' => $subTitle, 'splits' => $splits, 'selectedGroup' => $selectedGroup, 'groupArray' => $groupArray, 'events' => $events, 'attachments' => $attachments, 'links' => $links, 'accounts' => $accounts]); } private function getAmounts(array $group): array diff --git a/app/Http/Controllers/TransactionCurrency/CreateController.php b/app/Http/Controllers/TransactionCurrency/CreateController.php index 89febb82b5..c679dd16b8 100644 --- a/app/Http/Controllers/TransactionCurrency/CreateController.php +++ b/app/Http/Controllers/TransactionCurrency/CreateController.php @@ -70,7 +70,7 @@ class CreateController extends Controller * * @return Factory|Redirector|RedirectResponse|View */ - public function create(Request $request) + public function create(Request $request): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View { /** @var User $user */ $user = auth()->user(); @@ -91,7 +91,7 @@ class CreateController extends Controller Log::channel('audit')->info('Create new currency.'); - return view('currencies.create', compact('subTitleIcon', 'subTitle')); + return view('currencies.create', ['subTitleIcon' => $subTitleIcon, 'subTitle' => $subTitle]); } /** @@ -105,7 +105,7 @@ class CreateController extends Controller $user = auth()->user(); $data = $request->getCurrencyData(); if (!$this->userRepository->hasRole($user, 'owner')) { - app('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')->warning('Tried to create (POST) currency without admin rights.', $data); return redirect($this->getPreviousUrl('currencies.create.url'))->withInput(); @@ -116,7 +116,7 @@ class CreateController extends Controller try { $currency = $this->repository->store($data); } catch (FireflyException $e) { - app('log')->error($e->getMessage()); + Log::error($e->getMessage()); Log::channel('audit')->warning('Could not store (POST) currency without admin rights.', $data); $request->session()->flash('error', (string) trans('firefly.could_not_store_currency')); $currency = null; diff --git a/app/Http/Controllers/TransactionCurrency/DeleteController.php b/app/Http/Controllers/TransactionCurrency/DeleteController.php index 7a2348cdff..853242ea98 100644 --- a/app/Http/Controllers/TransactionCurrency/DeleteController.php +++ b/app/Http/Controllers/TransactionCurrency/DeleteController.php @@ -71,7 +71,7 @@ class DeleteController extends Controller * * @throws FireflyException */ - public function delete(Request $request, TransactionCurrency $currency) + public function delete(Request $request, TransactionCurrency $currency): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View { /** @var User $user */ $user = auth()->user(); @@ -96,17 +96,16 @@ class DeleteController extends Controller $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')); + return view('currencies.delete', ['currency' => $currency, 'subTitle' => $subTitle]); } /** * Destroys a currency. * - * @return Redirector|RedirectResponse * * @throws FireflyException */ - public function destroy(Request $request, TransactionCurrency $currency) + public function destroy(Request $request, TransactionCurrency $currency): Redirector|RedirectResponse { /** @var User $user */ $user = auth()->user(); diff --git a/app/Http/Controllers/TransactionCurrency/EditController.php b/app/Http/Controllers/TransactionCurrency/EditController.php index d079b5ec8e..6bd0732c30 100644 --- a/app/Http/Controllers/TransactionCurrency/EditController.php +++ b/app/Http/Controllers/TransactionCurrency/EditController.php @@ -67,7 +67,7 @@ class EditController extends Controller * * @return Factory|Redirector|RedirectResponse|View */ - public function edit(Request $request, TransactionCurrency $currency) + public function edit(Request $request, TransactionCurrency $currency): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View { /** @var User $user */ $user = auth()->user(); @@ -101,17 +101,16 @@ class EditController extends Controller } $request->session()->forget('currencies.edit.fromUpdate'); - return view('currencies.edit', compact('currency', 'subTitle', 'subTitleIcon')); + return view('currencies.edit', ['currency' => $currency, 'subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon]); } /** * Updates a currency. * - * @return Redirector|RedirectResponse * * @throws FireflyException */ - public function update(CurrencyFormRequest $request, TransactionCurrency $currency) + public function update(CurrencyFormRequest $request, TransactionCurrency $currency): Redirector|RedirectResponse { /** @var User $user */ $user = auth()->user(); diff --git a/app/Http/Controllers/TransactionCurrency/IndexController.php b/app/Http/Controllers/TransactionCurrency/IndexController.php index a24f1123d2..fbaabe16ab 100644 --- a/app/Http/Controllers/TransactionCurrency/IndexController.php +++ b/app/Http/Controllers/TransactionCurrency/IndexController.php @@ -68,7 +68,7 @@ class IndexController extends Controller * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function index(Request $request) + public function index(Request $request): Factory|\Illuminate\Contracts\View\View { /** @var User $user */ $user = auth()->user(); @@ -78,7 +78,7 @@ class IndexController extends Controller // order so default and enabled are on top: $collection = $collection->sortBy( - static function (TransactionCurrency $currency) { + static function (TransactionCurrency $currency): string { $primary = true === $currency->userGroupNative ? 0 : 1; $enabled = true === $currency->userGroupEnabled ? 0 : 1; @@ -96,6 +96,6 @@ class IndexController extends Controller $isOwner = false; } - return view('currencies.index', compact('currencies', 'isOwner')); + return view('currencies.index', ['currencies' => $currencies, 'isOwner' => $isOwner]); } } diff --git a/app/Http/Controllers/UserGroup/CreateController.php b/app/Http/Controllers/UserGroup/CreateController.php index 88ab1ec074..8ec1487e8c 100644 --- a/app/Http/Controllers/UserGroup/CreateController.php +++ b/app/Http/Controllers/UserGroup/CreateController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\UserGroup; +use Illuminate\Support\Facades\Log; use FireflyIII\Http\Controllers\Controller; use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\View; @@ -39,10 +40,10 @@ class CreateController extends Controller $title = (string) trans('firefly.administrations_page_title'); $subTitle = (string) trans('firefly.administrations_page_create_sub_title'); $mainTitleIcon = 'fa-book'; - app('log')->debug(sprintf('Now at %s', __METHOD__)); + Log::debug(sprintf('Now at %s', __METHOD__)); return view('administrations.create') // @phpstan-ignore-line - ->with(compact('title', 'subTitle', 'mainTitleIcon')) + ->with(['title' => $title, 'subTitle' => $subTitle, 'mainTitleIcon' => $mainTitleIcon]) ; } } diff --git a/app/Http/Controllers/UserGroup/EditController.php b/app/Http/Controllers/UserGroup/EditController.php index c8d68e991d..a8b7c8a2b2 100644 --- a/app/Http/Controllers/UserGroup/EditController.php +++ b/app/Http/Controllers/UserGroup/EditController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\UserGroup; +use Illuminate\Support\Facades\Log; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Models\UserGroup; use Illuminate\Contracts\View\Factory; @@ -40,8 +41,8 @@ class EditController extends Controller $title = (string) trans('firefly.administrations_page_title'); $subTitle = (string) trans('firefly.administrations_page_edit_sub_title', ['title' => $userGroup->title]); $mainTitleIcon = 'fa-book'; - app('log')->debug(sprintf('Now at %s', __METHOD__)); + Log::debug(sprintf('Now at %s', __METHOD__)); - return view('administrations.edit')->with(compact('title', 'subTitle', 'mainTitleIcon')); + return view('administrations.edit')->with(['title' => $title, 'subTitle' => $subTitle, 'mainTitleIcon' => $mainTitleIcon]); } } diff --git a/app/Http/Controllers/UserGroup/IndexController.php b/app/Http/Controllers/UserGroup/IndexController.php index 41c05ad8b1..199400babd 100644 --- a/app/Http/Controllers/UserGroup/IndexController.php +++ b/app/Http/Controllers/UserGroup/IndexController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\UserGroup; +use Illuminate\Support\Facades\Log; use FireflyIII\Http\Controllers\Controller; use Illuminate\Contracts\View\Factory; use Illuminate\Http\Request; @@ -41,8 +42,8 @@ class IndexController extends Controller $title = (string) trans('firefly.administrations_page_title'); $subTitle = (string) trans('firefly.administrations_page_sub_title'); $mainTitleIcon = 'fa-book'; - app('log')->debug(sprintf('Now at %s', __METHOD__)); + Log::debug(sprintf('Now at %s', __METHOD__)); - return view('administrations.index')->with(compact('title', 'subTitle', 'mainTitleIcon')); + return view('administrations.index')->with(['title' => $title, 'subTitle' => $subTitle, 'mainTitleIcon' => $mainTitleIcon]); } } diff --git a/app/Http/Controllers/Webhooks/CreateController.php b/app/Http/Controllers/Webhooks/CreateController.php index 70ac3cbd35..6d84d4bbd1 100644 --- a/app/Http/Controllers/Webhooks/CreateController.php +++ b/app/Http/Controllers/Webhooks/CreateController.php @@ -57,7 +57,7 @@ class CreateController extends Controller * * @return Factory|View */ - public function index() + public function index(): Factory|\Illuminate\Contracts\View\View { if (false === config('firefly.allow_webhooks')) { Log::channel('audit')->warning('User visits webhook create page, but webhooks are DISABLED.'); @@ -67,6 +67,6 @@ class CreateController extends Controller Log::channel('audit')->info('User visits webhook create page.'); $previousUrl = $this->rememberPreviousUrl('webhooks.create.url'); - return view('webhooks.create', compact('previousUrl')); + return view('webhooks.create', ['previousUrl' => $previousUrl]); } } diff --git a/app/Http/Controllers/Webhooks/DeleteController.php b/app/Http/Controllers/Webhooks/DeleteController.php index 4fd33895d1..472a4826d5 100644 --- a/app/Http/Controllers/Webhooks/DeleteController.php +++ b/app/Http/Controllers/Webhooks/DeleteController.php @@ -62,7 +62,7 @@ class DeleteController extends Controller * * @return Application|Factory|View */ - public function index(Webhook $webhook) + public function index(Webhook $webhook): Factory|View { if (false === config('firefly.allow_webhooks')) { Log::channel('audit')->warning('User visits webhook delete page, but webhooks are DISABLED.'); @@ -73,6 +73,6 @@ class DeleteController extends Controller $subTitle = (string) trans('firefly.delete_webhook', ['title' => $webhook->title]); $this->rememberPreviousUrl('webhooks.delete.url'); - return view('webhooks.delete', compact('webhook', 'subTitle')); + return view('webhooks.delete', ['webhook' => $webhook, 'subTitle' => $subTitle]); } } diff --git a/app/Http/Controllers/Webhooks/EditController.php b/app/Http/Controllers/Webhooks/EditController.php index 7ea2b6c63b..fd6c8e377d 100644 --- a/app/Http/Controllers/Webhooks/EditController.php +++ b/app/Http/Controllers/Webhooks/EditController.php @@ -61,7 +61,7 @@ class EditController extends Controller * * @return Application|Factory|View */ - public function index(Webhook $webhook) + public function index(Webhook $webhook): Factory|View { if (false === config('firefly.allow_webhooks')) { Log::channel('audit')->warning('User visits webhook edit page, but webhooks are DISABLED.'); @@ -72,6 +72,6 @@ class EditController extends Controller $subTitle = (string) trans('firefly.edit_webhook', ['title' => $webhook->title]); $this->rememberPreviousUrl('webhooks.edit.url'); - return view('webhooks.edit', compact('webhook', 'subTitle')); + return view('webhooks.edit', ['webhook' => $webhook, 'subTitle' => $subTitle]); } } diff --git a/app/Http/Controllers/Webhooks/IndexController.php b/app/Http/Controllers/Webhooks/IndexController.php index a3ca4790c2..14ae4b279b 100644 --- a/app/Http/Controllers/Webhooks/IndexController.php +++ b/app/Http/Controllers/Webhooks/IndexController.php @@ -53,7 +53,7 @@ class IndexController extends Controller /** * @return Factory|View */ - public function index() + public function index(): Factory|\Illuminate\Contracts\View\View { if (false === config('firefly.allow_webhooks')) { Log::channel('audit')->warning('User visits webhook index page, but webhooks are DISABLED.'); diff --git a/app/Http/Controllers/Webhooks/ShowController.php b/app/Http/Controllers/Webhooks/ShowController.php index 37e0e03003..051f6651ea 100644 --- a/app/Http/Controllers/Webhooks/ShowController.php +++ b/app/Http/Controllers/Webhooks/ShowController.php @@ -61,7 +61,7 @@ class ShowController extends Controller * * @return Application|Factory|View */ - public function index(Webhook $webhook) + public function index(Webhook $webhook): Factory|View { if (false === config('firefly.allow_webhooks')) { Log::channel('audit')->warning(sprintf('User visits webhook #%d page, but webhooks are DISABLED.', $webhook->id)); @@ -71,6 +71,6 @@ class ShowController extends Controller Log::channel('audit')->info(sprintf('User visits webhook #%d page.', $webhook->id)); $subTitle = (string) trans('firefly.show_webhook', ['title' => $webhook->title]); - return view('webhooks.show', compact('webhook', 'subTitle')); + return view('webhooks.show', ['webhook' => $webhook, 'subTitle' => $subTitle]); } } diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index a0319eb8cd..7f920a3e23 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Middleware; +use Illuminate\Support\Facades\Log; use Closure; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\Handler; @@ -126,22 +127,20 @@ class Authenticate private function validateBlockedUser(?User $user, array $guards): void { if (!$user instanceof User) { - app('log')->warning('User is null, throw exception?'); + Log::warning('User is null, throw exception?'); } - if ($user instanceof User) { - // app('log')->debug(get_class($user)); - if (1 === (int) $user->blocked) { - $message = (string) trans('firefly.block_account_logout'); - if ('email_changed' === $user->blocked_code) { - $message = (string) trans('firefly.email_changed_logout'); - } - app('log')->warning('User is blocked, cannot use authentication method.'); - app('session')->flash('logoutMessage', $message); - // @noinspection PhpUndefinedMethodInspection - $this->auth->logout(); // @phpstan-ignore-line (thinks function is undefined) - - throw new AuthenticationException('Blocked account.', $guards); + // \Illuminate\Support\Facades\Log::debug(get_class($user)); + if ($user instanceof User && 1 === (int) $user->blocked) { + $message = (string) trans('firefly.block_account_logout'); + if ('email_changed' === $user->blocked_code) { + $message = (string) trans('firefly.email_changed_logout'); } + Log::warning('User is blocked, cannot use authentication method.'); + app('session')->flash('logoutMessage', $message); + // @noinspection PhpUndefinedMethodInspection + $this->auth->logout(); + // @phpstan-ignore-line (thinks function is undefined) + throw new AuthenticationException('Blocked account.', $guards); } } } diff --git a/app/Http/Middleware/Binder.php b/app/Http/Middleware/Binder.php index 7b03830ba5..533cf46d44 100644 --- a/app/Http/Middleware/Binder.php +++ b/app/Http/Middleware/Binder.php @@ -34,27 +34,20 @@ use Illuminate\Routing\Route; */ class Binder { - /** - * The authentication factory instance. - * - * @var Auth - */ - protected $auth; - /** * The binders. - * - * @var array */ - protected $binders = []; + protected array $binders; /** * Binder constructor. */ - public function __construct(Auth $auth) + public function __construct(/** + * The authentication factory instance. + */ + protected Auth $auth) { $this->binders = Domain::getBindables(); - $this->auth = $auth; } /** diff --git a/app/Http/Middleware/IsDemoUser.php b/app/Http/Middleware/IsDemoUser.php index e792003b9a..13f004674c 100644 --- a/app/Http/Middleware/IsDemoUser.php +++ b/app/Http/Middleware/IsDemoUser.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Middleware; +use Illuminate\Support\Facades\Log; use Closure; use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\User; @@ -49,7 +50,7 @@ class IsDemoUser /** @var UserRepositoryInterface $repository */ $repository = app(UserRepositoryInterface::class); if ($repository->hasRole($user, 'demo')) { - app('log')->info('User is a demo user.'); + Log::info('User is a demo user.'); $request->session()->flash('info', (string) trans('firefly.not_available_demo_user')); $current = $request->url(); $previous = $request->session()->previousUrl(); diff --git a/app/Http/Middleware/Range.php b/app/Http/Middleware/Range.php index 47bcf126e2..b9a3ff0292 100644 --- a/app/Http/Middleware/Range.php +++ b/app/Http/Middleware/Range.php @@ -114,7 +114,7 @@ class Range // send error to view, if it could not set money format if (false === $moneyResult) { - app('log')->error('Could not set locale. The following array doesnt work: ', $localeArray); + Log::error('Could not set locale. The following array doesnt work: ', $localeArray); app('view')->share('invalidMonetaryLocale', true); } diff --git a/app/Http/Requests/AccountFormRequest.php b/app/Http/Requests/AccountFormRequest.php index 9cd8d51163..8d99bc4765 100644 --- a/app/Http/Requests/AccountFormRequest.php +++ b/app/Http/Requests/AccountFormRequest.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Enums\UserRoleEnum; use FireflyIII\Models\Account; use FireflyIII\Models\Location; @@ -33,7 +34,6 @@ use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class AccountFormRequest. diff --git a/app/Http/Requests/AttachmentFormRequest.php b/app/Http/Requests/AttachmentFormRequest.php index f481510ee6..2da2240168 100644 --- a/app/Http/Requests/AttachmentFormRequest.php +++ b/app/Http/Requests/AttachmentFormRequest.php @@ -23,11 +23,11 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class AttachmentFormRequest. diff --git a/app/Http/Requests/BillStoreRequest.php b/app/Http/Requests/BillStoreRequest.php index 37e9f7ef02..0f530a2191 100644 --- a/app/Http/Requests/BillStoreRequest.php +++ b/app/Http/Requests/BillStoreRequest.php @@ -23,12 +23,12 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Rules\IsValidPositiveAmount; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class BillStoreRequest. diff --git a/app/Http/Requests/BillUpdateRequest.php b/app/Http/Requests/BillUpdateRequest.php index cde6978364..f4376c00b4 100644 --- a/app/Http/Requests/BillUpdateRequest.php +++ b/app/Http/Requests/BillUpdateRequest.php @@ -23,13 +23,13 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Models\Bill; use FireflyIII\Rules\IsValidPositiveAmount; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class BillUpdateRequest. diff --git a/app/Http/Requests/BudgetFormStoreRequest.php b/app/Http/Requests/BudgetFormStoreRequest.php index 86779d3794..cb6c99f037 100644 --- a/app/Http/Requests/BudgetFormStoreRequest.php +++ b/app/Http/Requests/BudgetFormStoreRequest.php @@ -23,13 +23,13 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Rules\IsValidPositiveAmount; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Validation\AutoBudget\ValidatesAutoBudgetRequest; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class BudgetFormStoreRequest diff --git a/app/Http/Requests/BudgetFormUpdateRequest.php b/app/Http/Requests/BudgetFormUpdateRequest.php index cdebd759e7..459665e50f 100644 --- a/app/Http/Requests/BudgetFormUpdateRequest.php +++ b/app/Http/Requests/BudgetFormUpdateRequest.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Models\Budget; use FireflyIII\Rules\IsValidPositiveAmount; use FireflyIII\Support\Request\ChecksLogin; @@ -30,7 +31,6 @@ use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Validation\AutoBudget\ValidatesAutoBudgetRequest; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class BudgetFormUpdateRequest diff --git a/app/Http/Requests/BudgetIncomeRequest.php b/app/Http/Requests/BudgetIncomeRequest.php index d75f81faa9..d0a2b96b17 100644 --- a/app/Http/Requests/BudgetIncomeRequest.php +++ b/app/Http/Requests/BudgetIncomeRequest.php @@ -23,11 +23,11 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Rules\IsValidPositiveAmount; use FireflyIII\Support\Request\ChecksLogin; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class BudgetIncomeRequest. diff --git a/app/Http/Requests/BulkEditJournalRequest.php b/app/Http/Requests/BulkEditJournalRequest.php index 4bbaafa77b..bcbbf533ca 100644 --- a/app/Http/Requests/BulkEditJournalRequest.php +++ b/app/Http/Requests/BulkEditJournalRequest.php @@ -23,11 +23,11 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class MassEditBulkJournalRequest. diff --git a/app/Http/Requests/CategoryFormRequest.php b/app/Http/Requests/CategoryFormRequest.php index 8ca3455168..53e25c7be3 100644 --- a/app/Http/Requests/CategoryFormRequest.php +++ b/app/Http/Requests/CategoryFormRequest.php @@ -23,12 +23,12 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Models\Category; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class CategoryFormRequest. diff --git a/app/Http/Requests/ConfigurationRequest.php b/app/Http/Requests/ConfigurationRequest.php index 57f8a969b4..212b706b5f 100644 --- a/app/Http/Requests/ConfigurationRequest.php +++ b/app/Http/Requests/ConfigurationRequest.php @@ -23,10 +23,10 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Support\Request\ChecksLogin; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class ConfigurationRequest. diff --git a/app/Http/Requests/CurrencyFormRequest.php b/app/Http/Requests/CurrencyFormRequest.php index 959678e64c..9a4f49672c 100644 --- a/app/Http/Requests/CurrencyFormRequest.php +++ b/app/Http/Requests/CurrencyFormRequest.php @@ -23,12 +23,12 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Models\TransactionCurrency; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class CurrencyFormRequest. diff --git a/app/Http/Requests/DeleteAccountFormRequest.php b/app/Http/Requests/DeleteAccountFormRequest.php index 31222e084a..c06cba8b51 100644 --- a/app/Http/Requests/DeleteAccountFormRequest.php +++ b/app/Http/Requests/DeleteAccountFormRequest.php @@ -23,10 +23,10 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Support\Request\ChecksLogin; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class DeleteAccountFormRequest. diff --git a/app/Http/Requests/EmailFormRequest.php b/app/Http/Requests/EmailFormRequest.php index cd4369f3ec..26f2c66750 100644 --- a/app/Http/Requests/EmailFormRequest.php +++ b/app/Http/Requests/EmailFormRequest.php @@ -23,11 +23,11 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class EmailFormRequest. diff --git a/app/Http/Requests/ExistingTokenFormRequest.php b/app/Http/Requests/ExistingTokenFormRequest.php index b843012fba..37f7eb7867 100644 --- a/app/Http/Requests/ExistingTokenFormRequest.php +++ b/app/Http/Requests/ExistingTokenFormRequest.php @@ -23,10 +23,10 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Support\Request\ChecksLogin; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class ExistingTokenFormRequest. diff --git a/app/Http/Requests/InviteUserFormRequest.php b/app/Http/Requests/InviteUserFormRequest.php index 2c31d965ce..5c71175d81 100644 --- a/app/Http/Requests/InviteUserFormRequest.php +++ b/app/Http/Requests/InviteUserFormRequest.php @@ -24,11 +24,11 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class InviteUserFormRequest diff --git a/app/Http/Requests/JournalLinkRequest.php b/app/Http/Requests/JournalLinkRequest.php index 185aaea191..f924a24ee6 100644 --- a/app/Http/Requests/JournalLinkRequest.php +++ b/app/Http/Requests/JournalLinkRequest.php @@ -23,12 +23,12 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Models\LinkType; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class JournalLink. diff --git a/app/Http/Requests/LinkTypeFormRequest.php b/app/Http/Requests/LinkTypeFormRequest.php index 3fb7511c6a..202b3fe3b8 100644 --- a/app/Http/Requests/LinkTypeFormRequest.php +++ b/app/Http/Requests/LinkTypeFormRequest.php @@ -23,11 +23,11 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class LinkTypeFormRequest. diff --git a/app/Http/Requests/MassDeleteJournalRequest.php b/app/Http/Requests/MassDeleteJournalRequest.php index 603e8a7d51..5700ac4224 100644 --- a/app/Http/Requests/MassDeleteJournalRequest.php +++ b/app/Http/Requests/MassDeleteJournalRequest.php @@ -23,10 +23,10 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Support\Request\ChecksLogin; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class MassDeleteJournalRequest. diff --git a/app/Http/Requests/MassEditJournalRequest.php b/app/Http/Requests/MassEditJournalRequest.php index 7f217aaf67..d236c3abc0 100644 --- a/app/Http/Requests/MassEditJournalRequest.php +++ b/app/Http/Requests/MassEditJournalRequest.php @@ -23,10 +23,10 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Support\Request\ChecksLogin; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class MassEditJournalRequest. diff --git a/app/Http/Requests/NewUserFormRequest.php b/app/Http/Requests/NewUserFormRequest.php index bed1e3def7..1d0da88187 100644 --- a/app/Http/Requests/NewUserFormRequest.php +++ b/app/Http/Requests/NewUserFormRequest.php @@ -23,12 +23,12 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Rules\IsValidAmount; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class NewUserFormRequest. diff --git a/app/Http/Requests/ObjectGroupFormRequest.php b/app/Http/Requests/ObjectGroupFormRequest.php index 8d8dcb1b8a..5febc46231 100644 --- a/app/Http/Requests/ObjectGroupFormRequest.php +++ b/app/Http/Requests/ObjectGroupFormRequest.php @@ -23,12 +23,12 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Models\ObjectGroup; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class ObjectGroupFormRequest. diff --git a/app/Http/Requests/PiggyBankStoreRequest.php b/app/Http/Requests/PiggyBankStoreRequest.php index 87a13140da..9a1daf4a83 100644 --- a/app/Http/Requests/PiggyBankStoreRequest.php +++ b/app/Http/Requests/PiggyBankStoreRequest.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\TransactionCurrency; use FireflyIII\Repositories\Account\AccountRepositoryInterface; @@ -32,7 +33,6 @@ use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class PiggyBankStoreRequest. diff --git a/app/Http/Requests/PiggyBankUpdateRequest.php b/app/Http/Requests/PiggyBankUpdateRequest.php index a93fcada2f..0657f63a9a 100644 --- a/app/Http/Requests/PiggyBankUpdateRequest.php +++ b/app/Http/Requests/PiggyBankUpdateRequest.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\PiggyBank; use FireflyIII\Models\TransactionCurrency; @@ -33,7 +34,6 @@ use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class PiggyBankFormRequest. diff --git a/app/Http/Requests/ProfileFormRequest.php b/app/Http/Requests/ProfileFormRequest.php index bf741778e6..65034257b9 100644 --- a/app/Http/Requests/ProfileFormRequest.php +++ b/app/Http/Requests/ProfileFormRequest.php @@ -23,10 +23,10 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Support\Request\ChecksLogin; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class ProfileFormRequest. diff --git a/app/Http/Requests/ReconciliationStoreRequest.php b/app/Http/Requests/ReconciliationStoreRequest.php index 75a1a6d8e3..d3f8645888 100644 --- a/app/Http/Requests/ReconciliationStoreRequest.php +++ b/app/Http/Requests/ReconciliationStoreRequest.php @@ -24,13 +24,13 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Rules\IsValidAmount; use FireflyIII\Rules\ValidJournals; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class ReconciliationStoreRequest @@ -58,7 +58,7 @@ class ReconciliationStoreRequest extends FormRequest 'journals' => $transactions, 'reconcile' => $this->convertString('reconcile'), ]; - app('log')->debug('In ReconciliationStoreRequest::getAll(). Will now return data.'); + Log::debug('In ReconciliationStoreRequest::getAll(). Will now return data.'); return $data; } diff --git a/app/Http/Requests/RecurrenceFormRequest.php b/app/Http/Requests/RecurrenceFormRequest.php index d7340dd793..0a3f0a9c1c 100644 --- a/app/Http/Requests/RecurrenceFormRequest.php +++ b/app/Http/Requests/RecurrenceFormRequest.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Factory\CategoryFactory; @@ -36,7 +37,6 @@ use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Validation\AccountValidator; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class RecurrenceFormRequest @@ -126,7 +126,7 @@ class RecurrenceFormRequest extends FormRequest $return['transactions'][0]['source_id'] = $this->convertInteger('source_id'); $return['transactions'][0]['destination_id'] = $this->convertInteger('destination_id'); } - if (true === $throwError) { + if ($throwError) { throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->convertString('transaction_type'))); } @@ -292,7 +292,7 @@ class RecurrenceFormRequest extends FormRequest */ public function validateAccountInformation(Validator $validator): void { - app('log')->debug('Now in validateAccountInformation (RecurrenceFormRequest)()'); + Log::debug('Now in validateAccountInformation (RecurrenceFormRequest)()'); /** @var AccountValidator $accountValidator */ $accountValidator = app(AccountValidator::class); @@ -324,7 +324,7 @@ class RecurrenceFormRequest extends FormRequest $sourceId = (int) $data['source_id']; $destinationId = (int) ($data['destination_id'] ?? 0); } - if (true === $throwError) { + if ($throwError) { throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->convertString('transaction_type'))); } diff --git a/app/Http/Requests/ReportFormRequest.php b/app/Http/Requests/ReportFormRequest.php index eda973b3fb..344a95a70b 100644 --- a/app/Http/Requests/ReportFormRequest.php +++ b/app/Http/Requests/ReportFormRequest.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use Carbon\Carbon; use Exception; use FireflyIII\Exceptions\FireflyException; @@ -34,7 +35,6 @@ use FireflyIII\Support\Request\ChecksLogin; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; use Safe\Exceptions\PcreException; use function Safe\preg_match; @@ -153,8 +153,8 @@ class ReportFormRequest extends FormRequest $date = new Carbon($parts[1]); } catch (Exception $e) { // intentional generic exception $error = sprintf('"%s" is not a valid date range: %s', $range, $e->getMessage()); - app('log')->error($error); - app('log')->error($e->getTraceAsString()); + Log::error($error); + Log::error($e->getTraceAsString()); throw new FireflyException($error, 0, $e); } @@ -162,7 +162,7 @@ class ReportFormRequest extends FormRequest return $date; } $error = sprintf('"%s" is not a valid date range: %s', $range, 'invalid format :('); - app('log')->error($error); + Log::error($error); throw new FireflyException($error, 0); } @@ -192,8 +192,8 @@ class ReportFormRequest extends FormRequest $date = new Carbon($parts[0]); } catch (Exception $e) { // intentional generic exception $error = sprintf('"%s" is not a valid date range: %s', $range, $e->getMessage()); - app('log')->error($error); - app('log')->error($e->getTraceAsString()); + Log::error($error); + Log::error($e->getTraceAsString()); throw new FireflyException($error, 0, $e); } @@ -201,7 +201,7 @@ class ReportFormRequest extends FormRequest return $date; } $error = sprintf('"%s" is not a valid date range: %s', $range, 'invalid format :('); - app('log')->error($error); + Log::error($error); throw new FireflyException($error, 0); } @@ -219,15 +219,15 @@ class ReportFormRequest extends FormRequest $set = $this->get('tag'); $collection = new Collection(); if (is_array($set)) { - app('log')->debug('Set is:', $set); + Log::debug('Set is:', $set); } if (!is_array($set)) { - app('log')->debug(sprintf('Set is not an array! "%s"', $set)); + Log::debug(sprintf('Set is not an array! "%s"', $set)); return $collection; } foreach ($set as $tagTag) { - app('log')->debug(sprintf('Now searching for "%s"', $tagTag)); + Log::debug(sprintf('Now searching for "%s"', $tagTag)); $tag = $repository->findByTag($tagTag); if (null !== $tag) { $collection->push($tag); diff --git a/app/Http/Requests/RuleFormRequest.php b/app/Http/Requests/RuleFormRequest.php index 9cb1877ce9..7698156a5a 100644 --- a/app/Http/Requests/RuleFormRequest.php +++ b/app/Http/Requests/RuleFormRequest.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Models\Rule; use FireflyIII\Rules\IsValidActionExpression; use FireflyIII\Support\Request\ChecksLogin; @@ -30,7 +31,6 @@ use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\GetRuleConfiguration; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class RuleFormRequest. diff --git a/app/Http/Requests/RuleGroupFormRequest.php b/app/Http/Requests/RuleGroupFormRequest.php index 8f5c4af01b..f73cff0b74 100644 --- a/app/Http/Requests/RuleGroupFormRequest.php +++ b/app/Http/Requests/RuleGroupFormRequest.php @@ -23,13 +23,13 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Models\RuleGroup; use FireflyIII\Rules\IsBoolean; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class RuleGroupFormRequest. diff --git a/app/Http/Requests/SelectTransactionsRequest.php b/app/Http/Requests/SelectTransactionsRequest.php index fdd9e0ecf8..d5564d7bc4 100644 --- a/app/Http/Requests/SelectTransactionsRequest.php +++ b/app/Http/Requests/SelectTransactionsRequest.php @@ -23,10 +23,10 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Support\Request\ChecksLogin; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class SelectTransactionsRequest. diff --git a/app/Http/Requests/TagFormRequest.php b/app/Http/Requests/TagFormRequest.php index a156257b78..069ffd5ef3 100644 --- a/app/Http/Requests/TagFormRequest.php +++ b/app/Http/Requests/TagFormRequest.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Models\Location; use FireflyIII\Models\Tag; use FireflyIII\Support\Request\AppendsLocationData; @@ -30,7 +31,6 @@ use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class TagFormRequest. diff --git a/app/Http/Requests/TestRuleFormRequest.php b/app/Http/Requests/TestRuleFormRequest.php index 0cf0524667..fa4e289e4e 100644 --- a/app/Http/Requests/TestRuleFormRequest.php +++ b/app/Http/Requests/TestRuleFormRequest.php @@ -23,11 +23,11 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\GetRuleConfiguration; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class TestRuleFormRequest. diff --git a/app/Http/Requests/TokenFormRequest.php b/app/Http/Requests/TokenFormRequest.php index 3a53cbe7ab..19c0f3bc06 100644 --- a/app/Http/Requests/TokenFormRequest.php +++ b/app/Http/Requests/TokenFormRequest.php @@ -23,10 +23,10 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Support\Request\ChecksLogin; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class TokenFormRequest. diff --git a/app/Http/Requests/TriggerRecurrenceRequest.php b/app/Http/Requests/TriggerRecurrenceRequest.php index c03e531a00..36d16331d6 100644 --- a/app/Http/Requests/TriggerRecurrenceRequest.php +++ b/app/Http/Requests/TriggerRecurrenceRequest.php @@ -24,11 +24,11 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class TriggerRecurrenceRequest diff --git a/app/Http/Requests/UserFormRequest.php b/app/Http/Requests/UserFormRequest.php index 409cfba453..cc89dff35b 100644 --- a/app/Http/Requests/UserFormRequest.php +++ b/app/Http/Requests/UserFormRequest.php @@ -23,11 +23,11 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class UserFormRequest. diff --git a/app/Http/Requests/UserRegistrationRequest.php b/app/Http/Requests/UserRegistrationRequest.php index 6e26763831..8bd3504ea3 100644 --- a/app/Http/Requests/UserRegistrationRequest.php +++ b/app/Http/Requests/UserRegistrationRequest.php @@ -23,10 +23,10 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Support\Request\ChecksLogin; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Class UserRegistrationRequest. diff --git a/app/Jobs/CreateRecurringTransactions.php b/app/Jobs/CreateRecurringTransactions.php index a70e768868..9bbafdf3e4 100644 --- a/app/Jobs/CreateRecurringTransactions.php +++ b/app/Jobs/CreateRecurringTransactions.php @@ -156,7 +156,7 @@ class CreateRecurringTransactions implements ShouldQueue private function filterRecurrences(Collection $recurrences): Collection { return $recurrences->filter( - fn (Recurrence $recurrence) => $this->validRecurrence($recurrence) + fn (Recurrence $recurrence): bool => $this->validRecurrence($recurrence) ); } @@ -355,7 +355,7 @@ class CreateRecurringTransactions implements ShouldQueue return null; } - if ($journalCount > 0 && true === $this->force) { + if ($journalCount > 0 && $this->force) { Log::warning(sprintf('Already created %d groups for date %s but FORCED to continue.', $journalCount, $date->format('Y-m-d'))); } @@ -411,8 +411,7 @@ class CreateRecurringTransactions implements ShouldQueue $count = $this->repository->getJournalCount($recurrence) + 1; $transactions = $recurrence->recurrenceTransactions()->get(); - /** @var RecurrenceTransaction $first */ - $first = $transactions->first(); + $transactions->first(); $return = []; /** @var RecurrenceTransaction $transaction */ diff --git a/app/Jobs/DownloadExchangeRates.php b/app/Jobs/DownloadExchangeRates.php index e5be322d09..fbfef25a9e 100644 --- a/app/Jobs/DownloadExchangeRates.php +++ b/app/Jobs/DownloadExchangeRates.php @@ -54,7 +54,7 @@ class DownloadExchangeRates implements ShouldQueue use Queueable; use SerializesModels; - private array $active; + private array $active = []; private Carbon $date; private CurrencyRepositoryInterface $repository; private Collection $users; @@ -64,7 +64,6 @@ class DownloadExchangeRates implements ShouldQueue */ public function __construct(?Carbon $date) { - $this->active = []; $this->repository = app(CurrencyRepositoryInterface::class); // get all users: diff --git a/app/Jobs/SendWebhookMessage.php b/app/Jobs/SendWebhookMessage.php index dbaab99fe3..de1e87bf5e 100644 --- a/app/Jobs/SendWebhookMessage.php +++ b/app/Jobs/SendWebhookMessage.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Jobs; +use Illuminate\Support\Facades\Log; use FireflyIII\Models\WebhookMessage; use FireflyIII\Services\Webhook\WebhookSenderInterface; use Illuminate\Bus\Queueable; @@ -52,7 +53,8 @@ class SendWebhookMessage implements ShouldQueue */ public function handle(): void { - app('log')->debug(sprintf('Now handling webhook message #%d', $this->message->id)); + + Log::debug(sprintf('Now handling webhook message #%d', $this->message->id)); // send job! $sender = app(WebhookSenderInterface::class); $sender->setMessage($this->message); diff --git a/app/Jobs/WarnAboutBills.php b/app/Jobs/WarnAboutBills.php index 1433f54bc5..0c8a3e1461 100644 --- a/app/Jobs/WarnAboutBills.php +++ b/app/Jobs/WarnAboutBills.php @@ -127,11 +127,7 @@ class WarnAboutBills implements ShouldQueue $diff = $this->getDiff($bill, $field); $list = config('firefly.bill_reminder_periods'); Log::debug(sprintf('Difference in days for field "%s" ("%s") is %d day(s)', $field, $bill->{$field}->format('Y-m-d'), $diff)); - if (in_array($diff, $list, true)) { - return true; - } - - return false; + return in_array($diff, $list, true); } private function getDiff(Bill $bill, string $field): int @@ -193,11 +189,7 @@ class WarnAboutBills implements ShouldQueue Log::debug(sprintf('Earliest expected pay date is %s', $earliest->toAtomString())); $diff = $earliest->diffInDays($this->date); Log::debug(sprintf('Difference in days is %s', $diff)); - if ($diff < 2) { - return false; - } - - return true; + return $diff >= 2; } private function sendOverdueAlerts(User $user, array $overdue): void diff --git a/app/Mail/NewIPAddressWarningMail.php b/app/Mail/NewIPAddressWarningMail.php index 8afba582a9..11af099b21 100644 --- a/app/Mail/NewIPAddressWarningMail.php +++ b/app/Mail/NewIPAddressWarningMail.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Mail; +use Illuminate\Support\Facades\Log; use FireflyIII\Exceptions\FireflyException; use Illuminate\Bus\Queueable; use Illuminate\Mail\Mailable; @@ -58,7 +59,7 @@ class NewIPAddressWarningMail extends Mailable try { $hostName = app('steam')->getHostName($this->ipAddress); } catch (FireflyException $e) { - app('log')->error($e->getMessage()); + Log::error($e->getMessage()); $hostName = $this->ipAddress; } if ($hostName !== $this->ipAddress) { diff --git a/app/Models/Account.php b/app/Models/Account.php index 76d520856d..c59ad0317a 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -146,7 +146,7 @@ class Account extends Model protected function accountId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } @@ -177,7 +177,7 @@ class Account extends Model protected function accountTypeId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } @@ -221,14 +221,14 @@ class Account extends Model protected function iban(): Attribute { return Attribute::make( - get: static fn ($value) => null === $value ? null : trim(str_replace(' ', '', (string)$value)), + get: static fn ($value): ?string => null === $value ? null : trim(str_replace(' ', '', (string)$value)), ); } protected function order(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } @@ -238,7 +238,7 @@ class Account extends Model protected function virtualBalance(): Attribute { return Attribute::make( - get: static fn ($value) => (string)$value, + get: static fn ($value): string => (string)$value, ); } diff --git a/app/Models/AccountMeta.php b/app/Models/AccountMeta.php index a91e5eb778..4932c3a54f 100644 --- a/app/Models/AccountMeta.php +++ b/app/Models/AccountMeta.php @@ -53,6 +53,6 @@ class AccountMeta extends Model protected function data(): Attribute { - return Attribute::make(get: fn (mixed $value) => (string)json_decode((string)$value, true), set: fn (mixed $value) => ['data' => json_encode($value)]); + return Attribute::make(get: fn (mixed $value): string => (string)json_decode((string)$value, true), set: fn (mixed $value): array => ['data' => json_encode($value)]); } } diff --git a/app/Models/Attachment.php b/app/Models/Attachment.php index 0323697cb8..2ec45246a8 100644 --- a/app/Models/Attachment.php +++ b/app/Models/Attachment.php @@ -100,7 +100,7 @@ class Attachment extends Model protected function attachableId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } diff --git a/app/Models/AuditLogEntry.php b/app/Models/AuditLogEntry.php index fded5ca815..818b2c8d20 100644 --- a/app/Models/AuditLogEntry.php +++ b/app/Models/AuditLogEntry.php @@ -48,7 +48,7 @@ class AuditLogEntry extends Model protected function auditableId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } @@ -66,7 +66,7 @@ class AuditLogEntry extends Model protected function changerId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Models/AutoBudget.php b/app/Models/AutoBudget.php index 73dad3c6aa..925928448d 100644 --- a/app/Models/AutoBudget.php +++ b/app/Models/AutoBudget.php @@ -70,14 +70,14 @@ class AutoBudget extends Model protected function amount(): Attribute { return Attribute::make( - get: static fn ($value) => (string)$value, + get: static fn ($value): string => (string)$value, ); } protected function budgetId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } @@ -91,7 +91,7 @@ class AutoBudget extends Model protected function transactionCurrencyId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Models/AvailableBudget.php b/app/Models/AvailableBudget.php index 109abd0307..92d177961e 100644 --- a/app/Models/AvailableBudget.php +++ b/app/Models/AvailableBudget.php @@ -80,7 +80,7 @@ class AvailableBudget extends Model protected function amount(): Attribute { return Attribute::make( - get: static fn ($value) => (string)$value, + get: static fn ($value): string => (string)$value, ); } @@ -103,23 +103,23 @@ class AvailableBudget extends Model protected function endDate(): Attribute { return Attribute::make( - get: fn (string $value) => Carbon::parse($value), - set: fn (Carbon $value) => $value->format('Y-m-d'), + get: fn (string $value): Carbon => Carbon::parse($value), + set: fn (Carbon $value): string => $value->format('Y-m-d'), ); } protected function startDate(): Attribute { return Attribute::make( - get: fn (string $value) => Carbon::parse($value), - set: fn (Carbon $value) => $value->format('Y-m-d'), + get: fn (string $value): Carbon => Carbon::parse($value), + set: fn (Carbon $value): string => $value->format('Y-m-d'), ); } protected function transactionCurrencyId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Models/Bill.php b/app/Models/Bill.php index b57d98df1d..79420fed6e 100644 --- a/app/Models/Bill.php +++ b/app/Models/Bill.php @@ -151,7 +151,7 @@ class Bill extends Model protected function amountMax(): Attribute { return Attribute::make( - get: static fn ($value) => (string)$value, + get: static fn ($value): string => (string)$value, ); } @@ -161,7 +161,7 @@ class Bill extends Model protected function amountMin(): Attribute { return Attribute::make( - get: static fn ($value) => (string)$value, + get: static fn ($value): string => (string)$value, ); } @@ -189,7 +189,7 @@ class Bill extends Model protected function order(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } @@ -199,14 +199,14 @@ class Bill extends Model protected function skip(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } protected function transactionCurrencyId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Models/Budget.php b/app/Models/Budget.php index 481ad1c6dc..e49885b1f0 100644 --- a/app/Models/Budget.php +++ b/app/Models/Budget.php @@ -125,7 +125,7 @@ class Budget extends Model protected function order(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } diff --git a/app/Models/BudgetLimit.php b/app/Models/BudgetLimit.php index 6e454e4e3c..3c76514cbd 100644 --- a/app/Models/BudgetLimit.php +++ b/app/Models/BudgetLimit.php @@ -94,14 +94,14 @@ class BudgetLimit extends Model protected function amount(): Attribute { return Attribute::make( - get: static fn ($value) => (string)$value, + get: static fn ($value): string => (string)$value, ); } protected function budgetId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } @@ -121,7 +121,7 @@ class BudgetLimit extends Model protected function transactionCurrencyId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php index 3fd2d82a19..47fc0f8a28 100644 --- a/app/Models/Configuration.php +++ b/app/Models/Configuration.php @@ -52,6 +52,6 @@ class Configuration extends Model */ protected function data(): Attribute { - return Attribute::make(get: fn ($value) => json_decode((string)$value), set: fn ($value) => ['data' => json_encode($value)]); + return Attribute::make(get: fn ($value): mixed => json_decode((string)$value), set: fn ($value): array => ['data' => json_encode($value)]); } } diff --git a/app/Models/CurrencyExchangeRate.php b/app/Models/CurrencyExchangeRate.php index a1bfa4a013..ce0f0973a7 100644 --- a/app/Models/CurrencyExchangeRate.php +++ b/app/Models/CurrencyExchangeRate.php @@ -73,28 +73,28 @@ class CurrencyExchangeRate extends Model protected function fromCurrencyId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } protected function rate(): Attribute { return Attribute::make( - get: static fn ($value) => (string)$value, + get: static fn ($value): string => (string)$value, ); } protected function toCurrencyId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } protected function userRate(): Attribute { return Attribute::make( - get: static fn ($value) => (string)$value, + get: static fn ($value): string => (string)$value, ); } } diff --git a/app/Models/GroupMembership.php b/app/Models/GroupMembership.php index 52f6cf9b24..443f4e7654 100644 --- a/app/Models/GroupMembership.php +++ b/app/Models/GroupMembership.php @@ -66,7 +66,7 @@ class GroupMembership extends Model protected function userRoleId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Models/Location.php b/app/Models/Location.php index b8f2b31151..14812341e0 100644 --- a/app/Models/Location.php +++ b/app/Models/Location.php @@ -81,7 +81,7 @@ class Location extends Model protected function locatableId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Models/Note.php b/app/Models/Note.php index 2adeacc457..372406f58a 100644 --- a/app/Models/Note.php +++ b/app/Models/Note.php @@ -56,7 +56,7 @@ class Note extends Model protected function noteableId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Models/ObjectGroup.php b/app/Models/ObjectGroup.php index 189e543a41..046e909261 100644 --- a/app/Models/ObjectGroup.php +++ b/app/Models/ObjectGroup.php @@ -105,7 +105,7 @@ class ObjectGroup extends Model protected function order(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Models/PeriodStatistic.php b/app/Models/PeriodStatistic.php index c8878cfc9b..d9407ef4a0 100644 --- a/app/Models/PeriodStatistic.php +++ b/app/Models/PeriodStatistic.php @@ -33,7 +33,7 @@ class PeriodStatistic extends Model protected function count(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.php index d4eb25a787..29da6024f2 100644 --- a/app/Models/PiggyBank.php +++ b/app/Models/PiggyBank.php @@ -123,7 +123,7 @@ class PiggyBank extends Model protected function accountId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } @@ -146,7 +146,7 @@ class PiggyBank extends Model protected function order(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } @@ -156,7 +156,7 @@ class PiggyBank extends Model protected function targetAmount(): Attribute { return Attribute::make( - get: static fn ($value) => (string)$value, + get: static fn ($value): string => (string)$value, ); } } diff --git a/app/Models/PiggyBankEvent.php b/app/Models/PiggyBankEvent.php index 3395e3df53..6c5375b5e4 100644 --- a/app/Models/PiggyBankEvent.php +++ b/app/Models/PiggyBankEvent.php @@ -64,7 +64,7 @@ class PiggyBankEvent extends Model protected function amount(): Attribute { return Attribute::make( - get: static fn ($value) => (string)$value, + get: static fn ($value): string => (string)$value, ); } @@ -82,7 +82,7 @@ class PiggyBankEvent extends Model protected function piggyBankId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Models/PiggyBankRepetition.php b/app/Models/PiggyBankRepetition.php index 41af799266..71b9a554ca 100644 --- a/app/Models/PiggyBankRepetition.php +++ b/app/Models/PiggyBankRepetition.php @@ -68,7 +68,7 @@ class PiggyBankRepetition extends Model protected function currentAmount(): Attribute { return Attribute::make( - get: static fn ($value) => (string)$value, + get: static fn ($value): string => (string)$value, ); } @@ -81,7 +81,7 @@ class PiggyBankRepetition extends Model protected function piggyBankId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } diff --git a/app/Models/Recurrence.php b/app/Models/Recurrence.php index 1893fa023e..42f5cad07b 100644 --- a/app/Models/Recurrence.php +++ b/app/Models/Recurrence.php @@ -144,7 +144,7 @@ class Recurrence extends Model protected function transactionTypeId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Models/RecurrenceMeta.php b/app/Models/RecurrenceMeta.php index d031e0b883..0dbf376184 100644 --- a/app/Models/RecurrenceMeta.php +++ b/app/Models/RecurrenceMeta.php @@ -58,7 +58,7 @@ class RecurrenceMeta extends Model protected function recurrenceId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } From 68183a0a0ea12f0570184bcc086ac7fb58de7bd6 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 9 Nov 2025 09:08:03 +0100 Subject: [PATCH 03/12] Fix code quality with rector [skip ci] --- app/Models/RecurrenceRepetition.php | 6 +- app/Models/RecurrenceTransaction.php | 14 ++-- app/Models/RecurrenceTransactionMeta.php | 2 +- app/Models/Rule.php | 6 +- app/Models/RuleAction.php | 4 +- app/Models/RuleGroup.php | 2 +- app/Models/RuleTrigger.php | 4 +- app/Models/Transaction.php | 10 +-- app/Models/TransactionCurrency.php | 2 +- app/Models/TransactionJournal.php | 4 +- app/Models/TransactionJournalLink.php | 6 +- app/Models/TransactionJournalMeta.php | 4 +- app/Models/WebhookAttempt.php | 2 +- app/Models/WebhookDelivery.php | 2 +- app/Models/WebhookMessage.php | 4 +- app/Models/WebhookResponse.php | 2 +- app/Models/WebhookTrigger.php | 2 +- app/Notifications/User/NewAccessToken.php | 2 - app/Notifications/User/UserRegistration.php | 2 - app/Providers/AppServiceProvider.php | 10 +-- app/Providers/AuthServiceProvider.php | 4 +- app/Providers/CurrencyServiceProvider.php | 2 +- app/Providers/FireflyServiceProvider.php | 24 +++--- app/Providers/FireflySessionProvider.php | 2 +- .../Account/AccountRepository.php | 4 +- .../Attachment/AttachmentRepository.php | 5 +- app/Repositories/Bill/BillRepository.php | 44 +++++------ .../Budget/AvailableBudgetRepository.php | 2 +- .../Budget/BudgetLimitRepository.php | 2 +- app/Repositories/Budget/BudgetRepository.php | 4 +- .../Budget/OperationsRepository.php | 6 +- .../Category/CategoryRepository.php | 12 +-- .../Currency/CurrencyRepository.php | 11 ++- .../Journal/JournalAPIRepository.php | 2 +- .../Journal/JournalRepository.php | 12 +-- .../LinkType/LinkTypeRepository.php | 9 ++- .../ObjectGroup/ObjectGroupRepository.php | 7 +- .../PiggyBank/PiggyBankRepository.php | 2 +- .../Recurring/RecurringRepository.php | 12 +-- app/Repositories/Rule/RuleRepository.php | 11 +-- .../RuleGroup/RuleGroupRepository.php | 8 +- app/Repositories/Tag/TagRepository.php | 6 +- .../TransactionGroupRepository.php | 11 +-- .../TransactionTypeRepository.php | 7 +- app/Repositories/User/UserRepository.php | 36 ++------- .../UserGroup/UserGroupRepository.php | 31 ++++---- .../Webhook/WebhookRepository.php | 2 +- app/Rules/Account/IsValidAccountTypeList.php | 1 - app/Rules/BelongsUser.php | 9 ++- app/Rules/BelongsUserGroup.php | 9 ++- app/Rules/IsAllowedGroupAction.php | 65 +--------------- app/Rules/IsDateOrTime.php | 9 ++- app/Rules/IsDefaultUserGroupName.php | 3 +- app/Rules/IsTransferAccount.php | 7 +- app/Rules/IsValidDateRange.php | 5 +- app/Rules/IsValidZeroOrMoreAmount.php | 2 +- .../IsValidTransactionTypeList.php | 1 - app/Rules/UniqueAccountNumber.php | 9 ++- app/Rules/UniqueIban.php | 8 +- app/Rules/ValidJournals.php | 7 +- app/Rules/ValidRecurrenceRepetitionValue.php | 3 +- .../FireflyIIIOrg/Update/UpdateRequest.php | 4 +- .../Destroy/AccountDestroyService.php | 13 ++-- .../Destroy/JournalDestroyService.php | 7 +- .../TransactionGroupDestroyService.php | 3 +- .../Internal/Support/AccountServiceTrait.php | 77 +++++++++---------- .../Internal/Support/BillServiceTrait.php | 3 +- .../Support/CreditRecalculateService.php | 28 ++----- .../Internal/Support/JournalServiceTrait.php | 2 +- .../Support/RecurringTransactionTrait.php | 10 +-- .../Internal/Support/TransactionTypeTrait.php | 3 +- .../Internal/Update/AccountUpdateService.php | 21 ++--- .../Internal/Update/BillUpdateService.php | 13 ++-- .../Internal/Update/CategoryUpdateService.php | 13 ++-- .../Internal/Update/GroupUpdateService.php | 16 ++-- .../Internal/Update/JournalUpdateService.php | 58 ++++++-------- .../Update/RecurrenceUpdateService.php | 33 ++++---- app/Services/Password/PwndVerifierV2.php | 13 ++-- app/Support/Amount.php | 4 +- .../Authentication/RemoteUserGuard.php | 6 +- .../Authentication/RemoteUserProvider.php | 17 ++-- app/Support/Binder/AccountList.php | 5 +- app/Support/Binder/BudgetList.php | 7 +- app/Support/Binder/CLIToken.php | 10 +-- app/Support/Binder/CategoryList.php | 2 +- app/Support/Binder/Date.php | 5 +- app/Support/Binder/JournalList.php | 2 +- app/Support/Binder/TagList.php | 10 +-- app/Support/Binder/TagOrId.php | 5 +- app/Support/Calendar/Calculator.php | 8 +- .../Chart/Budget/FrontpageChartGenerator.php | 5 +- .../Category/FrontpageChartGenerator.php | 3 +- app/Support/Chart/ChartData.php | 7 +- app/Support/Cronjobs/AbstractCronjob.php | 15 ++-- app/Support/ExpandedForm.php | 59 +++++++------- app/Support/Export/ExportDataGenerator.php | 45 +++++------ app/Support/Facades/Preferences.php | 3 +- app/Support/FireflyConfig.php | 2 +- app/Support/Form/AccountForm.php | 5 +- app/Support/Form/CurrencyForm.php | 17 ++-- app/Support/Form/FormSupport.php | 9 ++- app/Support/Form/RuleForm.php | 3 - .../Http/Api/AccountBalanceGrouped.php | 5 +- .../Http/Api/ExchangeRateConverter.php | 16 ++-- .../Http/Api/SummaryBalanceGrouped.php | 6 +- .../Http/Controllers/GetConfigurationData.php | 6 +- .../Http/Controllers/ModelInformation.php | 13 ++-- .../Http/Controllers/PeriodOverview.php | 12 +-- .../Http/Controllers/RenderPartialViews.php | 47 +++++------ .../Http/Controllers/RequestInformation.php | 6 +- .../Http/Controllers/RuleManagement.php | 13 ++-- .../Http/Controllers/UserNavigation.php | 23 +++--- .../JsonApi/Enrichments/AccountEnrichment.php | 2 +- .../Enrichments/AvailableBudgetEnrichment.php | 8 +- .../JsonApi/Enrichments/BudgetEnrichment.php | 4 +- .../Enrichments/BudgetLimitEnrichment.php | 19 ++--- .../Enrichments/CategoryEnrichment.php | 2 +- .../Enrichments/PiggyBankEnrichment.php | 6 +- .../Enrichments/PiggyBankEventEnrichment.php | 6 +- .../Enrichments/RecurringEnrichment.php | 10 +-- .../Enrichments/SubscriptionEnrichment.php | 11 +-- .../TransactionGroupEnrichment.php | 9 +-- .../JsonApi/Enrichments/WebhookEnrichment.php | 6 +- app/Support/Models/ReturnsIntegerIdTrait.php | 2 +- .../Models/ReturnsIntegerUserIdTrait.php | 4 +- app/Support/ParseDateString.php | 6 +- .../Report/Budget/BudgetReportGenerator.php | 3 +- .../Summarizer/TransactionSummarizer.php | 2 +- .../Recurring/CalculateRangeOccurrences.php | 15 ++-- .../Recurring/CalculateXOccurrencesSince.php | 2 +- app/Support/Request/AppendsLocationData.php | 56 +++++++------- app/Support/Request/ChecksLogin.php | 17 ++-- app/Support/Request/ConvertsDataTypes.php | 6 +- app/Support/Request/ValidatesWebhooks.php | 2 +- app/Support/Search/AccountSearch.php | 12 +-- app/Support/Search/OperatorQuerySearch.php | 52 +++++-------- .../Search/QueryParser/GdbotsQueryParser.php | 8 +- app/Support/Steam.php | 33 ++++---- .../System/GeneratesInstallationId.php | 5 +- app/Support/System/OAuthKeys.php | 15 ++-- app/Support/Twig/General.php | 8 +- app/Support/Twig/Rule.php | 6 +- app/Support/Twig/TransactionGroupTwig.php | 5 +- app/Support/Twig/Translation.php | 7 +- app/TransactionRules/Actions/AddTag.php | 5 +- .../Actions/AppendDescriptionToNotes.php | 3 +- app/TransactionRules/Actions/AppendNotes.php | 3 +- .../Actions/AppendNotesToDescription.php | 9 ++- app/TransactionRules/Actions/ClearBudget.php | 5 +- .../Actions/ClearCategory.php | 5 +- app/TransactionRules/Actions/ClearNotes.php | 5 +- .../Actions/ConvertToDeposit.php | 29 +++---- .../Actions/ConvertToTransfer.php | 37 ++++----- .../Actions/ConvertToWithdrawal.php | 27 +++---- .../Actions/DeleteTransaction.php | 5 +- .../Actions/MoveDescriptionToNotes.php | 3 +- .../Actions/MoveNotesToDescription.php | 3 +- app/TransactionRules/Actions/PrependNotes.php | 3 +- .../Actions/RemoveAllTags.php | 5 +- app/TransactionRules/Actions/RemoveTag.php | 7 +- app/TransactionRules/Actions/SetAmount.php | 5 +- app/TransactionRules/Actions/SetBudget.php | 7 +- app/TransactionRules/Actions/SetCategory.php | 7 +- .../Actions/SetDescription.php | 2 +- .../Actions/SetDestinationAccount.php | 21 ++--- .../Actions/SetDestinationToCashAccount.php | 13 ++-- app/TransactionRules/Actions/SetNotes.php | 3 +- .../Actions/SetSourceAccount.php | 19 ++--- .../Actions/SetSourceToCashAccount.php | 13 ++-- .../Actions/SwitchAccounts.php | 9 ++- .../Engine/SearchRuleEngine.php | 28 +++---- .../Expressions/ActionExpression.php | 4 +- .../Factory/ActionFactory.php | 3 +- app/Transformers/AbstractTransformer.php | 9 +-- app/Transformers/BudgetLimitTransformer.php | 4 +- .../PiggyBankEventTransformer.php | 2 +- app/Transformers/RecurrenceTransformer.php | 5 -- .../TransactionGroupTransformer.php | 11 +-- app/Transformers/UserGroupTransformer.php | 13 +--- app/Transformers/WebhookTransformer.php | 5 -- app/Validation/Account/DepositValidation.php | 14 ++-- .../Account/LiabilityValidation.php | 33 ++++---- app/Validation/Account/OBValidation.php | 8 +- .../Account/ReconciliationValidation.php | 23 +++--- app/Validation/Account/TransferValidation.php | 27 +++---- .../Account/WithdrawalValidation.php | 22 +++--- app/Validation/AccountValidator.php | 29 +++---- .../Bulk/ValidatesBulkTransactionQuery.php | 2 +- .../AutoBudget/ValidatesAutoBudgetRequest.php | 8 +- app/Validation/CurrencyValidation.php | 4 +- app/Validation/FireflyValidator.php | 8 +- app/Validation/GroupValidation.php | 25 +++--- app/Validation/RecurrenceValidation.php | 49 ++++++------ app/Validation/TransactionValidation.php | 38 +++------ bootstrap/app.php | 8 -- config/app.php | 2 +- config/auth.php | 2 +- config/database.php | 16 ++-- config/debugbar.php | 2 +- config/session.php | 4 +- routes/channels.php | 2 +- routes/web.php | 2 +- .../Api/Chart/AccountControllerTest.php | 5 +- .../Api/Chart/BalanceControllerTest.php | 5 +- .../Api/Chart/BudgetControllerTest.php | 5 +- .../Api/Chart/CategoryControllerTest.php | 5 +- .../Api/Models/Account/ListControllerTest.php | 2 + .../Api/Models/Account/ShowControllerTest.php | 2 + .../Api/System/AboutControllerTest.php | 7 +- 209 files changed, 1021 insertions(+), 1248 deletions(-) diff --git a/app/Models/RecurrenceRepetition.php b/app/Models/RecurrenceRepetition.php index 52d8259877..3e11acc67e 100644 --- a/app/Models/RecurrenceRepetition.php +++ b/app/Models/RecurrenceRepetition.php @@ -82,21 +82,21 @@ class RecurrenceRepetition extends Model protected function recurrenceId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } protected function repetitionSkip(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } protected function weekend(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Models/RecurrenceTransaction.php b/app/Models/RecurrenceTransaction.php index c2d91a54ad..c1a1892b83 100644 --- a/app/Models/RecurrenceTransaction.php +++ b/app/Models/RecurrenceTransaction.php @@ -91,7 +91,7 @@ class RecurrenceTransaction extends Model protected function amount(): Attribute { return Attribute::make( - get: static fn ($value) => (string)$value, + get: static fn ($value): string => (string)$value, ); } @@ -110,42 +110,42 @@ class RecurrenceTransaction extends Model protected function destinationId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } protected function foreignAmount(): Attribute { return Attribute::make( - get: static fn ($value) => (string)$value, + get: static fn ($value): string => (string)$value, ); } protected function recurrenceId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } protected function sourceId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } protected function transactionCurrencyId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } protected function userId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Models/RecurrenceTransactionMeta.php b/app/Models/RecurrenceTransactionMeta.php index 442da02559..5ced2d13ae 100644 --- a/app/Models/RecurrenceTransactionMeta.php +++ b/app/Models/RecurrenceTransactionMeta.php @@ -58,7 +58,7 @@ class RecurrenceTransactionMeta extends Model protected function rtId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Models/Rule.php b/app/Models/Rule.php index d2c235f532..cffe9515e3 100644 --- a/app/Models/Rule.php +++ b/app/Models/Rule.php @@ -113,20 +113,20 @@ class Rule extends Model protected function description(): Attribute { - return Attribute::make(set: fn ($value) => ['description' => e($value)]); + return Attribute::make(set: fn ($value): array => ['description' => e($value)]); } protected function order(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } protected function ruleGroupId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Models/RuleAction.php b/app/Models/RuleAction.php index 0bb29a5236..3b706470b8 100644 --- a/app/Models/RuleAction.php +++ b/app/Models/RuleAction.php @@ -80,14 +80,14 @@ class RuleAction extends Model protected function order(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } protected function ruleId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Models/RuleGroup.php b/app/Models/RuleGroup.php index 16c87815bd..2236efbf1a 100644 --- a/app/Models/RuleGroup.php +++ b/app/Models/RuleGroup.php @@ -99,7 +99,7 @@ class RuleGroup extends Model protected function order(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Models/RuleTrigger.php b/app/Models/RuleTrigger.php index c3de8048ba..303ca028bb 100644 --- a/app/Models/RuleTrigger.php +++ b/app/Models/RuleTrigger.php @@ -53,14 +53,14 @@ class RuleTrigger extends Model protected function order(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } protected function ruleId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index e33cb0a1ac..90faba82d4 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -113,7 +113,7 @@ class Transaction extends Model protected function accountId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } @@ -151,14 +151,14 @@ class Transaction extends Model protected function amount(): Attribute { return Attribute::make( - get: static fn ($value) => (string)$value, + get: static fn ($value): string => (string)$value, ); } protected function balanceDirty(): Attribute { return Attribute::make( - get: static fn ($value) => 1 === (int)$value, + get: static fn ($value): bool => 1 === (int)$value, ); } @@ -201,14 +201,14 @@ class Transaction extends Model protected function foreignAmount(): Attribute { return Attribute::make( - get: static fn ($value) => (string)$value, + get: static fn ($value): string => (string)$value, ); } protected function transactionJournalId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } diff --git a/app/Models/TransactionCurrency.php b/app/Models/TransactionCurrency.php index 6f02375355..418442db77 100644 --- a/app/Models/TransactionCurrency.php +++ b/app/Models/TransactionCurrency.php @@ -115,7 +115,7 @@ class TransactionCurrency extends Model protected function decimalPlaces(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php index f6bd140648..6cab9c4e52 100644 --- a/app/Models/TransactionJournal.php +++ b/app/Models/TransactionJournal.php @@ -232,14 +232,14 @@ class TransactionJournal extends Model protected function order(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } protected function transactionTypeId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } diff --git a/app/Models/TransactionJournalLink.php b/app/Models/TransactionJournalLink.php index ab1a40c260..2bb5738c87 100644 --- a/app/Models/TransactionJournalLink.php +++ b/app/Models/TransactionJournalLink.php @@ -94,21 +94,21 @@ class TransactionJournalLink extends Model protected function destinationId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } protected function linkTypeId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } protected function sourceId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Models/TransactionJournalMeta.php b/app/Models/TransactionJournalMeta.php index 4a748bfb8b..25272f084b 100644 --- a/app/Models/TransactionJournalMeta.php +++ b/app/Models/TransactionJournalMeta.php @@ -57,7 +57,7 @@ class TransactionJournalMeta extends Model protected function data(): Attribute { - return Attribute::make(get: fn ($value) => json_decode((string)$value, false), set: function ($value) { + return Attribute::make(get: fn ($value): mixed => json_decode((string)$value, false), set: function ($value): array { $data = json_encode($value); return ['data' => $data, 'hash' => hash('sha256', $data)]; @@ -67,7 +67,7 @@ class TransactionJournalMeta extends Model protected function transactionJournalId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Models/WebhookAttempt.php b/app/Models/WebhookAttempt.php index a2de5dac3b..bd3f2b7866 100644 --- a/app/Models/WebhookAttempt.php +++ b/app/Models/WebhookAttempt.php @@ -68,7 +68,7 @@ class WebhookAttempt extends Model protected function webhookMessageId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Models/WebhookDelivery.php b/app/Models/WebhookDelivery.php index 33acf3b9b7..8ac1514a0a 100644 --- a/app/Models/WebhookDelivery.php +++ b/app/Models/WebhookDelivery.php @@ -41,7 +41,7 @@ class WebhookDelivery extends Model protected function key(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Models/WebhookMessage.php b/app/Models/WebhookMessage.php index dbccb97cbd..0209109c7d 100644 --- a/app/Models/WebhookMessage.php +++ b/app/Models/WebhookMessage.php @@ -89,14 +89,14 @@ class WebhookMessage extends Model protected function sent(): Attribute { return Attribute::make( - get: static fn ($value) => (bool)$value, + get: static fn ($value): bool => (bool)$value, ); } protected function webhookId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Models/WebhookResponse.php b/app/Models/WebhookResponse.php index 7b3e785a73..1cc885f9ef 100644 --- a/app/Models/WebhookResponse.php +++ b/app/Models/WebhookResponse.php @@ -41,7 +41,7 @@ class WebhookResponse extends Model protected function key(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Models/WebhookTrigger.php b/app/Models/WebhookTrigger.php index b7ccd7cfc5..7608d43d93 100644 --- a/app/Models/WebhookTrigger.php +++ b/app/Models/WebhookTrigger.php @@ -41,7 +41,7 @@ class WebhookTrigger extends Model protected function key(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Notifications/User/NewAccessToken.php b/app/Notifications/User/NewAccessToken.php index d6f4728e25..4c360da056 100644 --- a/app/Notifications/User/NewAccessToken.php +++ b/app/Notifications/User/NewAccessToken.php @@ -42,8 +42,6 @@ class NewAccessToken extends Notification { use Queueable; - public function __construct() {} - public function toArray(User $notifiable): array { return [ diff --git a/app/Notifications/User/UserRegistration.php b/app/Notifications/User/UserRegistration.php index fe0bbde10f..f00366f585 100644 --- a/app/Notifications/User/UserRegistration.php +++ b/app/Notifications/User/UserRegistration.php @@ -36,8 +36,6 @@ class UserRegistration extends Notification { use Queueable; - public function __construct() {} - /** * @SuppressWarnings("PHPMD.UnusedFormalParameter") */ diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 263342b753..70eb14d731 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -61,7 +61,7 @@ class AppServiceProvider extends ServiceProvider }); // blade extension - Blade::directive('activeXRoutePartial', function (string $route) { + Blade::directive('activeXRoutePartial', function (string $route): string { $name = Route::getCurrentRoute()->getName() ?? ''; if (str_contains($name, $route)) { return 'menu-open'; @@ -69,7 +69,7 @@ class AppServiceProvider extends ServiceProvider return ''; }); - Blade::if('partialroute', function (string $route, string $firstParam = '') { + Blade::if('partialroute', function (string $route, string $firstParam = ''): bool { $name = Route::getCurrentRoute()->getName() ?? ''; if ('' === $firstParam && str_contains($name, $route)) { return true; @@ -79,11 +79,7 @@ class AppServiceProvider extends ServiceProvider $params = Route::getCurrentRoute()->parameters(); $params ??= []; $objectType = $params['objectType'] ?? ''; - if ($objectType === $firstParam && str_contains($name, $route)) { - return true; - } - - return false; + return $objectType === $firstParam && str_contains($name, $route); }); } diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 9f39f3d8a8..621ed90117 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -48,12 +48,12 @@ class AuthServiceProvider extends ServiceProvider { Auth::provider( 'remote_user_provider', - static fn ($app, array $config) => new RemoteUserProvider() + static fn ($app, array $config): RemoteUserProvider => new RemoteUserProvider() ); Auth::extend( 'remote_user_guard', - static fn ($app, string $name, array $config) => new RemoteUserGuard(Auth::createUserProvider($config['provider']), $app) + static fn ($app, string $name, array $config): RemoteUserGuard => new RemoteUserGuard(Auth::createUserProvider($config['provider']), $app) ); Passport::tokensExpireIn(now()->addDays(14)); diff --git a/app/Providers/CurrencyServiceProvider.php b/app/Providers/CurrencyServiceProvider.php index 3b6a751b64..dbb917d293 100644 --- a/app/Providers/CurrencyServiceProvider.php +++ b/app/Providers/CurrencyServiceProvider.php @@ -51,7 +51,7 @@ class CurrencyServiceProvider extends ServiceProvider $this->app->bind( static function (Application $app): GroupCurrencyRepositoryInterface { /** @var CurrencyRepository $repository */ - $repository = app(CurrencyRepository::class); + $repository = app(GroupCurrencyRepository::class); // phpstan does not get the reference to auth if ($app->auth->check()) { // @phpstan-ignore-line $repository->setUser(auth()->user()); diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.php index cb9bebbbf4..7cd545d40f 100644 --- a/app/Providers/FireflyServiceProvider.php +++ b/app/Providers/FireflyServiceProvider.php @@ -93,7 +93,7 @@ class FireflyServiceProvider extends ServiceProvider public function boot(): void { Validator::resolver( - static fn ($translator, $data, $rules, $messages) => new FireflyValidator($translator, $data, $rules, $messages) + static fn ($translator, $data, $rules, $messages): FireflyValidator => new FireflyValidator($translator, $data, $rules, $messages) ); } @@ -107,52 +107,52 @@ class FireflyServiceProvider extends ServiceProvider { $this->app->bind( 'preferences', - static fn () => new Preferences() + static fn (): Preferences => new Preferences() ); $this->app->bind( 'fireflyconfig', - static fn () => new FireflyConfig() + static fn (): FireflyConfig => new FireflyConfig() ); $this->app->bind( 'navigation', - static fn () => new Navigation() + static fn (): Navigation => new Navigation() ); $this->app->bind( 'amount', - static fn () => new Amount() + static fn (): Amount => new Amount() ); $this->app->bind( 'steam', - static fn () => new Steam() + static fn (): Steam => new Steam() ); $this->app->bind( 'balance', - static fn () => new Balance() + static fn (): Balance => new Balance() ); $this->app->bind( 'expandedform', - static fn () => new ExpandedForm() + static fn (): ExpandedForm => new ExpandedForm() ); $this->app->bind( 'accountform', - static fn () => new AccountForm() + static fn (): AccountForm => new AccountForm() ); $this->app->bind( 'currencyform', - static fn () => new CurrencyForm() + static fn (): CurrencyForm => new CurrencyForm() ); $this->app->bind( 'piggybankform', - static fn () => new PiggyBankForm() + static fn (): PiggyBankForm => new PiggyBankForm() ); $this->app->bind( 'ruleform', - static fn () => new RuleForm() + static fn (): RuleForm => new RuleForm() ); // chart generator: diff --git a/app/Providers/FireflySessionProvider.php b/app/Providers/FireflySessionProvider.php index fee1b30ed6..6912eb254a 100644 --- a/app/Providers/FireflySessionProvider.php +++ b/app/Providers/FireflySessionProvider.php @@ -53,7 +53,7 @@ class FireflySessionProvider extends ServiceProvider { $this->app->singleton( 'session', - static fn ($app) => new SessionManager($app) + static fn ($app): SessionManager => new SessionManager($app) ); } diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index 8eacb438b4..546953a8c8 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -224,7 +224,7 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac $disk = Storage::disk('upload'); return $set->each( - static function (Attachment $attachment) use ($disk) { // @phpstan-ignore-line + static function (Attachment $attachment) use ($disk): Attachment { // @phpstan-ignore-line $notes = $attachment->notes()->first(); $attachment->file_exists = $disk->exists($attachment->fileName()); $attachment->notes_text = null !== $notes ? $notes->text : ''; @@ -414,7 +414,7 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac public function getMetaValue(Account $account, string $field): ?string { $result = $account->accountMeta->filter( - static fn (AccountMeta $meta) => strtolower($meta->name) === strtolower($field) + static fn (AccountMeta $meta): bool => strtolower($meta->name) === strtolower($field) ); if (0 === $result->count()) { return null; diff --git a/app/Repositories/Attachment/AttachmentRepository.php b/app/Repositories/Attachment/AttachmentRepository.php index cd0d3ea249..079b4b61dd 100644 --- a/app/Repositories/Attachment/AttachmentRepository.php +++ b/app/Repositories/Attachment/AttachmentRepository.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Repositories\Attachment; +use Illuminate\Support\Facades\Log; use Exception; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Factory\AttachmentFactory; @@ -78,7 +79,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface, UserGroupIn try { $unencryptedContent = Crypt::decrypt($encryptedContent); // verified } catch (DecryptException $e) { - app('log')->debug(sprintf('Could not decrypt attachment #%d but this is fine: %s', $attachment->id, $e->getMessage())); + Log::debug(sprintf('Could not decrypt attachment #%d but this is fine: %s', $attachment->id, $e->getMessage())); $unencryptedContent = $encryptedContent; } } @@ -161,7 +162,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface, UserGroupIn try { $dbNote->delete(); } catch (LogicException $e) { - app('log')->error($e->getMessage()); + Log::error($e->getMessage()); } } diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php index daa88a5a65..f33d339cc6 100644 --- a/app/Repositories/Bill/BillRepository.php +++ b/app/Repositories/Bill/BillRepository.php @@ -121,7 +121,7 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface if (null !== $billId) { $searchResult = $this->find($billId); if ($searchResult instanceof Bill) { - app('log')->debug(sprintf('Found bill based on #%d, will return it.', $billId)); + Log::debug(sprintf('Found bill based on #%d, will return it.', $billId)); return $searchResult; } @@ -129,12 +129,12 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface if (null !== $billName) { $searchResult = $this->findByName($billName); if ($searchResult instanceof Bill) { - app('log')->debug(sprintf('Found bill based on "%s", will return it.', $billName)); + Log::debug(sprintf('Found bill based on "%s", will return it.', $billName)); return $searchResult; } } - app('log')->debug('Found no bill in findBill()'); + Log::debug('Found no bill in findBill()'); return null; } @@ -166,7 +166,7 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface $disk = Storage::disk('upload'); return $set->each( - static function (Attachment $attachment) use ($disk) { // @phpstan-ignore-line + static function (Attachment $attachment) use ($disk): Attachment { // @phpstan-ignore-line $notes = $attachment->notes()->first(); $attachment->file_exists = $disk->exists($attachment->fileName()); $attachment->notes_text = null !== $notes ? $notes->text : ''; @@ -307,7 +307,7 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface */ public function getPaidDatesInRange(Bill $bill, Carbon $start, Carbon $end): Collection { - // app('log')->debug('Now in getPaidDatesInRange()'); + // \Illuminate\Support\Facades\Log::debug('Now in getPaidDatesInRange()'); Log::debug(sprintf('Search for linked journals between %s and %s', $start->toW3cString(), $end->toW3cString())); @@ -440,7 +440,7 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface $journal = $bill->user->transactionJournals()->find((int) $transaction['transaction_journal_id']); $journal->bill_id = $bill->id; $journal->save(); - app('log')->debug(sprintf('Linked journal #%d to bill #%d', $journal->id, $bill->id)); + Log::debug(sprintf('Linked journal #%d to bill #%d', $journal->id, $bill->id)); } } @@ -459,12 +459,12 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface // find the most recent date for this bill NOT in the future. Cache this date: $start = clone $bill->date; $start->startOfDay(); - app('log')->debug('nextExpectedMatch: Start is '.$start->format('Y-m-d')); + Log::debug('nextExpectedMatch: Start is '.$start->format('Y-m-d')); while ($start < $date) { - app('log')->debug(sprintf('$start (%s) < $date (%s)', $start->format('Y-m-d H:i:s'), $date->format('Y-m-d H:i:s'))); + Log::debug(sprintf('$start (%s) < $date (%s)', $start->format('Y-m-d H:i:s'), $date->format('Y-m-d H:i:s'))); $start = app('navigation')->addPeriod($start, $bill->repeat_freq, $bill->skip); - app('log')->debug('Start is now '.$start->format('Y-m-d H:i:s')); + Log::debug('Start is now '.$start->format('Y-m-d H:i:s')); } $end = app('navigation')->addPeriod($start, $bill->repeat_freq, $bill->skip); @@ -475,12 +475,12 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface if ($journalCount > 0) { // this period had in fact a bill. The new start is the current end, and we create a new end. - app('log')->debug(sprintf('Journal count is %d, so start becomes %s', $journalCount, $end->format('Y-m-d'))); + Log::debug(sprintf('Journal count is %d, so start becomes %s', $journalCount, $end->format('Y-m-d'))); $start = clone $end; $end = app('navigation')->addPeriod($start, $bill->repeat_freq, $bill->skip); } - app('log')->debug('nextExpectedMatch: Final start is '.$start->format('Y-m-d')); - app('log')->debug('nextExpectedMatch: Matching end is '.$end->format('Y-m-d')); + Log::debug('nextExpectedMatch: Final start is '.$start->format('Y-m-d')); + Log::debug('nextExpectedMatch: Matching end is '.$end->format('Y-m-d')); $cache->store($start); @@ -597,7 +597,7 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface public function sumUnpaidInRange(Carbon $start, Carbon $end): array { - app('log')->debug(sprintf('Now in sumUnpaidInRange("%s", "%s")', $start->format('Y-m-d'), $end->format('Y-m-d'))); + Log::debug(sprintf('Now in sumUnpaidInRange("%s", "%s")', $start->format('Y-m-d'), $end->format('Y-m-d'))); $bills = $this->getActiveBills(); $return = []; $convertToPrimary = Amount::convertToPrimary($this->user); @@ -605,12 +605,12 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface /** @var Bill $bill */ foreach ($bills as $bill) { - // app('log')->debug(sprintf('Processing bill #%d ("%s")', $bill->id, $bill->name)); + // \Illuminate\Support\Facades\Log::debug(sprintf('Processing bill #%d ("%s")', $bill->id, $bill->name)); $dates = $this->getPayDatesInRange($bill, $start, $end); $count = $bill->transactionJournals()->after($start)->before($end)->count(); $total = $dates->count() - $count; - // app('log')->debug(sprintf('Pay dates: %d, count: %d, left: %d', $dates->count(), $count, $total)); - // app('log')->debug('dates', $dates->toArray()); + // \Illuminate\Support\Facades\Log::debug(sprintf('Pay dates: %d, count: %d, left: %d', $dates->count(), $count, $total)); + // \Illuminate\Support\Facades\Log::debug('dates', $dates->toArray()); $minField = $convertToPrimary && $bill->transactionCurrency->id !== $primary->id ? 'native_amount_min' : 'amount_min'; $maxField = $convertToPrimary && $bill->transactionCurrency->id !== $primary->id ? 'native_amount_max' : 'amount_max'; @@ -642,21 +642,21 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface { $set = new Collection(); $currentStart = clone $start; - // app('log')->debug(sprintf('Now at bill "%s" (%s)', $bill->name, $bill->repeat_freq)); - // app('log')->debug(sprintf('First currentstart is %s', $currentStart->format('Y-m-d'))); + // \Illuminate\Support\Facades\Log::debug(sprintf('Now at bill "%s" (%s)', $bill->name, $bill->repeat_freq)); + // \Illuminate\Support\Facades\Log::debug(sprintf('First currentstart is %s', $currentStart->format('Y-m-d'))); while ($currentStart <= $end) { - // app('log')->debug(sprintf('Currentstart is now %s.', $currentStart->format('Y-m-d'))); + // \Illuminate\Support\Facades\Log::debug(sprintf('Currentstart is now %s.', $currentStart->format('Y-m-d'))); $nextExpectedMatch = $this->nextDateMatch($bill, $currentStart); - // app('log')->debug(sprintf('Next Date match after %s is %s', $currentStart->format('Y-m-d'), $nextExpectedMatch->format('Y-m-d'))); + // \Illuminate\Support\Facades\Log::debug(sprintf('Next Date match after %s is %s', $currentStart->format('Y-m-d'), $nextExpectedMatch->format('Y-m-d'))); if ($nextExpectedMatch > $end) {// If nextExpectedMatch is after end, we continue break; } $set->push(clone $nextExpectedMatch); - // app('log')->debug(sprintf('Now %d dates in set.', $set->count())); + // \Illuminate\Support\Facades\Log::debug(sprintf('Now %d dates in set.', $set->count())); $nextExpectedMatch->addDay(); - // app('log')->debug(sprintf('Currentstart (%s) has become %s.', $currentStart->format('Y-m-d'), $nextExpectedMatch->format('Y-m-d'))); + // \Illuminate\Support\Facades\Log::debug(sprintf('Currentstart (%s) has become %s.', $currentStart->format('Y-m-d'), $nextExpectedMatch->format('Y-m-d'))); $currentStart = clone $nextExpectedMatch; } diff --git a/app/Repositories/Budget/AvailableBudgetRepository.php b/app/Repositories/Budget/AvailableBudgetRepository.php index e992bff82d..1e1e7ed017 100644 --- a/app/Repositories/Budget/AvailableBudgetRepository.php +++ b/app/Repositories/Budget/AvailableBudgetRepository.php @@ -53,7 +53,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface, U $end = $availableBudget->end_date->format('Y-m-d'); $key = sprintf('%s-%s-%s', $availableBudget->transaction_currency_id, $start, $end); if (array_key_exists($key, $exists)) { - app('log')->debug(sprintf('Found duplicate AB: %s %s, %s-%s. Has been deleted', $availableBudget->transaction_currency_id, $availableBudget->amount, $start, $end)); + Log::debug(sprintf('Found duplicate AB: %s %s, %s-%s. Has been deleted', $availableBudget->transaction_currency_id, $availableBudget->amount, $start, $end)); $availableBudget->delete(); } $exists[$key] = true; diff --git a/app/Repositories/Budget/BudgetLimitRepository.php b/app/Repositories/Budget/BudgetLimitRepository.php index ab80405609..443f25677c 100644 --- a/app/Repositories/Budget/BudgetLimitRepository.php +++ b/app/Repositories/Budget/BudgetLimitRepository.php @@ -130,7 +130,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface, UserGroup public function getAllBudgetLimitsByCurrency(TransactionCurrency $currency, ?Carbon $start = null, ?Carbon $end = null): Collection { return $this->getAllBudgetLimits($start, $end)->filter( - static fn (BudgetLimit $budgetLimit) => $budgetLimit->transaction_currency_id === $currency->id + static fn (BudgetLimit $budgetLimit): bool => $budgetLimit->transaction_currency_id === $currency->id ); } diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php index 0b2d41395d..3714176818 100644 --- a/app/Repositories/Budget/BudgetRepository.php +++ b/app/Repositories/Budget/BudgetRepository.php @@ -307,7 +307,7 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface $autoBudget = $this->getAutoBudget($budget); // first things first: delete when no longer required: - $autoBudgetType = array_key_exists('auto_budget_type', $data) ? $data['auto_budget_type'] : null; + $autoBudgetType = $data['auto_budget_type'] ?? null; if (0 === $autoBudgetType && $autoBudget instanceof AutoBudget) { // delete! @@ -534,7 +534,7 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface $disk = Storage::disk('upload'); return $set->each( - static function (Attachment $attachment) use ($disk) { // @phpstan-ignore-line + static function (Attachment $attachment) use ($disk): Attachment { // @phpstan-ignore-line $notes = $attachment->notes()->first(); $attachment->file_exists = $disk->exists($attachment->fileName()); $attachment->notes_text = null !== $notes ? $notes->text : ''; diff --git a/app/Repositories/Budget/OperationsRepository.php b/app/Repositories/Budget/OperationsRepository.php index badde3a9fb..157e9ca4af 100644 --- a/app/Repositories/Budget/OperationsRepository.php +++ b/app/Repositories/Budget/OperationsRepository.php @@ -54,7 +54,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn */ public function budgetedPerDay(Budget $budget): string { - app('log')->debug(sprintf('Now with budget #%d "%s"', $budget->id, $budget->name)); + Log::debug(sprintf('Now with budget #%d "%s"', $budget->id, $budget->name)); $total = '0'; $count = 0; foreach ($budget->budgetlimits as $limit) { @@ -64,13 +64,13 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn $perDay = bcdiv((string) $amount, (string) $diff); $total = bcadd($total, $perDay); ++$count; - app('log')->debug(sprintf('Found %d budget limits. Per day is %s, total is %s', $count, $perDay, $total)); + Log::debug(sprintf('Found %d budget limits. Per day is %s, total is %s', $count, $perDay, $total)); } $avg = $total; if ($count > 0) { $avg = bcdiv($total, (string) $count); } - app('log')->debug(sprintf('%s / %d = %s = average.', $total, $count, $avg)); + Log::debug(sprintf('%s / %d = %s = average.', $total, $count, $avg)); return $avg; } diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.php index 6b1f75a91c..360e2a5409 100644 --- a/app/Repositories/Category/CategoryRepository.php +++ b/app/Repositories/Category/CategoryRepository.php @@ -108,11 +108,11 @@ class CategoryRepository implements CategoryRepositoryInterface, UserGroupInterf */ public function findCategory(?int $categoryId, ?string $categoryName): ?Category { - app('log')->debug('Now in findCategory()'); - app('log')->debug(sprintf('Searching for category with ID #%d...', $categoryId)); + Log::debug('Now in findCategory()'); + Log::debug(sprintf('Searching for category with ID #%d...', $categoryId)); $result = $this->find((int) $categoryId); if (!$result instanceof Category) { - app('log')->debug(sprintf('Searching for category with name %s...', $categoryName)); + Log::debug(sprintf('Searching for category with name %s...', $categoryName)); $result = $this->findByName((string) $categoryName); if (!$result instanceof Category && '' !== (string) $categoryName) { // create it! @@ -120,9 +120,9 @@ class CategoryRepository implements CategoryRepositoryInterface, UserGroupInterf } } if ($result instanceof Category) { - app('log')->debug(sprintf('Found category #%d: %s', $result->id, $result->name)); + Log::debug(sprintf('Found category #%d: %s', $result->id, $result->name)); } - app('log')->debug(sprintf('Found category result is null? %s', var_export(!$result instanceof Category, true))); + Log::debug(sprintf('Found category result is null? %s', var_export(!$result instanceof Category, true))); return $result; } @@ -240,7 +240,7 @@ class CategoryRepository implements CategoryRepositoryInterface, UserGroupInterf $disk = Storage::disk('upload'); return $set->each( - static function (Attachment $attachment) use ($disk) { // @phpstan-ignore-line + static function (Attachment $attachment) use ($disk): Attachment { // @phpstan-ignore-line $notes = $attachment->notes()->first(); $attachment->file_exists = $disk->exists($attachment->fileName()); $attachment->notes_text = null !== $notes ? $notes->text : ''; diff --git a/app/Repositories/Currency/CurrencyRepository.php b/app/Repositories/Currency/CurrencyRepository.php index eacd820c34..942bdccd5d 100644 --- a/app/Repositories/Currency/CurrencyRepository.php +++ b/app/Repositories/Currency/CurrencyRepository.php @@ -183,9 +183,9 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf $all = TransactionCurrency::orderBy('code', 'ASC')->get(); $local = $this->get(); - return $all->map(static function (TransactionCurrency $current) use ($local) { - $hasId = $local->contains(static fn (TransactionCurrency $entry) => $entry->id === $current->id); - $isPrimary = $local->contains(static fn (TransactionCurrency $entry) => 1 === (int)$entry->pivot->group_default && $entry->id === $current->id); + return $all->map(static function (TransactionCurrency $current) use ($local): TransactionCurrency { + $hasId = $local->contains(static fn (TransactionCurrency $entry): bool => $entry->id === $current->id); + $isPrimary = $local->contains(static fn (TransactionCurrency $entry): bool => 1 === (int)$entry->pivot->group_default && $entry->id === $current->id); $current->userGroupEnabled = $hasId; $current->userGroupNative = $isPrimary; @@ -196,14 +196,13 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf public function get(): Collection { $all = $this->userGroup->currencies()->orderBy('code', 'ASC')->withPivot(['group_default'])->get(); - $all->map(static function (TransactionCurrency $current) { // @phpstan-ignore-line + $all->map(static function (TransactionCurrency $current): TransactionCurrency { // @phpstan-ignore-line $current->userGroupEnabled = true; $current->userGroupNative = 1 === (int)$current->pivot->group_default; return $current; }); - /** @var Collection */ return $all; } @@ -402,7 +401,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf { Log::debug('Now in update()'); // can be true, false, null - $enabled = array_key_exists('enabled', $data) ? $data['enabled'] : null; + $enabled = $data['enabled'] ?? null; // can be true, false, but method only responds to "true". $default = array_key_exists('default', $data) ? $data['default'] : false; diff --git a/app/Repositories/Journal/JournalAPIRepository.php b/app/Repositories/Journal/JournalAPIRepository.php index 97efb75814..5a6dccdb64 100644 --- a/app/Repositories/Journal/JournalAPIRepository.php +++ b/app/Repositories/Journal/JournalAPIRepository.php @@ -65,7 +65,7 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface, UserGroupIn $disk = Storage::disk('upload'); return $set->each( - static function (Attachment $attachment) use ($disk) { + static function (Attachment $attachment) use ($disk): Attachment { $notes = $attachment->notes()->first(); $attachment->file_exists = $disk->exists($attachment->fileName()); $attachment->notes_text = null !== $notes ? $notes->text : ''; // TODO should not set notes like this. diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php index aee44f902b..f6c99daa4b 100644 --- a/app/Repositories/Journal/JournalRepository.php +++ b/app/Repositories/Journal/JournalRepository.php @@ -78,11 +78,7 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac { /** @var null|TransactionJournal $entry */ $entry = $this->user->transactionJournals()->orderBy('date', 'ASC')->first(['transaction_journals.*']); - if (null !== $entry) { - return $entry; - } - - return null; + return $entry; } public function getDestinationAccount(TransactionJournal $journal): Account @@ -120,11 +116,7 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac { /** @var null|TransactionJournal $entry */ $entry = $this->user->transactionJournals()->orderBy('date', 'DESC')->first(['transaction_journals.*']); - if (null !== $entry) { - return $entry; - } - - return null; + return $entry; } public function getLinkNoteText(TransactionJournalLink $link): string diff --git a/app/Repositories/LinkType/LinkTypeRepository.php b/app/Repositories/LinkType/LinkTypeRepository.php index 1110eb62ee..e978381255 100644 --- a/app/Repositories/LinkType/LinkTypeRepository.php +++ b/app/Repositories/LinkType/LinkTypeRepository.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Repositories\LinkType; +use Illuminate\Support\Facades\Log; use Exception; use FireflyIII\Models\LinkType; use FireflyIII\Models\Note; @@ -85,7 +86,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf */ public function findLink(TransactionJournal $one, TransactionJournal $two): bool { - app('log')->debug(sprintf('Now in findLink(%d, %d)', $one->id, $two->id)); + Log::debug(sprintf('Now in findLink(%d, %d)', $one->id, $two->id)); $count = TransactionJournalLink::whereDestinationId($one->id)->whereSourceId($two->id)->count(); $opposingCount = TransactionJournalLink::whereDestinationId($two->id)->whereSourceId($one->id)->count(); @@ -150,7 +151,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf $merged = $outward->merge($inward); return $merged->filter( - static fn (TransactionJournalLink $link) => null !== $link->source && null !== $link->destination + static fn (TransactionJournalLink $link): bool => null !== $link->source && null !== $link->destination ); } @@ -192,13 +193,13 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf $link = new TransactionJournalLink(); $link->linkType()->associate($linkType); if ('inward' === $information['direction']) { - app('log')->debug(sprintf('Link type is inwards ("%s"), so %d is source and %d is destination.', $linkType->inward, $inward->id, $outward->id)); + Log::debug(sprintf('Link type is inwards ("%s"), so %d is source and %d is destination.', $linkType->inward, $inward->id, $outward->id)); $link->source()->associate($inward); $link->destination()->associate($outward); } if ('outward' === $information['direction']) { - app('log')->debug(sprintf('Link type is inwards ("%s"), so %d is source and %d is destination.', $linkType->outward, $outward->id, $inward->id)); + Log::debug(sprintf('Link type is inwards ("%s"), so %d is source and %d is destination.', $linkType->outward, $outward->id, $inward->id)); $link->source()->associate($outward); $link->destination()->associate($inward); } diff --git a/app/Repositories/ObjectGroup/ObjectGroupRepository.php b/app/Repositories/ObjectGroup/ObjectGroupRepository.php index 4299155670..cd996dea24 100644 --- a/app/Repositories/ObjectGroup/ObjectGroupRepository.php +++ b/app/Repositories/ObjectGroup/ObjectGroupRepository.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Repositories\ObjectGroup; +use Illuminate\Support\Facades\Log; use FireflyIII\Models\ObjectGroup; use FireflyIII\Models\PiggyBank; use FireflyIII\Support\Repositories\UserGroup\UserGroupInterface; @@ -96,14 +97,14 @@ class ObjectGroupRepository implements ObjectGroupRepositoryInterface, UserGroup public function resetOrder(): void { - app('log')->debug('Now in resetOrder'); + Log::debug('Now in resetOrder'); $list = $this->get(); $index = 1; /** @var ObjectGroup $objectGroup */ foreach ($list as $objectGroup) { if ($index !== $objectGroup->order) { - app('log')->debug( + Log::debug( sprintf('objectGroup #%d ("%s"): order should %d be but is %d.', $objectGroup->id, $objectGroup->title, $index, $objectGroup->order) ); $objectGroup->order = $index; @@ -166,7 +167,7 @@ class ObjectGroupRepository implements ObjectGroupRepositoryInterface, UserGroup $objectGroup->save(); } - app('log')->debug(sprintf('Objectgroup #%d order is now %d', $objectGroup->id, $newOrder)); + Log::debug(sprintf('Objectgroup #%d order is now %d', $objectGroup->id, $newOrder)); return $objectGroup; } diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php index 022de3a98c..fb4c4e7305 100644 --- a/app/Repositories/PiggyBank/PiggyBankRepository.php +++ b/app/Repositories/PiggyBank/PiggyBankRepository.php @@ -118,7 +118,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface, UserGroupInte $disk = Storage::disk('upload'); return $set->each( - static function (Attachment $attachment) use ($disk) { // @phpstan-ignore-line + static function (Attachment $attachment) use ($disk): Attachment { // @phpstan-ignore-line $notes = $attachment->notes()->first(); $attachment->file_exists = $disk->exists($attachment->fileName()); $attachment->notes_text = null !== $notes ? $notes->text : ''; diff --git a/app/Repositories/Recurring/RecurringRepository.php b/app/Repositories/Recurring/RecurringRepository.php index 4e8a67ec0d..9726e41297 100644 --- a/app/Repositories/Recurring/RecurringRepository.php +++ b/app/Repositories/Recurring/RecurringRepository.php @@ -79,7 +79,7 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte foreach ($set as $journalMeta) { $count = TransactionJournalMeta::where(static function (Builder $q2) use ($date): void { $string = (string) $date; - app('log')->debug(sprintf('Search for date: %s', json_encode($string))); + Log::debug(sprintf('Search for date: %s', json_encode($string))); $q2->where('name', 'recurrence_date'); $q2->where('data', json_encode($string)); }) @@ -87,7 +87,7 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte ->count() ; if ($count > 0) { - app('log')->debug(sprintf('Looks like journal #%d was already created', $journalMeta->transaction_journal_id)); + Log::debug(sprintf('Looks like journal #%d was already created', $journalMeta->transaction_journal_id)); return true; } @@ -373,7 +373,7 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte */ public function getXOccurrencesSince(RecurrenceRepetition $repetition, Carbon $date, Carbon $afterDate, int $count): array { - app('log')->debug('Now in getXOccurrencesSince()'); + Log::debug('Now in getXOccurrencesSince()'); $skipMod = $repetition->repetition_skip + 1; $occurrences = []; @@ -433,7 +433,7 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte */ public function repetitionDescription(RecurrenceRepetition $repetition): string { - app('log')->debug('Now in repetitionDescription()'); + Log::debug('Now in repetitionDescription()'); /** @var Preference $pref */ $pref = app('preferences')->getForUser($this->user, 'language', config('firefly.default_language', 'en_US')); @@ -546,8 +546,8 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte $mutator = clone $start; $mutator->startOfDay(); $skipMod = $repetition->repetition_skip + 1; - app('log')->debug(sprintf('Calculating occurrences for rep type "%s"', $repetition->repetition_type)); - app('log')->debug(sprintf('Mutator is now: %s', $mutator->format('Y-m-d'))); + Log::debug(sprintf('Calculating occurrences for rep type "%s"', $repetition->repetition_type)); + Log::debug(sprintf('Mutator is now: %s', $mutator->format('Y-m-d'))); if ('daily' === $repetition->repetition_type) { $occurrences = $this->getDailyInRange($mutator, $end, $skipMod); diff --git a/app/Repositories/Rule/RuleRepository.php b/app/Repositories/Rule/RuleRepository.php index e8435dc6c2..7954bacf39 100644 --- a/app/Repositories/Rule/RuleRepository.php +++ b/app/Repositories/Rule/RuleRepository.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Repositories\Rule; +use Illuminate\Support\Facades\Log; use Exception; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\Rule; @@ -261,9 +262,9 @@ class RuleRepository implements RuleRepositoryInterface, UserGroupInterface // reset order: $this->resetRuleOrder($ruleGroup); - app('log')->debug('Done with resetting.'); + Log::debug('Done with resetting.'); if (array_key_exists('order', $data)) { - app('log')->debug(sprintf('User has submitted order %d', $data['order'])); + Log::debug(sprintf('User has submitted order %d', $data['order'])); $this->setOrder($rule, $data['order']); } @@ -318,7 +319,7 @@ class RuleRepository implements RuleRepositoryInterface, UserGroupInterface $groupId = $rule->rule_group_id; $maxOrder = $this->maxOrder($rule->ruleGroup); $newOrder = $newOrder > $maxOrder ? $maxOrder + 1 : $newOrder; - app('log')->debug(sprintf('New order will be %d', $newOrder)); + Log::debug(sprintf('New order will be %d', $newOrder)); if ($newOrder > $oldOrder) { $this->user->rules() @@ -329,7 +330,7 @@ class RuleRepository implements RuleRepositoryInterface, UserGroupInterface ->decrement('rules.order') ; $rule->order = $newOrder; - app('log')->debug(sprintf('Order of rule #%d ("%s") is now %d', $rule->id, $rule->title, $newOrder)); + Log::debug(sprintf('Order of rule #%d ("%s") is now %d', $rule->id, $rule->title, $newOrder)); $rule->save(); return; @@ -343,7 +344,7 @@ class RuleRepository implements RuleRepositoryInterface, UserGroupInterface ->increment('rules.order') ; $rule->order = $newOrder; - app('log')->debug(sprintf('Order of rule #%d ("%s") is now %d', $rule->id, $rule->title, $newOrder)); + Log::debug(sprintf('Order of rule #%d ("%s") is now %d', $rule->id, $rule->title, $newOrder)); $rule->save(); } diff --git a/app/Repositories/RuleGroup/RuleGroupRepository.php b/app/Repositories/RuleGroup/RuleGroupRepository.php index 37b6066a64..ead89a1b91 100644 --- a/app/Repositories/RuleGroup/RuleGroupRepository.php +++ b/app/Repositories/RuleGroup/RuleGroupRepository.php @@ -280,11 +280,11 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface, UserGroupInte Log::debug(sprintf('Will filter getRuleGroupsWithRules on "%s".', $filter)); return $groups->map( - static function (RuleGroup $group) use ($filter) { // @phpstan-ignore-line + static function (RuleGroup $group) use ($filter): RuleGroup { // @phpstan-ignore-line Log::debug(sprintf('Now filtering group #%d', $group->id)); // filter the rules in the rule group: $group->rules = $group->rules->filter( - static function (Rule $rule) use ($filter, $group) { + static function (Rule $rule) use ($filter, $group): bool { Log::debug(sprintf('Now filtering rule #%d', $rule->id)); foreach ($rule->ruleTriggers as $trigger) { if ('user_action' === $trigger->trigger_type && $filter === $trigger->trigger_value) { @@ -337,11 +337,11 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface, UserGroupInte Log::debug(sprintf('Will filter getRuleGroupsWithRules on "%s".', $filter)); return $groups->map( - static function (RuleGroup $group) use ($filter) { // @phpstan-ignore-line + static function (RuleGroup $group) use ($filter): RuleGroup { // @phpstan-ignore-line Log::debug(sprintf('Now filtering group #%d', $group->id)); // filter the rules in the rule group: $group->rules = $group->rules->filter( - static function (Rule $rule) use ($filter, $group) { + static function (Rule $rule) use ($filter, $group): bool { Log::debug(sprintf('Now filtering rule #%d', $rule->id)); foreach ($rule->ruleTriggers as $trigger) { if ('user_action' === $trigger->trigger_type && $filter === $trigger->trigger_value) { diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php index b900e9143a..c7a51f7ef7 100644 --- a/app/Repositories/Tag/TagRepository.php +++ b/app/Repositories/Tag/TagRepository.php @@ -110,7 +110,6 @@ class TagRepository implements TagRepositoryInterface, UserGroupInterface public function firstUseDate(Tag $tag): ?Carbon { - /** @var null|Carbon */ return $tag->transactionJournals()->orderBy('date', 'ASC')->first()?->date; } @@ -137,13 +136,13 @@ class TagRepository implements TagRepositoryInterface, UserGroupInterface // add date range (or not): if (null === $year) { - app('log')->debug('Get tags without a date.'); + Log::debug('Get tags without a date.'); $tagQuery->whereNull('tags.date'); } if (null !== $year) { $year = min(2038, max(1970, $year)); - app('log')->debug(sprintf('Get tags with year %s.', $year)); + Log::debug(sprintf('Get tags with year %s.', $year)); $tagQuery->where('tags.date', '>=', sprintf('%d-01-01 00:00:00', $year))->where('tags.date', '<=', sprintf('%d-12-31 23:59:59', $year)); } $collection = $tagQuery->get(); @@ -177,7 +176,6 @@ class TagRepository implements TagRepositoryInterface, UserGroupInterface public function lastUseDate(Tag $tag): ?Carbon { - /** @var null|Carbon */ return $tag->transactionJournals()->orderBy('date', 'DESC')->first()?->date; } diff --git a/app/Repositories/TransactionGroup/TransactionGroupRepository.php b/app/Repositories/TransactionGroup/TransactionGroupRepository.php index fbf45efb73..e2f3842a54 100644 --- a/app/Repositories/TransactionGroup/TransactionGroupRepository.php +++ b/app/Repositories/TransactionGroup/TransactionGroupRepository.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Repositories\TransactionGroup; +use Illuminate\Support\Facades\Log; use Carbon\Carbon; use Exception; use FireflyIII\Enums\TransactionTypeEnum; @@ -78,7 +79,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface, public function destroy(TransactionGroup $group): void { - app('log')->debug(sprintf('Now in %s', __METHOD__)); + Log::debug(sprintf('Now in %s', __METHOD__)); $service = new TransactionGroupDestroyService(); $service->destroy($group); } @@ -406,13 +407,13 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface, try { return $factory->create($data); } catch (DuplicateTransactionException $e) { - app('log')->warning('Group repository caught group factory with a duplicate exception!'); + Log::warning('Group repository caught group factory with a duplicate exception!'); throw new DuplicateTransactionException($e->getMessage(), 0, $e); } catch (FireflyException $e) { - app('log')->warning('Group repository caught group factory with an exception!'); - app('log')->error($e->getMessage()); - app('log')->error($e->getTraceAsString()); + Log::warning('Group repository caught group factory with an exception!'); + Log::error($e->getMessage()); + Log::error($e->getTraceAsString()); throw new FireflyException($e->getMessage(), 0, $e); } diff --git a/app/Repositories/TransactionType/TransactionTypeRepository.php b/app/Repositories/TransactionType/TransactionTypeRepository.php index 55c0e2abe5..ffd2860e1e 100644 --- a/app/Repositories/TransactionType/TransactionTypeRepository.php +++ b/app/Repositories/TransactionType/TransactionTypeRepository.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Repositories\TransactionType; +use Illuminate\Support\Facades\Log; use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Models\TransactionType; use Illuminate\Support\Collection; @@ -35,9 +36,9 @@ class TransactionTypeRepository implements TransactionTypeRepositoryInterface { public function findTransactionType(?TransactionType $type, ?string $typeString): TransactionType { - app('log')->debug('Now looking for a transaction type.'); + Log::debug('Now looking for a transaction type.'); if ($type instanceof TransactionType) { - app('log')->debug(sprintf('Found $type in parameters, its %s. Will return it.', $type->type)); + Log::debug(sprintf('Found $type in parameters, its %s. Will return it.', $type->type)); return $type; } @@ -46,7 +47,7 @@ class TransactionTypeRepository implements TransactionTypeRepositoryInterface if (!$search instanceof TransactionType) { $search = $this->findByType(TransactionTypeEnum::WITHDRAWAL->value); } - app('log')->debug(sprintf('Tried to search for "%s", came up with "%s". Will return it.', $typeString, $search->type)); + Log::debug(sprintf('Tried to search for "%s", came up with "%s". Will return it.', $typeString, $search->type)); return $search; } diff --git a/app/Repositories/User/UserRepository.php b/app/Repositories/User/UserRepository.php index da82fe44ad..be9abaf4df 100644 --- a/app/Repositories/User/UserRepository.php +++ b/app/Repositories/User/UserRepository.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Repositories\User; +use Illuminate\Support\Facades\Log; use Carbon\Carbon; use Exception; use FireflyIII\Exceptions\FireflyException; @@ -97,7 +98,7 @@ class UserRepository implements UserRepositoryInterface public function deleteInvite(InvitedUser $invite): void { - app('log')->debug(sprintf('Deleting invite #%d', $invite->id)); + Log::debug(sprintf('Deleting invite #%d', $invite->id)); $invite->delete(); } @@ -106,7 +107,7 @@ class UserRepository implements UserRepositoryInterface */ public function destroy(User $user): bool { - app('log')->debug(sprintf('Calling delete() on user %d', $user->id)); + Log::debug(sprintf('Calling delete() on user %d', $user->id)); $user->groupMemberships()->delete(); $user->delete(); @@ -123,7 +124,7 @@ class UserRepository implements UserRepositoryInterface foreach ($groups as $group) { $count = $group->groupMemberships()->count(); if (0 === $count) { - app('log')->info(sprintf('Deleted empty group #%d ("%s")', $group->id, $group->title)); + Log::info(sprintf('Deleted empty group #%d ("%s")', $group->id, $group->title)); $group->delete(); } } @@ -198,33 +199,12 @@ class UserRepository implements UserRepositoryInterface */ public function getUserData(User $user): array { - $return = []; - - // two factor: - $return['has_2fa'] = null !== $user->mfa_secret; - $return['is_admin'] = $this->hasRole($user, 'owner'); - $return['blocked'] = 1 === (int) $user->blocked; - $return['blocked_code'] = $user->blocked_code; - $return['accounts'] = $user->accounts()->count(); - $return['journals'] = $user->transactionJournals()->count(); - $return['transactions'] = $user->transactions()->count(); - $return['attachments'] = $user->attachments()->count(); - $return['attachments_size'] = $user->attachments()->sum('size'); - $return['bills'] = $user->bills()->count(); - $return['categories'] = $user->categories()->count(); - $return['budgets'] = $user->budgets()->count(); - $return['budgets_with_limits'] = BudgetLimit::distinct() + return ['has_2fa' => null !== $user->mfa_secret, 'is_admin' => $this->hasRole($user, 'owner'), 'blocked' => 1 === (int) $user->blocked, 'blocked_code' => $user->blocked_code, 'accounts' => $user->accounts()->count(), 'journals' => $user->transactionJournals()->count(), 'transactions' => $user->transactions()->count(), 'attachments' => $user->attachments()->count(), 'attachments_size' => $user->attachments()->sum('size'), 'bills' => $user->bills()->count(), 'categories' => $user->categories()->count(), 'budgets' => $user->budgets()->count(), 'budgets_with_limits' => BudgetLimit::distinct() ->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id') ->where('amount', '>', 0) ->whereNull('budgets.deleted_at') ->where('budgets.user_id', $user->id) - ->count('budget_limits.budget_id') - ; - $return['rule_groups'] = $user->ruleGroups()->count(); - $return['rules'] = $user->rules()->count(); - $return['tags'] = $user->tags()->count(); - - return $return; + ->count('budget_limits.budget_id'), 'rule_groups' => $user->ruleGroups()->count(), 'rules' => $user->rules()->count(), 'tags' => $user->tags()->count()]; } public function hasRole(Authenticatable|User|null $user, string $role): bool @@ -327,7 +307,7 @@ class UserRepository implements UserRepositoryInterface { $roleObject = Role::where('name', $role)->first(); if (null === $roleObject) { - app('log')->error(sprintf('Could not find role "%s" in attachRole()', $role)); + Log::error(sprintf('Could not find role "%s" in attachRole()', $role)); return false; } @@ -336,7 +316,7 @@ class UserRepository implements UserRepositoryInterface $user->roles()->attach($roleObject); } catch (QueryException $e) { // don't care - app('log')->error(sprintf('Query exception when giving user a role: %s', $e->getMessage())); + Log::error(sprintf('Query exception when giving user a role: %s', $e->getMessage())); } return true; diff --git a/app/Repositories/UserGroup/UserGroupRepository.php b/app/Repositories/UserGroup/UserGroupRepository.php index 80b3fc459c..273b74eccf 100644 --- a/app/Repositories/UserGroup/UserGroupRepository.php +++ b/app/Repositories/UserGroup/UserGroupRepository.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Repositories\UserGroup; +use Illuminate\Support\Facades\Log; use FireflyIII\Enums\UserRoleEnum; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Factory\UserGroupFactory; @@ -47,7 +48,7 @@ class UserGroupRepository implements UserGroupRepositoryInterface, UserGroupInte public function destroy(UserGroup $userGroup): void { - app('log')->debug(sprintf('Going to destroy user group #%d ("%s").', $userGroup->id, $userGroup->title)); + Log::debug(sprintf('Going to destroy user group #%d ("%s").', $userGroup->id, $userGroup->title)); $memberships = $userGroup->groupMemberships()->get(); /** @var GroupMembership $membership */ @@ -57,19 +58,19 @@ class UserGroupRepository implements UserGroupRepositoryInterface, UserGroupInte if (null === $user) { continue; } - app('log')->debug(sprintf('Processing membership #%d (user #%d "%s")', $membership->id, $user->id, $user->email)); + Log::debug(sprintf('Processing membership #%d (user #%d "%s")', $membership->id, $user->id, $user->email)); // user has memberships of other groups? $count = $user->groupMemberships()->where('user_group_id', '!=', $userGroup->id)->count(); if (0 === $count) { - app('log')->debug('User has no other memberships and needs a new user group.'); + Log::debug('User has no other memberships and needs a new user group.'); $newUserGroup = $this->createNewUserGroup($user); $user->user_group_id = $newUserGroup->id; $user->save(); - app('log')->debug(sprintf('Make new group #%d ("%s")', $newUserGroup->id, $newUserGroup->title)); + Log::debug(sprintf('Make new group #%d ("%s")', $newUserGroup->id, $newUserGroup->title)); } // user has other memberships, select one at random and assign it to the user. if ($count > 0) { - app('log')->debug('User has other memberships and will be assigned a new administration.'); + Log::debug('User has other memberships and will be assigned a new administration.'); /** @var GroupMembership $first */ $first = $user->groupMemberships()->where('user_group_id', '!=', $userGroup->id)->inRandomOrder()->first(); @@ -91,7 +92,7 @@ class UserGroupRepository implements UserGroupRepositoryInterface, UserGroupInte } } $userGroup->delete(); - app('log')->debug('Done!'); + Log::debug('Done!'); } /** @@ -216,23 +217,23 @@ class UserGroupRepository implements UserGroupRepositoryInterface, UserGroupInte public function updateMembership(UserGroup $userGroup, array $data): UserGroup { $owner = UserRole::whereTitle(UserRoleEnum::OWNER)->first(); - app('log')->debug('in update membership'); + Log::debug('in update membership'); /** @var null|User $user */ $user = null; if (array_key_exists('id', $data)) { /** @var null|User $user */ $user = User::find($data['id']); - app('log')->debug('Found user by ID'); + Log::debug('Found user by ID'); } if (array_key_exists('email', $data) && '' !== (string)$data['email']) { /** @var null|User $user */ $user = User::whereEmail($data['email'])->first(); - app('log')->debug('Found user by email'); + Log::debug('Found user by email'); } if (null === $user) { // should throw error, but validator already catches this. - app('log')->debug('No user found'); + Log::debug('No user found'); return $userGroup; } @@ -244,13 +245,13 @@ class UserGroupRepository implements UserGroupRepositoryInterface, UserGroupInte $lastUserId = $userGroup->groupMemberships()->distinct()->first(['group_memberships.user_id'])->user_id; // if this is also the user we're editing right now, and we remove all of their roles: if ($lastUserId === (int)$user->id && 0 === count($data['roles'])) { - app('log')->debug('User is last in this group, refuse to act'); + Log::debug('User is last in this group, refuse to act'); throw new FireflyException('You cannot remove the last member from this user group. Delete the user group instead.'); } // if this is also the user we're editing right now, and do not grant them the owner role: if ($lastUserId === (int)$user->id && count($data['roles']) > 0 && !in_array(UserRoleEnum::OWNER->value, $data['roles'], true)) { - app('log')->debug('User needs to have owner role in this group, refuse to act'); + Log::debug('User needs to have owner role in this group, refuse to act'); throw new FireflyException('The last member in this user group must get or keep the "owner" role.'); } @@ -267,7 +268,7 @@ class UserGroupRepository implements UserGroupRepositoryInterface, UserGroupInte && (0 === count($data['roles']) || (count($data['roles']) > 0 // @phpstan-ignore-line && !in_array(UserRoleEnum::OWNER->value, $data['roles'], true)))) { - app('log')->debug('User needs to keep owner role in this group, refuse to act'); + Log::debug('User needs to keep owner role in this group, refuse to act'); throw new FireflyException('The last owner in this user group must keep the "owner" role.'); } @@ -294,12 +295,12 @@ class UserGroupRepository implements UserGroupRepositoryInterface, UserGroupInte private function simplifyListByName(array $roles): array { if (in_array(UserRoleEnum::OWNER->value, $roles, true)) { - app('log')->debug(sprintf('List of roles is [%1$s] but this includes "%2$s", so return [%2$s]', implode(',', $roles), UserRoleEnum::OWNER->value)); + Log::debug(sprintf('List of roles is [%1$s] but this includes "%2$s", so return [%2$s]', implode(',', $roles), UserRoleEnum::OWNER->value)); return [UserRoleEnum::OWNER->value]; } if (in_array(UserRoleEnum::FULL->value, $roles, true)) { - app('log')->debug(sprintf('List of roles is [%1$s] but this includes "%2$s", so return [%2$s]', implode(',', $roles), UserRoleEnum::FULL->value)); + Log::debug(sprintf('List of roles is [%1$s] but this includes "%2$s", so return [%2$s]', implode(',', $roles), UserRoleEnum::FULL->value)); return [UserRoleEnum::FULL->value]; } diff --git a/app/Repositories/Webhook/WebhookRepository.php b/app/Repositories/Webhook/WebhookRepository.php index fb8da51d2c..0e787a3a75 100644 --- a/app/Repositories/Webhook/WebhookRepository.php +++ b/app/Repositories/Webhook/WebhookRepository.php @@ -92,7 +92,7 @@ class WebhookRepository implements WebhookRepositoryInterface, UserGroupInterfac ->where('webhook_messages.errored', 0) ->get(['webhook_messages.*']) ->filter( - static fn (WebhookMessage $message) // @phpstan-ignore-line + static fn (WebhookMessage $message): bool // @phpstan-ignore-line => $message->webhookAttempts()->count() <= 2 )->splice(0, 3) ; diff --git a/app/Rules/Account/IsValidAccountTypeList.php b/app/Rules/Account/IsValidAccountTypeList.php index 8f5b7422f2..9cb71bf44c 100644 --- a/app/Rules/Account/IsValidAccountTypeList.php +++ b/app/Rules/Account/IsValidAccountTypeList.php @@ -47,7 +47,6 @@ class IsValidAccountTypeList implements ValidationRule } $keys = array_keys($this->types); foreach ($values as $entry) { - $entry = (string) $entry; if (!in_array($entry, $keys, true)) { $fail('validation.invalid_account_list')->translate(); } diff --git a/app/Rules/BelongsUser.php b/app/Rules/BelongsUser.php index 48e44ddcbc..811ada0f2c 100644 --- a/app/Rules/BelongsUser.php +++ b/app/Rules/BelongsUser.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Rules; +use Illuminate\Support\Facades\Log; use Closure; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\Account; @@ -47,7 +48,7 @@ class BelongsUser implements ValidationRule return; } - app('log')->debug(sprintf('Going to validate %s', $attribute)); + Log::debug(sprintf('Going to validate %s', $attribute)); $result = match ($attribute) { 'piggy_bank_id' => $this->validatePiggyBankId((int) $value), @@ -126,7 +127,7 @@ class BelongsUser implements ValidationRule private function validateBillName(string $value): bool { $count = $this->countField(Bill::class, 'name', $value); - app('log')->debug(sprintf('Result of countField for bill name "%s" is %d', $value, $count)); + Log::debug(sprintf('Result of countField for bill name "%s" is %d', $value, $count)); return 1 === $count; } @@ -147,10 +148,10 @@ class BelongsUser implements ValidationRule $count = 0; foreach ($objects as $object) { $objectValue = trim((string) $object->{$field}); // @phpstan-ignore-line - app('log')->debug(sprintf('Comparing object "%s" with value "%s"', $objectValue, $value)); + Log::debug(sprintf('Comparing object "%s" with value "%s"', $objectValue, $value)); if ($objectValue === $value) { ++$count; - app('log')->debug(sprintf('Hit! Count is now %d', $count)); + Log::debug(sprintf('Hit! Count is now %d', $count)); } } diff --git a/app/Rules/BelongsUserGroup.php b/app/Rules/BelongsUserGroup.php index 488080a176..58d4fea871 100644 --- a/app/Rules/BelongsUserGroup.php +++ b/app/Rules/BelongsUserGroup.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Rules; +use Illuminate\Support\Facades\Log; use Closure; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\Account; @@ -56,7 +57,7 @@ class BelongsUserGroup implements ValidationRule return; } - app('log')->debug(sprintf('Group: Going to validate "%s"', $attribute)); + Log::debug(sprintf('Group: Going to validate "%s"', $attribute)); $result = match ($attribute) { 'piggy_bank_id' => $this->validatePiggyBankId((int) $value), @@ -121,10 +122,10 @@ class BelongsUserGroup implements ValidationRule $count = 0; foreach ($objects as $object) { $objectValue = trim((string) $object->{$field}); // @phpstan-ignore-line - app('log')->debug(sprintf('Comparing object "%s" with value "%s"', $objectValue, $value)); + Log::debug(sprintf('Comparing object "%s" with value "%s"', $objectValue, $value)); if ($objectValue === $value) { ++$count; - app('log')->debug(sprintf('Hit! Count is now %d', $count)); + Log::debug(sprintf('Hit! Count is now %d', $count)); } } @@ -154,7 +155,7 @@ class BelongsUserGroup implements ValidationRule private function validateBillName(string $value): bool { $count = $this->countField(Bill::class, 'name', $value); - app('log')->debug(sprintf('Result of countField for bill name "%s" is %d', $value, $count)); + Log::debug(sprintf('Result of countField for bill name "%s" is %d', $value, $count)); return 1 === $count; } diff --git a/app/Rules/IsAllowedGroupAction.php b/app/Rules/IsAllowedGroupAction.php index 8f63f5012c..d590f21bfd 100644 --- a/app/Rules/IsAllowedGroupAction.php +++ b/app/Rules/IsAllowedGroupAction.php @@ -28,8 +28,6 @@ use Closure; use FireflyIII\Enums\UserRoleEnum; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\Account; -use FireflyIII\Repositories\UserGroup\UserGroupRepositoryInterface; -use FireflyIII\User; use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Contracts\Validation\ValidationRule; use Illuminate\Support\Facades\Log; @@ -37,14 +35,11 @@ use Override; class IsAllowedGroupAction implements ValidationRule { - private array $acceptedRoles; - private readonly UserGroupRepositoryInterface $repository; + // you need these roles to do anything with any endpoint. + private array $acceptedRoles = [UserRoleEnum::OWNER, UserRoleEnum::FULL]; public function __construct(private readonly string $className, private readonly string $methodName) { - // you need these roles to do anything with any endpoint. - $this->acceptedRoles = [UserRoleEnum::OWNER, UserRoleEnum::FULL]; - $this->repository = app(UserGroupRepositoryInterface::class); } /** @@ -69,68 +64,16 @@ class IsAllowedGroupAction implements ValidationRule break; } } - $this->validateUserGroup((int)$value, $fail); + $this->validateUserGroup(); } - private function validateUserGroup(int $userGroupId, Closure $fail): void + private function validateUserGroup(): void { try { throw new FireflyException('Here we are'); } catch (FireflyException $e) { Log::error($e->getTraceAsString()); } - exit('here we are'); - Log::debug(sprintf('validateUserGroup: %s', static::class)); - if (!auth()->check()) { - Log::debug('validateUserGroup: user is not logged in, return NULL.'); - $fail('validation.no_auth_user_group')->translate(); - - return; - } - - /** @var User $user */ - $user = auth()->user(); - if (0 !== $userGroupId) { - Log::debug(sprintf('validateUserGroup: user group submitted, search for memberships in group #%d.', $userGroupId)); - } - if (0 === $userGroupId) { - $userGroupId = $user->user_group_id; - Log::debug(sprintf('validateUserGroup: no user group submitted, use default group #%d.', $userGroupId)); - } - - $this->repository->setUser($user); - $memberships = $this->repository->getMembershipsFromGroupId($userGroupId); - - if (0 === $memberships->count()) { - Log::debug(sprintf('validateUserGroup: user has no access to group #%d.', $userGroupId)); - $fail('validation.no_access_user_group')->translate(); - - return; - } - - // need to get the group from the membership: - $userGroup = $this->repository->getById($userGroupId); - if (null === $userGroup) { - Log::debug(sprintf('validateUserGroup: group #%d does not exist.', $userGroupId)); - $fail('validation.belongs_user_or_user_group')->translate(); - - return; - } - Log::debug(sprintf('validateUserGroup: validate access of user to group #%d ("%s").', $userGroupId, $userGroup->title)); - Log::debug(sprintf('validateUserGroup: have %d roles to check.', count($this->acceptedRoles)), $this->acceptedRoles); - - /** @var UserRoleEnum $role */ - foreach ($this->acceptedRoles as $role) { - if ($user->hasRoleInGroupOrOwner($userGroup, $role)) { - Log::debug(sprintf('validateUserGroup: User has role "%s" in group #%d, return.', $role->value, $userGroupId)); - - return; - } - Log::debug(sprintf('validateUserGroup: User does NOT have role "%s" in group #%d, continue searching.', $role->value, $userGroupId)); - } - - Log::debug('validateUserGroup: User does NOT have enough rights to access endpoint.'); - $fail('validation.belongs_user_or_user_group')->translate(); } } diff --git a/app/Rules/IsDateOrTime.php b/app/Rules/IsDateOrTime.php index ae732d0ab3..309c894c32 100644 --- a/app/Rules/IsDateOrTime.php +++ b/app/Rules/IsDateOrTime.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Rules; +use Illuminate\Support\Facades\Log; use Carbon\Carbon; use Carbon\Exceptions\InvalidDateException; use Carbon\Exceptions\InvalidFormatException; @@ -51,13 +52,13 @@ class IsDateOrTime implements ValidationRule try { Carbon::createFromFormat('Y-m-d', $value); } catch (InvalidDateException $e) { // @phpstan-ignore-line - app('log')->error(sprintf('"%s" is not a valid date: %s', $value, $e->getMessage())); + Log::error(sprintf('"%s" is not a valid date: %s', $value, $e->getMessage())); $fail('validation.date_or_time')->translate(); return; } catch (InvalidFormatException $e) { - app('log')->error(sprintf('"%s" is of an invalid format: %s', $value, $e->getMessage())); + Log::error(sprintf('"%s" is of an invalid format: %s', $value, $e->getMessage())); $fail('validation.date_or_time')->translate(); @@ -71,13 +72,13 @@ class IsDateOrTime implements ValidationRule try { Carbon::parse($value); } catch (InvalidDateException $e) { // @phpstan-ignore-line - app('log')->error(sprintf('"%s" is not a valid date or time: %s', $value, $e->getMessage())); + Log::error(sprintf('"%s" is not a valid date or time: %s', $value, $e->getMessage())); $fail('validation.date_or_time')->translate(); return; } catch (InvalidFormatException $e) { - app('log')->error(sprintf('"%s" is of an invalid format: %s', $value, $e->getMessage())); + Log::error(sprintf('"%s" is of an invalid format: %s', $value, $e->getMessage())); $fail('validation.date_or_time')->translate(); diff --git a/app/Rules/IsDefaultUserGroupName.php b/app/Rules/IsDefaultUserGroupName.php index f59ff49327..5ad43e323f 100644 --- a/app/Rules/IsDefaultUserGroupName.php +++ b/app/Rules/IsDefaultUserGroupName.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Rules; +use Illuminate\Support\Facades\Log; use Closure; use FireflyIII\Models\UserGroup; use FireflyIII\Repositories\User\UserRepositoryInterface; @@ -42,7 +43,7 @@ class IsDefaultUserGroupName implements ValidationRule */ public function validate(string $attribute, mixed $value, Closure $fail): void { - app('log')->debug(sprintf('Now in %s(%s)', __METHOD__, $value)); + Log::debug(sprintf('Now in %s(%s)', __METHOD__, $value)); // are you owner of this group and the name is the same? fail. /** @var User $user */ diff --git a/app/Rules/IsTransferAccount.php b/app/Rules/IsTransferAccount.php index d64f30fa38..069f92715c 100644 --- a/app/Rules/IsTransferAccount.php +++ b/app/Rules/IsTransferAccount.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Rules; +use Illuminate\Support\Facades\Log; use Closure; use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Validation\AccountValidator; @@ -39,7 +40,7 @@ class IsTransferAccount implements ValidationRule */ public function validate(string $attribute, mixed $value, Closure $fail): void { - app('log')->debug(sprintf('Now in %s(%s)', __METHOD__, $value)); + Log::debug(sprintf('Now in %s(%s)', __METHOD__, $value)); /** @var AccountValidator $validator */ $validator = app(AccountValidator::class); @@ -48,13 +49,13 @@ class IsTransferAccount implements ValidationRule $validAccount = $validator->validateSource(['name' => (string) $value]); if (true === $validAccount) { - app('log')->debug('Found account based on name. Return true.'); + Log::debug('Found account based on name. Return true.'); // found by name, use repos to return. return; } $validAccount = $validator->validateSource(['id' => (int) $value]); - app('log')->debug(sprintf('Search by id (%d), result is %s.', (int) $value, var_export($validAccount, true))); + Log::debug(sprintf('Search by id (%d), result is %s.', (int) $value, var_export($validAccount, true))); if (false === $validAccount) { $fail('validation.not_transfer_account')->translate(); diff --git a/app/Rules/IsValidDateRange.php b/app/Rules/IsValidDateRange.php index 75a6846fab..d396076dc4 100644 --- a/app/Rules/IsValidDateRange.php +++ b/app/Rules/IsValidDateRange.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Rules; +use Illuminate\Support\Facades\Log; use Carbon\Carbon; use Carbon\Exceptions\InvalidDateException; use Carbon\Exceptions\InvalidFormatException; @@ -54,13 +55,13 @@ class IsValidDateRange implements ValidationRule $left = Carbon::parse($value); $right = Carbon::parse($otherValue); } catch (InvalidDateException $e) { // @phpstan-ignore-line - app('log')->error(sprintf('"%s" or "%s" is not a valid date or time: %s', $value, $otherValue, $e->getMessage())); + Log::error(sprintf('"%s" or "%s" is not a valid date or time: %s', $value, $otherValue, $e->getMessage())); $fail('validation.date_or_time')->translate(); return; } catch (InvalidFormatException $e) { - app('log')->error(sprintf('"%s" or "%s" is of an invalid format: %s', $value, $otherValue, $e->getMessage())); + Log::error(sprintf('"%s" or "%s" is of an invalid format: %s', $value, $otherValue, $e->getMessage())); $fail('validation.date_or_time')->translate(); diff --git a/app/Rules/IsValidZeroOrMoreAmount.php b/app/Rules/IsValidZeroOrMoreAmount.php index f5880fa78a..eb10a43147 100644 --- a/app/Rules/IsValidZeroOrMoreAmount.php +++ b/app/Rules/IsValidZeroOrMoreAmount.php @@ -41,7 +41,7 @@ class IsValidZeroOrMoreAmount implements ValidationRule */ public function validate(string $attribute, mixed $value, Closure $fail): void { - if (true === $this->nullable && null === $value) { + if ($this->nullable && null === $value) { return; } $value = (string) $value; diff --git a/app/Rules/TransactionType/IsValidTransactionTypeList.php b/app/Rules/TransactionType/IsValidTransactionTypeList.php index f0c68e2af5..313f0090c1 100644 --- a/app/Rules/TransactionType/IsValidTransactionTypeList.php +++ b/app/Rules/TransactionType/IsValidTransactionTypeList.php @@ -47,7 +47,6 @@ class IsValidTransactionTypeList implements ValidationRule } $keys = array_keys($this->transactionTypes); foreach ($values as $entry) { - $entry = (string)$entry; if (!in_array($entry, $keys, true)) { $fail('validation.invalid_transaction_type_list')->translate(); } diff --git a/app/Rules/UniqueAccountNumber.php b/app/Rules/UniqueAccountNumber.php index 467c5e6c83..48d7310697 100644 --- a/app/Rules/UniqueAccountNumber.php +++ b/app/Rules/UniqueAccountNumber.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Rules; +use Illuminate\Support\Facades\Log; use Closure; use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Models\Account; @@ -55,7 +56,7 @@ class UniqueAccountNumber implements ValidationRule if ('asset' === $this->expectedType) { $this->expectedType = AccountTypeEnum::ASSET->value; } - app('log')->debug(sprintf('Expected type is "%s"', $this->expectedType)); + Log::debug(sprintf('Expected type is "%s"', $this->expectedType)); } /** @@ -87,9 +88,9 @@ class UniqueAccountNumber implements ValidationRule foreach ($maxCounts as $type => $max) { $count = $this->countHits($type, $value); - app('log')->debug(sprintf('Count for "%s" and account number "%s" is %d', $type, $value, $count)); + Log::debug(sprintf('Count for "%s" and account number "%s" is %d', $type, $value, $count)); if ($count > $max) { - app('log')->debug( + Log::debug( sprintf( 'account number "%s" is in use with %d account(s) of type "%s", which is too much for expected type "%s"', $value, @@ -104,7 +105,7 @@ class UniqueAccountNumber implements ValidationRule return; } } - app('log')->debug('Account number is valid.'); + Log::debug('Account number is valid.'); } private function getMaxOccurrences(): array diff --git a/app/Rules/UniqueIban.php b/app/Rules/UniqueIban.php index 3f83ab76bf..761d8eb641 100644 --- a/app/Rules/UniqueIban.php +++ b/app/Rules/UniqueIban.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Rules; +use Illuminate\Support\Facades\Log; use Closure; use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Models\Account; @@ -35,14 +36,13 @@ use Illuminate\Contracts\Validation\ValidationRule; */ class UniqueIban implements ValidationRule { - private array $expectedTypes; + private array $expectedTypes = []; /** * Create a new rule instance. */ public function __construct(private readonly ?Account $account, ?string $expectedType) { - $this->expectedTypes = []; if (null === $expectedType) { return; } @@ -104,9 +104,9 @@ class UniqueIban implements ValidationRule $value = Steam::filterSpaces($value); $count = $this->countHits($type, $value); - app('log')->debug(sprintf('Count for "%s" and IBAN "%s" is %d', $type, $value, $count)); + Log::debug(sprintf('Count for "%s" and IBAN "%s" is %d', $type, $value, $count)); if ($count > $max) { - app('log')->debug( + Log::debug( sprintf( 'IBAN "%s" is in use with %d account(s) of type "%s", which is too much for expected types "%s"', $value, diff --git a/app/Rules/ValidJournals.php b/app/Rules/ValidJournals.php index 221bef831d..463a3fe7f6 100644 --- a/app/Rules/ValidJournals.php +++ b/app/Rules/ValidJournals.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Rules; +use Illuminate\Support\Facades\Log; use Closure; use FireflyIII\Models\TransactionJournal; use Illuminate\Contracts\Validation\ValidationRule; @@ -38,7 +39,7 @@ class ValidJournals implements ValidationRule */ public function validate(string $attribute, mixed $value, Closure $fail): void { - app('log')->debug('In ValidJournals::passes'); + Log::debug('In ValidJournals::passes'); if (!is_array($value)) { return; } @@ -46,13 +47,13 @@ class ValidJournals implements ValidationRule foreach ($value as $journalId) { $count = TransactionJournal::where('id', $journalId)->where('user_id', $userId)->count(); if (0 === $count) { - app('log')->debug(sprintf('Count for transaction #%d and user #%d is zero! Return FALSE', $journalId, $userId)); + Log::debug(sprintf('Count for transaction #%d and user #%d is zero! Return FALSE', $journalId, $userId)); $fail('validation.invalid_selection')->translate(); return; } } - app('log')->debug('Return true!'); + Log::debug('Return true!'); } } diff --git a/app/Rules/ValidRecurrenceRepetitionValue.php b/app/Rules/ValidRecurrenceRepetitionValue.php index 9cd29b261b..ec770c6b9d 100644 --- a/app/Rules/ValidRecurrenceRepetitionValue.php +++ b/app/Rules/ValidRecurrenceRepetitionValue.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Rules; +use Illuminate\Support\Facades\Log; use Carbon\Carbon; use Closure; use Illuminate\Contracts\Validation\ValidationRule; @@ -105,7 +106,7 @@ class ValidRecurrenceRepetitionValue implements ValidationRule try { Carbon::createFromFormat('Y-m-d', $dateString); } catch (InvalidArgumentException $e) { - app('log')->debug(sprintf('Could not parse date %s: %s', $dateString, $e->getMessage())); + Log::debug(sprintf('Could not parse date %s: %s', $dateString, $e->getMessage())); return false; } diff --git a/app/Services/FireflyIIIOrg/Update/UpdateRequest.php b/app/Services/FireflyIIIOrg/Update/UpdateRequest.php index ad55aee903..a3433dc02c 100644 --- a/app/Services/FireflyIIIOrg/Update/UpdateRequest.php +++ b/app/Services/FireflyIIIOrg/Update/UpdateRequest.php @@ -149,7 +149,7 @@ class UpdateRequest implements UpdateRequestInterface $latest = substr($latest, 1); } if (str_starts_with($current, 'develop')) { - return $this->parseResultDevelop($current, $latest, $information); + return $this->parseResultDevelop($current, $latest); } $compare = version_compare($latest, $current); @@ -183,7 +183,7 @@ class UpdateRequest implements UpdateRequestInterface return $this->releasedNewVersion($current, $latest, $released); } - private function parseResultDevelop(string $current, string $latest, array $information): array + private function parseResultDevelop(string $current, string $latest): array { Log::debug(sprintf('User is running develop version "%s"', $current)); $compare = $this->compareDevelopVersions($current, $latest); diff --git a/app/Services/Internal/Destroy/AccountDestroyService.php b/app/Services/Internal/Destroy/AccountDestroyService.php index 2bd2f62c4e..5e6ec04144 100644 --- a/app/Services/Internal/Destroy/AccountDestroyService.php +++ b/app/Services/Internal/Destroy/AccountDestroyService.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Services\Internal\Destroy; +use Illuminate\Support\Facades\Log; use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Models\Account; use FireflyIII\Models\PiggyBank; @@ -65,7 +66,7 @@ class AccountDestroyService private function destroyOpeningBalance(Account $account): void { - app('log')->debug(sprintf('Searching for opening balance for account #%d "%s"', $account->id, $account->name)); + Log::debug(sprintf('Searching for opening balance for account #%d "%s"', $account->id, $account->name)); $set = $account->transactions() ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') ->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id') @@ -74,7 +75,7 @@ class AccountDestroyService ; if ($set->count() > 0) { $journalId = $set->first()->transaction_journal_id; - app('log')->debug(sprintf('Found opening balance journal with ID #%d', $journalId)); + Log::debug(sprintf('Found opening balance journal with ID #%d', $journalId)); // get transactions with this journal (should be just one): $transactions = Transaction::where('transaction_journal_id', $journalId) @@ -84,9 +85,9 @@ class AccountDestroyService /** @var Transaction $transaction */ foreach ($transactions as $transaction) { - app('log')->debug(sprintf('Found transaction with ID #%d', $transaction->id)); + Log::debug(sprintf('Found transaction with ID #%d', $transaction->id)); $ibAccount = $transaction->account; - app('log')->debug(sprintf('Connected to account #%d "%s"', $ibAccount->id, $ibAccount->name)); + Log::debug(sprintf('Connected to account #%d "%s"', $ibAccount->id, $ibAccount->name)); $ibAccount->accountMeta()->delete(); $transaction->delete(); @@ -105,7 +106,7 @@ class AccountDestroyService public function moveTransactions(Account $account, Account $moveTo): void { - app('log')->debug(sprintf('Move from account #%d to #%d', $account->id, $moveTo->id)); + Log::debug(sprintf('Move from account #%d to #%d', $account->id, $moveTo->id)); DB::table('transactions')->where('account_id', $account->id)->update(['account_id' => $moveTo->id]); $collection = Transaction::groupBy('transaction_journal_id', 'account_id')->where('account_id', $moveTo->id)->get(['transaction_journal_id', 'account_id', DB::raw('count(*) as the_count')]); @@ -123,7 +124,7 @@ class AccountDestroyService $journalId = $row->transaction_journal_id; $journal = $user->transactionJournals()->find($journalId); if (null !== $journal) { - app('log')->debug(sprintf('Deleted journal #%d because it has the same source as destination.', $journal->id)); + Log::debug(sprintf('Deleted journal #%d because it has the same source as destination.', $journal->id)); $service->destroy($journal); } } diff --git a/app/Services/Internal/Destroy/JournalDestroyService.php b/app/Services/Internal/Destroy/JournalDestroyService.php index 77f63fa3ff..e75cf2a92b 100644 --- a/app/Services/Internal/Destroy/JournalDestroyService.php +++ b/app/Services/Internal/Destroy/JournalDestroyService.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Services\Internal\Destroy; +use Illuminate\Support\Facades\Log; use FireflyIII\Models\Attachment; use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionJournal; @@ -38,18 +39,18 @@ class JournalDestroyService { public function destroy(TransactionJournal $journal): void { - app('log')->debug(sprintf('Now in %s', __METHOD__)); + Log::debug(sprintf('Now in %s', __METHOD__)); /** @var Transaction $transaction */ foreach ($journal->transactions()->get() as $transaction) { - app('log')->debug(sprintf('Will now delete transaction #%d', $transaction->id)); + Log::debug(sprintf('Will now delete transaction #%d', $transaction->id)); $transaction->delete(); } // also delete journal_meta entries. /** @var TransactionJournalMeta $meta */ foreach ($journal->transactionJournalMeta()->get() as $meta) { - app('log')->debug(sprintf('Will now delete meta-entry #%d', $meta->id)); + Log::debug(sprintf('Will now delete meta-entry #%d', $meta->id)); $meta->delete(); } diff --git a/app/Services/Internal/Destroy/TransactionGroupDestroyService.php b/app/Services/Internal/Destroy/TransactionGroupDestroyService.php index 281a49e0c8..159fca52e1 100644 --- a/app/Services/Internal/Destroy/TransactionGroupDestroyService.php +++ b/app/Services/Internal/Destroy/TransactionGroupDestroyService.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Services\Internal\Destroy; +use Illuminate\Support\Facades\Log; use FireflyIII\Events\DestroyedTransactionGroup; use FireflyIII\Models\TransactionGroup; @@ -34,7 +35,7 @@ class TransactionGroupDestroyService { public function destroy(TransactionGroup $transactionGroup): void { - app('log')->debug(sprintf('Now in %s', __METHOD__)); + Log::debug(sprintf('Now in %s', __METHOD__)); /** @var JournalDestroyService $service */ $service = app(JournalDestroyService::class); diff --git a/app/Services/Internal/Support/AccountServiceTrait.php b/app/Services/Internal/Support/AccountServiceTrait.php index 15cb35f760..bce254bd60 100644 --- a/app/Services/Internal/Support/AccountServiceTrait.php +++ b/app/Services/Internal/Support/AccountServiceTrait.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Services\Internal\Support; +use Illuminate\Support\Facades\Log; use Carbon\Carbon; use Deprecated; use FireflyIII\Enums\AccountTypeEnum; @@ -58,7 +59,7 @@ trait AccountServiceTrait $rules = ['iban' => 'required|iban']; $validator = Validator::make($data, $rules); if ($validator->fails()) { - app('log')->info(sprintf('Detected invalid IBAN ("%s"). Return NULL instead.', $iban)); + Log::info(sprintf('Detected invalid IBAN ("%s"). Return NULL instead.', $iban)); return null; } @@ -78,14 +79,8 @@ trait AccountServiceTrait return false; } // if is set, but is empty: - if ( - (array_key_exists('opening_balance', $data) && '' === $data['opening_balance']) - || (array_key_exists('opening_balance_date', $data) && '' === $data['opening_balance_date']) - ) { - return true; - } - - return false; + return (array_key_exists('opening_balance', $data) && '' === $data['opening_balance']) + || (array_key_exists('opening_balance_date', $data) && '' === $data['opening_balance_date']); } /** @@ -180,11 +175,11 @@ trait AccountServiceTrait } if ('' !== $data['opening_balance'] && array_key_exists('opening_balance_date', $data) && '' !== $data['opening_balance_date'] && $data['opening_balance_date'] instanceof Carbon) { - app('log')->debug('Array has valid opening balance data.'); + Log::debug('Array has valid opening balance data.'); return true; } - app('log')->debug('Array does not have valid opening balance data.'); + Log::debug('Array does not have valid opening balance data.'); return false; } @@ -196,7 +191,7 @@ trait AccountServiceTrait #[Deprecated] protected function createOBGroup(Account $account, array $data): TransactionGroup { - app('log')->debug('Now going to create an OB group.'); + Log::debug('Now going to create an OB group.'); $language = app('preferences')->getForUser($account->user, 'language', 'en_US')->data; if (is_array($language)) { $language = 'en_US'; @@ -210,19 +205,19 @@ trait AccountServiceTrait // amount is positive. if (1 === bccomp((string) $amount, '0')) { - app('log')->debug(sprintf('Amount is %s, which is positive. Source is a new IB account, destination is #%d', $amount, $account->id)); + Log::debug(sprintf('Amount is %s, which is positive. Source is a new IB account, destination is #%d', $amount, $account->id)); $sourceName = trans('firefly.initial_balance_description', ['account' => $account->name], $language); $destId = $account->id; } // amount is not positive if (-1 === bccomp((string) $amount, '0')) { - app('log')->debug(sprintf('Amount is %s, which is negative. Destination is a new IB account, source is #%d', $amount, $account->id)); + Log::debug(sprintf('Amount is %s, which is negative. Destination is a new IB account, source is #%d', $amount, $account->id)); $destName = trans('firefly.initial_balance_account', ['account' => $account->name], $language); $sourceId = $account->id; } // amount is 0 if (0 === bccomp((string) $amount, '0')) { - app('log')->debug('Amount is zero, so will not make an OB group.'); + Log::debug('Amount is zero, so will not make an OB group.'); throw new FireflyException('Amount for new opening balance was unexpectedly 0.'); } @@ -268,7 +263,7 @@ trait AccountServiceTrait ], ], ]; - app('log')->debug('Going for submission in createOBGroup', $submission); + Log::debug('Going for submission in createOBGroup', $submission); /** @var TransactionGroupFactory $factory */ $factory = app(TransactionGroupFactory::class); @@ -277,8 +272,8 @@ trait AccountServiceTrait try { $group = $factory->create($submission); } catch (DuplicateTransactionException $e) { - app('log')->error($e->getMessage()); - app('log')->error($e->getTraceAsString()); + Log::error($e->getMessage()); + Log::error($e->getTraceAsString()); throw new FireflyException($e->getMessage(), 0, $e); } @@ -291,11 +286,11 @@ trait AccountServiceTrait */ protected function deleteCreditTransaction(Account $account): void { - app('log')->debug(sprintf('deleteCreditTransaction() for account #%d', $account->id)); + Log::debug(sprintf('deleteCreditTransaction() for account #%d', $account->id)); $creditGroup = $this->getCreditTransaction($account); if (null !== $creditGroup) { - app('log')->debug('Credit journal found, delete journal.'); + Log::debug('Credit journal found, delete journal.'); /** @var TransactionGroupDestroyService $service */ $service = app(TransactionGroupDestroyService::class); @@ -308,7 +303,7 @@ trait AccountServiceTrait */ protected function getCreditTransaction(Account $account): ?TransactionGroup { - app('log')->debug(sprintf('Now at %s', __METHOD__)); + Log::debug(sprintf('Now at %s', __METHOD__)); return $this->accountRepository->getCreditTransactionGroup($account); } @@ -318,12 +313,12 @@ trait AccountServiceTrait */ protected function deleteOBGroup(Account $account): void { - app('log')->debug(sprintf('deleteOB() for account #%d', $account->id)); + Log::debug(sprintf('deleteOB() for account #%d', $account->id)); $openingBalanceGroup = $this->getOBGroup($account); // opening balance data? update it! if (null !== $openingBalanceGroup) { - app('log')->debug('Opening balance journal found, delete journal.'); + Log::debug('Opening balance journal found, delete journal.'); /** @var TransactionGroupDestroyService $service */ $service = app(TransactionGroupDestroyService::class); @@ -365,10 +360,10 @@ trait AccountServiceTrait */ protected function updateCreditTransaction(Account $account, string $direction, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup { - app('log')->debug(sprintf('Now in %s', __METHOD__)); + Log::debug(sprintf('Now in %s', __METHOD__)); if (0 === bccomp($openingBalance, '0')) { - app('log')->debug('Amount is zero, so will not update liability credit/debit group.'); + Log::debug('Amount is zero, so will not update liability credit/debit group.'); throw new FireflyException('Amount for update liability credit/debit was unexpectedly 0.'); } @@ -421,10 +416,10 @@ trait AccountServiceTrait */ protected function createCreditTransaction(Account $account, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup { - app('log')->debug('Now going to create an createCreditTransaction.'); + Log::debug('Now going to create an createCreditTransaction.'); if (0 === bccomp($openingBalance, '0')) { - app('log')->debug('Amount is zero, so will not make an liability credit group.'); + Log::debug('Amount is zero, so will not make an liability credit group.'); throw new FireflyException('Amount for new liability credit was unexpectedly 0.'); } @@ -490,7 +485,7 @@ trait AccountServiceTrait ], ], ]; - app('log')->debug('Going for submission in createCreditTransaction', $submission); + Log::debug('Going for submission in createCreditTransaction', $submission); /** @var TransactionGroupFactory $factory */ $factory = app(TransactionGroupFactory::class); @@ -499,8 +494,8 @@ trait AccountServiceTrait try { $group = $factory->create($submission); } catch (DuplicateTransactionException $e) { - app('log')->error($e->getMessage()); - app('log')->error($e->getTraceAsString()); + Log::error($e->getMessage()); + Log::error($e->getTraceAsString()); throw new FireflyException($e->getMessage(), 0, $e); } @@ -562,13 +557,13 @@ trait AccountServiceTrait */ protected function updateOBGroupV2(Account $account, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup { - app('log')->debug(sprintf('Now in %s', __METHOD__)); + Log::debug(sprintf('Now in %s', __METHOD__)); // create if not exists: $obGroup = $this->getOBGroup($account); if (null === $obGroup) { return $this->createOBGroupV2($account, $openingBalance, $openingBalanceDate); } - app('log')->debug('Update OB group'); + Log::debug('Update OB group'); // if exists, update: $currency = $this->accountRepository->getAccountCurrency($account); @@ -585,7 +580,7 @@ trait AccountServiceTrait // if amount is negative: if (1 === bccomp('0', $openingBalance)) { - app('log')->debug('Amount is negative.'); + Log::debug('Amount is negative.'); // account transaction loses money: $accountTransaction->amount = app('steam')->negative($openingBalance); $accountTransaction->transaction_currency_id = $currency->id; @@ -595,7 +590,7 @@ trait AccountServiceTrait $obTransaction->transaction_currency_id = $currency->id; } if (-1 === bccomp('0', $openingBalance)) { - app('log')->debug('Amount is positive.'); + Log::debug('Amount is positive.'); // account gains money: $accountTransaction->amount = app('steam')->positive($openingBalance); $accountTransaction->transaction_currency_id = $currency->id; @@ -618,7 +613,7 @@ trait AccountServiceTrait */ protected function createOBGroupV2(Account $account, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup { - app('log')->debug('Now going to create an OB group.'); + Log::debug('Now going to create an OB group.'); $language = app('preferences')->getForUser($account->user, 'language', 'en_US')->data; if (is_array($language)) { $language = 'en_US'; @@ -631,19 +626,19 @@ trait AccountServiceTrait // amount is positive. if (1 === bccomp($openingBalance, '0')) { - app('log')->debug(sprintf('Amount is %s, which is positive. Source is a new IB account, destination is #%d', $openingBalance, $account->id)); + Log::debug(sprintf('Amount is %s, which is positive. Source is a new IB account, destination is #%d', $openingBalance, $account->id)); $sourceName = trans('firefly.initial_balance_description', ['account' => $account->name], $language); $destId = $account->id; } // amount is not positive if (-1 === bccomp($openingBalance, '0')) { - app('log')->debug(sprintf('Amount is %s, which is negative. Destination is a new IB account, source is #%d', $openingBalance, $account->id)); + Log::debug(sprintf('Amount is %s, which is negative. Destination is a new IB account, source is #%d', $openingBalance, $account->id)); $destName = trans('firefly.initial_balance_account', ['account' => $account->name], $language); $sourceId = $account->id; } // amount is 0 if (0 === bccomp($openingBalance, '0')) { - app('log')->debug('Amount is zero, so will not make an OB group.'); + Log::debug('Amount is zero, so will not make an OB group.'); throw new FireflyException('Amount for new opening balance was unexpectedly 0.'); } @@ -689,7 +684,7 @@ trait AccountServiceTrait ], ], ]; - app('log')->debug('Going for submission in createOBGroupV2', $submission); + Log::debug('Going for submission in createOBGroupV2', $submission); /** @var TransactionGroupFactory $factory */ $factory = app(TransactionGroupFactory::class); @@ -698,8 +693,8 @@ trait AccountServiceTrait try { $group = $factory->create($submission); } catch (DuplicateTransactionException $e) { - app('log')->error($e->getMessage()); - app('log')->error($e->getTraceAsString()); + Log::error($e->getMessage()); + Log::error($e->getTraceAsString()); throw new FireflyException($e->getMessage(), 0, $e); } diff --git a/app/Services/Internal/Support/BillServiceTrait.php b/app/Services/Internal/Support/BillServiceTrait.php index a9217f347d..79fa463b86 100644 --- a/app/Services/Internal/Support/BillServiceTrait.php +++ b/app/Services/Internal/Support/BillServiceTrait.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Services\Internal\Support; +use Illuminate\Support\Facades\Log; use FireflyIII\Models\Bill; use FireflyIII\Models\Note; use FireflyIII\Models\RuleAction; @@ -46,7 +47,7 @@ trait BillServiceTrait /** @var RuleAction $ruleAction */ foreach ($set as $ruleAction) { - app('log')->debug(sprintf('Updated rule action #%d to search for new bill name "%s"', $ruleAction->id, $newName)); + Log::debug(sprintf('Updated rule action #%d to search for new bill name "%s"', $ruleAction->id, $newName)); $ruleAction->action_value = $newName; $ruleAction->save(); } diff --git a/app/Services/Internal/Support/CreditRecalculateService.php b/app/Services/Internal/Support/CreditRecalculateService.php index 66b5fc359c..b1dc2406aa 100644 --- a/app/Services/Internal/Support/CreditRecalculateService.php +++ b/app/Services/Internal/Support/CreditRecalculateService.php @@ -40,20 +40,10 @@ use Illuminate\Support\Facades\Log; */ class CreditRecalculateService { - private ?Account $account; - private ?TransactionGroup $group; + private ?Account $account = null; + private ?TransactionGroup $group = null; private AccountRepositoryInterface $repository; - private array $work; - - /** - * CreditRecalculateService constructor. - */ - public function __construct() - { - $this->group = null; - $this->account = null; - $this->work = []; - } + private array $work = []; public function recalculate(): void { @@ -163,12 +153,10 @@ class CreditRecalculateService $this->repository->setUser($account->user); $direction = (string) $this->repository->getMetaValue($account, 'liability_direction'); $openingBalance = $this->repository->getOpeningBalance($account); - if ($openingBalance instanceof TransactionJournal) { - // Log::debug(sprintf('Found opening balance transaction journal #%d', $openingBalance->id)); - // if account direction is "debit" ("I owe this amount") the opening balance must always be AWAY from the account: - if ('debit' === $direction) { - $this->validateOpeningBalance($account, $openingBalance); - } + // Log::debug(sprintf('Found opening balance transaction journal #%d', $openingBalance->id)); + // if account direction is "debit" ("I owe this amount") the opening balance must always be AWAY from the account: + if ($openingBalance instanceof TransactionJournal && 'debit' === $direction) { + $this->validateOpeningBalance($account, $openingBalance); } $startOfDebt = $this->repository->getOpeningBalanceAmount($account, false) ?? '0'; $leftOfDebt = app('steam')->positive($startOfDebt); @@ -188,7 +176,7 @@ class CreditRecalculateService ->orderBy('transaction_journals.date', 'ASC') ->get(['transactions.*']) ; - $total = $transactions->count(); + $transactions->count(); // Log::debug(sprintf('Found %d transaction(s) to process.', $total)); /** @var Transaction $transaction */ diff --git a/app/Services/Internal/Support/JournalServiceTrait.php b/app/Services/Internal/Support/JournalServiceTrait.php index ec9a7dec3e..94f6c46e33 100644 --- a/app/Services/Internal/Support/JournalServiceTrait.php +++ b/app/Services/Internal/Support/JournalServiceTrait.php @@ -258,7 +258,7 @@ trait JournalServiceTrait /** @var string $type */ foreach ($types as $type) { - if (true === in_array($type, $list, true)) { + if (in_array($type, $list, true)) { $result = $type; break; diff --git a/app/Services/Internal/Support/RecurringTransactionTrait.php b/app/Services/Internal/Support/RecurringTransactionTrait.php index ebb7aad99f..25f0fb75db 100644 --- a/app/Services/Internal/Support/RecurringTransactionTrait.php +++ b/app/Services/Internal/Support/RecurringTransactionTrait.php @@ -94,9 +94,9 @@ trait RecurringTransactionTrait */ protected function createTransactions(Recurrence $recurrence, array $transactions): void { - app('log')->debug('Now in createTransactions()'); + Log::debug('Now in createTransactions()'); foreach ($transactions as $index => $array) { - app('log')->debug(sprintf('Now at transaction #%d', $index)); + Log::debug(sprintf('Now at transaction #%d', $index)); $sourceTypes = config(sprintf('firefly.expected_source_types.source.%s', $recurrence->transactionType->type)); $destTypes = config(sprintf('firefly.expected_source_types.destination.%s', $recurrence->transactionType->type)); $source = $this->findAccount($sourceTypes, $array['source_id'], null); @@ -110,7 +110,7 @@ trait RecurringTransactionTrait $currency = app('amount')->getPrimaryCurrencyByUserGroup($recurrence->user->userGroup); } - app('log')->debug( + Log::debug( sprintf('Will set the validator type to %s based on the type of the recurrence (#%d).', $recurrence->transactionType->type, $recurrence->id) ); @@ -204,7 +204,7 @@ trait RecurringTransactionTrait try { $result = $factory->findOrCreate($accountName, $expectedType); } catch (FireflyException $e) { - app('log')->error($e->getMessage()); + Log::error($e->getMessage()); } } } @@ -325,7 +325,7 @@ trait RecurringTransactionTrait protected function deleteTransactions(Recurrence $recurrence): void { - app('log')->debug('deleteTransactions()'); + Log::debug('deleteTransactions()'); /** @var RecurrenceTransaction $transaction */ foreach ($recurrence->recurrenceTransactions as $transaction) { diff --git a/app/Services/Internal/Support/TransactionTypeTrait.php b/app/Services/Internal/Support/TransactionTypeTrait.php index a9fe1308c8..e16bfd87f7 100644 --- a/app/Services/Internal/Support/TransactionTypeTrait.php +++ b/app/Services/Internal/Support/TransactionTypeTrait.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Services\Internal\Support; +use Illuminate\Support\Facades\Log; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Factory\TransactionTypeFactory; use FireflyIII\Models\TransactionType; @@ -44,7 +45,7 @@ trait TransactionTypeTrait $factory = app(TransactionTypeFactory::class); $transactionType = $factory->find($type); if (null === $transactionType) { - app('log')->error(sprintf('Could not find transaction type for "%s"', $type)); + Log::error(sprintf('Could not find transaction type for "%s"', $type)); throw new FireflyException(sprintf('Could not find transaction type for "%s"', $type)); } diff --git a/app/Services/Internal/Update/AccountUpdateService.php b/app/Services/Internal/Update/AccountUpdateService.php index 9f38297e42..ea1b758124 100644 --- a/app/Services/Internal/Update/AccountUpdateService.php +++ b/app/Services/Internal/Update/AccountUpdateService.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Services\Internal\Update; +use Illuminate\Support\Facades\Log; use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Events\UpdatedAccount; use FireflyIII\Exceptions\FireflyException; @@ -68,7 +69,7 @@ class AccountUpdateService */ public function update(Account $account, array $data): Account { - app('log')->debug(sprintf('Now in %s', __METHOD__)); + Log::debug(sprintf('Now in %s', __METHOD__)); $this->accountRepository->setUser($account->user); $this->user = $account->user; $account = $this->updateAccount($account, $data); @@ -166,21 +167,21 @@ class AccountUpdateService { // skip if no order info if (!array_key_exists('order', $data) || $data['order'] === $account->order) { - app('log')->debug(sprintf('Account order will not be touched because its not set or already at %d.', $account->order)); + Log::debug(sprintf('Account order will not be touched because its not set or already at %d.', $account->order)); return $account; } // skip if not of orderable type. $type = $account->accountType->type; if (!in_array($type, [AccountTypeEnum::ASSET->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value], true)) { - app('log')->debug('Will not change order of this account.'); + Log::debug('Will not change order of this account.'); return $account; } // get account type ID's because a join and an update is hard: $oldOrder = $account->order; $newOrder = $data['order']; - app('log')->debug(sprintf('Order is set to be updated from %s to %s', $oldOrder, $newOrder)); + Log::debug(sprintf('Order is set to be updated from %s to %s', $oldOrder, $newOrder)); $list = $this->getTypeIds([AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value]); if (AccountTypeEnum::ASSET->value === $type) { $list = $this->getTypeIds([AccountTypeEnum::ASSET->value]); @@ -193,7 +194,7 @@ class AccountUpdateService ->decrement('order') ; $account->order = $newOrder; - app('log')->debug(sprintf('Order of account #%d ("%s") is now %d', $account->id, $account->name, $newOrder)); + Log::debug(sprintf('Order of account #%d ("%s") is now %d', $account->id, $account->name, $newOrder)); $account->save(); return $account; @@ -205,7 +206,7 @@ class AccountUpdateService ->increment('order') ; $account->order = $newOrder; - app('log')->debug(sprintf('Order of account #%d ("%s") is now %d', $account->id, $account->name, $newOrder)); + Log::debug(sprintf('Order of account #%d ("%s") is now %d', $account->id, $account->name, $newOrder)); $account->save(); return $account; @@ -298,17 +299,17 @@ class AccountUpdateService if (!is_array($array)) { $array = [$array]; } - app('log')->debug('Old array is: ', $array); - app('log')->debug(sprintf('Must remove : %d', $account->id)); + Log::debug('Old array is: ', $array); + Log::debug(sprintf('Must remove : %d', $account->id)); $removeAccountId = $account->id; $new = []; foreach ($array as $value) { if ((int) $value !== $removeAccountId) { - app('log')->debug(sprintf('Will include: %d', $value)); + Log::debug(sprintf('Will include: %d', $value)); $new[] = (int) $value; } } - app('log')->debug('Final new array is', $new); + Log::debug('Final new array is', $new); app('preferences')->setForUser($account->user, 'frontpageAccounts', $new); } } diff --git a/app/Services/Internal/Update/BillUpdateService.php b/app/Services/Internal/Update/BillUpdateService.php index 20825af2f2..cdf2118cc8 100644 --- a/app/Services/Internal/Update/BillUpdateService.php +++ b/app/Services/Internal/Update/BillUpdateService.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Services\Internal\Update; +use Illuminate\Support\Facades\Log; use FireflyIII\Factory\TransactionCurrencyFactory; use FireflyIII\Models\Bill; use FireflyIII\Models\ObjectGroup; @@ -193,18 +194,18 @@ class BillUpdateService private function updateBillTriggers(Bill $bill, array $oldData, array $newData): void { - app('log')->debug(sprintf('Now in updateBillTriggers(%d, "%s")', $bill->id, $bill->name)); + Log::debug(sprintf('Now in updateBillTriggers(%d, "%s")', $bill->id, $bill->name)); /** @var BillRepositoryInterface $repository */ $repository = app(BillRepositoryInterface::class); $repository->setUser($bill->user); $rules = $repository->getRulesForBill($bill); if (0 === $rules->count()) { - app('log')->debug('Found no rules.'); + Log::debug('Found no rules.'); return; } - app('log')->debug(sprintf('Found %d rules', $rules->count())); + Log::debug(sprintf('Found %d rules', $rules->count())); $fields = [ 'name' => 'description_contains', 'amount_min' => 'amount_more', @@ -216,7 +217,7 @@ class BillUpdateService continue; } if ($oldData[$field] === $newData[$field]) { - app('log')->debug(sprintf('Field %s is unchanged ("%s"), continue.', $field, $oldData[$field])); + Log::debug(sprintf('Field %s is unchanged ("%s"), continue.', $field, $oldData[$field])); continue; } @@ -230,7 +231,7 @@ class BillUpdateService foreach ($rules as $rule) { $trigger = $this->getRuleTrigger($rule, $key); if ($trigger instanceof RuleTrigger && $trigger->trigger_value === $oldValue) { - app('log')->debug(sprintf('Updated rule trigger #%d from value "%s" to value "%s"', $trigger->id, $oldValue, $newValue)); + Log::debug(sprintf('Updated rule trigger #%d from value "%s" to value "%s"', $trigger->id, $oldValue, $newValue)); $trigger->trigger_value = $newValue; $trigger->save(); @@ -238,7 +239,7 @@ class BillUpdateService } if ($trigger instanceof RuleTrigger && $trigger->trigger_value !== $oldValue && in_array($key, ['amount_more', 'amount_less'], true) && 0 === bccomp($trigger->trigger_value, $oldValue)) { - app('log')->debug(sprintf('Updated rule trigger #%d from value "%s" to value "%s"', $trigger->id, $oldValue, $newValue)); + Log::debug(sprintf('Updated rule trigger #%d from value "%s" to value "%s"', $trigger->id, $oldValue, $newValue)); $trigger->trigger_value = $newValue; $trigger->save(); } diff --git a/app/Services/Internal/Update/CategoryUpdateService.php b/app/Services/Internal/Update/CategoryUpdateService.php index b04c06686e..1561dcd6ce 100644 --- a/app/Services/Internal/Update/CategoryUpdateService.php +++ b/app/Services/Internal/Update/CategoryUpdateService.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Services\Internal\Update; +use Illuminate\Support\Facades\Log; use Exception; use FireflyIII\Models\Category; use FireflyIII\Models\Note; @@ -54,7 +55,7 @@ class CategoryUpdateService /** * @param mixed $user */ - public function setUser($user): void + public function setUser(User $user): void { $this->user = $user; } @@ -88,13 +89,13 @@ class CategoryUpdateService ->where('rule_triggers.trigger_value', $oldName) ->get(['rule_triggers.*']) ; - app('log')->debug(sprintf('Found %d triggers to update.', $triggers->count())); + Log::debug(sprintf('Found %d triggers to update.', $triggers->count())); /** @var RuleTrigger $trigger */ foreach ($triggers as $trigger) { $trigger->trigger_value = $newName; $trigger->save(); - app('log')->debug(sprintf('Updated trigger %d: %s', $trigger->id, $trigger->trigger_value)); + Log::debug(sprintf('Updated trigger %d: %s', $trigger->id, $trigger->trigger_value)); } } @@ -107,13 +108,13 @@ class CategoryUpdateService ->where('rule_actions.action_value', $oldName) ->get(['rule_actions.*']) ; - app('log')->debug(sprintf('Found %d actions to update.', $actions->count())); + Log::debug(sprintf('Found %d actions to update.', $actions->count())); /** @var RuleAction $action */ foreach ($actions as $action) { $action->action_value = $newName; $action->save(); - app('log')->debug(sprintf('Updated action %d: %s', $action->id, $action->action_value)); + Log::debug(sprintf('Updated action %d: %s', $action->id, $action->action_value)); } } @@ -133,7 +134,7 @@ class CategoryUpdateService */ private function updateNotes(Category $category, array $data): void { - $note = array_key_exists('notes', $data) ? $data['notes'] : null; + $note = $data['notes'] ?? null; if (null === $note) { return; } diff --git a/app/Services/Internal/Update/GroupUpdateService.php b/app/Services/Internal/Update/GroupUpdateService.php index 384f304938..fcf280a403 100644 --- a/app/Services/Internal/Update/GroupUpdateService.php +++ b/app/Services/Internal/Update/GroupUpdateService.php @@ -105,16 +105,14 @@ class GroupUpdateService $result = array_diff($existing, $updated); Log::debug('Result of DIFF: ', $result); - if (count($result) > 0) { - /** @var string $deletedId */ - foreach ($result as $deletedId) { - /** @var TransactionJournal $journal */ - $journal = $transactionGroup->transactionJournals()->find((int) $deletedId); + /** @var string $deletedId */ + foreach ($result as $deletedId) { + /** @var TransactionJournal $journal */ + $journal = $transactionGroup->transactionJournals()->find((int) $deletedId); - /** @var JournalDestroyService $service */ - $service = app(JournalDestroyService::class); - $service->destroy($journal); - } + /** @var JournalDestroyService $service */ + $service = app(JournalDestroyService::class); + $service->destroy($journal); } app('preferences')->mark(); diff --git a/app/Services/Internal/Update/JournalUpdateService.php b/app/Services/Internal/Update/JournalUpdateService.php index f960b8e3e0..0831b22d29 100644 --- a/app/Services/Internal/Update/JournalUpdateService.php +++ b/app/Services/Internal/Update/JournalUpdateService.php @@ -63,14 +63,29 @@ class JournalUpdateService private CurrencyRepositoryInterface $currencyRepository; private TransactionGroupRepositoryInterface $transactionGroupRepository; private array $data; - private ?Account $destinationAccount; - private ?Transaction $destinationTransaction; - private array $metaDate; - private array $metaString; - private ?Account $sourceAccount; - private ?Transaction $sourceTransaction; - private ?TransactionGroup $transactionGroup; - private ?TransactionJournal $transactionJournal; + private ?Account $destinationAccount = null; + private ?Transaction $destinationTransaction = null; + private array $metaDate = ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date', + 'invoice_date', ]; + private array $metaString = [ + 'sepa_cc', + 'sepa_ct_op', + 'sepa_ct_id', + 'sepa_db', + 'sepa_country', + 'sepa_ep', + 'sepa_ci', + 'sepa_batch_id', + 'recurrence_id', + 'internal_reference', + 'bunq_payment_id', + 'external_id', + 'external_url', + ]; + private ?Account $sourceAccount = null; + private ?Transaction $sourceTransaction = null; + private ?TransactionGroup $transactionGroup = null; + private ?TransactionJournal $transactionJournal = null; private string $startCompareHash = ''; /** @@ -78,12 +93,6 @@ class JournalUpdateService */ public function __construct() { - $this->destinationAccount = null; - $this->destinationTransaction = null; - $this->sourceAccount = null; - $this->sourceTransaction = null; - $this->transactionGroup = null; - $this->transactionJournal = null; $this->billRepository = app(BillRepositoryInterface::class); $this->categoryRepository = app(CategoryRepositoryInterface::class); $this->budgetRepository = app(BudgetRepositoryInterface::class); @@ -91,23 +100,6 @@ class JournalUpdateService $this->accountRepository = app(AccountRepositoryInterface::class); $this->currencyRepository = app(CurrencyRepositoryInterface::class); $this->transactionGroupRepository = app(TransactionGroupRepositoryInterface::class); - $this->metaString = [ - 'sepa_cc', - 'sepa_ct_op', - 'sepa_ct_id', - 'sepa_db', - 'sepa_country', - 'sepa_ep', - 'sepa_ci', - 'sepa_batch_id', - 'recurrence_id', - 'internal_reference', - 'bunq_payment_id', - 'external_id', - 'external_url', - ]; - $this->metaDate = ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date', - 'invoice_date', ]; } public function setData(array $data): void @@ -141,7 +133,7 @@ class JournalUpdateService Log::debug(sprintf('Now in %s', __METHOD__)); Log::debug(sprintf('Now in JournalUpdateService for journal #%d.', $this->transactionJournal->id)); - $this->data['reconciled'] = array_key_exists('reconciled', $this->data) ? $this->data['reconciled'] : null; + $this->data['reconciled'] ??= null; // can we update account data using the new type? if ($this->hasValidAccounts()) { @@ -221,7 +213,7 @@ class JournalUpdateService private function hasFields(array $fields): bool { - return array_any($fields, fn ($field) => array_key_exists($field, $this->data)); + return array_any($fields, fn ($field): bool => array_key_exists($field, $this->data)); } private function getOriginalSourceAccount(): Account diff --git a/app/Services/Internal/Update/RecurrenceUpdateService.php b/app/Services/Internal/Update/RecurrenceUpdateService.php index 7cad86a146..83c3856e29 100644 --- a/app/Services/Internal/Update/RecurrenceUpdateService.php +++ b/app/Services/Internal/Update/RecurrenceUpdateService.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Services\Internal\Update; +use Illuminate\Support\Facades\Log; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Factory\TransactionCurrencyFactory; use FireflyIII\Models\Note; @@ -94,7 +95,7 @@ class RecurrenceUpdateService // update all repetitions if (array_key_exists('repetitions', $data)) { - app('log')->debug('Will update repetitions array'); + Log::debug('Will update repetitions array'); // update each repetition or throw error yay $this->updateRepetitions($recurrence, $data['repetitions'] ?? []); } @@ -135,14 +136,14 @@ class RecurrenceUpdateService } // user added or removed repetitions, delete all and recreate: if ($originalCount !== count($repetitions)) { - app('log')->debug('Delete existing repetitions and create new ones.'); + Log::debug('Delete existing repetitions and create new ones.'); $this->deleteRepetitions($recurrence); $this->createRepetitions($recurrence, $repetitions); return; } // loop all and try to match them: - app('log')->debug('Loop and find'); + Log::debug('Loop and find'); foreach ($repetitions as $current) { $match = $this->matchRepetition($recurrence, $current); if (!$match instanceof RecurrenceRepetition) { @@ -167,7 +168,7 @@ class RecurrenceUpdateService { $originalCount = $recurrence->recurrenceRepetitions()->count(); if (1 === $originalCount) { - app('log')->debug('Return the first one'); + Log::debug('Return the first one'); /** @var null|RecurrenceRepetition */ return $recurrence->recurrenceRepetitions()->first(); @@ -198,12 +199,12 @@ class RecurrenceUpdateService */ private function updateTransactions(Recurrence $recurrence, array $transactions): void { - app('log')->debug('Now in updateTransactions()'); + Log::debug('Now in updateTransactions()'); $originalCount = $recurrence->recurrenceTransactions()->count(); - app('log')->debug(sprintf('Original count is %d', $originalCount)); + Log::debug(sprintf('Original count is %d', $originalCount)); if (0 === count($transactions)) { // won't drop transactions, rather avoid. - app('log')->warning('No transactions to update, too scared to continue!'); + Log::warning('No transactions to update, too scared to continue!'); return; } @@ -213,7 +214,7 @@ class RecurrenceUpdateService foreach ($originalTransactions as $i => $originalTransaction) { foreach ($transactions as $ii => $submittedTransaction) { if (array_key_exists('id', $submittedTransaction) && (int) $originalTransaction['id'] === (int) $submittedTransaction['id']) { - app('log')->debug(sprintf('Match original transaction #%d with an entry in the submitted array.', $originalTransaction['id'])); + Log::debug(sprintf('Match original transaction #%d with an entry in the submitted array.', $originalTransaction['id'])); $combinations[] = [ 'original' => $originalTransaction, 'submitted' => $submittedTransaction, @@ -225,7 +226,7 @@ class RecurrenceUpdateService // If one left of both we can match those as well and presto. if (1 === count($originalTransactions) && 1 === count($transactions)) { $first = array_shift($originalTransactions); - app('log')->debug(sprintf('One left of each, link them (ID is #%d)', $first['id'])); + Log::debug(sprintf('One left of each, link them (ID is #%d)', $first['id'])); $combinations[] = [ 'original' => $first, 'submitted' => array_shift($transactions), @@ -240,7 +241,7 @@ class RecurrenceUpdateService } // anything left in the original transactions array can be deleted. foreach ($originalTransactions as $original) { - app('log')->debug(sprintf('Original transaction #%d is unmatched, delete it!', $original['id'])); + Log::debug(sprintf('Original transaction #%d is unmatched, delete it!', $original['id'])); $this->deleteTransaction($recurrence, (int) $original['id']); } // anything left is new. @@ -261,7 +262,7 @@ class RecurrenceUpdateService /** @var RecurrenceTransaction $transaction */ $transaction = $recurrence->recurrenceTransactions()->find($original['id']); - app('log')->debug(sprintf('Now in updateCombination(#%d)', $original['id'])); + Log::debug(sprintf('Now in updateCombination(#%d)', $original['id'])); // loop all and try to match them: $currency = null; @@ -269,7 +270,7 @@ class RecurrenceUpdateService if (array_key_exists('currency_id', $submitted) || array_key_exists('currency_code', $submitted)) { $currency = $currencyFactory->find( array_key_exists('currency_id', $submitted) ? (int) $submitted['currency_id'] : null, - array_key_exists('currency_code', $submitted) ? $submitted['currency_code'] : null + $submitted['currency_code'] ?? null ); } if (null === $currency) { @@ -281,7 +282,7 @@ class RecurrenceUpdateService if (array_key_exists('foreign_currency_id', $submitted) || array_key_exists('foreign_currency_code', $submitted)) { $foreignCurrency = $currencyFactory->find( array_key_exists('foreign_currency_id', $submitted) ? (int) $submitted['foreign_currency_id'] : null, - array_key_exists('foreign_currency_code', $submitted) ? $submitted['foreign_currency_code'] : null + $submitted['foreign_currency_code'] ?? null ); } if (null === $foreignCurrency) { @@ -317,13 +318,13 @@ class RecurrenceUpdateService // reset category if name is set but empty: // can be removed when v1 is retired. if (array_key_exists('category_name', $submitted) && '' === (string) $submitted['category_name']) { - app('log')->debug('Category name is submitted but is empty. Set category to be empty.'); + Log::debug('Category name is submitted but is empty. Set category to be empty.'); $submitted['category_name'] = null; $submitted['category_id'] = 0; } if (array_key_exists('category_id', $submitted)) { - app('log')->debug(sprintf('Category ID is submitted, set category to be %d.', (int) $submitted['category_id'])); + Log::debug(sprintf('Category ID is submitted, set category to be %d.', (int) $submitted['category_id'])); $this->setCategory($transaction, (int) $submitted['category_id']); } @@ -337,7 +338,7 @@ class RecurrenceUpdateService private function deleteTransaction(Recurrence $recurrence, int $transactionId): void { - app('log')->debug(sprintf('Will delete transaction #%d in recurrence #%d.', $transactionId, $recurrence->id)); + Log::debug(sprintf('Will delete transaction #%d in recurrence #%d.', $transactionId, $recurrence->id)); $recurrence->recurrenceTransactions()->where('id', $transactionId)->delete(); } } diff --git a/app/Services/Password/PwndVerifierV2.php b/app/Services/Password/PwndVerifierV2.php index 79067b27f3..874e5e80a5 100644 --- a/app/Services/Password/PwndVerifierV2.php +++ b/app/Services/Password/PwndVerifierV2.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Services\Password; +use Illuminate\Support\Facades\Log; use GuzzleHttp\Client; use GuzzleHttp\Exception\GuzzleException; use GuzzleHttp\Exception\RequestException; @@ -50,28 +51,28 @@ class PwndVerifierV2 implements Verifier 'timeout' => 3.1415, ]; - app('log')->debug(sprintf('hash prefix is %s', $prefix)); - app('log')->debug(sprintf('rest is %s', $rest)); + Log::debug(sprintf('hash prefix is %s', $prefix)); + Log::debug(sprintf('rest is %s', $rest)); try { $client = new Client(); $res = $client->request('GET', $url, $opt); } catch (GuzzleException|RequestException $e) { - app('log')->error(sprintf('Could not verify password security: %s', $e->getMessage())); + Log::error(sprintf('Could not verify password security: %s', $e->getMessage())); return true; } - app('log')->debug(sprintf('Status code returned is %d', $res->getStatusCode())); + Log::debug(sprintf('Status code returned is %d', $res->getStatusCode())); if (404 === $res->getStatusCode()) { return true; } $strpos = stripos($res->getBody()->getContents(), $rest); if (false === $strpos) { - app('log')->debug(sprintf('%s was not found in result body. Return true.', $rest)); + Log::debug(sprintf('%s was not found in result body. Return true.', $rest)); return true; } - app('log')->debug(sprintf('Found %s, return FALSE.', $rest)); + Log::debug(sprintf('Found %s, return FALSE.', $rest)); return false; } diff --git a/app/Support/Amount.php b/app/Support/Amount.php index f4bf1de35c..ad117d2a39 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -174,7 +174,7 @@ class Amount $fmt->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, $decimalPlaces); $result = (string)$fmt->format((float)$rounded); // intentional float - if (true === $coloured) { + if ($coloured) { if (1 === bccomp($rounded, '0')) { return sprintf('%s', $result); } @@ -355,7 +355,7 @@ class Amount private function getLocaleField(array $info, string $field): bool { - return (is_bool($info[$field]) && true === $info[$field]) + return (is_bool($info[$field]) && $info[$field]) || (is_int($info[$field]) && 1 === $info[$field]); } diff --git a/app/Support/Authentication/RemoteUserGuard.php b/app/Support/Authentication/RemoteUserGuard.php index f53ecaa4fc..a1a19ddb56 100644 --- a/app/Support/Authentication/RemoteUserGuard.php +++ b/app/Support/Authentication/RemoteUserGuard.php @@ -40,18 +40,16 @@ use Illuminate\Support\Facades\Log; class RemoteUserGuard implements Guard { protected Application $application; - protected ?User $user; + protected ?User $user = null; /** * Create a new authentication guard. */ public function __construct(protected UserProvider $provider, Application $app) { - /** @var null|Request $request */ - $request = $app->get('request'); + $app->get('request'); // Log::debug(sprintf('Created RemoteUserGuard for %s "%s"', $request?->getMethod(), $request?->getRequestUri())); $this->application = $app; - $this->user = null; } public function authenticate(): void diff --git a/app/Support/Authentication/RemoteUserProvider.php b/app/Support/Authentication/RemoteUserProvider.php index 629ea7d5be..1b42607fef 100644 --- a/app/Support/Authentication/RemoteUserProvider.php +++ b/app/Support/Authentication/RemoteUserProvider.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Support\Authentication; +use Illuminate\Support\Facades\Log; use FireflyIII\Console\Commands\Correction\CreatesGroupMemberships; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\Role; @@ -41,7 +42,7 @@ class RemoteUserProvider implements UserProvider #[Override] public function rehashPasswordIfRequired(Authenticatable $user, array $credentials, bool $force = false): void { - app('log')->debug(sprintf('Now at %s', __METHOD__)); + Log::debug(sprintf('Now at %s', __METHOD__)); throw new FireflyException(sprintf('Did not implement %s', __METHOD__)); } @@ -53,7 +54,7 @@ class RemoteUserProvider implements UserProvider */ public function retrieveByCredentials(array $credentials): ?Authenticatable { - app('log')->debug(sprintf('Now at %s', __METHOD__)); + Log::debug(sprintf('Now at %s', __METHOD__)); throw new FireflyException(sprintf('Did not implement %s', __METHOD__)); } @@ -65,10 +66,10 @@ class RemoteUserProvider implements UserProvider */ public function retrieveById($identifier): User { - app('log')->debug(sprintf('Now at %s(%s)', __METHOD__, $identifier)); + Log::debug(sprintf('Now at %s(%s)', __METHOD__, $identifier)); $user = User::where('email', $identifier)->first(); if (null === $user) { - app('log')->debug(sprintf('User with email "%s" not found. Will be created.', $identifier)); + Log::debug(sprintf('User with email "%s" not found. Will be created.', $identifier)); $user = User::create( [ 'blocked' => false, @@ -86,7 +87,7 @@ class RemoteUserProvider implements UserProvider // make sure the user gets an administration as well. CreatesGroupMemberships::createGroupMembership($user); - app('log')->debug(sprintf('Going to return user #%d (%s)', $user->id, $user->email)); + Log::debug(sprintf('Going to return user #%d (%s)', $user->id, $user->email)); return $user; } @@ -101,7 +102,7 @@ class RemoteUserProvider implements UserProvider */ public function retrieveByToken($identifier, $token): ?Authenticatable { - app('log')->debug(sprintf('Now at %s', __METHOD__)); + Log::debug(sprintf('Now at %s', __METHOD__)); throw new FireflyException(sprintf('A) Did not implement %s', __METHOD__)); } @@ -115,7 +116,7 @@ class RemoteUserProvider implements UserProvider */ public function updateRememberToken(Authenticatable $user, $token): void { - app('log')->debug(sprintf('Now at %s', __METHOD__)); + Log::debug(sprintf('Now at %s', __METHOD__)); throw new FireflyException(sprintf('B) Did not implement %s', __METHOD__)); } @@ -127,7 +128,7 @@ class RemoteUserProvider implements UserProvider */ public function validateCredentials(Authenticatable $user, array $credentials): bool { - app('log')->debug(sprintf('Now at %s', __METHOD__)); + Log::debug(sprintf('Now at %s', __METHOD__)); throw new FireflyException(sprintf('C) Did not implement %s', __METHOD__)); } diff --git a/app/Support/Binder/AccountList.php b/app/Support/Binder/AccountList.php index 314a0c025f..e2d77aa9c3 100644 --- a/app/Support/Binder/AccountList.php +++ b/app/Support/Binder/AccountList.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Support\Binder; +use Illuminate\Support\Facades\Log; use FireflyIII\Enums\AccountTypeEnum; use Illuminate\Routing\Route; use Illuminate\Support\Collection; @@ -50,7 +51,7 @@ class AccountList implements BinderInterface ; } if ('allAssetAccounts' !== $value) { - $incoming = array_map('\intval', explode(',', $value)); + $incoming = array_map(\intval(...), explode(',', $value)); $list = array_merge(array_unique($incoming), [0]); /** @var Collection $collection */ @@ -66,7 +67,7 @@ class AccountList implements BinderInterface return $collection; } } - app('log')->error(sprintf('Trying to show account list (%s), but user is not logged in or list is empty.', $route->uri)); + Log::error(sprintf('Trying to show account list (%s), but user is not logged in or list is empty.', $route->uri)); throw new NotFoundHttpException(); } diff --git a/app/Support/Binder/BudgetList.php b/app/Support/Binder/BudgetList.php index 6526ebd38a..adaef6db1f 100644 --- a/app/Support/Binder/BudgetList.php +++ b/app/Support/Binder/BudgetList.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Support\Binder; +use Illuminate\Support\Facades\Log; use FireflyIII\Models\Budget; use Illuminate\Routing\Route; use Illuminate\Support\Collection; @@ -47,10 +48,10 @@ class BudgetList implements BinderInterface ; } - $list = array_unique(array_map('\intval', explode(',', $value))); + $list = array_unique(array_map(\intval(...), explode(',', $value))); if (0 === count($list)) { // @phpstan-ignore-line - app('log')->warning('Budget list count is zero, return 404.'); + Log::warning('Budget list count is zero, return 404.'); throw new NotFoundHttpException(); } @@ -71,7 +72,7 @@ class BudgetList implements BinderInterface return $collection; } } - app('log')->warning('BudgetList fallback to 404.'); + Log::warning('BudgetList fallback to 404.'); throw new NotFoundHttpException(); } diff --git a/app/Support/Binder/CLIToken.php b/app/Support/Binder/CLIToken.php index 09c54de3f0..d09da8c0b1 100644 --- a/app/Support/Binder/CLIToken.php +++ b/app/Support/Binder/CLIToken.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Support\Binder; +use Illuminate\Support\Facades\Log; use FireflyIII\Repositories\User\UserRepositoryInterface; use Illuminate\Routing\Route; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -33,10 +34,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; */ class CLIToken implements BinderInterface { - /** - * @return mixed - */ - public static function routeBinder(string $value, Route $route) + public static function routeBinder(string $value, Route $route): string { /** @var UserRepositoryInterface $repository */ $repository = app(UserRepositoryInterface::class); @@ -50,12 +48,12 @@ class CLIToken implements BinderInterface foreach ($users as $user) { $accessToken = app('preferences')->getForUser($user, 'access_token'); if (null !== $accessToken && $accessToken->data === $value) { - app('log')->info(sprintf('Recognized user #%d (%s) from his access token.', $user->id, $user->email)); + Log::info(sprintf('Recognized user #%d (%s) from his access token.', $user->id, $user->email)); return $value; } } - app('log')->error(sprintf('Recognized no users by access token "%s"', $value)); + Log::error(sprintf('Recognized no users by access token "%s"', $value)); throw new NotFoundHttpException(); } diff --git a/app/Support/Binder/CategoryList.php b/app/Support/Binder/CategoryList.php index 1275481fa3..1cd4eb0e3a 100644 --- a/app/Support/Binder/CategoryList.php +++ b/app/Support/Binder/CategoryList.php @@ -46,7 +46,7 @@ class CategoryList implements BinderInterface ; } - $list = array_unique(array_map('\intval', explode(',', $value))); + $list = array_unique(array_map(\intval(...), explode(',', $value))); if (0 === count($list)) { // @phpstan-ignore-line throw new NotFoundHttpException(); } diff --git a/app/Support/Binder/Date.php b/app/Support/Binder/Date.php index 99c0ce4c17..26b955716c 100644 --- a/app/Support/Binder/Date.php +++ b/app/Support/Binder/Date.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Support\Binder; +use Illuminate\Support\Facades\Log; use Carbon\Carbon; use Carbon\Exceptions\InvalidDateException; use Carbon\Exceptions\InvalidFormatException; @@ -61,7 +62,7 @@ class Date implements BinderInterface ]; if (array_key_exists($value, $magicWords)) { $return = $magicWords[$value]; - app('log')->debug(sprintf('User requests "%s", so will return "%s"', $value, $return)); + Log::debug(sprintf('User requests "%s", so will return "%s"', $value, $return)); return $return; } @@ -70,7 +71,7 @@ class Date implements BinderInterface $result = new Carbon($value); } catch (InvalidDateException|InvalidFormatException $e) { // @phpstan-ignore-line $message = sprintf('Could not parse date "%s" for user #%d: %s', $value, auth()->user()->id, $e->getMessage()); - app('log')->error($message); + Log::error($message); throw new NotFoundHttpException('Could not parse value', $e); } diff --git a/app/Support/Binder/JournalList.php b/app/Support/Binder/JournalList.php index 5eadcc587a..0ecdad1fff 100644 --- a/app/Support/Binder/JournalList.php +++ b/app/Support/Binder/JournalList.php @@ -60,7 +60,7 @@ class JournalList implements BinderInterface protected static function parseList(string $value): array { - $list = array_unique(array_map('\intval', explode(',', $value))); + $list = array_unique(array_map(\intval(...), explode(',', $value))); if (0 === count($list)) { // @phpstan-ignore-line throw new NotFoundHttpException(); } diff --git a/app/Support/Binder/TagList.php b/app/Support/Binder/TagList.php index d87c8c69b9..6894fa7c30 100644 --- a/app/Support/Binder/TagList.php +++ b/app/Support/Binder/TagList.php @@ -47,11 +47,11 @@ class TagList implements BinderInterface ->get() ; } - $list = array_unique(array_map('\strtolower', explode(',', $value))); - app('log')->debug('List of tags is', $list); + $list = array_unique(array_map(\strtolower(...), explode(',', $value))); + Log::debug('List of tags is', $list); if (0 === count($list)) { // @phpstan-ignore-line - app('log')->error('Tag list is empty.'); + Log::error('Tag list is empty.'); throw new NotFoundHttpException(); } @@ -62,7 +62,7 @@ class TagList implements BinderInterface $allTags = $repository->get(); $collection = $allTags->filter( - static function (Tag $tag) use ($list) { + static function (Tag $tag) use ($list): bool { if (in_array(strtolower($tag->tag), $list, true)) { Log::debug(sprintf('TagList: (string) found tag #%d ("%s") in list.', $tag->id, $tag->tag)); @@ -82,7 +82,7 @@ class TagList implements BinderInterface return $collection; } } - app('log')->error('TagList: user is not logged in.'); + Log::error('TagList: user is not logged in.'); throw new NotFoundHttpException(); } diff --git a/app/Support/Binder/TagOrId.php b/app/Support/Binder/TagOrId.php index e742fb674d..685119eff3 100644 --- a/app/Support/Binder/TagOrId.php +++ b/app/Support/Binder/TagOrId.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Support\Binder; +use Illuminate\Support\Facades\Log; use FireflyIII\Models\Tag; use FireflyIII\Repositories\Tag\TagRepositoryInterface; use Illuminate\Routing\Route; @@ -47,11 +48,11 @@ class TagOrId implements BinderInterface if (null !== $result) { return $result; } - app('log')->error('TagOrId: tag not found.'); + Log::error('TagOrId: tag not found.'); throw new NotFoundHttpException(); } - app('log')->error('TagOrId: user is not logged in.'); + Log::error('TagOrId: user is not logged in.'); throw new NotFoundHttpException(); } diff --git a/app/Support/Calendar/Calculator.php b/app/Support/Calendar/Calculator.php index ae5c1d7f72..5e08fd614d 100644 --- a/app/Support/Calendar/Calculator.php +++ b/app/Support/Calendar/Calculator.php @@ -37,12 +37,12 @@ class Calculator private static ?SplObjectStorage $intervalMap = null; // @phpstan-ignore-line private static array $intervals = []; - private static function containsInterval(Periodicity $periodicity): bool + private function containsInterval(Periodicity $periodicity): bool { - return self::loadIntervalMap()->contains($periodicity); + return $this->loadIntervalMap()->contains($periodicity); } - private static function loadIntervalMap(): SplObjectStorage + private function loadIntervalMap(): SplObjectStorage { if (self::$intervalMap instanceof SplObjectStorage) { return self::$intervalMap; @@ -59,7 +59,7 @@ class Calculator public function isAvailablePeriodicity(Periodicity $periodicity): bool { - return self::containsInterval($periodicity); + return $this->containsInterval($periodicity); } /** diff --git a/app/Support/Chart/Budget/FrontpageChartGenerator.php b/app/Support/Chart/Budget/FrontpageChartGenerator.php index b5af64fedd..1addb48b8b 100644 --- a/app/Support/Chart/Budget/FrontpageChartGenerator.php +++ b/app/Support/Chart/Budget/FrontpageChartGenerator.php @@ -45,7 +45,7 @@ class FrontpageChartGenerator private readonly BudgetLimitRepositoryInterface $blRepository; private readonly BudgetRepositoryInterface $budgetRepository; private Carbon $end; - private string $monthAndDayFormat; + private string $monthAndDayFormat = ''; private Carbon $start; /** @@ -56,7 +56,6 @@ class FrontpageChartGenerator $this->budgetRepository = app(BudgetRepositoryInterface::class); $this->blRepository = app(BudgetLimitRepositoryInterface::class); $this->opsRepository = app(OperationsRepositoryInterface::class); - $this->monthAndDayFormat = ''; } /** @@ -192,7 +191,7 @@ class FrontpageChartGenerator Log::debug(sprintf('Process spent row (%s)', $entry['currency_code'])); $data = $this->processRow($data, $budget, $limit, $entry); } - if (!($entry['currency_id'] === $limit->transaction_currency_id || $usePrimary)) { + if ($entry['currency_id'] !== $limit->transaction_currency_id && !$usePrimary) { Log::debug(sprintf('Skipping spent row (%s).', $entry['currency_code'])); } } diff --git a/app/Support/Chart/Category/FrontpageChartGenerator.php b/app/Support/Chart/Category/FrontpageChartGenerator.php index cc9b249235..45884c710f 100644 --- a/app/Support/Chart/Category/FrontpageChartGenerator.php +++ b/app/Support/Chart/Category/FrontpageChartGenerator.php @@ -45,7 +45,7 @@ class FrontpageChartGenerator public bool $convertToPrimary = false; public TransactionCurrency $primaryCurrency; private AccountRepositoryInterface $accountRepos; - private array $currencies; + private array $currencies = []; private NoCategoryRepositoryInterface $noCatRepos; private OperationsRepositoryInterface $opsRepos; private CategoryRepositoryInterface $repository; @@ -55,7 +55,6 @@ class FrontpageChartGenerator */ public function __construct(private Carbon $start, private Carbon $end) { - $this->currencies = []; $this->repository = app(CategoryRepositoryInterface::class); $this->accountRepos = app(AccountRepositoryInterface::class); $this->opsRepos = app(OperationsRepositoryInterface::class); diff --git a/app/Support/Chart/ChartData.php b/app/Support/Chart/ChartData.php index d35242c4d6..e3b086295b 100644 --- a/app/Support/Chart/ChartData.php +++ b/app/Support/Chart/ChartData.php @@ -31,12 +31,7 @@ use FireflyIII\Exceptions\FireflyException; */ class ChartData { - private array $series; - - public function __construct() - { - $this->series = []; - } + private array $series = []; /** * @throws FireflyException diff --git a/app/Support/Cronjobs/AbstractCronjob.php b/app/Support/Cronjobs/AbstractCronjob.php index fd287710ac..6211149b05 100644 --- a/app/Support/Cronjobs/AbstractCronjob.php +++ b/app/Support/Cronjobs/AbstractCronjob.php @@ -31,25 +31,20 @@ use Carbon\Carbon; */ abstract class AbstractCronjob { - public bool $jobErrored; - public bool $jobFired; - public bool $jobSucceeded; - public ?string $message; + public bool $jobErrored = false; + public bool $jobFired = false; + public bool $jobSucceeded = false; + public ?string $message = null; public int $timeBetweenRuns = 43200; protected Carbon $date; - protected bool $force; + protected bool $force = false; /** * AbstractCronjob constructor. */ public function __construct() { - $this->force = false; $this->date = today(config('app.timezone')); - $this->jobErrored = false; - $this->jobSucceeded = false; - $this->jobFired = false; - $this->message = null; } abstract public function fire(): void; diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.php index fc464fae22..26ca12798f 100644 --- a/app/Support/ExpandedForm.php +++ b/app/Support/ExpandedForm.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Support; +use Illuminate\Support\Facades\Log; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Support\Form\FormSupport; use Illuminate\Database\Eloquent\Model; @@ -56,9 +57,9 @@ class ExpandedForm // $value = round((float)$value, 8); // } try { - $html = view('form.amount-no-currency', compact('classes', 'name', 'label', 'value', 'options'))->render(); + $html = view('form.amount-no-currency', ['classes' => $classes, 'name' => $name, 'label' => $label, 'value' => $value, 'options' => $options])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Could not render amountNoCurrency(): %s', $e->getMessage())); + Log::error(sprintf('Could not render amountNoCurrency(): %s', $e->getMessage())); $html = 'Could not render amountNoCurrency.'; throw new FireflyException($html, 0, $e); @@ -91,9 +92,9 @@ class ExpandedForm unset($options['placeholder'], $options['autocomplete'], $options['class']); try { - $html = view('form.checkbox', compact('classes', 'name', 'label', 'value', 'options'))->render(); + $html = view('form.checkbox', ['classes' => $classes, 'name' => $name, 'label' => $label, 'value' => $value, 'options' => $options])->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Could not render checkbox(): %s', $e->getMessage())); + Log::debug(sprintf('Could not render checkbox(): %s', $e->getMessage())); $html = 'Could not render checkbox.'; throw new FireflyException($html, 0, $e); @@ -116,9 +117,9 @@ class ExpandedForm unset($options['placeholder']); try { - $html = view('form.date', compact('classes', 'name', 'label', 'value', 'options'))->render(); + $html = view('form.date', ['classes' => $classes, 'name' => $name, 'label' => $label, 'value' => $value, 'options' => $options])->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Could not render date(): %s', $e->getMessage())); + Log::debug(sprintf('Could not render date(): %s', $e->getMessage())); $html = 'Could not render date.'; throw new FireflyException($html, 0, $e); @@ -138,9 +139,9 @@ class ExpandedForm $classes = $this->getHolderClasses($name); try { - $html = view('form.file', compact('classes', 'name', 'label', 'options'))->render(); + $html = view('form.file', ['classes' => $classes, 'name' => $name, 'label' => $label, 'options' => $options])->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Could not render file(): %s', $e->getMessage())); + Log::debug(sprintf('Could not render file(): %s', $e->getMessage())); $html = 'Could not render file.'; throw new FireflyException($html, 0, $e); @@ -164,9 +165,9 @@ class ExpandedForm $options['step'] ??= '1'; try { - $html = view('form.integer', compact('classes', 'name', 'label', 'value', 'options'))->render(); + $html = view('form.integer', ['classes' => $classes, 'name' => $name, 'label' => $label, 'value' => $value, 'options' => $options])->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Could not render integer(): %s', $e->getMessage())); + Log::debug(sprintf('Could not render integer(): %s', $e->getMessage())); $html = 'Could not render integer.'; throw new FireflyException($html, 0, $e); @@ -189,9 +190,9 @@ class ExpandedForm $value = $this->fillFieldValue($name, $value); try { - $html = view('form.location', compact('classes', 'name', 'label', 'value', 'options'))->render(); + $html = view('form.location', ['classes' => $classes, 'name' => $name, 'label' => $label, 'value' => $value, 'options' => $options])->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Could not render location(): %s', $e->getMessage())); + Log::debug(sprintf('Could not render location(): %s', $e->getMessage())); $html = 'Could not render location.'; throw new FireflyException($html, 0, $e); @@ -224,8 +225,6 @@ class ExpandedForm } /** - * @param null $value - * * @throws FireflyException */ public function objectGroup($value = null, ?array $options = null): string @@ -242,9 +241,9 @@ class ExpandedForm } try { - $html = view('form.object_group', compact('classes', 'name', 'label', 'value', 'options'))->render(); + $html = view('form.object_group', ['classes' => $classes, 'name' => $name, 'label' => $label, 'value' => $value, 'options' => $options])->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Could not render objectGroup(): %s', $e->getMessage())); + Log::debug(sprintf('Could not render objectGroup(): %s', $e->getMessage())); $html = 'Could not render objectGroup.'; throw new FireflyException($html, 0, $e); @@ -259,9 +258,9 @@ class ExpandedForm public function optionsList(string $type, string $name): string { try { - $html = view('form.options', compact('type', 'name'))->render(); + $html = view('form.options', ['type' => $type, 'name' => $name])->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Could not render select(): %s', $e->getMessage())); + Log::debug(sprintf('Could not render select(): %s', $e->getMessage())); $html = 'Could not render optionsList.'; throw new FireflyException($html, 0, $e); @@ -280,9 +279,9 @@ class ExpandedForm $classes = $this->getHolderClasses($name); try { - $html = view('form.password', compact('classes', 'name', 'label', 'options'))->render(); + $html = view('form.password', ['classes' => $classes, 'name' => $name, 'label' => $label, 'options' => $options])->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Could not render password(): %s', $e->getMessage())); + Log::debug(sprintf('Could not render password(): %s', $e->getMessage())); $html = 'Could not render password.'; throw new FireflyException($html, 0, $e); @@ -301,9 +300,9 @@ class ExpandedForm $classes = $this->getHolderClasses($name); try { - $html = view('form.password', compact('classes', 'value', 'name', 'label', 'options'))->render(); + $html = view('form.password', ['classes' => $classes, 'value' => $value, 'name' => $name, 'label' => $label, 'options' => $options])->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Could not render passwordWithValue(): %s', $e->getMessage())); + Log::debug(sprintf('Could not render passwordWithValue(): %s', $e->getMessage())); $html = 'Could not render passwordWithValue.'; throw new FireflyException($html, 0, $e); @@ -329,9 +328,9 @@ class ExpandedForm unset($options['placeholder']); try { - $html = view('form.percentage', compact('classes', 'name', 'label', 'value', 'options'))->render(); + $html = view('form.percentage', ['classes' => $classes, 'name' => $name, 'label' => $label, 'value' => $value, 'options' => $options])->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Could not render percentage(): %s', $e->getMessage())); + Log::debug(sprintf('Could not render percentage(): %s', $e->getMessage())); $html = 'Could not render percentage.'; throw new FireflyException($html, 0, $e); @@ -352,9 +351,9 @@ class ExpandedForm $classes = $this->getHolderClasses($name); try { - $html = view('form.static', compact('classes', 'name', 'label', 'value', 'options'))->render(); + $html = view('form.static', ['classes' => $classes, 'name' => $name, 'label' => $label, 'value' => $value, 'options' => $options])->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Could not render staticText(): %s', $e->getMessage())); + Log::debug(sprintf('Could not render staticText(): %s', $e->getMessage())); $html = 'Could not render staticText.'; throw new FireflyException($html, 0, $e); @@ -376,9 +375,9 @@ class ExpandedForm $value = $this->fillFieldValue($name, $value); try { - $html = view('form.text', compact('classes', 'name', 'label', 'value', 'options'))->render(); + $html = view('form.text', ['classes' => $classes, 'name' => $name, 'label' => $label, 'value' => $value, 'options' => $options])->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Could not render text(): %s', $e->getMessage())); + Log::debug(sprintf('Could not render text(): %s', $e->getMessage())); $html = 'Could not render text.'; throw new FireflyException($html, 0, $e); @@ -405,9 +404,9 @@ class ExpandedForm } try { - $html = view('form.textarea', compact('classes', 'name', 'label', 'value', 'options'))->render(); + $html = view('form.textarea', ['classes' => $classes, 'name' => $name, 'label' => $label, 'value' => $value, 'options' => $options])->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Could not render textarea(): %s', $e->getMessage())); + Log::debug(sprintf('Could not render textarea(): %s', $e->getMessage())); $html = 'Could not render textarea.'; throw new FireflyException($html, 0, $e); diff --git a/app/Support/Export/ExportDataGenerator.php b/app/Support/Export/ExportDataGenerator.php index c9f25e12a5..df551fa84b 100644 --- a/app/Support/Export/ExportDataGenerator.php +++ b/app/Support/Export/ExportDataGenerator.php @@ -76,15 +76,15 @@ class ExportDataGenerator private const string EXPORT_ERR = 'Could not export to string: %s'; private Collection $accounts; private Carbon $end; - private bool $exportAccounts; - private bool $exportBills; - private bool $exportBudgets; - private bool $exportCategories; - private bool $exportPiggies; - private bool $exportRecurring; - private bool $exportRules; - private bool $exportTags; - private bool $exportTransactions; + private bool $exportAccounts = false; + private bool $exportBills = false; + private bool $exportBudgets = false; + private bool $exportCategories = false; + private bool $exportPiggies = false; + private bool $exportRecurring = false; + private bool $exportRules = false; + private bool $exportTags = false; + private bool $exportTransactions = false; private Carbon $start; private User $user; private UserGroup $userGroup; // @phpstan-ignore-line @@ -95,15 +95,6 @@ class ExportDataGenerator $this->start = today(config('app.timezone')); $this->start->subYear(); $this->end = today(config('app.timezone')); - $this->exportTransactions = false; - $this->exportAccounts = false; - $this->exportBudgets = false; - $this->exportCategories = false; - $this->exportTags = false; - $this->exportRecurring = false; - $this->exportRules = false; - $this->exportBills = false; - $this->exportPiggies = false; } /** @@ -306,7 +297,7 @@ class ExportDataGenerator try { $string = $csv->toString(); } catch (Exception $e) { // intentional generic exception - app('log')->error($e->getMessage()); + Log::error($e->getMessage()); throw new FireflyException(sprintf(self::EXPORT_ERR, $e->getMessage()), 0, $e); } @@ -375,7 +366,7 @@ class ExportDataGenerator try { $string = $csv->toString(); } catch (Exception $e) { // intentional generic exception - app('log')->error($e->getMessage()); + Log::error($e->getMessage()); throw new FireflyException(sprintf(self::EXPORT_ERR, $e->getMessage()), 0, $e); } @@ -444,7 +435,7 @@ class ExportDataGenerator try { $string = $csv->toString(); } catch (Exception $e) { // intentional generic exception - app('log')->error($e->getMessage()); + Log::error($e->getMessage()); throw new FireflyException(sprintf(self::EXPORT_ERR, $e->getMessage()), 0, $e); } @@ -495,7 +486,7 @@ class ExportDataGenerator try { $string = $csv->toString(); } catch (Exception $e) { // intentional generic exception - app('log')->error($e->getMessage()); + Log::error($e->getMessage()); throw new FireflyException(sprintf(self::EXPORT_ERR, $e->getMessage()), 0, $e); } @@ -575,7 +566,7 @@ class ExportDataGenerator try { $string = $csv->toString(); } catch (Exception $e) { // intentional generic exception - app('log')->error($e->getMessage()); + Log::error($e->getMessage()); throw new FireflyException(sprintf(self::EXPORT_ERR, $e->getMessage()), 0, $e); } @@ -667,7 +658,7 @@ class ExportDataGenerator try { $string = $csv->toString(); } catch (Exception $e) { // intentional generic exception - app('log')->error($e->getMessage()); + Log::error($e->getMessage()); throw new FireflyException(sprintf(self::EXPORT_ERR, $e->getMessage()), 0, $e); } @@ -744,7 +735,7 @@ class ExportDataGenerator try { $string = $csv->toString(); } catch (Exception $e) { // intentional generic exception - app('log')->error($e->getMessage()); + Log::error($e->getMessage()); throw new FireflyException(sprintf(self::EXPORT_ERR, $e->getMessage()), 0, $e); } @@ -800,7 +791,7 @@ class ExportDataGenerator try { $string = $csv->toString(); } catch (Exception $e) { // intentional generic exception - app('log')->error($e->getMessage()); + Log::error($e->getMessage()); throw new FireflyException(sprintf(self::EXPORT_ERR, $e->getMessage()), 0, $e); } @@ -901,7 +892,7 @@ class ExportDataGenerator try { $string = $csv->toString(); } catch (Exception $e) { // intentional generic exception - app('log')->error($e->getMessage()); + Log::error($e->getMessage()); throw new FireflyException(sprintf(self::EXPORT_ERR, $e->getMessage()), 0, $e); } diff --git a/app/Support/Facades/Preferences.php b/app/Support/Facades/Preferences.php index 694e94ec96..998763b705 100644 --- a/app/Support/Facades/Preferences.php +++ b/app/Support/Facades/Preferences.php @@ -23,13 +23,14 @@ declare(strict_types=1); namespace FireflyIII\Support\Facades; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Facade; class Preferences extends Facade { public function __construct() { - app('log')->warning('Hi there'); + Log::warning('Hi there'); } /** diff --git a/app/Support/FireflyConfig.php b/app/Support/FireflyConfig.php index 70d4650c6c..94f004ab5c 100644 --- a/app/Support/FireflyConfig.php +++ b/app/Support/FireflyConfig.php @@ -133,7 +133,7 @@ class FireflyConfig try { $config = Configuration::whereName($name)->whereNull('deleted_at')->first(); } catch (QueryException $e) { - app('log')->error($e->getMessage()); + Log::error($e->getMessage()); $item = new Configuration(); $item->name = $name; $item->data = $value; diff --git a/app/Support/Form/AccountForm.php b/app/Support/Form/AccountForm.php index 9b72eb285a..f512c1aa0c 100644 --- a/app/Support/Form/AccountForm.php +++ b/app/Support/Form/AccountForm.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Support\Form; +use Illuminate\Support\Facades\Log; use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\Account; @@ -93,9 +94,9 @@ class AccountForm unset($options['class']); try { - $html = view('form.assetAccountCheckList', compact('classes', 'selected', 'name', 'label', 'options', 'grouped'))->render(); + $html = view('form.assetAccountCheckList', ['classes' => $classes, 'selected' => $selected, 'name' => $name, 'label' => $label, 'options' => $options, 'grouped' => $grouped])->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Could not render assetAccountCheckList(): %s', $e->getMessage())); + Log::debug(sprintf('Could not render assetAccountCheckList(): %s', $e->getMessage())); $html = 'Could not render assetAccountCheckList.'; throw new FireflyException($html, 0, $e); diff --git a/app/Support/Form/CurrencyForm.php b/app/Support/Form/CurrencyForm.php index 5bf2e0ba77..c8005211cf 100644 --- a/app/Support/Form/CurrencyForm.php +++ b/app/Support/Form/CurrencyForm.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Support\Form; +use Illuminate\Support\Facades\Log; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\TransactionCurrency; use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; @@ -135,13 +136,13 @@ class CurrencyForm $key = 'amount_currency_id_'.$name; $sentCurrencyId = array_key_exists($key, $preFilled) ? (int)$preFilled[$key] : $primaryCurrency->id; - app('log')->debug(sprintf('Sent currency ID is %d', $sentCurrencyId)); + Log::debug(sprintf('Sent currency ID is %d', $sentCurrencyId)); // find this currency in set of currencies: foreach ($currencies as $currency) { if ($currency->id === $sentCurrencyId) { $primaryCurrency = $currency; - app('log')->debug(sprintf('default currency is now %s', $primaryCurrency->code)); + Log::debug(sprintf('default currency is now %s', $primaryCurrency->code)); break; } @@ -153,9 +154,9 @@ class CurrencyForm } try { - $html = view('form.'.$view, compact('primaryCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render(); + $html = view('form.'.$view, ['primaryCurrency' => $primaryCurrency, 'currencies' => $currencies, 'classes' => $classes, 'name' => $name, 'label' => $label, 'value' => $value, 'options' => $options])->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Could not render currencyField(): %s', $e->getMessage())); + Log::debug(sprintf('Could not render currencyField(): %s', $e->getMessage())); $html = 'Could not render currencyField.'; throw new FireflyException($html, 0, $e); @@ -187,13 +188,13 @@ class CurrencyForm $key = 'amount_currency_id_'.$name; $sentCurrencyId = array_key_exists($key, $preFilled) ? (int)$preFilled[$key] : $primaryCurrency->id; - app('log')->debug(sprintf('Sent currency ID is %d', $sentCurrencyId)); + Log::debug(sprintf('Sent currency ID is %d', $sentCurrencyId)); // find this currency in set of currencies: foreach ($currencies as $currency) { if ($currency->id === $sentCurrencyId) { $primaryCurrency = $currency; - app('log')->debug(sprintf('default currency is now %s', $primaryCurrency->code)); + Log::debug(sprintf('default currency is now %s', $primaryCurrency->code)); break; } @@ -205,9 +206,9 @@ class CurrencyForm } try { - $html = view('form.'.$view, compact('primaryCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render(); + $html = view('form.'.$view, ['primaryCurrency' => $primaryCurrency, 'currencies' => $currencies, 'classes' => $classes, 'name' => $name, 'label' => $label, 'value' => $value, 'options' => $options])->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Could not render currencyField(): %s', $e->getMessage())); + Log::debug(sprintf('Could not render currencyField(): %s', $e->getMessage())); $html = 'Could not render currencyField.'; throw new FireflyException($html, 0, $e); diff --git a/app/Support/Form/FormSupport.php b/app/Support/Form/FormSupport.php index 22a580c295..ff1a1f0a7b 100644 --- a/app/Support/Form/FormSupport.php +++ b/app/Support/Form/FormSupport.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Support\Form; +use Illuminate\Support\Facades\Log; use Carbon\Carbon; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use Illuminate\Support\MessageBag; @@ -45,9 +46,9 @@ trait FormSupport unset($options['autocomplete'], $options['placeholder']); try { - $html = view('form.multi-select', compact('classes', 'name', 'label', 'selected', 'options', 'list'))->render(); + $html = view('form.multi-select', ['classes' => $classes, 'name' => $name, 'label' => $label, 'selected' => $selected, 'options' => $options, 'list' => $list])->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Could not render multi-select(): %s', $e->getMessage())); + Log::debug(sprintf('Could not render multi-select(): %s', $e->getMessage())); $html = 'Could not render multi-select.'; } @@ -67,9 +68,9 @@ trait FormSupport unset($options['autocomplete'], $options['placeholder']); try { - $html = view('form.select', compact('classes', 'name', 'label', 'selected', 'options', 'list'))->render(); + $html = view('form.select', ['classes' => $classes, 'name' => $name, 'label' => $label, 'selected' => $selected, 'options' => $options, 'list' => $list])->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Could not render select(): %s', $e->getMessage())); + Log::debug(sprintf('Could not render select(): %s', $e->getMessage())); $html = 'Could not render select.'; } diff --git a/app/Support/Form/RuleForm.php b/app/Support/Form/RuleForm.php index 9566f0301f..066fdbb5f8 100644 --- a/app/Support/Form/RuleForm.php +++ b/app/Support/Form/RuleForm.php @@ -52,9 +52,6 @@ class RuleForm return $this->select($name, $array, $value, $options); } - /** - * @param null $value - */ public function ruleGroupListWithEmpty(string $name, $value = null, ?array $options = null): string { $options ??= []; diff --git a/app/Support/Http/Api/AccountBalanceGrouped.php b/app/Support/Http/Api/AccountBalanceGrouped.php index e335da23eb..0475d7753f 100644 --- a/app/Support/Http/Api/AccountBalanceGrouped.php +++ b/app/Support/Http/Api/AccountBalanceGrouped.php @@ -39,7 +39,7 @@ use Illuminate\Support\Facades\Log; */ class AccountBalanceGrouped { - private array $accountIds; + private array $accountIds = []; private string $carbonFormat; private readonly ExchangeRateConverter $converter; private array $currencies = []; @@ -52,7 +52,6 @@ class AccountBalanceGrouped public function __construct() { - $this->accountIds = []; $this->converter = app(ExchangeRateConverter::class); } @@ -258,7 +257,7 @@ class AccountBalanceGrouped try { $rate = $this->converter->getCurrencyRate($currency, $this->primary, $date); } catch (FireflyException $e) { - app('log')->error($e->getMessage()); + Log::error($e->getMessage()); $rate = '1'; } diff --git a/app/Support/Http/Api/ExchangeRateConverter.php b/app/Support/Http/Api/ExchangeRateConverter.php index 6f6728e825..deb9457f58 100644 --- a/app/Support/Http/Api/ExchangeRateConverter.php +++ b/app/Support/Http/Api/ExchangeRateConverter.php @@ -71,7 +71,7 @@ class ExchangeRateConverter public function enabled(): bool { - return false !== config('cer.enabled') || true === $this->ignoreSettings; + return false !== config('cer.enabled') || $this->ignoreSettings; } /** @@ -147,24 +147,24 @@ class ExchangeRateConverter $rate = $this->getFromDB($currency->id, $euroId, $date->format('Y-m-d')); if (null !== $rate) { - // app('log')->debug(sprintf('Rate for %s to EUR is %s.', $currency->code, $rate)); + // \Illuminate\Support\Facades\Log::debug(sprintf('Rate for %s to EUR is %s.', $currency->code, $rate)); return $rate; } $rate = $this->getFromDB($euroId, $currency->id, $date->format('Y-m-d')); if (null !== $rate) { return bcdiv('1', $rate); - // app('log')->debug(sprintf('Inverted rate for %s to EUR is %s.', $currency->code, $rate)); + // \Illuminate\Support\Facades\Log::debug(sprintf('Inverted rate for %s to EUR is %s.', $currency->code, $rate)); // return $rate; } // grab backup values from config file: $backup = config(sprintf('cer.rates.%s', $currency->code)); if (null !== $backup) { return bcdiv('1', (string)$backup); - // app('log')->debug(sprintf('Backup rate for %s to EUR is %s.', $currency->code, $backup)); + // \Illuminate\Support\Facades\Log::debug(sprintf('Backup rate for %s to EUR is %s.', $currency->code, $backup)); // return $backup; } - // app('log')->debug(sprintf('No rate for %s to EUR.', $currency->code)); + // \Illuminate\Support\Facades\Log::debug(sprintf('No rate for %s to EUR.', $currency->code)); return '0'; } @@ -209,16 +209,16 @@ class ExchangeRateConverter $rate = (string)$result?->rate; if ('' === $rate) { - app('log')->debug(sprintf('ExchangeRateConverter: Found no rate for #%d->#%d (%s) in the DB.', $from, $to, $date)); + Log::debug(sprintf('ExchangeRateConverter: Found no rate for #%d->#%d (%s) in the DB.', $from, $to, $date)); return null; } if (0 === bccomp('0', $rate)) { - app('log')->debug(sprintf('ExchangeRateConverter: Found rate for #%d->#%d (%s) in the DB, but it\'s zero.', $from, $to, $date)); + Log::debug(sprintf('ExchangeRateConverter: Found rate for #%d->#%d (%s) in the DB, but it\'s zero.', $from, $to, $date)); return null; } - app('log')->debug(sprintf('ExchangeRateConverter: Found rate for #%d->#%d (%s) in the DB: %s.', $from, $to, $date, $rate)); + Log::debug(sprintf('ExchangeRateConverter: Found rate for #%d->#%d (%s) in the DB: %s.', $from, $to, $date, $rate)); $cache->store($rate); // if the rate has not been cached during this particular run, save it diff --git a/app/Support/Http/Api/SummaryBalanceGrouped.php b/app/Support/Http/Api/SummaryBalanceGrouped.php index e4fdb41b68..f830ed83e5 100644 --- a/app/Support/Http/Api/SummaryBalanceGrouped.php +++ b/app/Support/Http/Api/SummaryBalanceGrouped.php @@ -33,15 +33,13 @@ class SummaryBalanceGrouped { private const string SUM = 'sum'; private array $amounts = []; - private array $currencies; + private array $currencies = []; private readonly CurrencyRepositoryInterface $currencyRepository; private TransactionCurrency $default; - private array $keys; + private array $keys = [self::SUM]; public function __construct() { - $this->keys = [self::SUM]; - $this->currencies = []; $this->currencyRepository = app(CurrencyRepositoryInterface::class); } diff --git a/app/Support/Http/Controllers/GetConfigurationData.php b/app/Support/Http/Controllers/GetConfigurationData.php index 097204bd83..d1f28200e0 100644 --- a/app/Support/Http/Controllers/GetConfigurationData.php +++ b/app/Support/Http/Controllers/GetConfigurationData.php @@ -70,7 +70,7 @@ trait GetConfigurationData $steps[] = $currentStep; } } - app('log')->debug(sprintf('Total basic steps for %s is %d', $routeKey, count($steps))); + Log::debug(sprintf('Total basic steps for %s is %d', $routeKey, count($steps))); return $steps; } @@ -199,7 +199,7 @@ trait GetConfigurationData } } } - app('log')->debug(sprintf('Total specific steps for route "%s" and page "%s" (routeKey is "%s") is %d', $route, $specificPage, $routeKey, count($steps))); + Log::debug(sprintf('Total specific steps for route "%s" and page "%s" (routeKey is "%s") is %d', $route, $specificPage, $routeKey, count($steps))); return $steps; } @@ -209,7 +209,7 @@ trait GetConfigurationData $config = FireflyConfig::get('last_rt_job', 0); $lastTime = (int)$config?->data; $now = Carbon::now()->getTimestamp(); - app('log')->debug(sprintf('verifyRecurringCronJob: last time is %d ("%s"), now is %d', $lastTime, $config?->data, $now)); + Log::debug(sprintf('verifyRecurringCronJob: last time is %d ("%s"), now is %d', $lastTime, $config?->data, $now)); if (0 === $lastTime) { request()->session()->flash('info', trans('firefly.recurring_never_cron')); diff --git a/app/Support/Http/Controllers/ModelInformation.php b/app/Support/Http/Controllers/ModelInformation.php index 093120cf7a..523c225d26 100644 --- a/app/Support/Http/Controllers/ModelInformation.php +++ b/app/Support/Http/Controllers/ModelInformation.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Support\Http\Controllers; +use Illuminate\Support\Facades\Log; use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\AccountType; @@ -57,8 +58,8 @@ trait ModelInformation ] )->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Throwable was thrown in getActionsForBill(): %s', $e->getMessage())); - app('log')->error($e->getTraceAsString()); + Log::error(sprintf('Throwable was thrown in getActionsForBill(): %s', $e->getMessage())); + Log::error($e->getTraceAsString()); $result = 'Could not render view. See log files.'; throw new FireflyException($result, 0, $e); @@ -144,8 +145,8 @@ trait ModelInformation ] )->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Throwable was thrown in getTriggersForBill(): %s', $e->getMessage())); - app('log')->debug($e->getTraceAsString()); + Log::debug(sprintf('Throwable was thrown in getTriggersForBill(): %s', $e->getMessage())); + Log::debug($e->getTraceAsString()); throw new FireflyException(sprintf('Could not render trigger: %s', $e->getMessage()), 0, $e); } @@ -260,8 +261,8 @@ trait ModelInformation ]; $string = view('rules.partials.trigger', $renderInfo)->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Throwable was thrown in getTriggersForJournal(): %s', $e->getMessage())); - app('log')->debug($e->getTraceAsString()); + Log::debug(sprintf('Throwable was thrown in getTriggersForJournal(): %s', $e->getMessage())); + Log::debug($e->getTraceAsString()); throw new FireflyException(sprintf('Could not render trigger: %s', $e->getMessage()), 0, $e); } diff --git a/app/Support/Http/Controllers/PeriodOverview.php b/app/Support/Http/Controllers/PeriodOverview.php index 6fec7eadda..897f8da732 100644 --- a/app/Support/Http/Controllers/PeriodOverview.php +++ b/app/Support/Http/Controllers/PeriodOverview.php @@ -331,7 +331,7 @@ trait PeriodOverview } return $this->statistics->filter( - fn (PeriodStatistic $statistic) => $statistic->start->eq($start) && $statistic->end->eq($end) && $statistic->type === $type + fn (PeriodStatistic $statistic): bool => $statistic->start->eq($start) && $statistic->end->eq($end) && $statistic->type === $type ); } @@ -344,7 +344,7 @@ trait PeriodOverview } return $this->statistics->filter( - fn (PeriodStatistic $statistic) => $statistic->start->eq($start) && $statistic->end->eq($end) && str_starts_with($statistic->type, $prefix) + fn (PeriodStatistic $statistic): bool => $statistic->start->eq($start) && $statistic->end->eq($end) && str_starts_with($statistic->type, $prefix) ); } @@ -571,10 +571,6 @@ trait PeriodOverview { $result = []; - /** - * @var int $index - * @var array $item - */ foreach ($this->transactions as $item) { $date = Carbon::parse($item['date']); $fits = $item['type'] === $type->value && $date >= $start && $date <= $end; @@ -595,10 +591,6 @@ trait PeriodOverview { $result = []; - /** - * @var int $index - * @var array $item - */ foreach ($this->transactions as $item) { $date = Carbon::parse($item['date']); if ($date >= $start && $date <= $end) { diff --git a/app/Support/Http/Controllers/RenderPartialViews.php b/app/Support/Http/Controllers/RenderPartialViews.php index f7d5df7cb8..962e9d5155 100644 --- a/app/Support/Http/Controllers/RenderPartialViews.php +++ b/app/Support/Http/Controllers/RenderPartialViews.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Support\Http\Controllers; +use Illuminate\Support\Facades\Log; use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Helpers\Report\PopupReportInterface; @@ -68,9 +69,9 @@ trait RenderPartialViews $journals = $popupHelper->balanceForBudget($budget, $account, $attributes); try { - $view = view('popup.report.balance-amount', compact('journals', 'budget', 'account'))->render(); + $view = view('popup.report.balance-amount', ['journals' => $journals, 'budget' => $budget, 'account' => $account])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Could not render: %s', $e->getMessage())); + Log::error(sprintf('Could not render: %s', $e->getMessage())); $view = 'Firefly III could not render the view. Please see the log files.'; throw new FireflyException($view, 0, $e); @@ -91,9 +92,9 @@ trait RenderPartialViews $budgets = $repository->getActiveBudgets(); try { - $result = view('reports.options.budget', compact('budgets'))->render(); + $result = view('reports.options.budget', ['budgets' => $budgets])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Cannot render reports.options.tag: %s', $e->getMessage())); + Log::error(sprintf('Cannot render reports.options.tag: %s', $e->getMessage())); $result = 'Could not render view.'; throw new FireflyException($result, 0, $e); @@ -123,9 +124,9 @@ trait RenderPartialViews $journals = $popupHelper->byBudget($budget, $attributes); try { - $view = view('popup.report.budget-spent-amount', compact('journals', 'budget'))->render(); + $view = view('popup.report.budget-spent-amount', ['journals' => $journals, 'budget' => $budget])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Could not render: %s', $e->getMessage())); + Log::error(sprintf('Could not render: %s', $e->getMessage())); $view = 'Firefly III could not render the view. Please see the log files.'; throw new FireflyException($view, 0, $e); @@ -150,9 +151,9 @@ trait RenderPartialViews $journals = $popupHelper->byCategory($category, $attributes); try { - $view = view('popup.report.category-entry', compact('journals', 'category'))->render(); + $view = view('popup.report.category-entry', ['journals' => $journals, 'category' => $category])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Could not render: %s', $e->getMessage())); + Log::error(sprintf('Could not render: %s', $e->getMessage())); $view = 'Firefly III could not render the view. Please see the log files.'; throw new FireflyException($view, 0, $e); @@ -173,9 +174,9 @@ trait RenderPartialViews $categories = $repository->getCategories(); try { - $result = view('reports.options.category', compact('categories'))->render(); + $result = view('reports.options.category', ['categories' => $categories])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Cannot render reports.options.category: %s', $e->getMessage())); + Log::error(sprintf('Cannot render reports.options.category: %s', $e->getMessage())); $result = 'Could not render view.'; throw new FireflyException($result, 0, $e); @@ -215,9 +216,9 @@ trait RenderPartialViews } try { - $result = view('reports.options.double', compact('set'))->render(); + $result = view('reports.options.double', ['set' => $set])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Cannot render reports.options.tag: %s', $e->getMessage())); + Log::error(sprintf('Cannot render reports.options.tag: %s', $e->getMessage())); $result = 'Could not render view.'; throw new FireflyException($result, 0, $e); @@ -248,9 +249,9 @@ trait RenderPartialViews $journals = $popupHelper->byExpenses($account, $attributes); try { - $view = view('popup.report.expense-entry', compact('journals', 'account'))->render(); + $view = view('popup.report.expense-entry', ['journals' => $journals, 'account' => $account])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Could not render: %s', $e->getMessage())); + Log::error(sprintf('Could not render: %s', $e->getMessage())); $view = 'Firefly III could not render the view. Please see the log files.'; throw new FireflyException($view, 0, $e); @@ -286,8 +287,8 @@ trait RenderPartialViews ] )->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Throwable was thrown in getCurrentActions(): %s', $e->getMessage())); - app('log')->error($e->getTraceAsString()); + Log::debug(sprintf('Throwable was thrown in getCurrentActions(): %s', $e->getMessage())); + Log::error($e->getTraceAsString()); throw new FireflyException(sprintf('Could not render: %s', $e->getMessage()), 0, $e); } @@ -341,8 +342,8 @@ trait RenderPartialViews ] )->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Throwable was thrown in getCurrentTriggers(): %s', $e->getMessage())); - app('log')->error($e->getTraceAsString()); + Log::debug(sprintf('Throwable was thrown in getCurrentTriggers(): %s', $e->getMessage())); + Log::error($e->getTraceAsString()); throw new FireflyException(sprintf('Could not render: %s', $e->getMessage()), 0, $e); } @@ -375,9 +376,9 @@ trait RenderPartialViews $journals = $popupHelper->byIncome($account, $attributes); try { - $view = view('popup.report.income-entry', compact('journals', 'account'))->render(); + $view = view('popup.report.income-entry', ['journals' => $journals, 'account' => $account])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Could not render: %s', $e->getMessage())); + Log::error(sprintf('Could not render: %s', $e->getMessage())); $view = 'Firefly III could not render the view. Please see the log files.'; throw new FireflyException($view, 0, $e); @@ -396,7 +397,7 @@ trait RenderPartialViews try { $result = view('reports.options.no-options')->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Cannot render reports.options.no-options: %s', $e->getMessage())); + Log::error(sprintf('Cannot render reports.options.no-options: %s', $e->getMessage())); $result = 'Could not render view.'; throw new FireflyException($result, 0, $e); @@ -417,9 +418,9 @@ trait RenderPartialViews $tags = $repository->get(); try { - $result = view('reports.options.tag', compact('tags'))->render(); + $result = view('reports.options.tag', ['tags' => $tags])->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Cannot render reports.options.tag: %s', $e->getMessage())); + Log::error(sprintf('Cannot render reports.options.tag: %s', $e->getMessage())); $result = 'Could not render view.'; throw new FireflyException($result, 0, $e); diff --git a/app/Support/Http/Controllers/RequestInformation.php b/app/Support/Http/Controllers/RequestInformation.php index 39a6df3aff..2bd5dad925 100644 --- a/app/Support/Http/Controllers/RequestInformation.php +++ b/app/Support/Http/Controllers/RequestInformation.php @@ -133,11 +133,7 @@ trait RequestInformation return true; } // start and end in the past? use $end - if ($start->lessThanOrEqualTo($date) && $end->lessThanOrEqualTo($date)) { - return true; - } - - return false; + return $start->lessThanOrEqualTo($date) && $end->lessThanOrEqualTo($date); } /** diff --git a/app/Support/Http/Controllers/RuleManagement.php b/app/Support/Http/Controllers/RuleManagement.php index 081d1c44d0..e26d27498c 100644 --- a/app/Support/Http/Controllers/RuleManagement.php +++ b/app/Support/Http/Controllers/RuleManagement.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Support\Http\Controllers; +use Illuminate\Support\Facades\Log; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface; use FireflyIII\Support\Search\OperatorQuerySearch; @@ -56,8 +57,8 @@ trait RuleManagement ] )->render(); } catch (Throwable $e) { - app('log')->error(sprintf('Throwable was thrown in getPreviousActions(): %s', $e->getMessage())); - app('log')->error($e->getTraceAsString()); + Log::error(sprintf('Throwable was thrown in getPreviousActions(): %s', $e->getMessage())); + Log::error($e->getTraceAsString()); throw new FireflyException(sprintf('Could not render: %s', $e->getMessage()), 0, $e); } @@ -101,8 +102,8 @@ trait RuleManagement ] )->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Throwable was thrown in getPreviousTriggers(): %s', $e->getMessage())); - app('log')->error($e->getTraceAsString()); + Log::debug(sprintf('Throwable was thrown in getPreviousTriggers(): %s', $e->getMessage())); + Log::error($e->getTraceAsString()); throw new FireflyException(sprintf('Could not render: %s', $e->getMessage()), 0, $e); } @@ -147,8 +148,8 @@ trait RuleManagement ] )->render(); } catch (Throwable $e) { - app('log')->debug(sprintf('Throwable was thrown in getPreviousTriggers(): %s', $e->getMessage())); - app('log')->error($e->getTraceAsString()); + Log::debug(sprintf('Throwable was thrown in getPreviousTriggers(): %s', $e->getMessage())); + Log::error($e->getTraceAsString()); throw new FireflyException(sprintf('Could not render: %s', $e->getMessage()), 0, $e); } diff --git a/app/Support/Http/Controllers/UserNavigation.php b/app/Support/Http/Controllers/UserNavigation.php index bee31f429e..86804c7dbb 100644 --- a/app/Support/Http/Controllers/UserNavigation.php +++ b/app/Support/Http/Controllers/UserNavigation.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Support\Http\Controllers; +use Illuminate\Support\Facades\Log; use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Models\Account; @@ -48,9 +49,9 @@ trait UserNavigation */ final protected function getPreviousUrl(string $identifier): string { - app('log')->debug(sprintf('Trying to retrieve URL stored under "%s"', $identifier)); + Log::debug(sprintf('Trying to retrieve URL stored under "%s"', $identifier)); $url = (string)session($identifier); - app('log')->debug(sprintf('The URL is %s', $url)); + Log::debug(sprintf('The URL is %s', $url)); return app('steam')->getSafeUrl($url, route('index')); } @@ -79,10 +80,7 @@ trait UserNavigation return in_array($type, $editable, true); } - /** - * @return Redirector|RedirectResponse - */ - final protected function redirectAccountToAccount(Account $account) + final protected function redirectAccountToAccount(Account $account): Redirector|RedirectResponse { $type = $account->accountType->type; if (AccountTypeEnum::RECONCILIATION->value === $type || AccountTypeEnum::INITIAL_BALANCE->value === $type || AccountTypeEnum::LIABILITY_CREDIT->value === $type) { @@ -91,7 +89,7 @@ trait UserNavigation /** @var null|Transaction $transaction */ $transaction = $account->transactions()->first(); if (null === $transaction) { - app('log')->error(sprintf('Account #%d has no transactions. Dont know where it belongs.', $account->id)); + Log::error(sprintf('Account #%d has no transactions. Dont know where it belongs.', $account->id)); session()->flash('error', trans('firefly.cant_find_redirect_account')); return redirect(route('index')); @@ -101,7 +99,7 @@ trait UserNavigation /** @var null|Transaction $other */ $other = $journal->transactions()->where('id', '!=', $transaction->id)->first(); if (null === $other) { - app('log')->error(sprintf('Account #%d has no valid journals. Dont know where it belongs.', $account->id)); + Log::error(sprintf('Account #%d has no valid journals. Dont know where it belongs.', $account->id)); session()->flash('error', trans('firefly.cant_find_redirect_account')); return redirect(route('index')); @@ -113,15 +111,12 @@ trait UserNavigation return redirect(route('index')); } - /** - * @return Redirector|RedirectResponse - */ - final protected function redirectGroupToAccount(TransactionGroup $group) + final protected function redirectGroupToAccount(TransactionGroup $group): Redirector|RedirectResponse { /** @var null|TransactionJournal $journal */ $journal = $group->transactionJournals()->first(); if (null === $journal) { - app('log')->error(sprintf('No journals in group #%d', $group->id)); + Log::error(sprintf('No journals in group #%d', $group->id)); return redirect(route('index')); } @@ -145,7 +140,7 @@ trait UserNavigation $return = app('steam')->getSafePreviousUrl(); session()->put($identifier, $return); - app('log')->debug(sprintf('rememberPreviousUrl: %s: "%s"', $identifier, $return)); + Log::debug(sprintf('rememberPreviousUrl: %s: "%s"', $identifier, $return)); return $return; } diff --git a/app/Support/JsonApi/Enrichments/AccountEnrichment.php b/app/Support/JsonApi/Enrichments/AccountEnrichment.php index 43179333d6..7b59442993 100644 --- a/app/Support/JsonApi/Enrichments/AccountEnrichment.php +++ b/app/Support/JsonApi/Enrichments/AccountEnrichment.php @@ -167,7 +167,7 @@ class AccountEnrichment implements EnrichmentInterface private function appendCollectedData(): void { - $this->collection = $this->collection->map(function (Account $item) { + $this->collection = $this->collection->map(function (Account $item): Account { $id = (int)$item->id; $item->full_account_type = $this->accountTypes[(int)$item->account_type_id] ?? null; $meta = [ diff --git a/app/Support/JsonApi/Enrichments/AvailableBudgetEnrichment.php b/app/Support/JsonApi/Enrichments/AvailableBudgetEnrichment.php index b794275706..8e09d2c5da 100644 --- a/app/Support/JsonApi/Enrichments/AvailableBudgetEnrichment.php +++ b/app/Support/JsonApi/Enrichments/AvailableBudgetEnrichment.php @@ -52,8 +52,6 @@ class AvailableBudgetEnrichment implements EnrichmentInterface private readonly BudgetRepositoryInterface $repository; private array $spentInBudgets = []; private array $spentOutsideBudgets = []; - private User $user; - private UserGroup $userGroup; public function __construct() { @@ -91,14 +89,12 @@ class AvailableBudgetEnrichment implements EnrichmentInterface #[Override] public function setUser(User $user): void { - $this->user = $user; $this->setUserGroup($user->userGroup); } #[Override] public function setUserGroup(UserGroup $userGroup): void { - $this->userGroup = $userGroup; $this->noBudgetRepository->setUserGroup($userGroup); $this->opsRepository->setUserGroup($userGroup); $this->repository->setUserGroup($userGroup); @@ -106,7 +102,7 @@ class AvailableBudgetEnrichment implements EnrichmentInterface private function appendCollectedData(): void { - $this->collection = $this->collection->map(function (AvailableBudget $item) { + $this->collection = $this->collection->map(function (AvailableBudget $item): AvailableBudget { $id = (int)$item->id; $currencyId = $this->currencyIds[$id]; $currency = $this->currencies[$currencyId]; @@ -158,7 +154,7 @@ class AvailableBudgetEnrichment implements EnrichmentInterface $this->spentInBudgets[$id] = array_values($filteredSpentInBudgets); $this->spentOutsideBudgets[$id] = array_values($filteredSpentOutsideBudgets); - if (true === $this->convertToPrimary) { + if ($this->convertToPrimary) { $pcFilteredSpentInBudgets = $this->opsRepository->sumCollectedExpenses($spentInBudgets, $availableBudget->start_date, $availableBudget->end_date, $currency, true); $pcFilteredSpentOutsideBudgets = $this->opsRepository->sumCollectedExpenses($spentOutsideBudgets, $availableBudget->start_date, $availableBudget->end_date, $currency, true); $this->pcSpentInBudgets[$id] = array_values($pcFilteredSpentInBudgets); diff --git a/app/Support/JsonApi/Enrichments/BudgetEnrichment.php b/app/Support/JsonApi/Enrichments/BudgetEnrichment.php index 8d548405d2..92e953a7be 100644 --- a/app/Support/JsonApi/Enrichments/BudgetEnrichment.php +++ b/app/Support/JsonApi/Enrichments/BudgetEnrichment.php @@ -54,8 +54,6 @@ class BudgetEnrichment implements EnrichmentInterface private User $user; private UserGroup $userGroup; - public function __construct() {} - public function enrich(Collection $collection): Collection { $this->collection = $collection; @@ -102,7 +100,7 @@ class BudgetEnrichment implements EnrichmentInterface private function appendCollectedData(): void { - $this->collection = $this->collection->map(function (Budget $item) { + $this->collection = $this->collection->map(function (Budget $item): Budget { $id = (int)$item->id; $meta = [ 'object_group_id' => null, diff --git a/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php b/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php index 8306274b4d..a7c3385645 100644 --- a/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php +++ b/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php @@ -41,7 +41,7 @@ use Illuminate\Support\Facades\Log; class BudgetLimitEnrichment implements EnrichmentInterface { private Collection $collection; - private bool $convertToPrimary; // @phpstan-ignore-line + private readonly bool $convertToPrimary; // @phpstan-ignore-line private array $currencies = []; private array $currencyIds = []; private Carbon $end; @@ -52,7 +52,6 @@ class BudgetLimitEnrichment implements EnrichmentInterface private readonly TransactionCurrency $primaryCurrency; private Carbon $start; private User $user; - private UserGroup $userGroup; public function __construct() { @@ -85,17 +84,15 @@ class BudgetLimitEnrichment implements EnrichmentInterface public function setUser(User $user): void { $this->user = $user; - $this->userGroup = $user->userGroup; } public function setUserGroup(UserGroup $userGroup): void { - $this->userGroup = $userGroup; } private function appendCollectedData(): void { - $this->collection = $this->collection->map(function (BudgetLimit $item) { + $this->collection = $this->collection->map(function (BudgetLimit $item): BudgetLimit { $id = (int)$item->id; $currencyId = (int)$item->transaction_currency_id; if (0 === $currencyId) { @@ -130,11 +127,11 @@ class BudgetLimitEnrichment implements EnrichmentInterface $filteredExpenses = $repository->sumCollectedExpenses($filteredExpenses, $budgetLimit->start_date, $budgetLimit->end_date, $budgetLimit->transactionCurrency); $this->expenses[$id] = array_values($filteredExpenses); - if (true === $this->convertToPrimary && $budgetLimit->transactionCurrency->id !== $this->primaryCurrency->id) { + if ($this->convertToPrimary && $budgetLimit->transactionCurrency->id !== $this->primaryCurrency->id) { $pcFilteredExpenses = $repository->sumCollectedExpenses($expenses, $budgetLimit->start_date, $budgetLimit->end_date, $budgetLimit->transactionCurrency, true); $this->pcExpenses[$id] = array_values($pcFilteredExpenses); } - if (true === $this->convertToPrimary && $budgetLimit->transactionCurrency->id === $this->primaryCurrency->id) { + if ($this->convertToPrimary && $budgetLimit->transactionCurrency->id === $this->primaryCurrency->id) { $this->pcExpenses[$id] = $this->expenses[$id] ?? []; } } @@ -184,7 +181,7 @@ class BudgetLimitEnrichment implements EnrichmentInterface private function filterToBudget(array $expenses, int $budget): array { - $result = array_filter($expenses, fn (array $item) => (int)$item['budget_id'] === $budget); + $result = array_filter($expenses, fn (array $item): bool => (int)$item['budget_id'] === $budget); Log::debug(sprintf('filterToBudget for budget #%d, from %d to %d items', $budget, count($expenses), count($result))); return $result; @@ -192,14 +189,14 @@ class BudgetLimitEnrichment implements EnrichmentInterface private function stringifyIds(): void { - $this->expenses = array_map(fn ($first) => array_map(function ($second) { + $this->expenses = array_map(fn ($first): array => array_map(function (array $second): array { $second['currency_id'] = (string)($second['currency_id'] ?? 0); return $second; }, $first), $this->expenses); - $this->pcExpenses = array_map(fn ($first) => array_map(function ($second) { - $second['currency_id'] = (string)($second['currency_id'] ?? 0); + $this->pcExpenses = array_map(fn (array $first): array => array_map(function (array $second): array { + $second['currency_id'] ??= 0; return $second; }, $first), $this->expenses); diff --git a/app/Support/JsonApi/Enrichments/CategoryEnrichment.php b/app/Support/JsonApi/Enrichments/CategoryEnrichment.php index f470e1c111..699102912e 100644 --- a/app/Support/JsonApi/Enrichments/CategoryEnrichment.php +++ b/app/Support/JsonApi/Enrichments/CategoryEnrichment.php @@ -94,7 +94,7 @@ class CategoryEnrichment implements EnrichmentInterface private function appendCollectedData(): void { - $this->collection = $this->collection->map(function (Category $item) { + $this->collection = $this->collection->map(function (Category $item): Category { $id = (int)$item->id; $meta = [ 'notes' => $this->notes[$id] ?? null, diff --git a/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php b/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php index 23f7b2d2d3..2309e6b228 100644 --- a/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php +++ b/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php @@ -55,8 +55,6 @@ class PiggyBankEnrichment implements EnrichmentInterface private array $notes = []; private array $objectGroups = []; private readonly TransactionCurrency $primaryCurrency; - private User $user; - private UserGroup $userGroup; private ?Carbon $date; public function __construct() @@ -89,18 +87,16 @@ class PiggyBankEnrichment implements EnrichmentInterface public function setUser(User $user): void { - $this->user = $user; $this->setUserGroup($user->userGroup); } public function setUserGroup(UserGroup $userGroup): void { - $this->userGroup = $userGroup; } private function appendCollectedData(): void { - $this->collection = $this->collection->map(function (PiggyBank $item) { + $this->collection = $this->collection->map(function (PiggyBank $item): PiggyBank { $id = (int)$item->id; $currencyId = (int)$item->transaction_currency_id; $currency = $this->currencies[$currencyId] ?? $this->primaryCurrency; diff --git a/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php b/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php index 56a0714466..b8c78464da 100644 --- a/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php +++ b/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php @@ -46,8 +46,6 @@ class PiggyBankEventEnrichment implements EnrichmentInterface private array $ids = []; private array $journalIds = []; private array $piggyBankIds = []; - private User $user; - private UserGroup $userGroup; // private bool $convertToPrimary = false; // private TransactionCurrency $primaryCurrency; @@ -77,18 +75,16 @@ class PiggyBankEventEnrichment implements EnrichmentInterface public function setUser(User $user): void { - $this->user = $user; $this->setUserGroup($user->userGroup); } public function setUserGroup(UserGroup $userGroup): void { - $this->userGroup = $userGroup; } private function appendCollectedData(): void { - $this->collection = $this->collection->map(function (PiggyBankEvent $item) { + $this->collection = $this->collection->map(function (PiggyBankEvent $item): PiggyBankEvent { $id = (int)$item->id; $piggyId = (int)$item->piggy_bank_id; $journalId = (int)$item->transaction_journal_id; diff --git a/app/Support/JsonApi/Enrichments/RecurringEnrichment.php b/app/Support/JsonApi/Enrichments/RecurringEnrichment.php index fb5115136a..1f881ddbc5 100644 --- a/app/Support/JsonApi/Enrichments/RecurringEnrichment.php +++ b/app/Support/JsonApi/Enrichments/RecurringEnrichment.php @@ -60,7 +60,7 @@ class RecurringEnrichment implements EnrichmentInterface private Collection $collection; // private array $transactionTypeIds = []; // private array $transactionTypes = []; - private bool $convertToPrimary; + private readonly bool $convertToPrimary; private array $currencies = []; private array $currencyIds = []; private array $destinationAccountIds = []; @@ -171,7 +171,7 @@ class RecurringEnrichment implements EnrichmentInterface private function appendCollectedData(): void { - $this->collection = $this->collection->map(function (Recurrence $item) { + $this->collection = $this->collection->map(function (Recurrence $item): Recurrence { $id = (int)$item->id; $meta = [ 'notes' => $this->notes[$id] ?? null, @@ -341,7 +341,7 @@ class RecurringEnrichment implements EnrichmentInterface /** @var RecurrenceRepetition $repetition */ foreach ($set as $repetition) { - $recurrence = $this->collection->filter(fn (Recurrence $item) => (int)$item->id === (int)$repetition->recurrence_id)->first(); + $recurrence = $this->collection->filter(fn (Recurrence $item): bool => (int)$item->id === (int)$repetition->recurrence_id)->first(); $fromDate = clone ($recurrence->latest_date ?? $recurrence->first_date); $id = (int)$repetition->recurrence_id; $repId = (int)$repetition->id; @@ -549,11 +549,11 @@ class RecurringEnrichment implements EnrichmentInterface $pcAmount = null; $pcForeignAmount = null; // set the same amount in the primary currency, if both are the same anyway. - if (true === $this->convertToPrimary && $currencyId === (int)$this->primaryCurrency->id) { + if ($this->convertToPrimary && $currencyId === (int)$this->primaryCurrency->id) { $pcAmount = $transaction['amount']; } // convert the amount to the primary currency, if it is not the same. - if (true === $this->convertToPrimary && $currencyId !== (int)$this->primaryCurrency->id) { + if ($this->convertToPrimary && $currencyId !== (int)$this->primaryCurrency->id) { $pcAmount = $converter->convert($this->currencies[$currencyId], $this->primaryCurrency, today(), $transaction['amount']); } if (null !== $transaction['foreign_amount'] && null !== $transaction['foreign_currency_id']) { diff --git a/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php b/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php index 3068c45d88..8d3c134f65 100644 --- a/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php +++ b/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php @@ -59,7 +59,6 @@ class SubscriptionEnrichment implements EnrichmentInterface private ?Carbon $start = null; private array $subscriptionIds = []; private User $user; - private UserGroup $userGroup; public function __construct() { @@ -84,7 +83,7 @@ class SubscriptionEnrichment implements EnrichmentInterface $notes = $this->notes; $paidDates = $this->paidDates; $payDates = $this->payDates; - $this->collection = $this->collection->map(function (Bill $item) use ($notes, $paidDates, $payDates) { + $this->collection = $this->collection->map(function (Bill $item) use ($notes, $paidDates, $payDates): Bill { $id = (int)$item->id; $currency = $item->transactionCurrency; $nem = $this->getNextExpectedMatch($payDates[$id] ?? []); @@ -165,12 +164,10 @@ class SubscriptionEnrichment implements EnrichmentInterface public function setUser(User $user): void { $this->user = $user; - $this->userGroup = $user->userGroup; } public function setUserGroup(UserGroup $userGroup): void { - $this->userGroup = $userGroup; } /** @@ -178,7 +175,7 @@ class SubscriptionEnrichment implements EnrichmentInterface */ protected function lastPaidDate(Bill $subscription, Collection $dates, Carbon $default): Carbon { - $filtered = $dates->filter(fn (TransactionJournal $journal) => (int)$journal->bill_id === (int)$subscription->id); + $filtered = $dates->filter(fn (TransactionJournal $journal): bool => (int)$journal->bill_id === (int)$subscription->id); Log::debug(sprintf('Filtered down from %d to %d entries for bill #%d.', $dates->count(), $filtered->count(), $subscription->id)); if (0 === $filtered->count()) { return $default; @@ -299,7 +296,7 @@ class SubscriptionEnrichment implements EnrichmentInterface // At this point the "next match" is exactly after the last time the bill was paid. $result = []; - $filtered = $set->filter(fn (TransactionJournal $journal) => (int)$journal->bill_id === (int)$subscription->id); + $filtered = $set->filter(fn (TransactionJournal $journal): bool => (int)$journal->bill_id === (int)$subscription->id); foreach ($filtered as $entry) { $array = [ 'transaction_group_id' => (string)$entry->transaction_group_id, @@ -390,7 +387,7 @@ class SubscriptionEnrichment implements EnrichmentInterface private function filterPaidDates(array $entries): array { - return array_map(function (array $entry) { + return array_map(function (array $entry): array { unset($entry['date_object']); return $entry; diff --git a/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php b/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php index a8dccfe9fc..f4d5fdebda 100644 --- a/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php +++ b/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php @@ -54,8 +54,6 @@ class TransactionGroupEnrichment implements EnrichmentInterface private array $notes = []; private readonly TransactionCurrency $primaryCurrency; private array $tags = []; // @phpstan-ignore-line - private User $user; - private UserGroup $userGroup; // @phpstan-ignore-line public function __construct() { @@ -98,13 +96,10 @@ class TransactionGroupEnrichment implements EnrichmentInterface public function setUser(User $user): void { - $this->user = $user; - $this->userGroup = $user->userGroup; } public function setUserGroup(UserGroup $userGroup): void { - $this->userGroup = $userGroup; } private function appendCollectedData(): void @@ -116,12 +111,12 @@ class TransactionGroupEnrichment implements EnrichmentInterface $attachmentCount = $this->attachmentCount; $primaryCurrency = $this->primaryCurrency; - $this->collection = $this->collection->map(function (array $item) use ($primaryCurrency, $notes, $tags, $metaData, $locations, $attachmentCount) { + $this->collection = $this->collection->map(function (array $item) use ($primaryCurrency, $notes, $tags, $metaData, $locations, $attachmentCount): array { foreach ($item['transactions'] as $index => $transaction) { $journalId = (int)$transaction['transaction_journal_id']; // attach notes if they exist: - $item['transactions'][$index]['notes'] = array_key_exists($journalId, $notes) ? $notes[$journalId] : null; + $item['transactions'][$index]['notes'] = $notes[$journalId] ?? null; // attach tags if they exist: $item['transactions'][$index]['tags'] = array_key_exists($journalId, $tags) ? $tags[$journalId] : []; diff --git a/app/Support/JsonApi/Enrichments/WebhookEnrichment.php b/app/Support/JsonApi/Enrichments/WebhookEnrichment.php index e847a16b0f..4553b494e8 100644 --- a/app/Support/JsonApi/Enrichments/WebhookEnrichment.php +++ b/app/Support/JsonApi/Enrichments/WebhookEnrichment.php @@ -47,8 +47,6 @@ class WebhookEnrichment implements EnrichmentInterface private array $ids = []; // @phpstan-ignore-line private array $responses = []; private array $triggers = []; - private User $user; - private UserGroup $userGroup; private array $webhookDeliveries = []; private array $webhookResponses = []; private array $webhookTriggers = []; @@ -77,17 +75,15 @@ class WebhookEnrichment implements EnrichmentInterface public function setUser(User $user): void { - $this->user = $user; } public function setUserGroup(UserGroup $userGroup): void { - $this->userGroup = $userGroup; } private function appendCollectedInfo(): void { - $this->collection = $this->collection->map(function (Webhook $item) { + $this->collection = $this->collection->map(function (Webhook $item): Webhook { $meta = [ 'deliveries' => $this->webhookDeliveries[$item->id] ?? [], 'responses' => $this->webhookResponses[$item->id] ?? [], diff --git a/app/Support/Models/ReturnsIntegerIdTrait.php b/app/Support/Models/ReturnsIntegerIdTrait.php index f3fac096ce..eb628bf26e 100644 --- a/app/Support/Models/ReturnsIntegerIdTrait.php +++ b/app/Support/Models/ReturnsIntegerIdTrait.php @@ -39,7 +39,7 @@ trait ReturnsIntegerIdTrait protected function id(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Support/Models/ReturnsIntegerUserIdTrait.php b/app/Support/Models/ReturnsIntegerUserIdTrait.php index 3f1808923d..e9aeed82ba 100644 --- a/app/Support/Models/ReturnsIntegerUserIdTrait.php +++ b/app/Support/Models/ReturnsIntegerUserIdTrait.php @@ -37,14 +37,14 @@ trait ReturnsIntegerUserIdTrait protected function userGroupId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } protected function userId(): Attribute { return Attribute::make( - get: static fn ($value) => (int)$value, + get: static fn ($value): int => (int)$value, ); } } diff --git a/app/Support/ParseDateString.php b/app/Support/ParseDateString.php index 46df80c290..b1e13aad5d 100644 --- a/app/Support/ParseDateString.php +++ b/app/Support/ParseDateString.php @@ -65,11 +65,7 @@ class ParseDateString return false; } // no x'es - if (!str_contains($date, 'xx') && !str_contains($date, 'xxxx')) { - return false; - } - - return true; + return !(!str_contains($date, 'xx') && !str_contains($date, 'xxxx')); } /** diff --git a/app/Support/Report/Budget/BudgetReportGenerator.php b/app/Support/Report/Budget/BudgetReportGenerator.php index 42f58a2728..246f05dd0d 100644 --- a/app/Support/Report/Budget/BudgetReportGenerator.php +++ b/app/Support/Report/Budget/BudgetReportGenerator.php @@ -49,7 +49,7 @@ class BudgetReportGenerator private Carbon $end; private readonly NoBudgetRepositoryInterface $nbRepository; private readonly OperationsRepositoryInterface $opsRepository; - private array $report; + private array $report = []; private readonly BudgetRepositoryInterface $repository; private Carbon $start; @@ -62,7 +62,6 @@ class BudgetReportGenerator $this->blRepository = app(BudgetLimitRepositoryInterface::class); $this->opsRepository = app(OperationsRepositoryInterface::class); $this->nbRepository = app(NoBudgetRepositoryInterface::class); - $this->report = []; } /** diff --git a/app/Support/Report/Summarizer/TransactionSummarizer.php b/app/Support/Report/Summarizer/TransactionSummarizer.php index 83f057c68c..326dd9f644 100644 --- a/app/Support/Report/Summarizer/TransactionSummarizer.php +++ b/app/Support/Report/Summarizer/TransactionSummarizer.php @@ -120,7 +120,7 @@ class TransactionSummarizer } // then process foreign amount, if it exists. - if (0 !== $foreignCurrencyId && true === $includeForeign) { + if (0 !== $foreignCurrencyId && $includeForeign) { $amount = (string)($journal['foreign_amount'] ?? '0'); $array[$foreignCurrencyId] ??= [ 'sum' => '0', diff --git a/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php b/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php index df73a72f60..f9fd9994ee 100644 --- a/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php +++ b/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Support\Repositories\Recurring; +use Illuminate\Support\Facades\Log; use Carbon\Carbon; /** @@ -110,30 +111,30 @@ trait CalculateRangeOccurrences { $return = []; $attempts = 0; - app('log')->debug('Rep is weekly.'); + Log::debug('Rep is weekly.'); // monday = 1 // sunday = 7 $dayOfWeek = (int)$moment; - app('log')->debug(sprintf('DoW in repetition is %d, in mutator is %d', $dayOfWeek, $start->dayOfWeekIso)); + Log::debug(sprintf('DoW in repetition is %d, in mutator is %d', $dayOfWeek, $start->dayOfWeekIso)); if ($start->dayOfWeekIso > $dayOfWeek) { // day has already passed this week, add one week: $start->addWeek(); - app('log')->debug(sprintf('Jump to next week, so mutator is now: %s', $start->format('Y-m-d'))); + Log::debug(sprintf('Jump to next week, so mutator is now: %s', $start->format('Y-m-d'))); } // today is wednesday (3), expected is friday (5): add two days. // today is friday (5), expected is monday (1), subtract four days. - app('log')->debug(sprintf('Mutator is now: %s', $start->format('Y-m-d'))); + Log::debug(sprintf('Mutator is now: %s', $start->format('Y-m-d'))); $dayDifference = $dayOfWeek - $start->dayOfWeekIso; $start->addDays($dayDifference); - app('log')->debug(sprintf('Mutator is now: %s', $start->format('Y-m-d'))); + Log::debug(sprintf('Mutator is now: %s', $start->format('Y-m-d'))); while ($start <= $end) { if (0 === $attempts % $skipMod && $start->lte($start) && $end->gte($start)) { - app('log')->debug('Date is in range of start+end, add to set.'); + Log::debug('Date is in range of start+end, add to set.'); $return[] = clone $start; } ++$attempts; $start->addWeek(); - app('log')->debug(sprintf('Mutator is now (end of loop): %s', $start->format('Y-m-d'))); + Log::debug(sprintf('Mutator is now (end of loop): %s', $start->format('Y-m-d'))); } return $return; diff --git a/app/Support/Repositories/Recurring/CalculateXOccurrencesSince.php b/app/Support/Repositories/Recurring/CalculateXOccurrencesSince.php index 9587ccc0f7..ccef5770ca 100644 --- a/app/Support/Repositories/Recurring/CalculateXOccurrencesSince.php +++ b/app/Support/Repositories/Recurring/CalculateXOccurrencesSince.php @@ -74,7 +74,7 @@ trait CalculateXOccurrencesSince Log::debug(sprintf('%d is after %d, add a month. Mutator is now...', $mutator->day, $dayOfMonth)); // day has passed already, add a month. $mutator->addMonth(); - Log::debug(sprintf('%s', $mutator->toAtomString())); + Log::debug($mutator->toAtomString()); } while ($total < $count) { diff --git a/app/Support/Request/AppendsLocationData.php b/app/Support/Request/AppendsLocationData.php index b77cd9ee41..26c54ef921 100644 --- a/app/Support/Request/AppendsLocationData.php +++ b/app/Support/Request/AppendsLocationData.php @@ -24,6 +24,8 @@ declare(strict_types=1); namespace FireflyIII\Support\Request; +use Illuminate\Support\Facades\Log; + /** * Trait AppendsLocationData */ @@ -33,8 +35,8 @@ trait AppendsLocationData { $return['store_location'] = false; if (true === $information['store_location']) { - $long = array_key_exists('longitude', $information) ? $information['longitude'] : null; - $lat = array_key_exists('latitude', $information) ? $information['latitude'] : null; + $long = $information['longitude'] ?? null; + $lat = $information['latitude'] ?? null; if (null !== $long && null !== $lat && $this->validLongitude($long) && $this->validLatitude($lat)) { $return['store_location'] = true; $return['longitude'] = $information['longitude']; @@ -49,11 +51,9 @@ trait AppendsLocationData /** * Abstract method stolen from "InteractsWithInput". * - * @param null $key * @param bool $default * * @return mixed - * * @SuppressWarnings("PHPMD.BooleanArgumentFlag") */ abstract public function boolean($key = null, $default = false); @@ -88,7 +88,7 @@ trait AppendsLocationData */ protected function appendLocationData(array $data, ?string $prefix): array { - app('log')->debug(sprintf('Now in appendLocationData("%s")', $prefix), $data); + Log::debug(sprintf('Now in appendLocationData("%s")', $prefix), $data); $data['store_location'] = false; $data['update_location'] = false; $data['remove_location'] = false; @@ -105,7 +105,7 @@ trait AppendsLocationData // for a POST (store), all fields must be present and not NULL. if ($isValidPOST) { - app('log')->debug('Method is POST and all fields present and not NULL.'); + Log::debug('Method is POST and all fields present and not NULL.'); $data['store_location'] = true; $data['longitude'] = $this->convertString($longitudeKey); $data['latitude'] = $this->convertString($latitudeKey); @@ -114,18 +114,18 @@ trait AppendsLocationData // for a PUT (api update) or POST update (UI) if ($isValidPUT) { - app('log')->debug('Method is PUT and all fields present and not NULL.'); + Log::debug('Method is PUT and all fields present and not NULL.'); $data['update_location'] = true; $data['longitude'] = $this->convertString($longitudeKey); $data['latitude'] = $this->convertString($latitudeKey); $data['zoom_level'] = $this->convertString($zoomLevelKey); } if ($isValidEmptyPUT) { - app('log')->debug('Method is PUT and all fields present and NULL.'); + Log::debug('Method is PUT and all fields present and NULL.'); $data['remove_location'] = true; } - app('log')->debug(sprintf('Returning longitude: "%s", latitude: "%s", zoom level: "%s"', $data['longitude'], $data['latitude'], $data['zoom_level'])); - app('log')->debug( + Log::debug(sprintf('Returning longitude: "%s", latitude: "%s", zoom level: "%s"', $data['longitude'], $data['latitude'], $data['zoom_level'])); + Log::debug( sprintf( 'Returning actions: store: %s, update: %s, delete: %s', var_export($data['store_location'], true), @@ -168,74 +168,74 @@ trait AppendsLocationData $latitudeKey = $this->getLocationKey($prefix, 'latitude'); $zoomLevelKey = $this->getLocationKey($prefix, 'zoom_level'); $hasLocationKey = $this->getLocationKey($prefix, 'has_location'); - app('log')->debug('Now in isValidPUT()'); + Log::debug('Now in isValidPUT()'); // all fields must be set: - if (null !== $this->get($longitudeKey) && null !== $this->get($latitudeKey) && null !== $this->get($zoomLevelKey)) { - app('log')->debug('All fields present.'); + if (!in_array(null, [$this->get($longitudeKey), $this->get($latitudeKey), $this->get($zoomLevelKey)], true)) { + Log::debug('All fields present.'); // must be PUT and API route: if ('PUT' === $this->method() && $this->routeIs('api.v1.*')) { - app('log')->debug('Is API location'); + Log::debug('Is API location'); return true; } // if POST and not API route, must also have "has_location" // if is POST and route does not contain API, must also have "has_location" = true if ('POST' === $this->method() && $this->routeIs('*.update') && !$this->routeIs('api.v1.*') && '' !== $hasLocationKey) { - app('log')->debug('Is POST + store route.'); + Log::debug('Is POST + store route.'); $hasLocation = $this->boolean($hasLocationKey); if (true === $hasLocation) { - app('log')->debug('Has form location data + has_location'); + Log::debug('Has form location data + has_location'); return true; } - app('log')->debug('Does not have form location'); + Log::debug('Does not have form location'); return false; } - app('log')->debug('Is not POST API or POST form'); + Log::debug('Is not POST API or POST form'); return false; } - app('log')->debug('Fields not present'); + Log::debug('Fields not present'); return false; } private function isValidPost(?string $prefix): bool { - app('log')->debug('Now in isValidPost()'); + Log::debug('Now in isValidPost()'); $longitudeKey = $this->getLocationKey($prefix, 'longitude'); $latitudeKey = $this->getLocationKey($prefix, 'latitude'); $zoomLevelKey = $this->getLocationKey($prefix, 'zoom_level'); $hasLocationKey = $this->getLocationKey($prefix, 'has_location'); // fields must not be null: - if (null !== $this->get($longitudeKey) && null !== $this->get($latitudeKey) && null !== $this->get($zoomLevelKey)) { - app('log')->debug('All fields present'); + if (!in_array(null, [$this->get($longitudeKey), $this->get($latitudeKey), $this->get($zoomLevelKey)], true)) { + Log::debug('All fields present'); // if is POST and route contains API, this is enough: if ('POST' === $this->method() && $this->routeIs('api.v1.*')) { - app('log')->debug('Is API location'); + Log::debug('Is API location'); return true; } // if is POST and route does not contain API, must also have "has_location" = true if ('POST' === $this->method() && $this->routeIs('*.store') && !$this->routeIs('api.v1.*') && '' !== $hasLocationKey) { - app('log')->debug('Is POST + store route.'); + Log::debug('Is POST + store route.'); $hasLocation = $this->boolean($hasLocationKey); if (true === $hasLocation) { - app('log')->debug('Has form form location'); + Log::debug('Has form form location'); return true; } - app('log')->debug('Does not have form location'); + Log::debug('Does not have form location'); return false; } - app('log')->debug('Is not POST API or POST form'); + Log::debug('Is not POST API or POST form'); return false; } - app('log')->debug('Fields not present'); + Log::debug('Fields not present'); return false; } diff --git a/app/Support/Request/ChecksLogin.php b/app/Support/Request/ChecksLogin.php index 0f9753ee62..2781c131db 100644 --- a/app/Support/Request/ChecksLogin.php +++ b/app/Support/Request/ChecksLogin.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Support\Request; +use Illuminate\Support\Facades\Log; use FireflyIII\Enums\UserRoleEnum; use FireflyIII\Models\UserGroup; use FireflyIII\User; @@ -38,14 +39,14 @@ trait ChecksLogin */ public function authorize(): bool { - app('log')->debug(sprintf('Now in %s', __METHOD__)); + Log::debug(sprintf('Now in %s', __METHOD__)); // Only allow logged-in users $check = auth()->check(); if (!$check) { return false; } if (!property_exists($this, 'acceptedRoles')) { // @phpstan-ignore-line - app('log')->debug('Request class has no acceptedRoles array'); + Log::debug('Request class has no acceptedRoles array'); return true; // check for false already took place. } @@ -54,7 +55,7 @@ trait ChecksLogin $user = auth()->user(); $userGroup = $this->getUserGroup(); if (null === $userGroup) { - app('log')->error('User has no valid user group submitted or otherwise.'); + Log::error('User has no valid user group submitted or otherwise.'); return false; } @@ -80,24 +81,24 @@ trait ChecksLogin { /** @var User $user */ $user = auth()->user(); - app('log')->debug('Now in getUserGroup()'); + Log::debug('Now in getUserGroup()'); /** @var null|UserGroup $userGroup */ $userGroup = $this->route()?->parameter('userGroup'); if (null === $userGroup) { - app('log')->debug('Request class has no userGroup parameter, but perhaps there is a parameter.'); + Log::debug('Request class has no userGroup parameter, but perhaps there is a parameter.'); $userGroupId = (int)$this->get('user_group_id'); if (0 === $userGroupId) { - app('log')->debug(sprintf('Request class has no user_group_id parameter, grab default from user (group #%d).', $user->user_group_id)); + Log::debug(sprintf('Request class has no user_group_id parameter, grab default from user (group #%d).', $user->user_group_id)); $userGroupId = (int)$user->user_group_id; } $userGroup = UserGroup::find($userGroupId); if (null === $userGroup) { - app('log')->error(sprintf('Request class has user_group_id (#%d), but group does not exist.', $userGroupId)); + Log::error(sprintf('Request class has user_group_id (#%d), but group does not exist.', $userGroupId)); return null; } - app('log')->debug('Request class has valid user_group_id.'); + Log::debug('Request class has valid user_group_id.'); } return $userGroup; diff --git a/app/Support/Request/ConvertsDataTypes.php b/app/Support/Request/ConvertsDataTypes.php index f8cb76378f..64804987b9 100644 --- a/app/Support/Request/ConvertsDataTypes.php +++ b/app/Support/Request/ConvertsDataTypes.php @@ -274,11 +274,7 @@ trait ConvertsDataTypes if ('y' === $value) { return true; } - if ('1' === $value) { - return true; - } - - return false; + return '1' === $value; } protected function convertDateTime(?string $string): ?Carbon diff --git a/app/Support/Request/ValidatesWebhooks.php b/app/Support/Request/ValidatesWebhooks.php index 15d41f41ef..331eecc552 100644 --- a/app/Support/Request/ValidatesWebhooks.php +++ b/app/Support/Request/ValidatesWebhooks.php @@ -25,10 +25,10 @@ declare(strict_types=1); namespace FireflyIII\Support\Request; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Enums\WebhookTrigger; use FireflyIII\Models\Webhook; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; trait ValidatesWebhooks { diff --git a/app/Support/Search/AccountSearch.php b/app/Support/Search/AccountSearch.php index 44bb34e893..3820caf7bc 100644 --- a/app/Support/Search/AccountSearch.php +++ b/app/Support/Search/AccountSearch.php @@ -36,30 +36,20 @@ use function Safe\json_encode; */ class AccountSearch implements GenericSearchInterface { - /** @var string */ public const string SEARCH_ALL = 'all'; - /** @var string */ public const string SEARCH_IBAN = 'iban'; - /** @var string */ public const string SEARCH_ID = 'id'; - /** @var string */ public const string SEARCH_NAME = 'name'; - /** @var string */ public const string SEARCH_NUMBER = 'number'; private string $field; private string $query; - private array $types; + private array $types = []; private User $user; - public function __construct() - { - $this->types = []; - } - public function search(): Collection { $searchQuery = $this->user->accounts() diff --git a/app/Support/Search/OperatorQuerySearch.php b/app/Support/Search/OperatorQuerySearch.php index 5546fbc8c9..d13ebc8dd1 100644 --- a/app/Support/Search/OperatorQuerySearch.php +++ b/app/Support/Search/OperatorQuerySearch.php @@ -66,19 +66,19 @@ class OperatorQuerySearch implements SearchInterface private readonly CategoryRepositoryInterface $categoryRepository; private GroupCollectorInterface $collector; private readonly CurrencyRepositoryInterface $currencyRepository; - private array $excludeTags; - private array $includeAnyTags; + private array $excludeTags = []; + private array $includeAnyTags = []; // added to fix #8632 - private array $includeTags; - private array $invalidOperators; - private int $limit; + private array $includeTags = []; + private array $invalidOperators = []; + private int $limit = 25; private readonly Collection $operators; - private int $page; - private array $prohibitedWords; + private int $page = 1; + private array $prohibitedWords = []; private readonly float $startTime; private readonly TagRepositoryInterface $tagRepository; private readonly array $validOperators; - private array $words; + private array $words = []; /** * OperatorQuerySearch constructor. @@ -87,14 +87,6 @@ class OperatorQuerySearch implements SearchInterface { Log::debug('Constructed OperatorQuerySearch'); $this->operators = new Collection(); - $this->page = 1; - $this->words = []; - $this->excludeTags = []; - $this->includeAnyTags = []; - $this->includeTags = []; - $this->prohibitedWords = []; - $this->invalidOperators = []; - $this->limit = 25; $this->validOperators = array_keys(config('search.operators')); $this->startTime = microtime(true); $this->accountRepository = app(AccountRepositoryInterface::class); @@ -293,15 +285,13 @@ class OperatorQuerySearch implements SearchInterface // must be valid operator: $inArray = in_array($operator, $this->validOperators, true); - if ($inArray) { - if ($this->updateCollector($operator, $value, $prohibited)) { - $this->operators->push([ - 'type' => self::getRootOperator($operator), - 'value' => $value, - 'prohibited' => $prohibited, - ]); - Log::debug(sprintf('Added operator type "%s"', $operator)); - } + if ($inArray && $this->updateCollector($operator, $value, $prohibited)) { + $this->operators->push([ + 'type' => self::getRootOperator($operator), + 'value' => $value, + 'prohibited' => $prohibited, + ]); + Log::debug(sprintf('Added operator type "%s"', $operator)); } if (!$inArray) { Log::debug(sprintf('Added INVALID operator type "%s"', $operator)); @@ -495,14 +485,14 @@ class OperatorQuerySearch implements SearchInterface return; } - if (0 === $accounts->count() && true === $prohibited) { + if (0 === $accounts->count() && $prohibited) { Log::debug('Found zero accounts, but the search is negated, so effectively we ignore the search parameter.'); return; } Log::debug(sprintf('Found %d accounts, will filter.', $accounts->count())); $filtered = $accounts->filter( - static fn (Account $account) => $stringMethod(strtolower($account->name), strtolower($value)) + static fn (Account $account): bool => $stringMethod(strtolower($account->name), strtolower($value)) ); if (0 === $filtered->count()) { @@ -530,7 +520,7 @@ class OperatorQuerySearch implements SearchInterface // search direction (default): for source accounts $searchTypes = [AccountTypeEnum::ASSET->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::REVENUE->value]; $collectorMethod = 'setSourceAccounts'; - if (true === $prohibited) { + if ($prohibited) { $collectorMethod = 'excludeSourceAccounts'; } @@ -539,7 +529,7 @@ class OperatorQuerySearch implements SearchInterface // destination can be $searchTypes = [AccountTypeEnum::ASSET->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::EXPENSE->value]; $collectorMethod = 'setDestinationAccounts'; - if (true === $prohibited) { + if ($prohibited) { $collectorMethod = 'excludeDestinationAccounts'; } } @@ -548,7 +538,7 @@ class OperatorQuerySearch implements SearchInterface if (SearchDirection::BOTH === $searchDirection) { $searchTypes = [AccountTypeEnum::ASSET->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::EXPENSE->value, AccountTypeEnum::REVENUE->value]; $collectorMethod = 'setAccounts'; - if (true === $prohibited) { + if ($prohibited) { $collectorMethod = 'excludeAccounts'; } } @@ -580,7 +570,7 @@ class OperatorQuerySearch implements SearchInterface // if found, do filter Log::debug(sprintf('Found %d accounts, will filter.', $accounts->count())); $filtered = $accounts->filter( - static function (Account $account) use ($value, $stringMethod) { + static function (Account $account) use ($value, $stringMethod): bool { // either IBAN or account number $ibanMatch = $stringMethod(strtolower((string)$account->iban), strtolower($value)); $accountNrMatch = false; diff --git a/app/Support/Search/QueryParser/GdbotsQueryParser.php b/app/Support/Search/QueryParser/GdbotsQueryParser.php index 209b09721a..95d65556e8 100644 --- a/app/Support/Search/QueryParser/GdbotsQueryParser.php +++ b/app/Support/Search/QueryParser/GdbotsQueryParser.php @@ -54,15 +54,15 @@ class GdbotsQueryParser implements QueryParserInterface try { $result = $this->parser->parse($query); $nodes = array_map( - fn (GdbotsNode\Node $node) => $this->convertNode($node), + $this->convertNode(...), $result->getNodes() ); return new NodeGroup($nodes); } catch (LogicException|TypeError $e) { fwrite(STDERR, "Setting up GdbotsQueryParserTest\n"); - app('log')->error($e->getMessage()); - app('log')->error(sprintf('Could not parse search: "%s".', $query)); + Log::error($e->getMessage()); + Log::error(sprintf('Could not parse search: "%s".', $query)); throw new FireflyException(sprintf('Invalid search value "%s". See the logs.', e($query)), 0, $e); } @@ -87,7 +87,7 @@ class GdbotsQueryParser implements QueryParserInterface return new NodeGroup( array_map( - fn (GdbotsNode\Node $subNode) => $this->convertNode($subNode), + $this->convertNode(...), $node->getNodes() ) ); diff --git a/app/Support/Steam.php b/app/Support/Steam.php index ebab95b7ae..dde23d2087 100644 --- a/app/Support/Steam.php +++ b/app/Support/Steam.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Support; +use Deprecated; use Carbon\Carbon; use Exception; use FireflyIII\Exceptions\FireflyException; @@ -78,7 +79,7 @@ class Steam $currency = $currencies[$account->id]; // second array - $accountSums = array_filter($arrayOfSums, fn ($entry) => $entry['account_id'] === $account->id); + $accountSums = array_filter($arrayOfSums, fn (array $entry): bool => $entry['account_id'] === $account->id); if (0 === count($accountSums)) { $result[$account->id] = $return; @@ -289,21 +290,21 @@ class Steam return str_replace($search, '', $string); } - /** - * @deprecated - * By default this method returns "smaller than or equal to", so be careful with END OF DAY. - * If you need end of day balance, use "inclusive = false". - * - * Returns the balance of an account at exact moment given. Array with at least one value. - * Always returns: - * "balance": balance in the account's currency OR user's primary currency if the account has no currency - * "EUR": balance in EUR (or whatever currencies the account has balance in) - * - * If the user has $convertToPrimary: - * "balance": balance in the account's currency OR user's primary currency if the account has no currency - * --> "pc_balance": balance in the user's primary currency, with all amounts converted to the primary currency. - * "EUR": balance in EUR (or whatever currencies the account has balance in) - */ + #[Deprecated(message: <<<'TXT' + + By default this method returns "smaller than or equal to", so be careful with END OF DAY. + If you need end of day balance, use "inclusive = false". + + Returns the balance of an account at exact moment given. Array with at least one value. + Always returns: + "balance": balance in the account's currency OR user's primary currency if the account has no currency + "EUR": balance in EUR (or whatever currencies the account has balance in) + + If the user has $convertToPrimary: + "balance": balance in the account's currency OR user's primary currency if the account has no currency + --> "pc_balance": balance in the user's primary currency, with all amounts converted to the primary currency. + "EUR": balance in EUR (or whatever currencies the account has balance in) + TXT)] public function finalAccountBalance(Account $account, Carbon $date, ?TransactionCurrency $primary = null, ?bool $convertToPrimary = null, bool $inclusive = true): array { diff --git a/app/Support/System/GeneratesInstallationId.php b/app/Support/System/GeneratesInstallationId.php index 732237214f..32ca760483 100644 --- a/app/Support/System/GeneratesInstallationId.php +++ b/app/Support/System/GeneratesInstallationId.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Support\System; +use Illuminate\Support\Facades\Log; use FireflyIII\Exceptions\FireflyException; use Ramsey\Uuid\Uuid; @@ -37,7 +38,7 @@ trait GeneratesInstallationId try { $config = app('fireflyconfig')->get('installation_id'); } catch (FireflyException) { - app('log')->info('Could not create or generate installation ID. Do not continue.'); + Log::info('Could not create or generate installation ID. Do not continue.'); return; } @@ -50,7 +51,7 @@ trait GeneratesInstallationId if (null === $config) { $uuid4 = Uuid::uuid4(); $uniqueId = (string)$uuid4; - app('log')->info(sprintf('Created Firefly III installation ID %s', $uniqueId)); + Log::info(sprintf('Created Firefly III installation ID %s', $uniqueId)); app('fireflyconfig')->set('installation_id', $uniqueId); } } diff --git a/app/Support/System/OAuthKeys.php b/app/Support/System/OAuthKeys.php index 0f66372a69..a41c56085b 100644 --- a/app/Support/System/OAuthKeys.php +++ b/app/Support/System/OAuthKeys.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Support\System; +use Illuminate\Support\Facades\Log; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Support\Facades\FireflyConfig; use Illuminate\Contracts\Encryption\DecryptException; @@ -69,15 +70,11 @@ class OAuthKeys $privateKey = (string)FireflyConfig::get(self::PRIVATE_KEY)?->data; $publicKey = (string)FireflyConfig::get(self::PUBLIC_KEY)?->data; } catch (ContainerExceptionInterface|FireflyException|NotFoundExceptionInterface $e) { - app('log')->error(sprintf('Could not validate keysInDatabase(): %s', $e->getMessage())); - app('log')->error($e->getTraceAsString()); + Log::error(sprintf('Could not validate keysInDatabase(): %s', $e->getMessage())); + Log::error($e->getTraceAsString()); } } - if ('' !== $privateKey && '' !== $publicKey) { - return true; - } - - return false; + return '' !== $privateKey && '' !== $publicKey; } /** @@ -95,8 +92,8 @@ class OAuthKeys $privateContent = Crypt::decrypt($privateKey); $publicContent = Crypt::decrypt($publicKey); } catch (DecryptException $e) { - app('log')->error('Could not decrypt pub/private keypair.'); - app('log')->error($e->getMessage()); + Log::error('Could not decrypt pub/private keypair.'); + Log::error($e->getMessage()); // delete config vars from DB: FireflyConfig::delete(self::PRIVATE_KEY); diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php index 840b7353d5..7ff9b09f3e 100644 --- a/app/Support/Twig/General.php +++ b/app/Support/Twig/General.php @@ -104,7 +104,7 @@ class General extends AbstractExtension { return new TwigFunction( 'activeRoutePartialObjectType', - static function ($context): string { + static function (array $context): string { [, $route, $objectType] = func_get_args(); $activeObjectType = $context['objectType'] ?? false; @@ -292,11 +292,7 @@ class General extends AbstractExtension 'hasRole', static function (string $role): bool { $repository = app(UserRepositoryInterface::class); - if ($repository->hasRole(auth()->user(), $role)) { - return true; - } - - return false; + return $repository->hasRole(auth()->user(), $role); } ); } diff --git a/app/Support/Twig/Rule.php b/app/Support/Twig/Rule.php index ea60a67a3e..afd1d49bb4 100644 --- a/app/Support/Twig/Rule.php +++ b/app/Support/Twig/Rule.php @@ -37,7 +37,7 @@ class Rule extends AbstractExtension { return new TwigFunction( 'allRuleActions', - static function () { + static function (): array { // array of valid values for actions $ruleActions = array_keys(Config::get('firefly.rule-actions')); $possibleActions = []; @@ -56,7 +56,7 @@ class Rule extends AbstractExtension { return new TwigFunction( 'allJournalTriggers', - static fn () => [ + static fn (): array => [ 'store-journal' => (string)trans('firefly.rule_trigger_store_journal'), 'update-journal' => (string)trans('firefly.rule_trigger_update_journal'), 'manual-activation' => (string)trans('firefly.rule_trigger_manual'), @@ -68,7 +68,7 @@ class Rule extends AbstractExtension { return new TwigFunction( 'allRuleTriggers', - static function () { + static function (): array { $ruleTriggers = array_keys(config('search.operators')); $possibleTriggers = []; foreach ($ruleTriggers as $key) { diff --git a/app/Support/Twig/TransactionGroupTwig.php b/app/Support/Twig/TransactionGroupTwig.php index 3033a84872..74c8199469 100644 --- a/app/Support/Twig/TransactionGroupTwig.php +++ b/app/Support/Twig/TransactionGroupTwig.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Support\Twig; +use Carbon\CarbonInterface; use Carbon\Carbon; use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Enums\TransactionTypeEnum; @@ -80,7 +81,7 @@ class TransactionGroupTwig extends AbstractExtension { return new TwigFunction( 'journalGetMetaDate', - static function (int $journalId, string $metaField) { + static function (int $journalId, string $metaField): CarbonInterface|Carbon { /** @var null|TransactionJournalMeta $entry */ $entry = DB::table('journal_meta') ->where('name', $metaField) @@ -122,7 +123,7 @@ class TransactionGroupTwig extends AbstractExtension { return new TwigFunction( 'journalHasMeta', - static function (int $journalId, string $metaField) { + static function (int $journalId, string $metaField): bool { $count = DB::table('journal_meta') ->where('name', $metaField) ->where('transaction_journal_id', $journalId) diff --git a/app/Support/Twig/Translation.php b/app/Support/Twig/Translation.php index d316895ed7..fca8a41fbb 100644 --- a/app/Support/Twig/Translation.php +++ b/app/Support/Twig/Translation.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Support\Twig; +use Illuminate\Contracts\Translation\Translator; use Override; use Twig\Extension\AbstractExtension; use Twig\TwigFilter; @@ -39,7 +40,7 @@ class Translation extends AbstractExtension return [ new TwigFilter( '_', - static fn ($name) => (string)trans(sprintf('firefly.%s', $name)), + static fn (string $name) => (string)trans(sprintf('firefly.%s', $name)), ['is_safe' => ['html']] ), ]; @@ -58,7 +59,7 @@ class Translation extends AbstractExtension { return new TwigFunction( 'journalLinkTranslation', - static function (string $direction, string $original) { + static function (string $direction, string $original): string|Translator|array { $key = sprintf('firefly.%s_%s', $original, $direction); $translation = trans($key); if ($key === $translation) { @@ -75,7 +76,7 @@ class Translation extends AbstractExtension { return new TwigFunction( '__', - static function (string $key) { + static function (string $key): string|Translator|array { $translation = trans($key); if ($key === $translation) { return $key; diff --git a/app/TransactionRules/Actions/AddTag.php b/app/TransactionRules/Actions/AddTag.php index 3823f7721f..d5e25c8be9 100644 --- a/app/TransactionRules/Actions/AddTag.php +++ b/app/TransactionRules/Actions/AddTag.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Illuminate\Support\Facades\Log; use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray; use FireflyIII\Events\TriggeredAuditLog; use FireflyIII\Factory\TagFactory; @@ -68,7 +69,7 @@ class AddTag implements ActionInterface if (0 === $count) { // add to journal: DB::table('tag_transaction_journal')->insert(['tag_id' => $tag->id, 'transaction_journal_id' => $journal['transaction_journal_id']]); - app('log')->debug(sprintf('RuleAction AddTag. Added tag #%d ("%s") to journal %d.', $tag->id, $tag->tag, $journal['transaction_journal_id'])); + Log::debug(sprintf('RuleAction AddTag. Added tag #%d ("%s") to journal %d.', $tag->id, $tag->tag, $journal['transaction_journal_id'])); /** @var TransactionJournal $object */ $object = TransactionJournal::find($journal['transaction_journal_id']); @@ -78,7 +79,7 @@ class AddTag implements ActionInterface return true; } - app('log')->debug( + Log::debug( sprintf('RuleAction AddTag fired but tag %d ("%s") was already added to journal %d.', $tag->id, $tag->tag, $journal['transaction_journal_id']) ); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.tag_already_added', ['tag' => $tagName]))); diff --git a/app/TransactionRules/Actions/AppendDescriptionToNotes.php b/app/TransactionRules/Actions/AppendDescriptionToNotes.php index 952d27fd3a..bff3b7b292 100644 --- a/app/TransactionRules/Actions/AppendDescriptionToNotes.php +++ b/app/TransactionRules/Actions/AppendDescriptionToNotes.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Illuminate\Support\Facades\Log; use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray; use FireflyIII\Events\TriggeredAuditLog; use FireflyIII\Models\Note; @@ -51,7 +52,7 @@ class AppendDescriptionToNotes implements ActionInterface /** @var null|TransactionJournal $object */ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); if (null === $object) { - app('log')->error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id'])); + Log::error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id'])); event(new RuleActionFailedOnArray($this->action, $journal, (string) trans('rules.journal_other_user'))); return false; diff --git a/app/TransactionRules/Actions/AppendNotes.php b/app/TransactionRules/Actions/AppendNotes.php index c27853d8ed..483accfd44 100644 --- a/app/TransactionRules/Actions/AppendNotes.php +++ b/app/TransactionRules/Actions/AppendNotes.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Illuminate\Support\Facades\Log; use FireflyIII\Events\TriggeredAuditLog; use FireflyIII\Models\Note; use FireflyIII\Models\RuleAction; @@ -64,7 +65,7 @@ class AppendNotes implements ActionInterface /** @var TransactionJournal $object */ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); - app('log')->debug(sprintf('RuleAction AppendNotes appended "%s" to "%s".', $append, $before)); + Log::debug(sprintf('RuleAction AppendNotes appended "%s" to "%s".', $append, $before)); event(new TriggeredAuditLog($this->action->rule, $object, 'update_notes', $before, $text)); return true; diff --git a/app/TransactionRules/Actions/AppendNotesToDescription.php b/app/TransactionRules/Actions/AppendNotesToDescription.php index 86c46891b3..e9543f7f1d 100644 --- a/app/TransactionRules/Actions/AppendNotesToDescription.php +++ b/app/TransactionRules/Actions/AppendNotesToDescription.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Illuminate\Support\Facades\Log; use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray; use FireflyIII\Events\TriggeredAuditLog; use FireflyIII\Models\Note; @@ -48,20 +49,20 @@ class AppendNotesToDescription implements ActionInterface public function actOnArray(array $journal): bool { - app('log')->debug('Now in AppendNotesToDescription'); + Log::debug('Now in AppendNotesToDescription'); $this->refreshNotes($journal); /** @var null|TransactionJournal $object */ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); if (null === $object) { - app('log')->error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id'])); + Log::error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_other_user'))); return false; } $note = $object->notes()->first(); if (null === $note) { - app('log')->debug('Journal has no notes.'); + Log::debug('Journal has no notes.'); $note = new Note(); $note->noteable()->associate($object); $note->text = ''; @@ -71,7 +72,7 @@ class AppendNotesToDescription implements ActionInterface $before = $object->description; $object->description = trim(sprintf('%s %s', $object->description, (string) $this->clearString($note->text))); $object->save(); - app('log')->debug(sprintf('Journal description is updated to "%s".', $object->description)); + Log::debug(sprintf('Journal description is updated to "%s".', $object->description)); event(new TriggeredAuditLog($this->action->rule, $object, 'update_description', $before, $object->description)); diff --git a/app/TransactionRules/Actions/ClearBudget.php b/app/TransactionRules/Actions/ClearBudget.php index 08e7dce7fa..3d9ece4d31 100644 --- a/app/TransactionRules/Actions/ClearBudget.php +++ b/app/TransactionRules/Actions/ClearBudget.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Illuminate\Support\Facades\Log; use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray; use FireflyIII\Events\TriggeredAuditLog; use FireflyIII\Models\RuleAction; @@ -45,7 +46,7 @@ class ClearBudget implements ActionInterface $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); $budget = $object->budgets()->first(); if (null === $budget) { - app('log')->debug(sprintf('RuleAction ClearBudget, no budget in journal #%d.', $journal['transaction_journal_id'])); + Log::debug(sprintf('RuleAction ClearBudget, no budget in journal #%d.', $journal['transaction_journal_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_already_no_budget'))); return false; @@ -55,7 +56,7 @@ class ClearBudget implements ActionInterface event(new TriggeredAuditLog($this->action->rule, $object, 'clear_budget', $budget->name, null)); - app('log')->debug(sprintf('RuleAction ClearBudget removed all budgets from journal #%d.', $journal['transaction_journal_id'])); + Log::debug(sprintf('RuleAction ClearBudget removed all budgets from journal #%d.', $journal['transaction_journal_id'])); return true; } diff --git a/app/TransactionRules/Actions/ClearCategory.php b/app/TransactionRules/Actions/ClearCategory.php index 73fa40b3f0..05e3857bd5 100644 --- a/app/TransactionRules/Actions/ClearCategory.php +++ b/app/TransactionRules/Actions/ClearCategory.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Illuminate\Support\Facades\Log; use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray; use FireflyIII\Events\TriggeredAuditLog; use FireflyIII\Models\RuleAction; @@ -45,7 +46,7 @@ class ClearCategory implements ActionInterface $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); $category = $object->categories()->first(); if (null === $category) { - app('log')->debug(sprintf('RuleAction ClearCategory, no category in journal #%d.', $journal['transaction_journal_id'])); + Log::debug(sprintf('RuleAction ClearCategory, no category in journal #%d.', $journal['transaction_journal_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_already_no_category'))); return false; @@ -55,7 +56,7 @@ class ClearCategory implements ActionInterface event(new TriggeredAuditLog($this->action->rule, $object, 'clear_category', $category->name, null)); - app('log')->debug(sprintf('RuleAction ClearCategory removed all categories from journal #%d.', $journal['transaction_journal_id'])); + Log::debug(sprintf('RuleAction ClearCategory removed all categories from journal #%d.', $journal['transaction_journal_id'])); return true; } diff --git a/app/TransactionRules/Actions/ClearNotes.php b/app/TransactionRules/Actions/ClearNotes.php index 48e770012b..8e03c895c0 100644 --- a/app/TransactionRules/Actions/ClearNotes.php +++ b/app/TransactionRules/Actions/ClearNotes.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Illuminate\Support\Facades\Log; use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray; use FireflyIII\Events\TriggeredAuditLog; use FireflyIII\Models\Note; @@ -48,7 +49,7 @@ class ClearNotes implements ActionInterface /** @var null|Note $notes */ $notes = $object->notes()->first(); if (null === $notes) { - app('log')->debug(sprintf('RuleAction ClearNotes, journal #%d has no notes.', $journal['transaction_journal_id'])); + Log::debug(sprintf('RuleAction ClearNotes, journal #%d has no notes.', $journal['transaction_journal_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_already_no_notes'))); return false; @@ -60,7 +61,7 @@ class ClearNotes implements ActionInterface ->where('noteable_type', TransactionJournal::class) ->delete() ; - app('log')->debug(sprintf('RuleAction ClearNotes removed all notes from journal #%d.', $journal['transaction_journal_id'])); + Log::debug(sprintf('RuleAction ClearNotes removed all notes from journal #%d.', $journal['transaction_journal_id'])); event(new TriggeredAuditLog($this->action->rule, $object, 'clear_notes', $before, null)); diff --git a/app/TransactionRules/Actions/ConvertToDeposit.php b/app/TransactionRules/Actions/ConvertToDeposit.php index b61599190d..cb95871410 100644 --- a/app/TransactionRules/Actions/ConvertToDeposit.php +++ b/app/TransactionRules/Actions/ConvertToDeposit.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Illuminate\Support\Facades\Log; use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray; @@ -56,36 +57,36 @@ class ConvertToDeposit implements ActionInterface /** @var null|TransactionJournal $object */ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); if (null === $object) { - app('log')->error(sprintf('Cannot find journal #%d, cannot convert to deposit.', $journal['transaction_journal_id'])); + Log::error(sprintf('Cannot find journal #%d, cannot convert to deposit.', $journal['transaction_journal_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_not_found'))); return false; } $groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count(); if ($groupCount > 1) { - app('log')->error(sprintf('Group #%d has more than one transaction in it, cannot convert to deposit.', $journal['transaction_group_id'])); + Log::error(sprintf('Group #%d has more than one transaction in it, cannot convert to deposit.', $journal['transaction_group_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.split_group'))); return false; } - app('log')->debug(sprintf('Convert journal #%d to deposit.', $journal['transaction_journal_id'])); + Log::debug(sprintf('Convert journal #%d to deposit.', $journal['transaction_journal_id'])); $type = $object->transactionType->type; if (TransactionTypeEnum::DEPOSIT->value === $type) { - app('log')->error(sprintf('Journal #%d is already a deposit (rule #%d).', $journal['transaction_journal_id'], $this->action->rule_id)); + Log::error(sprintf('Journal #%d is already a deposit (rule #%d).', $journal['transaction_journal_id'], $this->action->rule_id)); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.is_already_deposit'))); return false; } if (TransactionTypeEnum::WITHDRAWAL->value === $type) { - app('log')->debug('Going to transform a withdrawal to a deposit.'); + Log::debug('Going to transform a withdrawal to a deposit.'); try { $res = $this->convertWithdrawalArray($object, $actionValue); } catch (FireflyException $e) { - app('log')->debug('Could not convert withdrawal to deposit.'); - app('log')->error($e->getMessage()); + Log::debug('Could not convert withdrawal to deposit.'); + Log::error($e->getMessage()); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.complex_error'))); return false; @@ -96,13 +97,13 @@ class ConvertToDeposit implements ActionInterface return $res; } if (TransactionTypeEnum::TRANSFER->value === $type) { - app('log')->debug('Going to transform a transfer to a deposit.'); + Log::debug('Going to transform a transfer to a deposit.'); try { $res = $this->convertTransferArray($object, $actionValue); } catch (FireflyException $e) { - app('log')->debug('Could not convert transfer to deposit.'); - app('log')->error($e->getMessage()); + Log::debug('Could not convert transfer to deposit.'); + Log::error($e->getMessage()); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.complex_error'))); return false; @@ -147,7 +148,7 @@ class ConvertToDeposit implements ActionInterface $opposingAccount = $factory->findOrCreate($opposingName, AccountTypeEnum::REVENUE->value); } - app('log')->debug(sprintf('ConvertToDeposit. Action value is "%s", new opposing name is "%s"', $actionValue, $opposingAccount->name)); + Log::debug(sprintf('ConvertToDeposit. Action value is "%s", new opposing name is "%s"', $actionValue, $opposingAccount->name)); // update the source transaction and put in the new revenue ID. DB::table('transactions') @@ -171,7 +172,7 @@ class ConvertToDeposit implements ActionInterface ->update(['transaction_type_id' => $newType->id, 'bill_id' => null]) ; - app('log')->debug('Converted withdrawal to deposit.'); + Log::debug('Converted withdrawal to deposit.'); return true; } @@ -235,7 +236,7 @@ class ConvertToDeposit implements ActionInterface $opposingAccount = $factory->findOrCreate($opposingName, AccountTypeEnum::REVENUE->value); } - app('log')->debug(sprintf('ConvertToDeposit. Action value is "%s", revenue name is "%s"', $actionValue, $opposingAccount->name)); + Log::debug(sprintf('ConvertToDeposit. Action value is "%s", revenue name is "%s"', $actionValue, $opposingAccount->name)); // update source transaction(s) to be revenue account DB::table('transactions') @@ -252,7 +253,7 @@ class ConvertToDeposit implements ActionInterface ->update(['transaction_type_id' => $newType->id, 'bill_id' => null]) ; - app('log')->debug('Converted transfer to deposit.'); + Log::debug('Converted transfer to deposit.'); return true; } diff --git a/app/TransactionRules/Actions/ConvertToTransfer.php b/app/TransactionRules/Actions/ConvertToTransfer.php index ba613d795f..0e4a7726b7 100644 --- a/app/TransactionRules/Actions/ConvertToTransfer.php +++ b/app/TransactionRules/Actions/ConvertToTransfer.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Illuminate\Support\Facades\Log; use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray; use FireflyIII\Events\Model\Rule\RuleActionFailedOnObject; @@ -59,14 +60,14 @@ class ConvertToTransfer implements ActionInterface /** @var null|TransactionJournal $object */ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); if (null === $object) { - app('log')->error(sprintf('Cannot find journal #%d, cannot convert to transfer.', $journal['transaction_journal_id'])); + Log::error(sprintf('Cannot find journal #%d, cannot convert to transfer.', $journal['transaction_journal_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_not_found'))); return false; } $groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count(); if ($groupCount > 1) { - app('log')->error(sprintf('Group #%d has more than one transaction in it, cannot convert to transfer.', $journal['transaction_group_id'])); + Log::error(sprintf('Group #%d has more than one transaction in it, cannot convert to transfer.', $journal['transaction_group_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.split_group'))); return false; @@ -76,7 +77,7 @@ class ConvertToTransfer implements ActionInterface $user = $object->user; $journalId = $object->id; if (TransactionTypeEnum::TRANSFER->value === $type) { - app('log')->error( + Log::error( sprintf('Journal #%d is already a transfer so cannot be converted (rule #%d).', $object->id, $this->action->rule_id) ); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.is_already_transfer'))); @@ -105,7 +106,7 @@ class ConvertToTransfer implements ActionInterface $opposing = $repository->findByName($accountName, [$expectedType]); if (null === $opposing) { - app('log')->error( + Log::error( sprintf( 'Journal #%d cannot be converted because no valid %s account with name "%s" exists (rule #%d).', $expectedType, @@ -120,36 +121,36 @@ class ConvertToTransfer implements ActionInterface } if (TransactionTypeEnum::WITHDRAWAL->value === $type) { - app('log')->debug('Going to transform a withdrawal to a transfer.'); + Log::debug('Going to transform a withdrawal to a transfer.'); try { $res = $this->convertWithdrawalArray($object, $opposing); } catch (FireflyException $e) { - app('log')->debug('Could not convert withdrawal to transfer.'); - app('log')->error($e->getMessage()); + Log::debug('Could not convert withdrawal to transfer.'); + Log::error($e->getMessage()); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.complex_error'))); return false; } - if (false !== $res) { + if ($res) { event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::TRANSFER->value)); } return $res; } // can only be a deposit at this point. - app('log')->debug('Going to transform a deposit to a transfer.'); + Log::debug('Going to transform a deposit to a transfer.'); try { $res = $this->convertDepositArray($object, $opposing); } catch (FireflyException $e) { - app('log')->debug('Could not convert deposit to transfer.'); - app('log')->error($e->getMessage()); + Log::debug('Could not convert deposit to transfer.'); + Log::error($e->getMessage()); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.complex_error'))); return false; } - if (false !== $res) { + if ($res) { event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionTypeEnum::DEPOSIT->value, TransactionTypeEnum::TRANSFER->value)); } @@ -161,7 +162,7 @@ class ConvertToTransfer implements ActionInterface /** @var null|TransactionJournal $journal */ $journal = TransactionJournal::find($journalId); if (null === $journal) { - app('log')->error(sprintf('Journal #%d does not exist. Cannot convert to transfer.', $journalId)); + Log::error(sprintf('Journal #%d does not exist. Cannot convert to transfer.', $journalId)); return ''; } @@ -174,7 +175,7 @@ class ConvertToTransfer implements ActionInterface /** @var null|TransactionJournal $journal */ $journal = TransactionJournal::find($journalId); if (null === $journal) { - app('log')->error(sprintf('Journal #%d does not exist. Cannot convert to transfer.', $journalId)); + Log::error(sprintf('Journal #%d does not exist. Cannot convert to transfer.', $journalId)); return ''; } @@ -193,7 +194,7 @@ class ConvertToTransfer implements ActionInterface { $sourceAccount = $this->getSourceAccount($journal); if ($sourceAccount->id === $opposing->id) { - app('log')->error( + Log::error( vsprintf( 'Journal #%d has already has "%s" as a source asset. ConvertToTransfer failed. (rule #%d).', [$journal->id, $opposing->name, $this->action->rule_id] @@ -219,7 +220,7 @@ class ConvertToTransfer implements ActionInterface ->update(['transaction_type_id' => $newType->id, 'bill_id' => null]) ; - app('log')->debug('Converted withdrawal to transfer.'); + Log::debug('Converted withdrawal to transfer.'); return true; } @@ -248,7 +249,7 @@ class ConvertToTransfer implements ActionInterface { $destAccount = $this->getDestinationAccount($journal); if ($destAccount->id === $opposing->id) { - app('log')->error( + Log::error( vsprintf( 'Journal #%d has already has "%s" as a destination asset. ConvertToTransfer failed. (rule #%d).', [$journal->id, $opposing->name, $this->action->rule_id] @@ -274,7 +275,7 @@ class ConvertToTransfer implements ActionInterface ->update(['transaction_type_id' => $newType->id, 'bill_id' => null]) ; - app('log')->debug('Converted deposit to transfer.'); + Log::debug('Converted deposit to transfer.'); return true; } diff --git a/app/TransactionRules/Actions/ConvertToWithdrawal.php b/app/TransactionRules/Actions/ConvertToWithdrawal.php index 61fba99de4..803163ca83 100644 --- a/app/TransactionRules/Actions/ConvertToWithdrawal.php +++ b/app/TransactionRules/Actions/ConvertToWithdrawal.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Illuminate\Support\Facades\Log; use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray; @@ -56,14 +57,14 @@ class ConvertToWithdrawal implements ActionInterface /** @var null|TransactionJournal $object */ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); if (null === $object) { - app('log')->error(sprintf('Cannot find journal #%d, cannot convert to withdrawal.', $journal['transaction_journal_id'])); + Log::error(sprintf('Cannot find journal #%d, cannot convert to withdrawal.', $journal['transaction_journal_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_not_found'))); return false; } $groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count(); if ($groupCount > 1) { - app('log')->error(sprintf('Group #%d has more than one transaction in it, cannot convert to withdrawal.', $journal['transaction_group_id'])); + Log::error(sprintf('Group #%d has more than one transaction in it, cannot convert to withdrawal.', $journal['transaction_group_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.split_group'))); return false; @@ -71,7 +72,7 @@ class ConvertToWithdrawal implements ActionInterface $type = $object->transactionType->type; if (TransactionTypeEnum::WITHDRAWAL->value === $type) { - app('log')->error(sprintf('Journal #%d is already a withdrawal (rule #%d).', $journal['transaction_journal_id'], $this->action->rule_id)); + Log::error(sprintf('Journal #%d is already a withdrawal (rule #%d).', $journal['transaction_journal_id'], $this->action->rule_id)); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.is_already_withdrawal'))); return false; @@ -82,13 +83,13 @@ class ConvertToWithdrawal implements ActionInterface return false; } if (TransactionTypeEnum::DEPOSIT->value === $type) { - app('log')->debug('Going to transform a deposit to a withdrawal.'); + Log::debug('Going to transform a deposit to a withdrawal.'); try { $res = $this->convertDepositArray($object, $actionValue); } catch (FireflyException $e) { - app('log')->debug('Could not convert transfer to deposit.'); - app('log')->error($e->getMessage()); + Log::debug('Could not convert transfer to deposit.'); + Log::error($e->getMessage()); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.complex_error'))); return false; @@ -98,13 +99,13 @@ class ConvertToWithdrawal implements ActionInterface return $res; } // can only be transfer at this point. - app('log')->debug('Going to transform a transfer to a withdrawal.'); + Log::debug('Going to transform a transfer to a withdrawal.'); try { $res = $this->convertTransferArray($object, $actionValue); } catch (FireflyException $e) { - app('log')->debug('Could not convert transfer to deposit.'); - app('log')->error($e->getMessage()); + Log::debug('Could not convert transfer to deposit.'); + Log::error($e->getMessage()); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.complex_error'))); return false; @@ -141,7 +142,7 @@ class ConvertToWithdrawal implements ActionInterface $opposingAccount = $factory->findOrCreate($opposingName, AccountTypeEnum::EXPENSE->value); } - app('log')->debug(sprintf('ConvertToWithdrawal. Action value is "%s", expense name is "%s"', $actionValue, $opposingName)); + Log::debug(sprintf('ConvertToWithdrawal. Action value is "%s", expense name is "%s"', $actionValue, $opposingName)); // update source transaction(s) to be the original destination account DB::table('transactions') @@ -164,7 +165,7 @@ class ConvertToWithdrawal implements ActionInterface ->update(['transaction_type_id' => $newType->id]) ; - app('log')->debug('Converted deposit to withdrawal.'); + Log::debug('Converted deposit to withdrawal.'); return true; } @@ -227,7 +228,7 @@ class ConvertToWithdrawal implements ActionInterface $opposingAccount = $factory->findOrCreate($opposingName, AccountTypeEnum::EXPENSE->value); } - app('log')->debug(sprintf('ConvertToWithdrawal. Action value is "%s", destination name is "%s"', $actionValue, $opposingName)); + Log::debug(sprintf('ConvertToWithdrawal. Action value is "%s", destination name is "%s"', $actionValue, $opposingName)); // update destination transaction(s) to be new expense account. DB::table('transactions') @@ -243,7 +244,7 @@ class ConvertToWithdrawal implements ActionInterface ->update(['transaction_type_id' => $newType->id]) ; - app('log')->debug('Converted transfer to withdrawal.'); + Log::debug('Converted transfer to withdrawal.'); return true; } diff --git a/app/TransactionRules/Actions/DeleteTransaction.php b/app/TransactionRules/Actions/DeleteTransaction.php index fec4cb3ad4..530d3967de 100644 --- a/app/TransactionRules/Actions/DeleteTransaction.php +++ b/app/TransactionRules/Actions/DeleteTransaction.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Illuminate\Support\Facades\Log; use FireflyIII\Events\TriggeredAuditLog; use FireflyIII\Models\RuleAction; use FireflyIII\Models\TransactionGroup; @@ -46,7 +47,7 @@ class DeleteTransaction implements ActionInterface // destroy entire group. if (1 === $count) { - app('log')->debug( + Log::debug( sprintf( 'RuleAction DeleteTransaction DELETED the entire transaction group of journal #%d ("%s").', $journal['transaction_journal_id'], @@ -63,7 +64,7 @@ class DeleteTransaction implements ActionInterface return true; } - app('log')->debug( + Log::debug( sprintf('RuleAction DeleteTransaction DELETED transaction journal #%d ("%s").', $journal['transaction_journal_id'], $journal['description']) ); diff --git a/app/TransactionRules/Actions/MoveDescriptionToNotes.php b/app/TransactionRules/Actions/MoveDescriptionToNotes.php index 62711bf5e6..9d33d00438 100644 --- a/app/TransactionRules/Actions/MoveDescriptionToNotes.php +++ b/app/TransactionRules/Actions/MoveDescriptionToNotes.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Illuminate\Support\Facades\Log; use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray; use FireflyIII\Events\TriggeredAuditLog; use FireflyIII\Models\Note; @@ -46,7 +47,7 @@ class MoveDescriptionToNotes implements ActionInterface /** @var null|TransactionJournal $object */ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); if (null === $object) { - app('log')->error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id'])); + Log::error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_other_user'))); return false; diff --git a/app/TransactionRules/Actions/MoveNotesToDescription.php b/app/TransactionRules/Actions/MoveNotesToDescription.php index 6852f5644b..26ed48c2b6 100644 --- a/app/TransactionRules/Actions/MoveNotesToDescription.php +++ b/app/TransactionRules/Actions/MoveNotesToDescription.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Illuminate\Support\Facades\Log; use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray; use FireflyIII\Events\TriggeredAuditLog; use FireflyIII\Models\RuleAction; @@ -52,7 +53,7 @@ class MoveNotesToDescription implements ActionInterface /** @var null|TransactionJournal $object */ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); if (null === $object) { - app('log')->error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id'])); + Log::error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_other_user'))); return false; diff --git a/app/TransactionRules/Actions/PrependNotes.php b/app/TransactionRules/Actions/PrependNotes.php index e4e8249c8b..71bdfb028e 100644 --- a/app/TransactionRules/Actions/PrependNotes.php +++ b/app/TransactionRules/Actions/PrependNotes.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Illuminate\Support\Facades\Log; use FireflyIII\Events\TriggeredAuditLog; use FireflyIII\Models\Note; use FireflyIII\Models\RuleAction; @@ -53,7 +54,7 @@ class PrependNotes implements ActionInterface } $before = $dbNote->text; $after = $this->action->getValue($journal); - app('log')->debug(sprintf('RuleAction PrependNotes prepended "%s" to "%s".', $after, $dbNote->text)); + Log::debug(sprintf('RuleAction PrependNotes prepended "%s" to "%s".', $after, $dbNote->text)); $text = sprintf('%s%s', $after, $dbNote->text); $dbNote->text = $text; $dbNote->save(); diff --git a/app/TransactionRules/Actions/RemoveAllTags.php b/app/TransactionRules/Actions/RemoveAllTags.php index cf5d7ee783..f21a6c2254 100644 --- a/app/TransactionRules/Actions/RemoveAllTags.php +++ b/app/TransactionRules/Actions/RemoveAllTags.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Illuminate\Support\Facades\Log; use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray; use FireflyIII\Events\TriggeredAuditLog; use FireflyIII\Models\RuleAction; @@ -44,12 +45,12 @@ class RemoveAllTags implements ActionInterface DB::table('tag_transaction_journal')->where('transaction_journal_id', $journal['transaction_journal_id'])->delete(); $count = DB::table('tag_transaction_journal')->where('transaction_journal_id', $journal['transaction_journal_id'])->count(); if (0 === $count) { - app('log')->debug(sprintf('RuleAction RemoveAllTags, journal #%d has no tags.', $journal['transaction_journal_id'])); + Log::debug(sprintf('RuleAction RemoveAllTags, journal #%d has no tags.', $journal['transaction_journal_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.no_tags_to_remove'))); return false; } - app('log')->debug(sprintf('RuleAction RemoveAllTags removed all tags from journal %d.', $journal['transaction_journal_id'])); + Log::debug(sprintf('RuleAction RemoveAllTags removed all tags from journal %d.', $journal['transaction_journal_id'])); /** @var TransactionJournal $object */ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); diff --git a/app/TransactionRules/Actions/RemoveTag.php b/app/TransactionRules/Actions/RemoveTag.php index 956835b2e3..80c8f13066 100644 --- a/app/TransactionRules/Actions/RemoveTag.php +++ b/app/TransactionRules/Actions/RemoveTag.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Illuminate\Support\Facades\Log; use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray; use FireflyIII\Events\TriggeredAuditLog; use FireflyIII\Models\RuleAction; @@ -50,7 +51,7 @@ class RemoveTag implements ActionInterface // if tag does not exist, no need to continue: if (null === $tag) { - app('log')->debug( + Log::debug( sprintf('RuleAction RemoveTag tried to remove tag "%s" from journal #%d but no such tag exists.', $name, $journal['transaction_journal_id']) ); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_tag', ['tag' => $name]))); @@ -59,7 +60,7 @@ class RemoveTag implements ActionInterface } $count = DB::table('tag_transaction_journal')->where('transaction_journal_id', $journal['transaction_journal_id'])->where('tag_id', $tag->id)->count(); if (0 === $count) { - app('log')->debug( + Log::debug( sprintf('RuleAction RemoveTag tried to remove tag "%s" from journal #%d but no such tag is linked.', $name, $journal['transaction_journal_id']) ); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_unlink_tag', ['tag' => $name]))); @@ -67,7 +68,7 @@ class RemoveTag implements ActionInterface return false; } - app('log')->debug(sprintf('RuleAction RemoveTag removed tag #%d ("%s") from journal #%d.', $tag->id, $tag->tag, $journal['transaction_journal_id'])); + Log::debug(sprintf('RuleAction RemoveTag removed tag #%d ("%s") from journal #%d.', $tag->id, $tag->tag, $journal['transaction_journal_id'])); DB::table('tag_transaction_journal') ->where('transaction_journal_id', $journal['transaction_journal_id']) ->where('tag_id', $tag->id) diff --git a/app/TransactionRules/Actions/SetAmount.php b/app/TransactionRules/Actions/SetAmount.php index c7c2e47518..4c362e74c7 100644 --- a/app/TransactionRules/Actions/SetAmount.php +++ b/app/TransactionRules/Actions/SetAmount.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Illuminate\Support\Facades\Log; use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray; use FireflyIII\Events\TriggeredAuditLog; use FireflyIII\Models\RuleAction; @@ -47,7 +48,7 @@ class SetAmount implements ActionInterface // not on slpit transactions $groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count(); if ($groupCount > 1) { - app('log')->error(sprintf('Group #%d has more than one transaction in it, cannot convert to transfer.', $journal['transaction_group_id'])); + Log::error(sprintf('Group #%d has more than one transaction in it, cannot convert to transfer.', $journal['transaction_group_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.split_group'))); return false; @@ -56,7 +57,7 @@ class SetAmount implements ActionInterface $value = $this->action->getValue($journal); if (!is_numeric($value) || 0 === bccomp($value, '0')) { - app('log')->debug(sprintf('RuleAction SetAmount, amount "%s" is not a number or is zero, will not continue.', $value)); + Log::debug(sprintf('RuleAction SetAmount, amount "%s" is not a number or is zero, will not continue.', $value)); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_invalid_amount', ['amount' => $value]))); return false; diff --git a/app/TransactionRules/Actions/SetBudget.php b/app/TransactionRules/Actions/SetBudget.php index 54bb75902b..4aa0c06243 100644 --- a/app/TransactionRules/Actions/SetBudget.php +++ b/app/TransactionRules/Actions/SetBudget.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Illuminate\Support\Facades\Log; use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray; use FireflyIII\Events\TriggeredAuditLog; @@ -49,7 +50,7 @@ class SetBudget implements ActionInterface $budget = $user->budgets()->where('name', $search)->first(); if (null === $budget) { - app('log')->debug( + Log::debug( sprintf( 'RuleAction SetBudget could not set budget of journal #%d to "%s" because no such budget exists.', $journal['transaction_journal_id'], @@ -62,7 +63,7 @@ class SetBudget implements ActionInterface } if (TransactionTypeEnum::WITHDRAWAL->value !== $journal['transaction_type_type']) { - app('log')->debug( + Log::debug( sprintf( 'RuleAction SetBudget could not set budget of journal #%d to "%s" because journal is a %s.', $journal['transaction_journal_id'], @@ -86,7 +87,7 @@ class SetBudget implements ActionInterface return false; } - app('log')->debug( + Log::debug( sprintf('RuleAction SetBudget set the budget of journal #%d to budget #%d ("%s").', $journal['transaction_journal_id'], $budget->id, $budget->name) ); diff --git a/app/TransactionRules/Actions/SetCategory.php b/app/TransactionRules/Actions/SetCategory.php index c546dcad1a..0ac36cd83e 100644 --- a/app/TransactionRules/Actions/SetCategory.php +++ b/app/TransactionRules/Actions/SetCategory.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Illuminate\Support\Facades\Log; use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray; use FireflyIII\Events\TriggeredAuditLog; use FireflyIII\Factory\CategoryFactory; @@ -47,7 +48,7 @@ class SetCategory implements ActionInterface $user = User::find($journal['user_id']); $search = $this->action->getValue($journal); if (null === $user) { - app('log')->error(sprintf('Journal has no valid user ID so action SetCategory("%s") cannot be applied', $search), $journal); + Log::error(sprintf('Journal has no valid user ID so action SetCategory("%s") cannot be applied', $search), $journal); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.no_such_journal'))); return false; @@ -58,7 +59,7 @@ class SetCategory implements ActionInterface $factory->setUser($user); $category = $factory->findOrCreate(null, $search); if (null === $category) { - app('log')->debug( + Log::debug( sprintf( 'RuleAction SetCategory could not set category of journal #%d to "%s" because no such category exists.', $journal['transaction_journal_id'], @@ -70,7 +71,7 @@ class SetCategory implements ActionInterface return false; } - app('log')->debug( + Log::debug( sprintf( 'RuleAction SetCategory set the category of journal #%d to category #%d ("%s").', $journal['transaction_journal_id'], diff --git a/app/TransactionRules/Actions/SetDescription.php b/app/TransactionRules/Actions/SetDescription.php index d6cc04fd6a..66c0023450 100644 --- a/app/TransactionRules/Actions/SetDescription.php +++ b/app/TransactionRules/Actions/SetDescription.php @@ -64,7 +64,7 @@ class SetDescription implements ActionInterface ->update(['description' => $after]) ; - app('log')->debug( + Log::debug( sprintf( 'RuleAction SetDescription changed the description of journal #%d from "%s" to "%s".', $journal['transaction_journal_id'], diff --git a/app/TransactionRules/Actions/SetDestinationAccount.php b/app/TransactionRules/Actions/SetDestinationAccount.php index b749889eb1..c2e71b0f24 100644 --- a/app/TransactionRules/Actions/SetDestinationAccount.php +++ b/app/TransactionRules/Actions/SetDestinationAccount.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Illuminate\Support\Facades\Log; use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray; use FireflyIII\Events\TriggeredAuditLog; @@ -58,7 +59,7 @@ class SetDestinationAccount implements ActionInterface $this->repository = app(AccountRepositoryInterface::class); if (null === $object) { - app('log')->error('Could not find journal.'); + Log::error('Could not find journal.'); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.no_such_journal'))); return false; @@ -69,7 +70,7 @@ class SetDestinationAccount implements ActionInterface // if this is a transfer or a deposit, the new destination account must be an asset account or a default account, and it MUST exist: $newAccount = $this->findAssetAccount($type, $accountName); if ((TransactionTypeEnum::DEPOSIT->value === $type || TransactionTypeEnum::TRANSFER->value === $type) && !$newAccount instanceof Account) { - app('log')->error( + Log::error( sprintf( 'Cant change destination account of journal #%d because no asset account with name "%s" exists.', $object->id, @@ -85,20 +86,20 @@ class SetDestinationAccount implements ActionInterface /** @var null|Transaction $source */ $source = $object->transactions()->where('amount', '<', 0)->first(); if (null === $source) { - app('log')->error('Could not find source transaction.'); + Log::error('Could not find source transaction.'); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_source_transaction'))); return false; } // account must not be deleted (in the meantime): if (null === $source->account) { - app('log')->error('Could not find source transaction account.'); + Log::error('Could not find source transaction account.'); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_source_transaction_account'))); return false; } if ($newAccount instanceof Account && $newAccount->id === $source->account_id) { - app('log')->error( + Log::error( sprintf( 'New destination account ID #%d and current source account ID #%d are the same. Do nothing.', $newAccount->id, @@ -117,7 +118,7 @@ class SetDestinationAccount implements ActionInterface $newAccount = $this->findWithdrawalDestinationAccount($accountName); } if (!$newAccount instanceof Account) { - app('log')->error( + Log::error( sprintf( 'No destination account found for name "%s".', $accountName @@ -129,7 +130,7 @@ class SetDestinationAccount implements ActionInterface return false; } - app('log')->debug(sprintf('New destination account is #%d ("%s").', $newAccount->id, $newAccount->name)); + Log::debug(sprintf('New destination account is #%d ("%s").', $newAccount->id, $newAccount->name)); event(new TriggeredAuditLog($this->action->rule, $object, 'set_destination', null, $newAccount->name)); @@ -140,7 +141,7 @@ class SetDestinationAccount implements ActionInterface ->update(['account_id' => $newAccount->id]) ; - app('log')->debug(sprintf('Updated journal #%d (group #%d) and gave it new destination account ID.', $object->id, $object->transaction_group_id)); + Log::debug(sprintf('Updated journal #%d (group #%d) and gave it new destination account ID.', $object->id, $object->transaction_group_id)); return true; } @@ -150,7 +151,7 @@ class SetDestinationAccount implements ActionInterface // switch on type: $allowed = config(sprintf('firefly.expected_source_types.destination.%s', $type)); $allowed = is_array($allowed) ? $allowed : []; - app('log')->debug(sprintf('Check config for expected_source_types.destination.%s, result is', $type), $allowed); + Log::debug(sprintf('Check config for expected_source_types.destination.%s, result is', $type), $allowed); return $this->repository->findByName($accountName, $allowed); } @@ -170,7 +171,7 @@ class SetDestinationAccount implements ActionInterface ]; $account = $this->repository->store($data); } - app('log')->debug(sprintf('Found or created expense account #%d ("%s")', $account->id, $account->name)); + Log::debug(sprintf('Found or created expense account #%d ("%s")', $account->id, $account->name)); return $account; } diff --git a/app/TransactionRules/Actions/SetDestinationToCashAccount.php b/app/TransactionRules/Actions/SetDestinationToCashAccount.php index 967e07928d..34aa5392c3 100644 --- a/app/TransactionRules/Actions/SetDestinationToCashAccount.php +++ b/app/TransactionRules/Actions/SetDestinationToCashAccount.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Illuminate\Support\Facades\Log; use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray; use FireflyIII\Events\TriggeredAuditLog; @@ -54,14 +55,14 @@ class SetDestinationToCashAccount implements ActionInterface $repository = app(AccountRepositoryInterface::class); if (null === $object) { - app('log')->error('Could not find journal.'); + Log::error('Could not find journal.'); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.no_such_journal'))); return false; } $type = $object->transactionType->type; if (TransactionTypeEnum::WITHDRAWAL->value !== $type) { - app('log')->error('Transaction must be withdrawal.'); + Log::error('Transaction must be withdrawal.'); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.not_withdrawal'))); return false; @@ -75,20 +76,20 @@ class SetDestinationToCashAccount implements ActionInterface /** @var null|Transaction $source */ $source = $object->transactions()->where('amount', '<', 0)->first(); if (null === $source) { - app('log')->error('Could not find source transaction.'); + Log::error('Could not find source transaction.'); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_source_transaction'))); return false; } // account must not be deleted (in the meantime): if (null === $source->account) { - app('log')->error('Could not find source transaction account.'); + Log::error('Could not find source transaction account.'); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_source_transaction_account'))); return false; } if ($cashAccount->id === $source->account_id) { - app('log')->error( + Log::error( sprintf( 'New destination account ID #%d and current source account ID #%d are the same. Do nothing.', $cashAccount->id, @@ -110,7 +111,7 @@ class SetDestinationToCashAccount implements ActionInterface ->update(['account_id' => $cashAccount->id]) ; - app('log')->debug(sprintf('Updated journal #%d (group #%d) and gave it new destination account ID.', $object->id, $object->transaction_group_id)); + Log::debug(sprintf('Updated journal #%d (group #%d) and gave it new destination account ID.', $object->id, $object->transaction_group_id)); return true; } diff --git a/app/TransactionRules/Actions/SetNotes.php b/app/TransactionRules/Actions/SetNotes.php index a3c144fa11..26e48501bb 100644 --- a/app/TransactionRules/Actions/SetNotes.php +++ b/app/TransactionRules/Actions/SetNotes.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Illuminate\Support\Facades\Log; use FireflyIII\Events\TriggeredAuditLog; use FireflyIII\Models\Note; use FireflyIII\Models\RuleAction; @@ -54,7 +55,7 @@ class SetNotes implements ActionInterface $dbNote->text = $newNotes; $dbNote->save(); - app('log')->debug( + Log::debug( sprintf( 'RuleAction SetNotes changed the notes of journal #%d from "%s" to "%s".', $journal['transaction_journal_id'], diff --git a/app/TransactionRules/Actions/SetSourceAccount.php b/app/TransactionRules/Actions/SetSourceAccount.php index 3eddb9e7c7..ba6ae75d8e 100644 --- a/app/TransactionRules/Actions/SetSourceAccount.php +++ b/app/TransactionRules/Actions/SetSourceAccount.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Illuminate\Support\Facades\Log; use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray; use FireflyIII\Events\TriggeredAuditLog; @@ -57,7 +58,7 @@ class SetSourceAccount implements ActionInterface $object = $user->transactionJournals()->find((int) $journal['transaction_journal_id']); $this->repository = app(AccountRepositoryInterface::class); if (null === $object) { - app('log')->error('Could not find journal.'); + Log::error('Could not find journal.'); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.no_such_journal'))); return false; @@ -68,7 +69,7 @@ class SetSourceAccount implements ActionInterface // if this is a transfer or a withdrawal, the new source account must be an asset account or a default account, and it MUST exist: $newAccount = $this->findAssetAccount($type, $accountName); if ((TransactionTypeEnum::WITHDRAWAL->value === $type || TransactionTypeEnum::TRANSFER->value === $type) && !$newAccount instanceof Account) { - app('log')->error( + Log::error( sprintf('Cant change source account of journal #%d because no asset account with name "%s" exists.', $object->id, $accountName) ); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_asset', ['name' => $accountName]))); @@ -80,20 +81,20 @@ class SetSourceAccount implements ActionInterface /** @var null|Transaction $destination */ $destination = $object->transactions()->where('amount', '>', 0)->first(); if (null === $destination) { - app('log')->error('Could not find destination transaction.'); + Log::error('Could not find destination transaction.'); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_destination_transaction'))); return false; } // account must not be deleted (in the meantime): if (null === $destination->account) { - app('log')->error('Could not find destination transaction account.'); + Log::error('Could not find destination transaction account.'); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_destination_transaction_account'))); return false; } if ($newAccount instanceof Account && $newAccount->id === $destination->account_id) { - app('log')->error( + Log::error( sprintf( 'New source account ID #%d and current destination account ID #%d are the same. Do nothing.', $newAccount->id, @@ -111,7 +112,7 @@ class SetSourceAccount implements ActionInterface $newAccount = $this->findDepositSourceAccount($accountName); } - app('log')->debug(sprintf('New source account is #%d ("%s").', $newAccount->id, $newAccount->name)); + Log::debug(sprintf('New source account is #%d ("%s").', $newAccount->id, $newAccount->name)); // update source transaction with new source account: DB::table('transactions') @@ -122,7 +123,7 @@ class SetSourceAccount implements ActionInterface event(new TriggeredAuditLog($this->action->rule, $object, 'set_source', null, $newAccount->name)); - app('log')->debug(sprintf('Updated journal #%d (group #%d) and gave it new source account ID.', $object->id, $object->transaction_group_id)); + Log::debug(sprintf('Updated journal #%d (group #%d) and gave it new source account ID.', $object->id, $object->transaction_group_id)); return true; } @@ -132,7 +133,7 @@ class SetSourceAccount implements ActionInterface // switch on type: $allowed = config(sprintf('firefly.expected_source_types.source.%s', $type)); $allowed = is_array($allowed) ? $allowed : []; - app('log')->debug(sprintf('Check config for expected_source_types.source.%s, result is', $type), $allowed); + Log::debug(sprintf('Check config for expected_source_types.source.%s, result is', $type), $allowed); return $this->repository->findByName($accountName, $allowed); } @@ -153,7 +154,7 @@ class SetSourceAccount implements ActionInterface ]; $account = $this->repository->store($data); } - app('log')->debug(sprintf('Found or created revenue account #%d ("%s")', $account->id, $account->name)); + Log::debug(sprintf('Found or created revenue account #%d ("%s")', $account->id, $account->name)); return $account; } diff --git a/app/TransactionRules/Actions/SetSourceToCashAccount.php b/app/TransactionRules/Actions/SetSourceToCashAccount.php index bb83c36908..9cea693e82 100644 --- a/app/TransactionRules/Actions/SetSourceToCashAccount.php +++ b/app/TransactionRules/Actions/SetSourceToCashAccount.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Illuminate\Support\Facades\Log; use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray; use FireflyIII\Events\TriggeredAuditLog; @@ -54,14 +55,14 @@ class SetSourceToCashAccount implements ActionInterface $repository = app(AccountRepositoryInterface::class); if (null === $object) { - app('log')->error('Could not find journal.'); + Log::error('Could not find journal.'); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.no_such_journal'))); return false; } $type = $object->transactionType->type; if (TransactionTypeEnum::DEPOSIT->value !== $type) { - app('log')->error('Transaction must be deposit.'); + Log::error('Transaction must be deposit.'); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.not_deposit'))); return false; @@ -75,20 +76,20 @@ class SetSourceToCashAccount implements ActionInterface /** @var null|Transaction $destination */ $destination = $object->transactions()->where('amount', '>', 0)->first(); if (null === $destination) { - app('log')->error('Could not find destination transaction.'); + Log::error('Could not find destination transaction.'); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_destination_transaction'))); return false; } // account must not be deleted (in the meantime): if (null === $destination->account) { - app('log')->error('Could not find destination transaction account.'); + Log::error('Could not find destination transaction account.'); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_destination_transaction_account'))); return false; } if ($cashAccount->id === $destination->account_id) { - app('log')->error( + Log::error( sprintf( 'New source account ID #%d and current destination account ID #%d are the same. Do nothing.', $cashAccount->id, @@ -110,7 +111,7 @@ class SetSourceToCashAccount implements ActionInterface ->update(['account_id' => $cashAccount->id]) ; - app('log')->debug(sprintf('Updated journal #%d (group #%d) and gave it new source account ID.', $object->id, $object->transaction_group_id)); + Log::debug(sprintf('Updated journal #%d (group #%d) and gave it new source account ID.', $object->id, $object->transaction_group_id)); return true; } diff --git a/app/TransactionRules/Actions/SwitchAccounts.php b/app/TransactionRules/Actions/SwitchAccounts.php index e49ea4a19d..5ee4219b0d 100644 --- a/app/TransactionRules/Actions/SwitchAccounts.php +++ b/app/TransactionRules/Actions/SwitchAccounts.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Illuminate\Support\Facades\Log; use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray; use FireflyIII\Events\TriggeredAuditLog; @@ -47,14 +48,14 @@ class SwitchAccounts implements ActionInterface /** @var null|TransactionJournal $object */ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); if (null === $object) { - app('log')->error(sprintf('Cannot find journal #%d, cannot switch accounts.', $journal['transaction_journal_id'])); + Log::error(sprintf('Cannot find journal #%d, cannot switch accounts.', $journal['transaction_journal_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.no_such_journal'))); return false; } $groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count(); if ($groupCount > 1) { - app('log')->error(sprintf('Group #%d has more than one transaction in it, cannot switch accounts.', $journal['transaction_group_id'])); + Log::error(sprintf('Group #%d has more than one transaction in it, cannot switch accounts.', $journal['transaction_group_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.split_group'))); return false; @@ -62,7 +63,7 @@ class SwitchAccounts implements ActionInterface $type = $object->transactionType->type; if (TransactionTypeEnum::TRANSFER->value !== $type) { - app('log')->error(sprintf('Journal #%d is NOT a transfer (rule #%d), cannot switch accounts.', $journal['transaction_journal_id'], $this->action->rule_id)); + Log::error(sprintf('Journal #%d is NOT a transfer (rule #%d), cannot switch accounts.', $journal['transaction_journal_id'], $this->action->rule_id)); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.is_not_transfer'))); return false; @@ -74,7 +75,7 @@ class SwitchAccounts implements ActionInterface /** @var null|Transaction $destTransaction */ $destTransaction = $object->transactions()->where('amount', '>', 0)->first(); if (null === $sourceTransaction || null === $destTransaction) { - app('log')->error(sprintf('Journal #%d has no source or destination transaction (rule #%d), cannot switch accounts.', $journal['transaction_journal_id'], $this->action->rule_id)); + Log::error(sprintf('Journal #%d has no source or destination transaction (rule #%d), cannot switch accounts.', $journal['transaction_journal_id'], $this->action->rule_id)); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_accounts'))); return false; diff --git a/app/TransactionRules/Engine/SearchRuleEngine.php b/app/TransactionRules/Engine/SearchRuleEngine.php index 70f55f4d24..fbebad10cd 100644 --- a/app/TransactionRules/Engine/SearchRuleEngine.php +++ b/app/TransactionRules/Engine/SearchRuleEngine.php @@ -45,9 +45,10 @@ use Illuminate\Support\Facades\Log; class SearchRuleEngine implements RuleEngineInterface { private readonly Collection $groups; - private array $operators; - private bool $refreshTriggers; - private array $resultCount; + private array $operators = []; + // always collect the triggers from the database, unless indicated otherwise. + private bool $refreshTriggers = true; + private array $resultCount = []; private readonly Collection $rules; private User $user; @@ -55,11 +56,6 @@ class SearchRuleEngine implements RuleEngineInterface { $this->rules = new Collection(); $this->groups = new Collection(); - $this->operators = []; - $this->resultCount = []; - - // always collect the triggers from the database, unless indicated otherwise. - $this->refreshTriggers = true; } public function addOperator(array $operator): void @@ -119,7 +115,7 @@ class SearchRuleEngine implements RuleEngineInterface Log::debug(sprintf('SearchRuleEngine:: add a rule trigger (no context): %s:true', $ruleTrigger->trigger_type)); $searchArray[$ruleTrigger->trigger_type][] = 'true'; } - if (true === $needsContext) { + if ($needsContext) { Log::debug(sprintf('SearchRuleEngine:: add a rule trigger (context): %s:"%s"', $ruleTrigger->trigger_type, $ruleTrigger->trigger_value)); $searchArray[$ruleTrigger->trigger_type][] = sprintf('"%s"', $ruleTrigger->trigger_value); } @@ -288,7 +284,7 @@ class SearchRuleEngine implements RuleEngineInterface // make collection unique $unique = $total->unique( - static function (array $group) { + static function (array $group): string { $str = ''; foreach ($group['transactions'] as $transaction) { $str = sprintf('%s%d', $str, $transaction['transaction_journal_id']); @@ -319,7 +315,7 @@ class SearchRuleEngine implements RuleEngineInterface /** @var Rule $rule */ foreach ($this->rules as $rule) { // @phpstan-ignore-line $result = $this->fireRule($rule); - if (true === $result && true === $rule->stop_processing) { + if ($result && true === $rule->stop_processing) { Log::debug(sprintf('Rule #%d has triggered and executed, but calls to stop processing. Since not in the context of a group, do not stop.', $rule->id)); } if (false === $result && true === $rule->stop_processing) { @@ -378,7 +374,7 @@ class SearchRuleEngine implements RuleEngineInterface $this->processResults($rule, $collection); $result = $collection->count() > 0; - if (true === $result) { + if ($result) { Log::debug(sprintf('SearchRuleEngine:: Done. Rule #%d was triggered (on %d transaction(s)).', $rule->id, $collection->count())); return true; @@ -428,7 +424,7 @@ class SearchRuleEngine implements RuleEngineInterface continue; } $break = $this->processRuleAction($ruleAction, $transaction); - if (true === $break) { + if ($break) { break; } } @@ -444,7 +440,7 @@ class SearchRuleEngine implements RuleEngineInterface $actionClass = ActionFactory::getAction($ruleAction); $result = $actionClass->actOnArray($transaction); $journalId = $transaction['transaction_journal_id'] ?? 0; - if (true === $result) { + if ($result) { $this->resultCount[$journalId] = array_key_exists($journalId, $this->resultCount) ? $this->resultCount[$journalId]++ : 1; Log::debug( sprintf( @@ -460,7 +456,7 @@ class SearchRuleEngine implements RuleEngineInterface } // pick up from the action if it actually acted or not: - if (true === $ruleAction->stop_processing && true === $result) { + if (true === $ruleAction->stop_processing && $result) { Log::debug(sprintf('Rule action "%s" reports changes AND asks to break, so break!', $ruleAction->action_type)); return true; @@ -527,7 +523,7 @@ class SearchRuleEngine implements RuleEngineInterface foreach ($rules as $rule) { Log::debug(sprintf('Going to fire rule #%d with order #%d from group #%d', $rule->id, $rule->order, $group->id)); $result = $this->fireRule($rule); - if (true === $result && true === $rule->stop_processing) { + if ($result && true === $rule->stop_processing) { Log::debug(sprintf('The rule was triggered and rule->stop_processing = true, so group #%d will stop processing further rules.', $group->id)); return; diff --git a/app/TransactionRules/Expressions/ActionExpression.php b/app/TransactionRules/Expressions/ActionExpression.php index 6e578c8444..e940f2fb5f 100644 --- a/app/TransactionRules/Expressions/ActionExpression.php +++ b/app/TransactionRules/Expressions/ActionExpression.php @@ -90,11 +90,11 @@ class ActionExpression { $this->expressionLanguage = app(ExpressionLanguage::class); - $this->isExpression = self::isExpression($this->expr); + $this->isExpression = $this->isExpression($this->expr); $this->validationError = $this->validate(); } - private static function isExpression(string $expr): bool + private function isExpression(string $expr): bool { return str_starts_with($expr, '=') && strlen($expr) > 1; } diff --git a/app/TransactionRules/Factory/ActionFactory.php b/app/TransactionRules/Factory/ActionFactory.php index 23780bce6d..c05dca063a 100644 --- a/app/TransactionRules/Factory/ActionFactory.php +++ b/app/TransactionRules/Factory/ActionFactory.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Factory; +use Illuminate\Support\Facades\Log; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\RuleAction; use FireflyIII\Support\Domain; @@ -47,7 +48,7 @@ class ActionFactory public static function getAction(RuleAction $action): ActionInterface { $class = self::getActionClass($action->action_type); - app('log')->debug(sprintf('self::getActionClass("%s") = "%s"', $action->action_type, $class)); + Log::debug(sprintf('self::getActionClass("%s") = "%s"', $action->action_type, $class)); return new $class($action); // @phpstan-ignore-line } diff --git a/app/Transformers/AbstractTransformer.php b/app/Transformers/AbstractTransformer.php index d741ba0cf7..1be605aaf1 100644 --- a/app/Transformers/AbstractTransformer.php +++ b/app/Transformers/AbstractTransformer.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Transformers; +use Deprecated; use League\Fractal\TransformerAbstract; use Symfony\Component\HttpFoundation\ParameterBag; @@ -34,17 +35,13 @@ abstract class AbstractTransformer extends TransformerAbstract { protected ParameterBag $parameters; - /** - * @deprecated - */ + #[Deprecated] final public function getParameters(): ParameterBag { return $this->parameters; } - /** - * @deprecated - */ + #[Deprecated] final public function setParameters(ParameterBag $parameters): void { $this->parameters = $parameters; diff --git a/app/Transformers/BudgetLimitTransformer.php b/app/Transformers/BudgetLimitTransformer.php index 12107e5636..edd1287ee3 100644 --- a/app/Transformers/BudgetLimitTransformer.php +++ b/app/Transformers/BudgetLimitTransformer.php @@ -51,10 +51,8 @@ class BudgetLimitTransformer extends AbstractTransformer /** * Include Budget - * - * @return Item */ - public function includeBudget(BudgetLimit $limit) + public function includeBudget(BudgetLimit $limit): Item { // enrich budget $budget = $limit->budget; diff --git a/app/Transformers/PiggyBankEventTransformer.php b/app/Transformers/PiggyBankEventTransformer.php index d5097b6136..a4fc3ea440 100644 --- a/app/Transformers/PiggyBankEventTransformer.php +++ b/app/Transformers/PiggyBankEventTransformer.php @@ -36,7 +36,7 @@ use FireflyIII\Support\Facades\Steam; class PiggyBankEventTransformer extends AbstractTransformer { private readonly TransactionCurrency $primaryCurrency; - private bool $convertToPrimary; + private readonly bool $convertToPrimary; /** * PiggyBankEventTransformer constructor. diff --git a/app/Transformers/RecurrenceTransformer.php b/app/Transformers/RecurrenceTransformer.php index d2e1bb914c..03d7058184 100644 --- a/app/Transformers/RecurrenceTransformer.php +++ b/app/Transformers/RecurrenceTransformer.php @@ -32,11 +32,6 @@ use Illuminate\Support\Facades\Log; */ class RecurrenceTransformer extends AbstractTransformer { - /** - * RecurrenceTransformer constructor. - */ - public function __construct() {} - /** * Transform the recurring transaction. */ diff --git a/app/Transformers/TransactionGroupTransformer.php b/app/Transformers/TransactionGroupTransformer.php index 93ac1558ab..86e70b36bc 100644 --- a/app/Transformers/TransactionGroupTransformer.php +++ b/app/Transformers/TransactionGroupTransformer.php @@ -259,12 +259,7 @@ class TransactionGroupTransformer extends AbstractTransformer return (string) $array[$key]; } - - if (null !== $default) { - return $default; - } - - return null; + return $default; } /** @@ -429,7 +424,7 @@ class TransactionGroupTransformer extends AbstractTransformer private function getSourceTransaction(TransactionJournal $journal): Transaction { $result = $journal->transactions->first( - static function (Transaction $transaction) { + static function (Transaction $transaction): bool { return (float) $transaction->amount < 0; // lame but it works. } ); @@ -446,7 +441,7 @@ class TransactionGroupTransformer extends AbstractTransformer private function getDestinationTransaction(TransactionJournal $journal): Transaction { $result = $journal->transactions->first( - static function (Transaction $transaction) { + static function (Transaction $transaction): bool { return (float) $transaction->amount > 0; // lame but it works } ); diff --git a/app/Transformers/UserGroupTransformer.php b/app/Transformers/UserGroupTransformer.php index 486db21253..d89ac03fe7 100644 --- a/app/Transformers/UserGroupTransformer.php +++ b/app/Transformers/UserGroupTransformer.php @@ -36,16 +36,9 @@ use Illuminate\Support\Collection; */ class UserGroupTransformer extends AbstractTransformer { - private array $inUse; - private array $memberships; - private array $membershipsVisible; - - public function __construct() - { - $this->memberships = []; - $this->membershipsVisible = []; - $this->inUse = []; - } + private array $inUse = []; + private array $memberships = []; + private array $membershipsVisible = []; public function collectMetaData(Collection $objects): Collection { diff --git a/app/Transformers/WebhookTransformer.php b/app/Transformers/WebhookTransformer.php index d402cd7852..9eace066e5 100644 --- a/app/Transformers/WebhookTransformer.php +++ b/app/Transformers/WebhookTransformer.php @@ -31,11 +31,6 @@ use FireflyIII\Models\Webhook; */ class WebhookTransformer extends AbstractTransformer { - /** - * WebhookTransformer constructor. - */ - public function __construct() {} - /** * Transform webhook. */ diff --git a/app/Validation/Account/DepositValidation.php b/app/Validation/Account/DepositValidation.php index 36cd7e7d35..574f00cb9b 100644 --- a/app/Validation/Account/DepositValidation.php +++ b/app/Validation/Account/DepositValidation.php @@ -37,9 +37,9 @@ trait DepositValidation protected function validateDepositDestination(array $array): bool { $result = null; - $accountId = array_key_exists('id', $array) ? $array['id'] : null; - $accountName = array_key_exists('name', $array) ? $array['name'] : null; - $accountIban = array_key_exists('iban', $array) ? $array['iban'] : null; + $accountId = $array['id'] ?? null; + $accountName = $array['name'] ?? null; + $accountIban = $array['iban'] ?? null; Log::debug('Now in validateDepositDestination', $array); @@ -89,10 +89,10 @@ trait DepositValidation */ protected function validateDepositSource(array $array): bool { - $accountId = array_key_exists('id', $array) ? $array['id'] : null; - $accountName = array_key_exists('name', $array) ? $array['name'] : null; - $accountIban = array_key_exists('iban', $array) ? $array['iban'] : null; - $accountNumber = array_key_exists('number', $array) ? $array['number'] : null; + $accountId = $array['id'] ?? null; + $accountName = $array['name'] ?? null; + $accountIban = $array['iban'] ?? null; + $accountNumber = $array['number'] ?? null; Log::debug('Now in validateDepositSource', $array); // null = we found nothing at all or didn't even search diff --git a/app/Validation/Account/LiabilityValidation.php b/app/Validation/Account/LiabilityValidation.php index 4c08694ecf..b66c84651b 100644 --- a/app/Validation/Account/LiabilityValidation.php +++ b/app/Validation/Account/LiabilityValidation.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Validation\Account; +use Illuminate\Support\Facades\Log; use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Models\Account; use FireflyIII\Models\AccountType; @@ -35,23 +36,23 @@ trait LiabilityValidation { protected function validateLCDestination(array $array): bool { - app('log')->debug('Now in validateLCDestination', $array); + Log::debug('Now in validateLCDestination', $array); $result = null; - $accountId = array_key_exists('id', $array) ? $array['id'] : null; - $accountName = array_key_exists('name', $array) ? $array['name'] : null; + $accountId = $array['id'] ?? null; + $accountName = $array['name'] ?? null; $validTypes = config('firefly.valid_liabilities'); // if the ID is not null the source account should be a dummy account of the type liability credit. // the ID of the destination must belong to a liability. if (null !== $accountId) { if (AccountTypeEnum::LIABILITY_CREDIT->value !== $this->source?->accountType?->type) { - app('log')->error('Source account is not a liability.'); + Log::error('Source account is not a liability.'); return false; } $result = $this->findExistingAccount($validTypes, $array); if (null === $result) { - app('log')->error('Destination account is not a liability.'); + Log::error('Destination account is not a liability.'); return false; } @@ -60,11 +61,11 @@ trait LiabilityValidation } if (null !== $accountName && '' !== $accountName) { - app('log')->debug('Destination ID is null, now we can assume the destination is a (new) liability credit account.'); + Log::debug('Destination ID is null, now we can assume the destination is a (new) liability credit account.'); return true; } - app('log')->error('Destination ID is null, but destination name is also NULL.'); + Log::error('Destination ID is null, but destination name is also NULL.'); return false; } @@ -74,35 +75,35 @@ trait LiabilityValidation */ protected function validateLCSource(array $array): bool { - app('log')->debug('Now in validateLCSource', $array); + Log::debug('Now in validateLCSource', $array); // if the array has an ID and ID is not null, try to find it and check type. // this account must be a liability - $accountId = array_key_exists('id', $array) ? $array['id'] : null; + $accountId = $array['id'] ?? null; if (null !== $accountId) { - app('log')->debug('Source ID is not null, assume were looking for a liability.'); + Log::debug('Source ID is not null, assume were looking for a liability.'); // find liability credit: $result = $this->findExistingAccount(config('firefly.valid_liabilities'), $array); if (null === $result) { - app('log')->error('Did not find a liability account, return false.'); + Log::error('Did not find a liability account, return false.'); return false; } - app('log')->debug(sprintf('Return true, found #%d ("%s")', $result->id, $result->name)); + Log::debug(sprintf('Return true, found #%d ("%s")', $result->id, $result->name)); $this->setSource($result); return true; } // if array has name and is not null, return true. - $accountName = array_key_exists('name', $array) ? $array['name'] : null; + $accountName = $array['name'] ?? null; $result = true; if ('' === $accountName || null === $accountName) { - app('log')->error('Array must have a name, is not the case, return false.'); + Log::error('Array must have a name, is not the case, return false.'); $result = false; } - if (true === $result) { - app('log')->error('Array has a name, return true.'); + if ($result) { + Log::error('Array has a name, return true.'); // set the source to be a (dummy) revenue account. $account = new Account(); $accountType = AccountType::whereType(AccountTypeEnum::LIABILITY_CREDIT->value)->first(); diff --git a/app/Validation/Account/OBValidation.php b/app/Validation/Account/OBValidation.php index b0633c63f9..39d2b5fc22 100644 --- a/app/Validation/Account/OBValidation.php +++ b/app/Validation/Account/OBValidation.php @@ -37,8 +37,8 @@ trait OBValidation protected function validateOBDestination(array $array): bool { $result = null; - $accountId = array_key_exists('id', $array) ? $array['id'] : null; - $accountName = array_key_exists('name', $array) ? $array['name'] : null; + $accountId = $array['id'] ?? null; + $accountName = $array['name'] ?? null; Log::debug('Now in validateOBDestination', $array); // source can be any of the following types. @@ -83,8 +83,8 @@ trait OBValidation */ protected function validateOBSource(array $array): bool { - $accountId = array_key_exists('id', $array) ? $array['id'] : null; - $accountName = array_key_exists('name', $array) ? $array['name'] : null; + $accountId = $array['id'] ?? null; + $accountName = $array['name'] ?? null; Log::debug('Now in validateOBSource', $array); $result = null; // source can be any of the following types. diff --git a/app/Validation/Account/ReconciliationValidation.php b/app/Validation/Account/ReconciliationValidation.php index 52b97201d4..91514fc092 100644 --- a/app/Validation/Account/ReconciliationValidation.php +++ b/app/Validation/Account/ReconciliationValidation.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Validation\Account; +use Illuminate\Support\Facades\Log; use FireflyIII\Models\Account; /** @@ -36,8 +37,8 @@ trait ReconciliationValidation protected function validateReconciliationDestination(array $array): bool { - $accountId = array_key_exists('id', $array) ? $array['id'] : null; - $accountName = array_key_exists('name', $array) ? $array['name'] : null; + $accountId = $array['id'] ?? null; + $accountName = $array['name'] ?? null; // if both are NULL, the destination is valid because the reconciliation // is expected to be "negative", i.e. the money flows towards the // destination to the asset account which is the source. @@ -47,19 +48,19 @@ trait ReconciliationValidation } // after that, search for it expecting an asset account or a liability. - app('log')->debug('Now in validateReconciliationDestination', $array); + Log::debug('Now in validateReconciliationDestination', $array); // source can be any of the following types. $validTypes = array_keys($this->combinations[$this->transactionType]); $search = $this->findExistingAccount($validTypes, $array); if (null === $search) { $this->sourceError = (string) trans('validation.reconciliation_source_bad_data', ['id' => $accountId, 'name' => $accountName]); - app('log')->warning('Not a valid source. Cant find it.', $validTypes); + Log::warning('Not a valid source. Cant find it.', $validTypes); return false; } $this->setSource($search); - app('log')->debug('Valid source account!'); + Log::debug('Valid source account!'); return true; } @@ -69,32 +70,32 @@ trait ReconciliationValidation */ protected function validateReconciliationSource(array $array): bool { - $accountId = array_key_exists('id', $array) ? $array['id'] : null; - $accountName = array_key_exists('name', $array) ? $array['name'] : null; + $accountId = $array['id'] ?? null; + $accountName = $array['name'] ?? null; // if both are NULL, the source is valid because the reconciliation // is expected to be "positive", i.e. the money flows from the // source to the asset account that is the destination. if (null === $accountId && null === $accountName) { - app('log')->debug('The source is valid because ID and name are NULL.'); + Log::debug('The source is valid because ID and name are NULL.'); $this->setSource(new Account()); return true; } // after that, search for it expecting an asset account or a liability. - app('log')->debug('Now in validateReconciliationSource', $array); + Log::debug('Now in validateReconciliationSource', $array); // source can be any of the following types. $validTypes = array_keys($this->combinations[$this->transactionType]); $search = $this->findExistingAccount($validTypes, $array); if (null === $search) { $this->sourceError = (string) trans('validation.reconciliation_source_bad_data', ['id' => $accountId, 'name' => $accountName]); - app('log')->warning('Not a valid source. Cant find it.', $validTypes); + Log::warning('Not a valid source. Cant find it.', $validTypes); return false; } $this->setSource($search); - app('log')->debug('Valid source account!'); + Log::debug('Valid source account!'); return true; } diff --git a/app/Validation/Account/TransferValidation.php b/app/Validation/Account/TransferValidation.php index ff01b7eab6..6efcff3fe6 100644 --- a/app/Validation/Account/TransferValidation.php +++ b/app/Validation/Account/TransferValidation.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Validation\Account; +use Illuminate\Support\Facades\Log; use FireflyIII\Models\Account; /** @@ -33,17 +34,17 @@ trait TransferValidation { protected function validateTransferDestination(array $array): bool { - $accountId = array_key_exists('id', $array) ? $array['id'] : null; - $accountName = array_key_exists('name', $array) ? $array['name'] : null; - $accountIban = array_key_exists('iban', $array) ? $array['iban'] : null; - app('log')->debug('Now in validateTransferDestination', $array); + $accountId = $array['id'] ?? null; + $accountName = $array['name'] ?? null; + $accountIban = $array['iban'] ?? null; + Log::debug('Now in validateTransferDestination', $array); // source can be any of the following types. $validTypes = $this->combinations[$this->transactionType][$this->source->accountType->type] ?? []; if (null === $accountId && null === $accountName && null === $accountIban && false === $this->canCreateTypes($validTypes)) { // if both values are NULL we return false, // because the destination of a transfer can't be created. $this->destError = (string) trans('validation.transfer_dest_need_data'); - app('log')->error('Both values are NULL, cant create transfer destination.'); + Log::error('Both values are NULL, cant create transfer destination.'); return false; } @@ -74,11 +75,11 @@ trait TransferValidation protected function validateTransferSource(array $array): bool { - $accountId = array_key_exists('id', $array) ? $array['id'] : null; - $accountName = array_key_exists('name', $array) ? $array['name'] : null; - $accountIban = array_key_exists('iban', $array) ? $array['iban'] : null; - $accountNumber = array_key_exists('number', $array) ? $array['number'] : null; - app('log')->debug('Now in validateTransferSource', $array); + $accountId = $array['id'] ?? null; + $accountName = $array['name'] ?? null; + $accountIban = $array['iban'] ?? null; + $accountNumber = $array['number'] ?? null; + Log::debug('Now in validateTransferSource', $array); // source can be any of the following types. $validTypes = array_keys($this->combinations[$this->transactionType]); if (null === $accountId && null === $accountName @@ -87,7 +88,7 @@ trait TransferValidation // if both values are NULL we return false, // because the source of a withdrawal can't be created. $this->sourceError = (string) trans('validation.transfer_source_need_data'); - app('log')->warning('Not a valid source, need more data.'); + Log::warning('Not a valid source, need more data.'); return false; } @@ -96,12 +97,12 @@ trait TransferValidation $search = $this->findExistingAccount($validTypes, $array); if (null === $search) { $this->sourceError = (string) trans('validation.transfer_source_bad_data', ['id' => $accountId, 'name' => $accountName]); - app('log')->warning('Not a valid source, cant find it.', $validTypes); + Log::warning('Not a valid source, cant find it.', $validTypes); return false; } $this->setSource($search); - app('log')->debug('Valid source!'); + Log::debug('Valid source!'); return true; } diff --git a/app/Validation/Account/WithdrawalValidation.php b/app/Validation/Account/WithdrawalValidation.php index ac2a06d825..3abd29b17b 100644 --- a/app/Validation/Account/WithdrawalValidation.php +++ b/app/Validation/Account/WithdrawalValidation.php @@ -35,9 +35,9 @@ trait WithdrawalValidation { protected function validateGenericSource(array $array): bool { - $accountId = array_key_exists('id', $array) ? $array['id'] : null; - $accountName = array_key_exists('name', $array) ? $array['name'] : null; - $accountIban = array_key_exists('iban', $array) ? $array['iban'] : null; + $accountId = $array['id'] ?? null; + $accountName = $array['name'] ?? null; + $accountIban = $array['iban'] ?? null; Log::debug('Now in validateGenericSource', $array); // source can be any of the following types. $validTypes = [AccountTypeEnum::ASSET->value, AccountTypeEnum::REVENUE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value]; @@ -70,10 +70,10 @@ trait WithdrawalValidation protected function validateWithdrawalDestination(array $array): bool { - $accountId = array_key_exists('id', $array) ? $array['id'] : null; - $accountName = array_key_exists('name', $array) ? $array['name'] : null; - $accountIban = array_key_exists('iban', $array) ? $array['iban'] : null; - $accountNumber = array_key_exists('number', $array) ? $array['number'] : null; + $accountId = $array['id'] ?? null; + $accountName = $array['name'] ?? null; + $accountIban = $array['iban'] ?? null; + $accountNumber = $array['number'] ?? null; Log::debug('Now in validateWithdrawalDestination()', $array); // source can be any of the following types. $validTypes = $this->combinations[$this->transactionType][$this->source->accountType->type] ?? []; @@ -121,10 +121,10 @@ trait WithdrawalValidation protected function validateWithdrawalSource(array $array): bool { - $accountId = array_key_exists('id', $array) ? $array['id'] : null; - $accountName = array_key_exists('name', $array) ? $array['name'] : null; - $accountIban = array_key_exists('iban', $array) ? $array['iban'] : null; - $accountNumber = array_key_exists('number', $array) ? $array['number'] : null; + $accountId = $array['id'] ?? null; + $accountName = $array['name'] ?? null; + $accountIban = $array['iban'] ?? null; + $accountNumber = $array['number'] ?? null; Log::debug('Now in validateWithdrawalSource', $array); // source can be any of the following types. diff --git a/app/Validation/AccountValidator.php b/app/Validation/AccountValidator.php index 0605b82bf0..385ead80da 100644 --- a/app/Validation/AccountValidator.php +++ b/app/Validation/AccountValidator.php @@ -50,11 +50,11 @@ class AccountValidator use TransferValidation; use WithdrawalValidation; - public bool $createMode; - public string $destError; - public ?Account $destination; - public ?Account $source; - public string $sourceError; + public bool $createMode = false; + public string $destError = 'No error yet.'; + public ?Account $destination = null; + public ?Account $source = null; + public string $sourceError = 'No error yet.'; private AccountRepositoryInterface $accountRepository; private array $combinations; private string $transactionType; @@ -64,12 +64,7 @@ class AccountValidator */ public function __construct() { - $this->createMode = false; - $this->destError = 'No error yet.'; - $this->sourceError = 'No error yet.'; $this->combinations = config('firefly.source_dests'); - $this->source = null; - $this->destination = null; $this->accountRepository = app(AccountRepositoryInterface::class); } @@ -235,11 +230,7 @@ class AccountValidator protected function canCreateType(string $accountType): bool { $canCreate = [AccountTypeEnum::EXPENSE->value, AccountTypeEnum::REVENUE->value, AccountTypeEnum::INITIAL_BALANCE->value, AccountTypeEnum::LIABILITY_CREDIT->value]; - if (in_array($accountType, $canCreate, true)) { - return true; - } - - return false; + return in_array($accountType, $canCreate, true); } /** @@ -253,10 +244,10 @@ class AccountValidator { Log::debug('Now in findExistingAccount', [$validTypes, $data]); Log::debug('The search will be reversed!'); - $accountId = array_key_exists('id', $data) ? $data['id'] : null; - $accountIban = array_key_exists('iban', $data) ? $data['iban'] : null; - $accountNumber = array_key_exists('number', $data) ? $data['number'] : null; - $accountName = array_key_exists('name', $data) ? $data['name'] : null; + $accountId = $data['id'] ?? null; + $accountIban = $data['iban'] ?? null; + $accountNumber = $data['number'] ?? null; + $accountName = $data['name'] ?? null; // find by ID if (null !== $accountId && $accountId > 0) { diff --git a/app/Validation/Api/Data/Bulk/ValidatesBulkTransactionQuery.php b/app/Validation/Api/Data/Bulk/ValidatesBulkTransactionQuery.php index 8f8cffba91..89ea275b39 100644 --- a/app/Validation/Api/Data/Bulk/ValidatesBulkTransactionQuery.php +++ b/app/Validation/Api/Data/Bulk/ValidatesBulkTransactionQuery.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace FireflyIII\Validation\Api\Data\Bulk; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Repositories\Account\AccountRepositoryInterface; -use Illuminate\Validation\Validator; use function Safe\json_decode; diff --git a/app/Validation/AutoBudget/ValidatesAutoBudgetRequest.php b/app/Validation/AutoBudget/ValidatesAutoBudgetRequest.php index 581e0da61c..28bad253e3 100644 --- a/app/Validation/AutoBudget/ValidatesAutoBudgetRequest.php +++ b/app/Validation/AutoBudget/ValidatesAutoBudgetRequest.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Validation\AutoBudget; -use Illuminate\Validation\Validator; +use Illuminate\Contracts\Validation\Validator; /** * Trait ValidatesAutoBudgetRequest @@ -40,10 +40,10 @@ trait ValidatesAutoBudgetRequest $type = $data['auto_budget_type'] ?? ''; /** @var null|float|int|string $amount */ - $amount = array_key_exists('auto_budget_amount', $data) ? $data['auto_budget_amount'] : null; - $period = array_key_exists('auto_budget_period', $data) ? $data['auto_budget_period'] : null; + $amount = $data['auto_budget_amount'] ?? null; + $period = $data['auto_budget_period'] ?? null; $currencyId = array_key_exists('auto_budget_currency_id', $data) ? (int) $data['auto_budget_currency_id'] : null; - $currencyCode = array_key_exists('auto_budget_currency_code', $data) ? $data['auto_budget_currency_code'] : null; + $currencyCode = $data['auto_budget_currency_code'] ?? null; if (is_numeric($type)) { $type = (int) $type; } diff --git a/app/Validation/CurrencyValidation.php b/app/Validation/CurrencyValidation.php index 52bad8ff61..3409114cb6 100644 --- a/app/Validation/CurrencyValidation.php +++ b/app/Validation/CurrencyValidation.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace FireflyIII\Validation; +use Illuminate\Contracts\Validation\Validator; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Trait CurrencyValidation @@ -44,7 +44,7 @@ trait CurrencyValidation if ($validator->errors()->count() > 0) { return; } - app('log')->debug('Now in validateForeignCurrencyInformation()'); + Log::debug('Now in validateForeignCurrencyInformation()'); $transactions = $this->getTransactionsArray($validator); foreach ($transactions as $index => $transaction) { diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php index e420a44f50..380d2e4e48 100644 --- a/app/Validation/FireflyValidator.php +++ b/app/Validation/FireflyValidator.php @@ -123,11 +123,7 @@ class FireflyValidator extends Validator } $regex = '/^[a-z]{6}[0-9a-z]{2}([0-9a-z]{3})?\z/i'; $result = preg_match($regex, $value); - if (0 === $result) { - return false; - } - - return true; + return 0 !== $result; } public function validateExistingMfaCode(mixed $attribute, mixed $value): bool @@ -459,7 +455,7 @@ class FireflyValidator extends Validator * * @SuppressWarnings("PHPMD.UnusedFormalParameter") */ - public function validateSecurePassword($attribute, $value): bool + public function validateSecurePassword($attribute, string $value): bool { $verify = false; if (array_key_exists('verify_password', $this->data)) { diff --git a/app/Validation/GroupValidation.php b/app/Validation/GroupValidation.php index 84c32cfc90..61acde4f07 100644 --- a/app/Validation/GroupValidation.php +++ b/app/Validation/GroupValidation.php @@ -24,10 +24,11 @@ declare(strict_types=1); namespace FireflyIII\Validation; +use Illuminate\Support\Facades\Log; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionGroup; -use Illuminate\Validation\Validator; /** * Trait GroupValidation. @@ -89,7 +90,7 @@ trait GroupValidation protected function preventUpdateReconciled(Validator $validator, TransactionGroup $transactionGroup): void { - app('log')->debug(sprintf('Now in %s', __METHOD__)); + Log::debug(sprintf('Now in %s', __METHOD__)); $count = Transaction::leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id') ->leftJoin('transaction_groups', 'transaction_groups.id', 'transaction_journals.transaction_group_id') @@ -97,7 +98,7 @@ trait GroupValidation ->where('transactions.reconciled', 1)->where('transactions.amount', '<', 0)->count('transactions.id') ; if (0 === $count) { - app('log')->debug(sprintf('Transaction is not reconciled, done with %s', __METHOD__)); + Log::debug(sprintf('Transaction is not reconciled, done with %s', __METHOD__)); return; } @@ -123,7 +124,7 @@ trait GroupValidation } } - app('log')->debug(sprintf('Done with %s', __METHOD__)); + Log::debug(sprintf('Done with %s', __METHOD__)); } /** @@ -135,7 +136,7 @@ trait GroupValidation if ($validator->errors()->count() > 0) { return; } - app('log')->debug('Now in GroupValidation::validateDescriptions()'); + Log::debug('Now in GroupValidation::validateDescriptions()'); $transactions = $this->getTransactionsArray($validator); $validDescriptions = 0; foreach ($transactions as $transaction) { @@ -158,7 +159,7 @@ trait GroupValidation if ($validator->errors()->count() > 0) { return; } - app('log')->debug('Now in validateGroupDescription()'); + Log::debug('Now in validateGroupDescription()'); $data = $validator->getData(); $transactions = $this->getTransactionsArray($validator); @@ -175,12 +176,12 @@ trait GroupValidation */ protected function validateJournalIds(Validator $validator, TransactionGroup $transactionGroup): void { - app('log')->debug(sprintf('Now in GroupValidation::validateJournalIds(%d)', $transactionGroup->id)); + Log::debug(sprintf('Now in GroupValidation::validateJournalIds(%d)', $transactionGroup->id)); $transactions = $this->getTransactionsArray($validator); if (count($transactions) < 2) { // no need for validation. - app('log')->debug(sprintf('%d transaction(s) in submission, can skip this check.', count($transactions))); + Log::debug(sprintf('%d transaction(s) in submission, can skip this check.', count($transactions))); return; } @@ -204,17 +205,17 @@ trait GroupValidation if (array_key_exists('transaction_journal_id', $transaction)) { $journalId = $transaction['transaction_journal_id']; } - app('log')->debug(sprintf('Now in validateJournalId(%d, %d)', $index, $journalId)); + Log::debug(sprintf('Now in validateJournalId(%d, %d)', $index, $journalId)); if (0 === $journalId || '' === $journalId || '0' === $journalId) { - app('log')->debug('Submitted 0, will accept to be used in a new transaction.'); + Log::debug('Submitted 0, will accept to be used in a new transaction.'); return; } $journalId = (int) $journalId; $count = $transactionGroup->transactionJournals()->where('transaction_journals.id', $journalId)->count(); if (0 === $journalId || 0 === $count) { - app('log')->warning(sprintf('Transaction group #%d has %d journals with ID %d', $transactionGroup->id, $count, $journalId)); - app('log')->warning('Invalid submission: Each split must have transaction_journal_id (either valid ID or 0).'); + Log::warning(sprintf('Transaction group #%d has %d journals with ID %d', $transactionGroup->id, $count, $journalId)); + Log::warning('Invalid submission: Each split must have transaction_journal_id (either valid ID or 0).'); $validator->errors()->add(sprintf('transactions.%d.source_name', $index), (string) trans('validation.need_id_in_edit')); } } diff --git a/app/Validation/RecurrenceValidation.php b/app/Validation/RecurrenceValidation.php index 52b829203e..a76bd8b19a 100644 --- a/app/Validation/RecurrenceValidation.php +++ b/app/Validation/RecurrenceValidation.php @@ -24,10 +24,11 @@ declare(strict_types=1); namespace FireflyIII\Validation; +use Illuminate\Support\Facades\Log; +use Illuminate\Contracts\Validation\Validator; use Carbon\Carbon; use FireflyIII\Models\Recurrence; use FireflyIII\Models\RecurrenceTransaction; -use Illuminate\Validation\Validator; use InvalidArgumentException; /** @@ -50,22 +51,22 @@ trait RecurrenceValidation // grab model from parameter and try to set the transaction type from it if ('invalid' === $transactionType) { - app('log')->debug('Type is invalid but we will search for it.'); + Log::debug('Type is invalid but we will search for it.'); /** @var null|Recurrence $recurrence */ $recurrence = $this->route()?->parameter('recurrence'); if (null !== $recurrence) { - app('log')->debug('There is a recurrence in the route.'); + Log::debug('There is a recurrence in the route.'); // ok so we have a recurrence should be able to extract type somehow. /** @var null|RecurrenceTransaction $first */ $first = $recurrence->recurrenceTransactions()->first(); if (null !== $first) { $transactionType = null !== $first->transactionType ? $first->transactionType->type : 'withdrawal'; - app('log')->debug(sprintf('Determined type to be %s.', $transactionType)); + Log::debug(sprintf('Determined type to be %s.', $transactionType)); } if (null === $first) { - app('log')->warning('Just going to assume type is a withdrawal.'); + Log::warning('Just going to assume type is a withdrawal.'); $transactionType = 'withdrawal'; } } @@ -76,7 +77,7 @@ trait RecurrenceValidation /** @var AccountValidator $accountValidator */ $accountValidator = app(AccountValidator::class); - app('log')->debug(sprintf('Going to loop %d transaction(s)', count($transactions))); + Log::debug(sprintf('Going to loop %d transaction(s)', count($transactions))); foreach ($transactions as $index => $transaction) { $transactionType = $transaction['type'] ?? $transactionType; $accountValidator->setTransactionType($transactionType); @@ -296,7 +297,7 @@ trait RecurrenceValidation try { Carbon::createFromFormat('Y-m-d', $moment); } catch (InvalidArgumentException $e) { // @phpstan-ignore-line - app('log')->debug(sprintf('Invalid argument for Carbon: %s', $e->getMessage())); + Log::debug(sprintf('Invalid argument for Carbon: %s', $e->getMessage())); $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string) trans('validation.valid_recurrence_rep_moment')); } } @@ -306,12 +307,12 @@ trait RecurrenceValidation */ protected function validateTransactionId(Recurrence $recurrence, Validator $validator): void { - app('log')->debug('Now in validateTransactionId'); + Log::debug('Now in validateTransactionId'); $transactions = $this->getTransactionData(); $submittedTrCount = count($transactions); if (0 === $submittedTrCount) { - app('log')->warning('[b] User submitted no transactions.'); + Log::warning('[b] User submitted no transactions.'); $validator->errors()->add('transactions', (string) trans('validation.at_least_one_transaction')); return; @@ -320,31 +321,31 @@ trait RecurrenceValidation if (1 === $submittedTrCount && 1 === $originalTrCount) { $first = $transactions[0]; // can safely assume index 0. if (!array_key_exists('id', $first)) { - app('log')->debug('Single count and no ID, done.'); + Log::debug('Single count and no ID, done.'); return; // home safe! } $id = $first['id']; if ('' === (string) $id) { - app('log')->debug('Single count and empty ID, done.'); + Log::debug('Single count and empty ID, done.'); return; // home safe! } $integer = (int) $id; $secondCount = $recurrence->recurrenceTransactions()->where('recurrences_transactions.id', $integer)->count(); - app('log')->debug(sprintf('Result of ID count: %d', $secondCount)); + Log::debug(sprintf('Result of ID count: %d', $secondCount)); if (0 === $secondCount) { $validator->errors()->add('transactions.0.id', (string) trans('validation.id_does_not_match', ['id' => $integer])); } - app('log')->debug('Single ID validation done.'); + Log::debug('Single ID validation done.'); return; } - app('log')->debug('Multi ID validation.'); + Log::debug('Multi ID validation.'); $idsMandatory = false; if ($submittedTrCount < $originalTrCount) { - app('log')->debug(sprintf('User submits %d transaction, recurrence has %d transactions. All entries must have ID.', $submittedTrCount, $originalTrCount)); + Log::debug(sprintf('User submits %d transaction, recurrence has %d transactions. All entries must have ID.', $submittedTrCount, $originalTrCount)); $idsMandatory = true; } @@ -362,41 +363,41 @@ trait RecurrenceValidation $unmatchedIds = 0; foreach ($transactions as $index => $transaction) { - app('log')->debug(sprintf('Now at %d/%d', $index + 1, $submittedTrCount)); + Log::debug(sprintf('Now at %d/%d', $index + 1, $submittedTrCount)); if (!is_array($transaction)) { - app('log')->warning('Not an array. Give error.'); + Log::warning('Not an array. Give error.'); $validator->errors()->add(sprintf('transactions.%d.id', $index), (string) trans('validation.at_least_one_transaction')); return; } if (!array_key_exists('id', $transaction) && $idsMandatory) { - app('log')->warning('ID is mandatory but array has no ID.'); + Log::warning('ID is mandatory but array has no ID.'); $validator->errors()->add(sprintf('transactions.%d.id', $index), (string) trans('validation.need_id_to_match')); return; } if (array_key_exists('id', $transaction)) { // don't matter if $idsMandatory - app('log')->debug('Array has ID.'); + Log::debug('Array has ID.'); $idCount = $recurrence->recurrenceTransactions()->where('recurrences_transactions.id', (int) $transaction['id'])->count(); if (0 === $idCount) { - app('log')->debug('ID does not exist or no match. Count another unmatched ID.'); + Log::debug('ID does not exist or no match. Count another unmatched ID.'); ++$unmatchedIds; } } if (!array_key_exists('id', $transaction) && !$idsMandatory) { - app('log')->debug('Array has no ID but was not mandatory at this point.'); + Log::debug('Array has no ID but was not mandatory at this point.'); ++$unmatchedIds; } } // if too many don't match, but you haven't submitted more than already present: $maxUnmatched = max(1, $submittedTrCount - $originalTrCount); - app('log')->debug(sprintf('Submitted: %d. Original: %d. User can submit %d unmatched transactions.', $submittedTrCount, $originalTrCount, $maxUnmatched)); + Log::debug(sprintf('Submitted: %d. Original: %d. User can submit %d unmatched transactions.', $submittedTrCount, $originalTrCount, $maxUnmatched)); if ($unmatchedIds > $maxUnmatched) { - app('log')->warning(sprintf('Too many unmatched transactions (%d).', $unmatchedIds)); + Log::warning(sprintf('Too many unmatched transactions (%d).', $unmatchedIds)); $validator->errors()->add('transactions.0.id', (string) trans('validation.too_many_unmatched')); return; } - app('log')->debug('Done with ID validation.'); + Log::debug('Done with ID validation.'); } } diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.php index b44333bd90..be8270f264 100644 --- a/app/Validation/TransactionValidation.php +++ b/app/Validation/TransactionValidation.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Validation; +use Illuminate\Contracts\Validation\Validator; use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Exceptions\FireflyException; @@ -36,7 +37,6 @@ use FireflyIII\Repositories\Account\AccountRepository; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\User; use Illuminate\Support\Facades\Log; -use Illuminate\Validation\Validator; /** * Trait TransactionValidation @@ -302,11 +302,7 @@ trait TransactionValidation private function isLiability(Account $account): bool { $type = $account->accountType->type; - if (in_array($type, config('firefly.valid_liabilities'), true)) { - return true; - } - - return false; + return in_array($type, config('firefly.valid_liabilities'), true); } private function isAsset(Account $account): bool @@ -327,11 +323,7 @@ trait TransactionValidation if ('' === $transaction['foreign_amount']) { return false; } - if (0 === bccomp('0', (string) $transaction['foreign_amount'])) { - return false; - } - - return true; + return 0 !== bccomp('0', (string) $transaction['foreign_amount']); } /** @@ -758,12 +750,8 @@ trait TransactionValidation // source ID's are equal, return void. return true; } - if ($this->arrayEqual($comparison['source_name'])) { - // source names are equal, return void. - return true; - } - - return false; + // source names are equal, return void. + return (bool) $this->arrayEqual($comparison['source_name']); } private function arrayEqual(array $array): bool @@ -777,12 +765,8 @@ trait TransactionValidation // destination ID's are equal, return void. return true; } - if ($this->arrayEqual($comparison['destination_name'])) { - // destination names are equal, return void. - return true; - } - - return false; + // destination names are equal, return void. + return (bool) $this->arrayEqual($comparison['destination_name']); } private function compareAccountDataTransfer(array $comparison): bool @@ -799,11 +783,7 @@ trait TransactionValidation // destination ID's are equal, return void. return true; } - if ($this->arrayEqual($comparison['destination_name'])) { - // destination names are equal, return void. - return true; - } - - return false; + // destination names are equal, return void. + return (bool) $this->arrayEqual($comparison['destination_name']); } } diff --git a/bootstrap/app.php b/bootstrap/app.php index f384f4ba78..63d02d4f5b 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -42,8 +42,6 @@ bcscale(12); if (!function_exists('envNonEmpty')) { /** - * @param string $key - * @param string|int|bool|null $default * * @return mixed|null */ @@ -59,12 +57,6 @@ if (!function_exists('envNonEmpty')) { } if (!function_exists('stringIsEqual')) { - /** - * @param string $left - * @param string $right - * - * @return bool - */ function stringIsEqual(string $left, string $right): bool { return $left === $right; diff --git a/config/app.php b/config/app.php index 7600ef8514..2dad30bc1e 100644 --- a/config/app.php +++ b/config/app.php @@ -156,7 +156,7 @@ return [ 'RuleForm' => RuleForm::class, ], - 'asset_url' => env('ASSET_URL', null), + 'asset_url' => env('ASSET_URL'), /* |-------------------------------------------------------------------------- diff --git a/config/auth.php b/config/auth.php index de43714e23..7159b7e590 100644 --- a/config/auth.php +++ b/config/auth.php @@ -41,7 +41,7 @@ return [ 'passwords' => 'users', ], 'guard_header' => envNonEmpty('AUTHENTICATION_GUARD_HEADER', 'REMOTE_USER'), - 'guard_email' => envNonEmpty('AUTHENTICATION_GUARD_EMAIL', null), + 'guard_email' => envNonEmpty('AUTHENTICATION_GUARD_EMAIL'), /* |-------------------------------------------------------------------------- diff --git a/config/database.php b/config/database.php index 77fe7499e7..cd557e2bc4 100644 --- a/config/database.php +++ b/config/database.php @@ -41,12 +41,12 @@ if (false !== $databaseUrl) { } // Get SSL parameters from .env file. -$mysql_ssl_ca_dir = envNonEmpty('MYSQL_SSL_CAPATH', null); -$mysql_ssl_ca_file = envNonEmpty('MYSQL_SSL_CA', null); -$mysql_ssl_cert = envNonEmpty('MYSQL_SSL_CERT', null); -$mysql_ssl_key = envNonEmpty('MYSQL_SSL_KEY', null); -$mysql_ssl_ciphers = envNonEmpty('MYSQL_SSL_CIPHER', null); -$mysql_ssl_verify = envNonEmpty('MYSQL_SSL_VERIFY_SERVER_CERT', null); +$mysql_ssl_ca_dir = envNonEmpty('MYSQL_SSL_CAPATH'); +$mysql_ssl_ca_file = envNonEmpty('MYSQL_SSL_CA'); +$mysql_ssl_cert = envNonEmpty('MYSQL_SSL_CERT'); +$mysql_ssl_key = envNonEmpty('MYSQL_SSL_KEY'); +$mysql_ssl_ciphers = envNonEmpty('MYSQL_SSL_CIPHER'); +$mysql_ssl_verify = envNonEmpty('MYSQL_SSL_VERIFY_SERVER_CERT'); $mySqlSSLOptions = []; $useSSL = envNonEmpty('MYSQL_USE_SSL', false); @@ -145,7 +145,7 @@ return [ 'host' => envNonEmpty('REDIS_HOST', '127.0.0.1'), 'port' => envNonEmpty('REDIS_PORT', 6379), 'username' => env('REDIS_USERNAME'), - 'password' => env('REDIS_PASSWORD', null), + 'password' => env('REDIS_PASSWORD'), 'database' => env('REDIS_DB', '0'), ], 'cache' => [ @@ -155,7 +155,7 @@ return [ 'host' => envNonEmpty('REDIS_HOST', '127.0.0.1'), 'port' => envNonEmpty('REDIS_PORT', 6379), 'username' => env('REDIS_USERNAME'), - 'password' => env('REDIS_PASSWORD', null), + 'password' => env('REDIS_PASSWORD'), 'database' => env('REDIS_CACHE_DB', '1'), ], ], diff --git a/config/debugbar.php b/config/debugbar.php index e96846011b..3e980f35a9 100644 --- a/config/debugbar.php +++ b/config/debugbar.php @@ -36,7 +36,7 @@ return [ | */ - 'enabled' => env('DEBUGBAR_ENABLED', null), + 'enabled' => env('DEBUGBAR_ENABLED'), 'except' => [ 'telescope*', 'horizon*', diff --git a/config/session.php b/config/session.php index 8881108f8b..6f099565cb 100644 --- a/config/session.php +++ b/config/session.php @@ -34,8 +34,8 @@ return [ 'lottery' => [2, 100], 'cookie' => env('COOKIE_NAME', 'firefly_iii_session'), 'path' => env('COOKIE_PATH', '/'), - 'domain' => env('COOKIE_DOMAIN', null), - 'secure' => env('COOKIE_SECURE', null), + 'domain' => env('COOKIE_DOMAIN'), + 'secure' => env('COOKIE_SECURE'), 'http_only' => true, 'same_site' => env('COOKIE_SAMESITE', 'lax'), ]; diff --git a/routes/channels.php b/routes/channels.php index 92bf6b22ef..e5e9a52dbc 100644 --- a/routes/channels.php +++ b/routes/channels.php @@ -37,5 +37,5 @@ use Illuminate\Support\Facades\Broadcast; Broadcast::channel( 'App.User.{id}', - static fn ($user, $id) => (int)$user->id === (int)$id + static fn ($user, $id): bool => (int)$user->id === (int)$id ); diff --git a/routes/web.php b/routes/web.php index 4f05a8622c..7d5b40234c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -42,7 +42,7 @@ Route::group( Route::get('/authorize', ['uses' => 'AuthorizationController@authorize', 'as' => 'authorizations.authorize', 'middleware' => 'user-full-auth']); // the rest - $guard = config('passport.guard', null); + $guard = config('passport.guard'); Route::middleware(['web', null !== $guard ? 'auth:'.$guard : 'auth'])->group(function (): void { Route::post('/token/refresh', ['uses' => 'TransientTokenController@refresh', 'as' => 'token.refresh']); Route::post('/authorize', ['uses' => 'ApproveAuthorizationController@approve', 'as' => 'authorizations.approve']); diff --git a/tests/integration/Api/Chart/AccountControllerTest.php b/tests/integration/Api/Chart/AccountControllerTest.php index f0afcd93e9..fbb60429c0 100644 --- a/tests/integration/Api/Chart/AccountControllerTest.php +++ b/tests/integration/Api/Chart/AccountControllerTest.php @@ -25,6 +25,7 @@ declare(strict_types=1); namespace Tests\integration\Api\Chart; +use FireflyIII\User; use Override; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\integration\TestCase; @@ -37,14 +38,14 @@ use Tests\integration\TestCase; final class AccountControllerTest extends TestCase { use RefreshDatabase; - private $user; + private ?User $user = null; #[Override] protected function setUp(): void { parent::setUp(); - if (!isset($this->user)) { + if (!$this->user instanceof User) { $this->user = $this->createAuthenticatedUser(); } $this->actingAs($this->user); diff --git a/tests/integration/Api/Chart/BalanceControllerTest.php b/tests/integration/Api/Chart/BalanceControllerTest.php index 4ad490d9f6..bcfc308467 100644 --- a/tests/integration/Api/Chart/BalanceControllerTest.php +++ b/tests/integration/Api/Chart/BalanceControllerTest.php @@ -25,6 +25,7 @@ declare(strict_types=1); namespace Tests\integration\Api\Chart; +use FireflyIII\User; use Override; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\integration\TestCase; @@ -37,14 +38,14 @@ use Tests\integration\TestCase; final class BalanceControllerTest extends TestCase { use RefreshDatabase; - private $user; + private ?User $user = null; #[Override] protected function setUp(): void { parent::setUp(); - if (!isset($this->user)) { + if (!$this->user instanceof User) { $this->user = $this->createAuthenticatedUser(); } $this->actingAs($this->user); diff --git a/tests/integration/Api/Chart/BudgetControllerTest.php b/tests/integration/Api/Chart/BudgetControllerTest.php index d0f9c980af..f565dcda28 100644 --- a/tests/integration/Api/Chart/BudgetControllerTest.php +++ b/tests/integration/Api/Chart/BudgetControllerTest.php @@ -25,6 +25,7 @@ declare(strict_types=1); namespace Tests\integration\Api\Chart; +use FireflyIII\User; use Override; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\integration\TestCase; @@ -37,14 +38,14 @@ use Tests\integration\TestCase; final class BudgetControllerTest extends TestCase { use RefreshDatabase; - private $user; + private ?User $user = null; #[Override] protected function setUp(): void { parent::setUp(); - if (!isset($this->user)) { + if (!$this->user instanceof User) { $this->user = $this->createAuthenticatedUser(); } $this->actingAs($this->user); diff --git a/tests/integration/Api/Chart/CategoryControllerTest.php b/tests/integration/Api/Chart/CategoryControllerTest.php index 045dc61691..ed77df6a98 100644 --- a/tests/integration/Api/Chart/CategoryControllerTest.php +++ b/tests/integration/Api/Chart/CategoryControllerTest.php @@ -25,6 +25,7 @@ declare(strict_types=1); namespace Tests\integration\Api\Chart; +use FireflyIII\User; use Override; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\integration\TestCase; @@ -37,14 +38,14 @@ use Tests\integration\TestCase; final class CategoryControllerTest extends TestCase { use RefreshDatabase; - private $user; + private ?User $user = null; #[Override] protected function setUp(): void { parent::setUp(); - if (!isset($this->user)) { + if (!$this->user instanceof User) { $this->user = $this->createAuthenticatedUser(); } $this->actingAs($this->user); diff --git a/tests/integration/Api/Models/Account/ListControllerTest.php b/tests/integration/Api/Models/Account/ListControllerTest.php index d22823fefb..2d508a7796 100644 --- a/tests/integration/Api/Models/Account/ListControllerTest.php +++ b/tests/integration/Api/Models/Account/ListControllerTest.php @@ -25,6 +25,7 @@ declare(strict_types=1); namespace Tests\integration\Api\Models\Account; +use Override; use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Factory\AttachmentFactory; use FireflyIII\Models\Account; @@ -43,6 +44,7 @@ final class ListControllerTest extends TestCase private User $user; private Account $account; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/integration/Api/Models/Account/ShowControllerTest.php b/tests/integration/Api/Models/Account/ShowControllerTest.php index e952e63b16..c80943f01d 100644 --- a/tests/integration/Api/Models/Account/ShowControllerTest.php +++ b/tests/integration/Api/Models/Account/ShowControllerTest.php @@ -25,6 +25,7 @@ declare(strict_types=1); namespace Tests\integration\Api\Models\Account; +use Override; use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Models\Account; use FireflyIII\User; @@ -41,6 +42,7 @@ final class ShowControllerTest extends TestCase use RefreshDatabase; private User $user; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/integration/Api/System/AboutControllerTest.php b/tests/integration/Api/System/AboutControllerTest.php index 6ffb04b044..71db85f1ea 100644 --- a/tests/integration/Api/System/AboutControllerTest.php +++ b/tests/integration/Api/System/AboutControllerTest.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace Tests\integration\Api\System; +use FireflyIII\User; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Testing\Fluent\AssertableJson; use Tests\integration\TestCase; @@ -39,14 +40,14 @@ use Override; final class AboutControllerTest extends TestCase { use RefreshDatabase; - private $user; + private ?User $user = null; #[Override] protected function setUp(): void { parent::setUp(); - if (!isset($this->user)) { + if (!$this->user instanceof User) { $this->user = $this->createAuthenticatedUser(); } $this->actingAs($this->user); @@ -74,7 +75,7 @@ final class AboutControllerTest extends TestCase $response->assertOk(); $response->assertJson( - fn (AssertableJson $json) => $json + fn (AssertableJson $json): AssertableJson => $json ->where('data.attributes.email', $this->user->email) ->where('data.attributes.role', $this->user->role) ); From a498169148869a9fb0d7f7070381388a2359c409 Mon Sep 17 00:00:00 2001 From: JC5 Date: Sun, 9 Nov 2025 09:11:55 +0100 Subject: [PATCH 04/12] =?UTF-8?q?=F0=9F=A4=96=20Auto=20commit=20for=20rele?= =?UTF-8?q?ase=20'develop'=20on=202025-11-09?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Api/V1/Controllers/Controller.php | 6 +-- .../Controllers/Summary/BasicController.php | 1 + .../Correction/CorrectsUnevenAmount.php | 1 + .../Upgrade/UpgradesLiabilitiesEight.php | 1 + app/Exceptions/IntervalException.php | 4 +- app/Factory/TransactionFactory.php | 4 +- .../Report/Category/MonthReportGenerator.php | 2 +- .../Report/Standard/MonthReportGenerator.php | 4 +- .../Standard/MultiYearReportGenerator.php | 4 +- .../Report/Standard/YearReportGenerator.php | 4 +- app/Helpers/Report/ReportHelper.php | 4 +- .../Controllers/Account/DeleteController.php | 2 +- .../Controllers/Account/EditController.php | 2 +- .../Account/ReconcileController.php | 3 +- .../Controllers/Account/ShowController.php | 40 +++++++++---------- app/Http/Controllers/Admin/LinkController.php | 4 +- app/Http/Controllers/Admin/UserController.php | 2 +- app/Http/Controllers/Auth/LoginController.php | 4 +- .../Auth/ResetPasswordController.php | 1 + .../Controllers/Auth/TwoFactorController.php | 2 +- app/Http/Controllers/DebugController.php | 11 ++++- app/Http/Controllers/NewUserController.php | 2 +- .../Controllers/PreferencesController.php | 1 - .../Controllers/Profile/MfaController.php | 1 - app/Http/Controllers/ProfileController.php | 4 +- app/Http/Controllers/ReportController.php | 1 - .../Controllers/System/CronController.php | 2 +- .../Controllers/System/InstallController.php | 4 +- .../Transaction/ConvertController.php | 2 +- .../Transaction/CreateController.php | 1 - .../Transaction/DeleteController.php | 2 +- .../Transaction/EditController.php | 2 +- .../Transaction/MassController.php | 1 - .../TransactionCurrency/CreateController.php | 2 +- .../TransactionCurrency/DeleteController.php | 3 +- .../TransactionCurrency/EditController.php | 3 +- app/Http/Middleware/Authenticate.php | 1 + app/Http/Middleware/Binder.php | 4 +- app/Jobs/WarnAboutBills.php | 2 + app/Providers/AppServiceProvider.php | 1 + .../Journal/JournalRepository.php | 6 +-- app/Rules/IsAllowedGroupAction.php | 5 +-- .../Internal/Support/AccountServiceTrait.php | 1 + .../Support/CreditRecalculateService.php | 4 +- .../Internal/Update/GroupUpdateService.php | 1 + .../Internal/Update/JournalUpdateService.php | 16 ++++---- .../Authentication/RemoteUserGuard.php | 1 - .../Chart/Budget/FrontpageChartGenerator.php | 8 ++-- .../Category/FrontpageChartGenerator.php | 2 +- app/Support/Cronjobs/AbstractCronjob.php | 12 +++--- app/Support/ExpandedForm.php | 2 + app/Support/Export/ExportDataGenerator.php | 26 ++++++------ .../Http/Api/AccountBalanceGrouped.php | 2 +- .../Http/Api/SummaryBalanceGrouped.php | 6 +-- .../Http/Controllers/RequestInformation.php | 1 + .../Enrichments/BudgetLimitEnrichment.php | 6 +-- .../Enrichments/PiggyBankEnrichment.php | 4 +- .../Enrichments/PiggyBankEventEnrichment.php | 4 +- .../Enrichments/SubscriptionEnrichment.php | 6 +-- .../TransactionGroupEnrichment.php | 8 +--- .../JsonApi/Enrichments/WebhookEnrichment.php | 8 +--- app/Support/ParseDateString.php | 1 + app/Support/Request/AppendsLocationData.php | 4 +- app/Support/Request/ConvertsDataTypes.php | 1 + app/Support/Search/AccountSearch.php | 2 +- app/Support/Search/OperatorQuerySearch.php | 14 +++---- app/Support/Steam.php | 28 ++++++------- app/Support/System/OAuthKeys.php | 1 + app/Support/Twig/General.php | 1 + app/Support/Twig/TransactionGroupTwig.php | 2 +- app/Support/Twig/Translation.php | 4 +- .../Engine/SearchRuleEngine.php | 8 ++-- .../TransactionGroupTransformer.php | 1 + app/Transformers/UserGroupTransformer.php | 4 +- app/Validation/AccountValidator.php | 7 ++-- app/Validation/FireflyValidator.php | 1 + app/Validation/TransactionValidation.php | 5 +++ config/firefly.php | 4 +- 78 files changed, 183 insertions(+), 179 deletions(-) diff --git a/app/Api/V1/Controllers/Controller.php b/app/Api/V1/Controllers/Controller.php index 8c6cff0d16..93508c4ed3 100644 --- a/app/Api/V1/Controllers/Controller.php +++ b/app/Api/V1/Controllers/Controller.php @@ -102,9 +102,9 @@ abstract class Controller extends BaseController } #[Deprecated(message: <<<'TXT' - use Request classes - Method to grab all parameters from the URL - TXT)] + use Request classes + Method to grab all parameters from the URL + TXT)] private function getParameters(): ParameterBag { $bag = new ParameterBag(); diff --git a/app/Api/V1/Controllers/Summary/BasicController.php b/app/Api/V1/Controllers/Summary/BasicController.php index 730bfd3c6e..22b938783c 100644 --- a/app/Api/V1/Controllers/Summary/BasicController.php +++ b/app/Api/V1/Controllers/Summary/BasicController.php @@ -651,6 +651,7 @@ class BasicController extends Controller if ($start->greaterThanOrEqualTo($date) && $end->greaterThanOrEqualTo($date)) { return true; } + // start and end in the past? use $end return $start->lessThanOrEqualTo($date) && $end->lessThanOrEqualTo($date); } diff --git a/app/Console/Commands/Correction/CorrectsUnevenAmount.php b/app/Console/Commands/Correction/CorrectsUnevenAmount.php index 491f6dde2b..16c8140387 100644 --- a/app/Console/Commands/Correction/CorrectsUnevenAmount.php +++ b/app/Console/Commands/Correction/CorrectsUnevenAmount.php @@ -251,6 +251,7 @@ class CorrectsUnevenAmount extends Command /** @var Transaction $source */ $source = $journal->transactions()->where('amount', '<', 0)->first(); + // safety catch on NULL should not be necessary, we just had that catch. // source amount = dest foreign amount // source currency = dest foreign currency diff --git a/app/Console/Commands/Upgrade/UpgradesLiabilitiesEight.php b/app/Console/Commands/Upgrade/UpgradesLiabilitiesEight.php index 611aa7d08b..9a03e0445c 100644 --- a/app/Console/Commands/Upgrade/UpgradesLiabilitiesEight.php +++ b/app/Console/Commands/Upgrade/UpgradesLiabilitiesEight.php @@ -136,6 +136,7 @@ class UpgradesLiabilitiesEight extends Command if (null === $liabilityJournal) { return false; } + return (bool) $openingJournal->date->isSameDay($liabilityJournal->date); } diff --git a/app/Exceptions/IntervalException.php b/app/Exceptions/IntervalException.php index 046e9cdef7..09ab3c6469 100644 --- a/app/Exceptions/IntervalException.php +++ b/app/Exceptions/IntervalException.php @@ -34,10 +34,10 @@ use Throwable; final class IntervalException extends Exception { public array $availableIntervals = []; - public Periodicity $periodicity = Periodicity::Monthly; + public Periodicity $periodicity = Periodicity::Monthly; /** @var mixed */ - protected $message = 'The periodicity %s is unknown. Choose one of available periodicity: %s'; + protected $message = 'The periodicity %s is unknown. Choose one of available periodicity: %s'; public function __construct(string $message = '', int $code = 0, ?Throwable $previous = null) { diff --git a/app/Factory/TransactionFactory.php b/app/Factory/TransactionFactory.php index 354dc53418..a5a58a96a6 100644 --- a/app/Factory/TransactionFactory.php +++ b/app/Factory/TransactionFactory.php @@ -43,9 +43,9 @@ class TransactionFactory private Account $account; private array $accountInformation = []; private TransactionCurrency $currency; - private ?TransactionCurrency $foreignCurrency = null; + private ?TransactionCurrency $foreignCurrency = null; private TransactionJournal $journal; - private bool $reconciled = false; + private bool $reconciled = false; /** * Create transaction with negative amount (for source accounts). diff --git a/app/Generator/Report/Category/MonthReportGenerator.php b/app/Generator/Report/Category/MonthReportGenerator.php index 2360b93abd..3bae1a373c 100644 --- a/app/Generator/Report/Category/MonthReportGenerator.php +++ b/app/Generator/Report/Category/MonthReportGenerator.php @@ -42,7 +42,7 @@ class MonthReportGenerator implements ReportGeneratorInterface private Collection $categories; private Carbon $end; private array $expenses = []; - private array $income = []; + private array $income = []; private Carbon $start; /** diff --git a/app/Generator/Report/Standard/MonthReportGenerator.php b/app/Generator/Report/Standard/MonthReportGenerator.php index f8ad0b4f82..54cc09855e 100644 --- a/app/Generator/Report/Standard/MonthReportGenerator.php +++ b/app/Generator/Report/Standard/MonthReportGenerator.php @@ -39,10 +39,10 @@ class MonthReportGenerator implements ReportGeneratorInterface private ?Collection $accounts = null; /** @var Carbon The end date. */ - private ?Carbon $end = null; + private ?Carbon $end = null; /** @var Carbon The start date. */ - private ?Carbon $start = null; + private ?Carbon $start = null; /** * Generates the report. diff --git a/app/Generator/Report/Standard/MultiYearReportGenerator.php b/app/Generator/Report/Standard/MultiYearReportGenerator.php index dc49d75e7c..10f89ea80b 100644 --- a/app/Generator/Report/Standard/MultiYearReportGenerator.php +++ b/app/Generator/Report/Standard/MultiYearReportGenerator.php @@ -39,10 +39,10 @@ class MultiYearReportGenerator implements ReportGeneratorInterface private ?Collection $accounts = null; /** @var Carbon The end date. */ - private ?Carbon $end = null; + private ?Carbon $end = null; /** @var Carbon The start date. */ - private ?Carbon $start = null; + private ?Carbon $start = null; /** * Generates the report. diff --git a/app/Generator/Report/Standard/YearReportGenerator.php b/app/Generator/Report/Standard/YearReportGenerator.php index 995d49d335..8c394d4c64 100644 --- a/app/Generator/Report/Standard/YearReportGenerator.php +++ b/app/Generator/Report/Standard/YearReportGenerator.php @@ -39,10 +39,10 @@ class YearReportGenerator implements ReportGeneratorInterface private ?Collection $accounts = null; /** @var Carbon The end date. */ - private ?Carbon $end = null; + private ?Carbon $end = null; /** @var Carbon The start date. */ - private ?Carbon $start = null; + private ?Carbon $start = null; /** * Generates the report. diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php index 7c1d4cc113..140667989c 100644 --- a/app/Helpers/Report/ReportHelper.php +++ b/app/Helpers/Report/ReportHelper.php @@ -42,9 +42,7 @@ class ReportHelper implements ReportHelperInterface public function __construct( /** @var BudgetRepositoryInterface The budget repository */ protected BudgetRepositoryInterface $budgetRepository - ) - { - } + ) {} /** * This method generates a full report for the given period on all diff --git a/app/Http/Controllers/Account/DeleteController.php b/app/Http/Controllers/Account/DeleteController.php index d2370eab4b..49686ffe61 100644 --- a/app/Http/Controllers/Account/DeleteController.php +++ b/app/Http/Controllers/Account/DeleteController.php @@ -66,7 +66,7 @@ class DeleteController extends Controller * * @return Factory|Redirector|RedirectResponse|View */ - public function delete(Account $account): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View + public function delete(Account $account): Factory|\Illuminate\Contracts\View\View|Redirector|RedirectResponse { if (!$this->isEditableAccount($account)) { return $this->redirectAccountToAccount($account); diff --git a/app/Http/Controllers/Account/EditController.php b/app/Http/Controllers/Account/EditController.php index 98b6c99ccb..9fa0eea7c0 100644 --- a/app/Http/Controllers/Account/EditController.php +++ b/app/Http/Controllers/Account/EditController.php @@ -76,7 +76,7 @@ class EditController extends Controller * * @return Factory|Redirector|RedirectResponse|View */ - public function edit(Request $request, Account $account, AccountRepositoryInterface $repository): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View + public function edit(Request $request, Account $account, AccountRepositoryInterface $repository): Factory|\Illuminate\Contracts\View\View|Redirector|RedirectResponse { if (!$this->isEditableAccount($account)) { return $this->redirectAccountToAccount($account); diff --git a/app/Http/Controllers/Account/ReconcileController.php b/app/Http/Controllers/Account/ReconcileController.php index ff99abb88a..a6cbc328cb 100644 --- a/app/Http/Controllers/Account/ReconcileController.php +++ b/app/Http/Controllers/Account/ReconcileController.php @@ -78,7 +78,7 @@ class ReconcileController extends Controller * * @throws FireflyException * */ - public function reconcile(Account $account, ?Carbon $start = null, ?Carbon $end = null): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View + public function reconcile(Account $account, ?Carbon $start = null, ?Carbon $end = null): Factory|\Illuminate\Contracts\View\View|Redirector|RedirectResponse { if (!$this->isEditableAccount($account)) { return $this->redirectAccountToAccount($account); @@ -146,7 +146,6 @@ class ReconcileController extends Controller /** * Submit a new reconciliation. * - * * @throws DuplicateTransactionException */ public function submit(ReconciliationStoreRequest $request, Account $account, Carbon $start, Carbon $end): Redirector|RedirectResponse diff --git a/app/Http/Controllers/Account/ShowController.php b/app/Http/Controllers/Account/ShowController.php index dfbb046410..1d5edb91fc 100644 --- a/app/Http/Controllers/Account/ShowController.php +++ b/app/Http/Controllers/Account/ShowController.php @@ -84,7 +84,7 @@ class ShowController extends Controller * @throws FireflyException * @throws NotFoundExceptionInterface */ - public function show(Request $request, Account $account, ?Carbon $start = null, ?Carbon $end = null): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View + public function show(Request $request, Account $account, ?Carbon $start = null, ?Carbon $end = null): Factory|\Illuminate\Contracts\View\View|Redirector|RedirectResponse { if (0 === $account->id) { throw new NotFoundHttpException(); @@ -187,47 +187,47 @@ class ShowController extends Controller * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function showAll(Request $request, Account $account): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View + public function showAll(Request $request, Account $account): Factory|\Illuminate\Contracts\View\View|Redirector|RedirectResponse { if (!$this->isEditableAccount($account)) { return $this->redirectAccountToAccount($account); } - $location = $this->repository->getLocation($account); - $isLiability = $this->repository->isLiability($account); - $attachments = $this->repository->getAttachments($account); - $objectType = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type)); - $end = today(config('app.timezone')); - $today = today(config('app.timezone')); + $location = $this->repository->getLocation($account); + $isLiability = $this->repository->isLiability($account); + $attachments = $this->repository->getAttachments($account); + $objectType = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type)); + $end = today(config('app.timezone')); + $today = today(config('app.timezone')); $this->repository->getAccountCurrency($account); - $start = $this->repository->oldestJournalDate($account) ?? today(config('app.timezone'))->startOfMonth(); - $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) ?? $this->primaryCurrency; - $subTitle = (string) trans('firefly.all_journals_for_account', ['name' => $account->name]); - $periods = new Collection(); + $start = $this->repository->oldestJournalDate($account) ?? today(config('app.timezone'))->startOfMonth(); + $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) ?? $this->primaryCurrency; + $subTitle = (string) trans('firefly.all_journals_for_account', ['name' => $account->name]); + $periods = new Collection(); $end->endOfDay(); /** @var GroupCollectorInterface $collector */ - $collector = app(GroupCollectorInterface::class); + $collector = app(GroupCollectorInterface::class); $collector->setAccounts(new Collection()->push($account))->setLimit($pageSize)->setPage($page)->withAccountInformation()->withCategoryInformation(); // this search will not include transaction groups where this asset account (or liability) // is just part of ONE of the journals. To force this: $collector->setExpandGroupSearch(true); - $groups = $collector->getPaginatedGroups(); + $groups = $collector->getPaginatedGroups(); $groups->setPath(route('accounts.show.all', [$account->id])); - $chartUrl = route('chart.account.period', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]); - $showAll = true; + $chartUrl = route('chart.account.period', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]); + $showAll = true; // correct Log::debug(sprintf('showAll: Call accountsBalancesOptimized with date/time "%s"', $end->toIso8601String())); // 2025-10-08 replace finalAccountBalance with accountsBalancesOptimized. // $balances = Steam::finalAccountBalance($account, $end); // $balances = Steam::filterAccountBalance($balances, $account, $this->convertToPrimary, $accountCurrency); - $balances = Steam::accountsBalancesOptimized(new Collection()->push($account), $end)[$account->id]; + $balances = Steam::accountsBalancesOptimized(new Collection()->push($account), $end)[$account->id]; return view( 'accounts.show', diff --git a/app/Http/Controllers/Admin/LinkController.php b/app/Http/Controllers/Admin/LinkController.php index 06c66deeb1..234c980471 100644 --- a/app/Http/Controllers/Admin/LinkController.php +++ b/app/Http/Controllers/Admin/LinkController.php @@ -86,7 +86,7 @@ class LinkController extends Controller * * @return Factory|Redirector|RedirectResponse|View */ - public function delete(Request $request, LinkType $linkType): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View + public function delete(Request $request, LinkType $linkType): Factory|\Illuminate\Contracts\View\View|Redirector|RedirectResponse { if (false === $linkType->editable) { $request->session()->flash('error', (string) trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)])); @@ -135,7 +135,7 @@ class LinkController extends Controller * * @return Factory|Redirector|RedirectResponse|View */ - public function edit(Request $request, LinkType $linkType): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View + public function edit(Request $request, LinkType $linkType): Factory|\Illuminate\Contracts\View\View|Redirector|RedirectResponse { if (false === $linkType->editable) { $request->session()->flash('error', (string) trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)])); diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index dbebe2ba5d..b2a50a5da5 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -73,7 +73,7 @@ class UserController extends Controller /** * @return Application|Factory|Redirector|RedirectResponse|View */ - public function delete(User $user): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View + public function delete(User $user): Factory|\Illuminate\Contracts\View\View|Redirector|RedirectResponse { if ($this->externalIdentity) { request()->session()->flash('error', trans('firefly.external_user_mgt_disabled')); diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 8866f1aba5..2c330a516b 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -68,7 +68,7 @@ class LoginController extends Controller protected string $redirectTo = RouteServiceProvider::HOME; private UserRepositoryInterface $repository; - private string $username = 'email'; + private string $username = 'email'; /** * Create a new controller instance. @@ -222,7 +222,7 @@ class LoginController extends Controller * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function showLoginForm(Request $request): Redirector|RedirectResponse|Factory|View + public function showLoginForm(Request $request): Factory|Redirector|RedirectResponse|View { Log::channel('audit')->info('Show login form (1.1).'); diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index 9b4f2dc7dd..2b82d826bf 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -114,6 +114,7 @@ class ResetPasswordController extends Controller * * If no token is present, display the link request form. * + * @param null|mixed $token * * @return Factory|View * diff --git a/app/Http/Controllers/Auth/TwoFactorController.php b/app/Http/Controllers/Auth/TwoFactorController.php index b9e956d7e1..2116f1b827 100644 --- a/app/Http/Controllers/Auth/TwoFactorController.php +++ b/app/Http/Controllers/Auth/TwoFactorController.php @@ -59,7 +59,6 @@ class TwoFactorController extends Controller } /** - * * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ @@ -211,6 +210,7 @@ class TwoFactorController extends Controller if (!is_array($list)) { $list = []; } + return in_array($mfaCode, $list, true); } diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.php index e374dd2adb..a721ac7d83 100644 --- a/app/Http/Controllers/DebugController.php +++ b/app/Http/Controllers/DebugController.php @@ -96,7 +96,6 @@ class DebugController extends Controller /** * Clear log and session. * - * * @throws FireflyException */ public function flush(Request $request): Redirector|RedirectResponse @@ -514,30 +513,40 @@ class DebugController extends Controller case 'userGroup': return '1'; + case 'start_date': case 'date': return '20241201'; + case 'end_date': return '20241231'; + case 'fromCurrencyCode': return 'EUR'; + case 'toCurrencyCode': return 'USD'; + case 'accountList': return '1,6'; + case 'budgetList': case 'categoryList': case 'doubleList': case 'tagList': case 'journalList': return '1,2'; + case 'route': return 'accounts'; + case 'specificPage': return 'show'; + case 'reportType': return 'default'; + case 'transactionType': return 'withdrawal'; diff --git a/app/Http/Controllers/NewUserController.php b/app/Http/Controllers/NewUserController.php index 0c914d965a..db8360ba6f 100644 --- a/app/Http/Controllers/NewUserController.php +++ b/app/Http/Controllers/NewUserController.php @@ -64,7 +64,7 @@ class NewUserController extends Controller * * @return Factory|Redirector|RedirectResponse|View */ - public function index(): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View + public function index(): Factory|\Illuminate\Contracts\View\View|Redirector|RedirectResponse { app('view')->share('title', (string) trans('firefly.welcome')); app('view')->share('mainTitleIcon', 'fa-fire'); diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php index 43fd16f342..229f853f3c 100644 --- a/app/Http/Controllers/PreferencesController.php +++ b/app/Http/Controllers/PreferencesController.php @@ -188,7 +188,6 @@ class PreferencesController extends Controller /** * Store new preferences. * - * * @throws FireflyException * * @SuppressWarnings("PHPMD.ExcessiveMethodLength") diff --git a/app/Http/Controllers/Profile/MfaController.php b/app/Http/Controllers/Profile/MfaController.php index 0114474be4..e434a2e525 100644 --- a/app/Http/Controllers/Profile/MfaController.php +++ b/app/Http/Controllers/Profile/MfaController.php @@ -228,7 +228,6 @@ class MfaController extends Controller /** * Submit 2FA for the first time. * - * * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 8939c61b30..67e28666fd 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -288,7 +288,7 @@ class ProfileController extends Controller * * @return Factory|Redirector|RedirectResponse|View */ - public function changePassword(Request $request): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View + public function changePassword(Request $request): Factory|\Illuminate\Contracts\View\View|Redirector|RedirectResponse { if (!$this->internalAuth) { $request->session()->flash('error', trans('firefly.external_user_mgt_disabled')); @@ -361,7 +361,6 @@ class ProfileController extends Controller /** * Regenerate access token. * - * * @throws Exception */ public function regenerate(Request $request): Redirector|RedirectResponse @@ -384,7 +383,6 @@ class ProfileController extends Controller /** * Undo change of user email address. * - * * @throws FireflyException */ public function undoEmailChange(UserRepositoryInterface $repository, string $token, string $hash): Redirector|RedirectResponse diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index b248e31bf7..3cdc068f1e 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -193,7 +193,6 @@ class ReportController extends Controller /** * Show account report. * - * * @throws FireflyException */ public function doubleReport(Collection $accounts, Collection $expense, Carbon $start, Carbon $end): string diff --git a/app/Http/Controllers/System/CronController.php b/app/Http/Controllers/System/CronController.php index 7667a998b5..eeb3cf9baf 100644 --- a/app/Http/Controllers/System/CronController.php +++ b/app/Http/Controllers/System/CronController.php @@ -37,7 +37,7 @@ class CronController /** * @return Application|Response|ResponseFactory */ - public function cron(): ResponseFactory|Response + public function cron(): Response|ResponseFactory { Log::error('The cron endpoint has moved to GET /api/v1/cron/[token]'); diff --git a/app/Http/Controllers/System/InstallController.php b/app/Http/Controllers/System/InstallController.php index ff2ee33a22..8a8a163082 100644 --- a/app/Http/Controllers/System/InstallController.php +++ b/app/Http/Controllers/System/InstallController.php @@ -51,9 +51,9 @@ class InstallController extends Controller public const string BASEDIR_ERROR = 'Firefly III cannot execute the upgrade commands. It is not allowed to because of an open_basedir restriction.'; public const string FORBIDDEN_ERROR = 'Internal PHP function "proc_close" is disabled for your installation. Auto-migration is not possible.'; public const string OTHER_ERROR = 'An unknown error prevented Firefly III from executing the upgrade commands. Sorry.'; - private string $lastError = ''; + private string $lastError = ''; // empty on purpose. - private array $upgradeCommands = [ + private array $upgradeCommands = [ // there are 5 initial commands // Check 4 places: InstallController, Docker image, UpgradeDatabase, composer.json 'migrate' => ['--seed' => true, '--force' => true], diff --git a/app/Http/Controllers/Transaction/ConvertController.php b/app/Http/Controllers/Transaction/ConvertController.php index 2861cfda36..603f622469 100644 --- a/app/Http/Controllers/Transaction/ConvertController.php +++ b/app/Http/Controllers/Transaction/ConvertController.php @@ -87,7 +87,7 @@ class ConvertController extends Controller * * @throws Exception */ - public function index(TransactionType $destinationType, TransactionGroup $group): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View + public function index(TransactionType $destinationType, TransactionGroup $group): Factory|\Illuminate\Contracts\View\View|Redirector|RedirectResponse { if (!$this->isEditableGroup($group)) { return $this->redirectGroupToAccount($group); diff --git a/app/Http/Controllers/Transaction/CreateController.php b/app/Http/Controllers/Transaction/CreateController.php index 8f7b521c31..878e589c04 100644 --- a/app/Http/Controllers/Transaction/CreateController.php +++ b/app/Http/Controllers/Transaction/CreateController.php @@ -100,7 +100,6 @@ class CreateController extends Controller /** * Create a new transaction group. * - * * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface * @throws UrlException diff --git a/app/Http/Controllers/Transaction/DeleteController.php b/app/Http/Controllers/Transaction/DeleteController.php index 990a1fd753..1e82c2cd12 100644 --- a/app/Http/Controllers/Transaction/DeleteController.php +++ b/app/Http/Controllers/Transaction/DeleteController.php @@ -68,7 +68,7 @@ class DeleteController extends Controller /** * Shows the form that allows a user to delete a transaction journal. */ - public function delete(TransactionGroup $group): Redirector|RedirectResponse|Factory|View + public function delete(TransactionGroup $group): Factory|Redirector|RedirectResponse|View { if (!$this->isEditableGroup($group)) { return $this->redirectGroupToAccount($group); diff --git a/app/Http/Controllers/Transaction/EditController.php b/app/Http/Controllers/Transaction/EditController.php index 2b26986c01..00f0e0bc62 100644 --- a/app/Http/Controllers/Transaction/EditController.php +++ b/app/Http/Controllers/Transaction/EditController.php @@ -74,7 +74,7 @@ class EditController extends Controller * @throws NotFoundExceptionInterface * @throws UrlException */ - public function edit(TransactionGroup $transactionGroup): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View + public function edit(TransactionGroup $transactionGroup): Factory|\Illuminate\Contracts\View\View|Redirector|RedirectResponse { app('preferences')->mark(); diff --git a/app/Http/Controllers/Transaction/MassController.php b/app/Http/Controllers/Transaction/MassController.php index b0a552097a..3c70dfb089 100644 --- a/app/Http/Controllers/Transaction/MassController.php +++ b/app/Http/Controllers/Transaction/MassController.php @@ -154,7 +154,6 @@ class MassController extends Controller /** * Mass update of journals. * - * * @throws FireflyException */ public function update(MassEditJournalRequest $request): Redirector|RedirectResponse diff --git a/app/Http/Controllers/TransactionCurrency/CreateController.php b/app/Http/Controllers/TransactionCurrency/CreateController.php index c679dd16b8..057089b5da 100644 --- a/app/Http/Controllers/TransactionCurrency/CreateController.php +++ b/app/Http/Controllers/TransactionCurrency/CreateController.php @@ -70,7 +70,7 @@ class CreateController extends Controller * * @return Factory|Redirector|RedirectResponse|View */ - public function create(Request $request): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View + public function create(Request $request): Factory|\Illuminate\Contracts\View\View|Redirector|RedirectResponse { /** @var User $user */ $user = auth()->user(); diff --git a/app/Http/Controllers/TransactionCurrency/DeleteController.php b/app/Http/Controllers/TransactionCurrency/DeleteController.php index 853242ea98..b9364f98e1 100644 --- a/app/Http/Controllers/TransactionCurrency/DeleteController.php +++ b/app/Http/Controllers/TransactionCurrency/DeleteController.php @@ -71,7 +71,7 @@ class DeleteController extends Controller * * @throws FireflyException */ - public function delete(Request $request, TransactionCurrency $currency): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View + public function delete(Request $request, TransactionCurrency $currency): Factory|\Illuminate\Contracts\View\View|Redirector|RedirectResponse { /** @var User $user */ $user = auth()->user(); @@ -102,7 +102,6 @@ class DeleteController extends Controller /** * Destroys a currency. * - * * @throws FireflyException */ public function destroy(Request $request, TransactionCurrency $currency): Redirector|RedirectResponse diff --git a/app/Http/Controllers/TransactionCurrency/EditController.php b/app/Http/Controllers/TransactionCurrency/EditController.php index 6bd0732c30..6bf640391d 100644 --- a/app/Http/Controllers/TransactionCurrency/EditController.php +++ b/app/Http/Controllers/TransactionCurrency/EditController.php @@ -67,7 +67,7 @@ class EditController extends Controller * * @return Factory|Redirector|RedirectResponse|View */ - public function edit(Request $request, TransactionCurrency $currency): Redirector|RedirectResponse|Factory|\Illuminate\Contracts\View\View + public function edit(Request $request, TransactionCurrency $currency): Factory|\Illuminate\Contracts\View\View|Redirector|RedirectResponse { /** @var User $user */ $user = auth()->user(); @@ -107,7 +107,6 @@ class EditController extends Controller /** * Updates a currency. * - * * @throws FireflyException */ public function update(CurrencyFormRequest $request, TransactionCurrency $currency): Redirector|RedirectResponse diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index 7f920a3e23..57c3d74c9c 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -139,6 +139,7 @@ class Authenticate app('session')->flash('logoutMessage', $message); // @noinspection PhpUndefinedMethodInspection $this->auth->logout(); + // @phpstan-ignore-line (thinks function is undefined) throw new AuthenticationException('Blocked account.', $guards); } diff --git a/app/Http/Middleware/Binder.php b/app/Http/Middleware/Binder.php index 533cf46d44..0dfc35e433 100644 --- a/app/Http/Middleware/Binder.php +++ b/app/Http/Middleware/Binder.php @@ -45,8 +45,8 @@ class Binder public function __construct(/** * The authentication factory instance. */ - protected Auth $auth) - { + protected Auth $auth + ) { $this->binders = Domain::getBindables(); } diff --git a/app/Jobs/WarnAboutBills.php b/app/Jobs/WarnAboutBills.php index 0c8a3e1461..bf217497ee 100644 --- a/app/Jobs/WarnAboutBills.php +++ b/app/Jobs/WarnAboutBills.php @@ -127,6 +127,7 @@ class WarnAboutBills implements ShouldQueue $diff = $this->getDiff($bill, $field); $list = config('firefly.bill_reminder_periods'); Log::debug(sprintf('Difference in days for field "%s" ("%s") is %d day(s)', $field, $bill->{$field}->format('Y-m-d'), $diff)); + return in_array($diff, $list, true); } @@ -189,6 +190,7 @@ class WarnAboutBills implements ShouldQueue Log::debug(sprintf('Earliest expected pay date is %s', $earliest->toAtomString())); $diff = $earliest->diffInDays($this->date); Log::debug(sprintf('Difference in days is %s', $diff)); + return $diff >= 2; } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 70eb14d731..60b90efad6 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -79,6 +79,7 @@ class AppServiceProvider extends ServiceProvider $params = Route::getCurrentRoute()->parameters(); $params ??= []; $objectType = $params['objectType'] ?? ''; + return $objectType === $firstParam && str_contains($name, $route); }); } diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php index f6c99daa4b..c249f834a4 100644 --- a/app/Repositories/Journal/JournalRepository.php +++ b/app/Repositories/Journal/JournalRepository.php @@ -77,8 +77,7 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac public function firstNull(): ?TransactionJournal { /** @var null|TransactionJournal $entry */ - $entry = $this->user->transactionJournals()->orderBy('date', 'ASC')->first(['transaction_journals.*']); - return $entry; + return $this->user->transactionJournals()->orderBy('date', 'ASC')->first(['transaction_journals.*']); } public function getDestinationAccount(TransactionJournal $journal): Account @@ -115,8 +114,7 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac public function getLast(): ?TransactionJournal { /** @var null|TransactionJournal $entry */ - $entry = $this->user->transactionJournals()->orderBy('date', 'DESC')->first(['transaction_journals.*']); - return $entry; + return $this->user->transactionJournals()->orderBy('date', 'DESC')->first(['transaction_journals.*']); } public function getLinkNoteText(TransactionJournalLink $link): string diff --git a/app/Rules/IsAllowedGroupAction.php b/app/Rules/IsAllowedGroupAction.php index d590f21bfd..d9bbf8c3da 100644 --- a/app/Rules/IsAllowedGroupAction.php +++ b/app/Rules/IsAllowedGroupAction.php @@ -38,9 +38,7 @@ class IsAllowedGroupAction implements ValidationRule // you need these roles to do anything with any endpoint. private array $acceptedRoles = [UserRoleEnum::OWNER, UserRoleEnum::FULL]; - public function __construct(private readonly string $className, private readonly string $methodName) - { - } + public function __construct(private readonly string $className, private readonly string $methodName) {} /** * @throws AuthorizationException @@ -74,6 +72,7 @@ class IsAllowedGroupAction implements ValidationRule } catch (FireflyException $e) { Log::error($e->getTraceAsString()); } + exit('here we are'); } } diff --git a/app/Services/Internal/Support/AccountServiceTrait.php b/app/Services/Internal/Support/AccountServiceTrait.php index bce254bd60..245410d31f 100644 --- a/app/Services/Internal/Support/AccountServiceTrait.php +++ b/app/Services/Internal/Support/AccountServiceTrait.php @@ -78,6 +78,7 @@ trait AccountServiceTrait // not set, so false. return false; } + // if is set, but is empty: return (array_key_exists('opening_balance', $data) && '' === $data['opening_balance']) || (array_key_exists('opening_balance_date', $data) && '' === $data['opening_balance_date']); diff --git a/app/Services/Internal/Support/CreditRecalculateService.php b/app/Services/Internal/Support/CreditRecalculateService.php index b1dc2406aa..711732155d 100644 --- a/app/Services/Internal/Support/CreditRecalculateService.php +++ b/app/Services/Internal/Support/CreditRecalculateService.php @@ -41,9 +41,9 @@ use Illuminate\Support\Facades\Log; class CreditRecalculateService { private ?Account $account = null; - private ?TransactionGroup $group = null; + private ?TransactionGroup $group = null; private AccountRepositoryInterface $repository; - private array $work = []; + private array $work = []; public function recalculate(): void { diff --git a/app/Services/Internal/Update/GroupUpdateService.php b/app/Services/Internal/Update/GroupUpdateService.php index fcf280a403..58c245d201 100644 --- a/app/Services/Internal/Update/GroupUpdateService.php +++ b/app/Services/Internal/Update/GroupUpdateService.php @@ -105,6 +105,7 @@ class GroupUpdateService $result = array_diff($existing, $updated); Log::debug('Result of DIFF: ', $result); + /** @var string $deletedId */ foreach ($result as $deletedId) { /** @var TransactionJournal $journal */ diff --git a/app/Services/Internal/Update/JournalUpdateService.php b/app/Services/Internal/Update/JournalUpdateService.php index 0831b22d29..44278679bb 100644 --- a/app/Services/Internal/Update/JournalUpdateService.php +++ b/app/Services/Internal/Update/JournalUpdateService.php @@ -63,11 +63,11 @@ class JournalUpdateService private CurrencyRepositoryInterface $currencyRepository; private TransactionGroupRepositoryInterface $transactionGroupRepository; private array $data; - private ?Account $destinationAccount = null; - private ?Transaction $destinationTransaction = null; - private array $metaDate = ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date', + private ?Account $destinationAccount = null; + private ?Transaction $destinationTransaction = null; + private array $metaDate = ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date', 'invoice_date', ]; - private array $metaString = [ + private array $metaString = [ 'sepa_cc', 'sepa_ct_op', 'sepa_ct_id', @@ -82,11 +82,11 @@ class JournalUpdateService 'external_id', 'external_url', ]; - private ?Account $sourceAccount = null; - private ?Transaction $sourceTransaction = null; - private ?TransactionGroup $transactionGroup = null; + private ?Account $sourceAccount = null; + private ?Transaction $sourceTransaction = null; + private ?TransactionGroup $transactionGroup = null; private ?TransactionJournal $transactionJournal = null; - private string $startCompareHash = ''; + private string $startCompareHash = ''; /** * JournalUpdateService constructor. diff --git a/app/Support/Authentication/RemoteUserGuard.php b/app/Support/Authentication/RemoteUserGuard.php index a1a19ddb56..2d74a0d8c5 100644 --- a/app/Support/Authentication/RemoteUserGuard.php +++ b/app/Support/Authentication/RemoteUserGuard.php @@ -31,7 +31,6 @@ use Illuminate\Contracts\Auth\Authenticatable; use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Auth\UserProvider; use Illuminate\Contracts\Foundation\Application; -use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; /** diff --git a/app/Support/Chart/Budget/FrontpageChartGenerator.php b/app/Support/Chart/Budget/FrontpageChartGenerator.php index 1addb48b8b..7633e4fb92 100644 --- a/app/Support/Chart/Budget/FrontpageChartGenerator.php +++ b/app/Support/Chart/Budget/FrontpageChartGenerator.php @@ -39,7 +39,7 @@ use Illuminate\Support\Facades\Log; */ class FrontpageChartGenerator { - public bool $convertToPrimary = false; + public bool $convertToPrimary = false; public TransactionCurrency $default; protected OperationsRepositoryInterface $opsRepository; private readonly BudgetLimitRepositoryInterface $blRepository; @@ -53,9 +53,9 @@ class FrontpageChartGenerator */ public function __construct() { - $this->budgetRepository = app(BudgetRepositoryInterface::class); - $this->blRepository = app(BudgetLimitRepositoryInterface::class); - $this->opsRepository = app(OperationsRepositoryInterface::class); + $this->budgetRepository = app(BudgetRepositoryInterface::class); + $this->blRepository = app(BudgetLimitRepositoryInterface::class); + $this->opsRepository = app(OperationsRepositoryInterface::class); } /** diff --git a/app/Support/Chart/Category/FrontpageChartGenerator.php b/app/Support/Chart/Category/FrontpageChartGenerator.php index 45884c710f..655f44092b 100644 --- a/app/Support/Chart/Category/FrontpageChartGenerator.php +++ b/app/Support/Chart/Category/FrontpageChartGenerator.php @@ -45,7 +45,7 @@ class FrontpageChartGenerator public bool $convertToPrimary = false; public TransactionCurrency $primaryCurrency; private AccountRepositoryInterface $accountRepos; - private array $currencies = []; + private array $currencies = []; private NoCategoryRepositoryInterface $noCatRepos; private OperationsRepositoryInterface $opsRepos; private CategoryRepositoryInterface $repository; diff --git a/app/Support/Cronjobs/AbstractCronjob.php b/app/Support/Cronjobs/AbstractCronjob.php index 6211149b05..43f4fa579c 100644 --- a/app/Support/Cronjobs/AbstractCronjob.php +++ b/app/Support/Cronjobs/AbstractCronjob.php @@ -31,20 +31,20 @@ use Carbon\Carbon; */ abstract class AbstractCronjob { - public bool $jobErrored = false; - public bool $jobFired = false; - public bool $jobSucceeded = false; - public ?string $message = null; + public bool $jobErrored = false; + public bool $jobFired = false; + public bool $jobSucceeded = false; + public ?string $message = null; public int $timeBetweenRuns = 43200; protected Carbon $date; - protected bool $force = false; + protected bool $force = false; /** * AbstractCronjob constructor. */ public function __construct() { - $this->date = today(config('app.timezone')); + $this->date = today(config('app.timezone')); } abstract public function fire(): void; diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.php index 26ca12798f..92d315ab15 100644 --- a/app/Support/ExpandedForm.php +++ b/app/Support/ExpandedForm.php @@ -225,6 +225,8 @@ class ExpandedForm } /** + * @param null|mixed $value + * * @throws FireflyException */ public function objectGroup($value = null, ?array $options = null): string diff --git a/app/Support/Export/ExportDataGenerator.php b/app/Support/Export/ExportDataGenerator.php index df551fa84b..f7cf2a8c41 100644 --- a/app/Support/Export/ExportDataGenerator.php +++ b/app/Support/Export/ExportDataGenerator.php @@ -72,18 +72,18 @@ class ExportDataGenerator { use ConvertsDataTypes; - private const string ADD_RECORD_ERR = 'Could not add record to set: %s'; - private const string EXPORT_ERR = 'Could not export to string: %s'; + private const string ADD_RECORD_ERR = 'Could not add record to set: %s'; + private const string EXPORT_ERR = 'Could not export to string: %s'; private Collection $accounts; private Carbon $end; - private bool $exportAccounts = false; - private bool $exportBills = false; - private bool $exportBudgets = false; - private bool $exportCategories = false; - private bool $exportPiggies = false; - private bool $exportRecurring = false; - private bool $exportRules = false; - private bool $exportTags = false; + private bool $exportAccounts = false; + private bool $exportBills = false; + private bool $exportBudgets = false; + private bool $exportCategories = false; + private bool $exportPiggies = false; + private bool $exportRecurring = false; + private bool $exportRules = false; + private bool $exportTags = false; private bool $exportTransactions = false; private Carbon $start; private User $user; @@ -91,10 +91,10 @@ class ExportDataGenerator public function __construct() { - $this->accounts = new Collection(); - $this->start = today(config('app.timezone')); + $this->accounts = new Collection(); + $this->start = today(config('app.timezone')); $this->start->subYear(); - $this->end = today(config('app.timezone')); + $this->end = today(config('app.timezone')); } /** diff --git a/app/Support/Http/Api/AccountBalanceGrouped.php b/app/Support/Http/Api/AccountBalanceGrouped.php index 0475d7753f..060371a4a5 100644 --- a/app/Support/Http/Api/AccountBalanceGrouped.php +++ b/app/Support/Http/Api/AccountBalanceGrouped.php @@ -52,7 +52,7 @@ class AccountBalanceGrouped public function __construct() { - $this->converter = app(ExchangeRateConverter::class); + $this->converter = app(ExchangeRateConverter::class); } /** diff --git a/app/Support/Http/Api/SummaryBalanceGrouped.php b/app/Support/Http/Api/SummaryBalanceGrouped.php index f830ed83e5..1bed87a1c6 100644 --- a/app/Support/Http/Api/SummaryBalanceGrouped.php +++ b/app/Support/Http/Api/SummaryBalanceGrouped.php @@ -31,12 +31,12 @@ use Illuminate\Support\Facades\Log; class SummaryBalanceGrouped { - private const string SUM = 'sum'; - private array $amounts = []; + private const string SUM = 'sum'; + private array $amounts = []; private array $currencies = []; private readonly CurrencyRepositoryInterface $currencyRepository; private TransactionCurrency $default; - private array $keys = [self::SUM]; + private array $keys = [self::SUM]; public function __construct() { diff --git a/app/Support/Http/Controllers/RequestInformation.php b/app/Support/Http/Controllers/RequestInformation.php index 2bd5dad925..5b7be59977 100644 --- a/app/Support/Http/Controllers/RequestInformation.php +++ b/app/Support/Http/Controllers/RequestInformation.php @@ -132,6 +132,7 @@ trait RequestInformation if ($start->greaterThanOrEqualTo($date) && $end->greaterThanOrEqualTo($date)) { return true; } + // start and end in the past? use $end return $start->lessThanOrEqualTo($date) && $end->lessThanOrEqualTo($date); } diff --git a/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php b/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php index a7c3385645..b5ebb7ca7f 100644 --- a/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php +++ b/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php @@ -83,12 +83,10 @@ class BudgetLimitEnrichment implements EnrichmentInterface public function setUser(User $user): void { - $this->user = $user; + $this->user = $user; } - public function setUserGroup(UserGroup $userGroup): void - { - } + public function setUserGroup(UserGroup $userGroup): void {} private function appendCollectedData(): void { diff --git a/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php b/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php index 2309e6b228..318768d807 100644 --- a/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php +++ b/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php @@ -90,9 +90,7 @@ class PiggyBankEnrichment implements EnrichmentInterface $this->setUserGroup($user->userGroup); } - public function setUserGroup(UserGroup $userGroup): void - { - } + public function setUserGroup(UserGroup $userGroup): void {} private function appendCollectedData(): void { diff --git a/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php b/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php index b8c78464da..4ada77c069 100644 --- a/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php +++ b/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php @@ -78,9 +78,7 @@ class PiggyBankEventEnrichment implements EnrichmentInterface $this->setUserGroup($user->userGroup); } - public function setUserGroup(UserGroup $userGroup): void - { - } + public function setUserGroup(UserGroup $userGroup): void {} private function appendCollectedData(): void { diff --git a/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php b/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php index 8d3c134f65..4a97d262a6 100644 --- a/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php +++ b/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php @@ -163,12 +163,10 @@ class SubscriptionEnrichment implements EnrichmentInterface public function setUser(User $user): void { - $this->user = $user; + $this->user = $user; } - public function setUserGroup(UserGroup $userGroup): void - { - } + public function setUserGroup(UserGroup $userGroup): void {} /** * Returns the latest date in the set, or start when set is empty. diff --git a/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php b/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php index f4d5fdebda..78f87d5f7b 100644 --- a/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php +++ b/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php @@ -94,13 +94,9 @@ class TransactionGroupEnrichment implements EnrichmentInterface throw new FireflyException('Cannot enrich single model.'); } - public function setUser(User $user): void - { - } + public function setUser(User $user): void {} - public function setUserGroup(UserGroup $userGroup): void - { - } + public function setUserGroup(UserGroup $userGroup): void {} private function appendCollectedData(): void { diff --git a/app/Support/JsonApi/Enrichments/WebhookEnrichment.php b/app/Support/JsonApi/Enrichments/WebhookEnrichment.php index 4553b494e8..6fdddf2632 100644 --- a/app/Support/JsonApi/Enrichments/WebhookEnrichment.php +++ b/app/Support/JsonApi/Enrichments/WebhookEnrichment.php @@ -73,13 +73,9 @@ class WebhookEnrichment implements EnrichmentInterface return $collection->first(); } - public function setUser(User $user): void - { - } + public function setUser(User $user): void {} - public function setUserGroup(UserGroup $userGroup): void - { - } + public function setUserGroup(UserGroup $userGroup): void {} private function appendCollectedInfo(): void { diff --git a/app/Support/ParseDateString.php b/app/Support/ParseDateString.php index b1e13aad5d..7e518f9a04 100644 --- a/app/Support/ParseDateString.php +++ b/app/Support/ParseDateString.php @@ -64,6 +64,7 @@ class ParseDateString if ('xxxx-xx-xx' === strtolower($date)) { return false; } + // no x'es return !(!str_contains($date, 'xx') && !str_contains($date, 'xxxx')); } diff --git a/app/Support/Request/AppendsLocationData.php b/app/Support/Request/AppendsLocationData.php index 26c54ef921..bcad45157d 100644 --- a/app/Support/Request/AppendsLocationData.php +++ b/app/Support/Request/AppendsLocationData.php @@ -51,9 +51,11 @@ trait AppendsLocationData /** * Abstract method stolen from "InteractsWithInput". * - * @param bool $default + * @param bool $default + * @param null|mixed $key * * @return mixed + * * @SuppressWarnings("PHPMD.BooleanArgumentFlag") */ abstract public function boolean($key = null, $default = false); diff --git a/app/Support/Request/ConvertsDataTypes.php b/app/Support/Request/ConvertsDataTypes.php index 64804987b9..8b13aefa74 100644 --- a/app/Support/Request/ConvertsDataTypes.php +++ b/app/Support/Request/ConvertsDataTypes.php @@ -274,6 +274,7 @@ trait ConvertsDataTypes if ('y' === $value) { return true; } + return '1' === $value; } diff --git a/app/Support/Search/AccountSearch.php b/app/Support/Search/AccountSearch.php index 3820caf7bc..9fbaa27e37 100644 --- a/app/Support/Search/AccountSearch.php +++ b/app/Support/Search/AccountSearch.php @@ -47,7 +47,7 @@ class AccountSearch implements GenericSearchInterface public const string SEARCH_NUMBER = 'number'; private string $field; private string $query; - private array $types = []; + private array $types = []; private User $user; public function search(): Collection diff --git a/app/Support/Search/OperatorQuerySearch.php b/app/Support/Search/OperatorQuerySearch.php index d13ebc8dd1..a8b8b6b961 100644 --- a/app/Support/Search/OperatorQuerySearch.php +++ b/app/Support/Search/OperatorQuerySearch.php @@ -66,19 +66,19 @@ class OperatorQuerySearch implements SearchInterface private readonly CategoryRepositoryInterface $categoryRepository; private GroupCollectorInterface $collector; private readonly CurrencyRepositoryInterface $currencyRepository; - private array $excludeTags = []; + private array $excludeTags = []; private array $includeAnyTags = []; // added to fix #8632 - private array $includeTags = []; - private array $invalidOperators = []; - private int $limit = 25; + private array $includeTags = []; + private array $invalidOperators = []; + private int $limit = 25; private readonly Collection $operators; - private int $page = 1; - private array $prohibitedWords = []; + private int $page = 1; + private array $prohibitedWords = []; private readonly float $startTime; private readonly TagRepositoryInterface $tagRepository; private readonly array $validOperators; - private array $words = []; + private array $words = []; /** * OperatorQuerySearch constructor. diff --git a/app/Support/Steam.php b/app/Support/Steam.php index dde23d2087..45b3595a40 100644 --- a/app/Support/Steam.php +++ b/app/Support/Steam.php @@ -291,20 +291,20 @@ class Steam } #[Deprecated(message: <<<'TXT' - - By default this method returns "smaller than or equal to", so be careful with END OF DAY. - If you need end of day balance, use "inclusive = false". - - Returns the balance of an account at exact moment given. Array with at least one value. - Always returns: - "balance": balance in the account's currency OR user's primary currency if the account has no currency - "EUR": balance in EUR (or whatever currencies the account has balance in) - - If the user has $convertToPrimary: - "balance": balance in the account's currency OR user's primary currency if the account has no currency - --> "pc_balance": balance in the user's primary currency, with all amounts converted to the primary currency. - "EUR": balance in EUR (or whatever currencies the account has balance in) - TXT)] + + By default this method returns "smaller than or equal to", so be careful with END OF DAY. + If you need end of day balance, use "inclusive = false". + + Returns the balance of an account at exact moment given. Array with at least one value. + Always returns: + "balance": balance in the account's currency OR user's primary currency if the account has no currency + "EUR": balance in EUR (or whatever currencies the account has balance in) + + If the user has $convertToPrimary: + "balance": balance in the account's currency OR user's primary currency if the account has no currency + --> "pc_balance": balance in the user's primary currency, with all amounts converted to the primary currency. + "EUR": balance in EUR (or whatever currencies the account has balance in) + TXT)] public function finalAccountBalance(Account $account, Carbon $date, ?TransactionCurrency $primary = null, ?bool $convertToPrimary = null, bool $inclusive = true): array { diff --git a/app/Support/System/OAuthKeys.php b/app/Support/System/OAuthKeys.php index a41c56085b..94b823820a 100644 --- a/app/Support/System/OAuthKeys.php +++ b/app/Support/System/OAuthKeys.php @@ -74,6 +74,7 @@ class OAuthKeys Log::error($e->getTraceAsString()); } } + return '' !== $privateKey && '' !== $publicKey; } diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php index 7ff9b09f3e..98ca0625ae 100644 --- a/app/Support/Twig/General.php +++ b/app/Support/Twig/General.php @@ -292,6 +292,7 @@ class General extends AbstractExtension 'hasRole', static function (string $role): bool { $repository = app(UserRepositoryInterface::class); + return $repository->hasRole(auth()->user(), $role); } ); diff --git a/app/Support/Twig/TransactionGroupTwig.php b/app/Support/Twig/TransactionGroupTwig.php index 74c8199469..f22a0618d1 100644 --- a/app/Support/Twig/TransactionGroupTwig.php +++ b/app/Support/Twig/TransactionGroupTwig.php @@ -81,7 +81,7 @@ class TransactionGroupTwig extends AbstractExtension { return new TwigFunction( 'journalGetMetaDate', - static function (int $journalId, string $metaField): CarbonInterface|Carbon { + static function (int $journalId, string $metaField): Carbon|CarbonInterface { /** @var null|TransactionJournalMeta $entry */ $entry = DB::table('journal_meta') ->where('name', $metaField) diff --git a/app/Support/Twig/Translation.php b/app/Support/Twig/Translation.php index fca8a41fbb..3acc5509be 100644 --- a/app/Support/Twig/Translation.php +++ b/app/Support/Twig/Translation.php @@ -59,7 +59,7 @@ class Translation extends AbstractExtension { return new TwigFunction( 'journalLinkTranslation', - static function (string $direction, string $original): string|Translator|array { + static function (string $direction, string $original): array|string|Translator { $key = sprintf('firefly.%s_%s', $original, $direction); $translation = trans($key); if ($key === $translation) { @@ -76,7 +76,7 @@ class Translation extends AbstractExtension { return new TwigFunction( '__', - static function (string $key): string|Translator|array { + static function (string $key): array|string|Translator { $translation = trans($key); if ($key === $translation) { return $key; diff --git a/app/TransactionRules/Engine/SearchRuleEngine.php b/app/TransactionRules/Engine/SearchRuleEngine.php index fbebad10cd..80ce408749 100644 --- a/app/TransactionRules/Engine/SearchRuleEngine.php +++ b/app/TransactionRules/Engine/SearchRuleEngine.php @@ -45,17 +45,17 @@ use Illuminate\Support\Facades\Log; class SearchRuleEngine implements RuleEngineInterface { private readonly Collection $groups; - private array $operators = []; + private array $operators = []; // always collect the triggers from the database, unless indicated otherwise. private bool $refreshTriggers = true; - private array $resultCount = []; + private array $resultCount = []; private readonly Collection $rules; private User $user; public function __construct() { - $this->rules = new Collection(); - $this->groups = new Collection(); + $this->rules = new Collection(); + $this->groups = new Collection(); } public function addOperator(array $operator): void diff --git a/app/Transformers/TransactionGroupTransformer.php b/app/Transformers/TransactionGroupTransformer.php index 86e70b36bc..8f2152f973 100644 --- a/app/Transformers/TransactionGroupTransformer.php +++ b/app/Transformers/TransactionGroupTransformer.php @@ -259,6 +259,7 @@ class TransactionGroupTransformer extends AbstractTransformer return (string) $array[$key]; } + return $default; } diff --git a/app/Transformers/UserGroupTransformer.php b/app/Transformers/UserGroupTransformer.php index d89ac03fe7..2eb115fe4a 100644 --- a/app/Transformers/UserGroupTransformer.php +++ b/app/Transformers/UserGroupTransformer.php @@ -36,8 +36,8 @@ use Illuminate\Support\Collection; */ class UserGroupTransformer extends AbstractTransformer { - private array $inUse = []; - private array $memberships = []; + private array $inUse = []; + private array $memberships = []; private array $membershipsVisible = []; public function collectMetaData(Collection $objects): Collection diff --git a/app/Validation/AccountValidator.php b/app/Validation/AccountValidator.php index 385ead80da..f79768aba0 100644 --- a/app/Validation/AccountValidator.php +++ b/app/Validation/AccountValidator.php @@ -50,10 +50,10 @@ class AccountValidator use TransferValidation; use WithdrawalValidation; - public bool $createMode = false; - public string $destError = 'No error yet.'; + public bool $createMode = false; + public string $destError = 'No error yet.'; public ?Account $destination = null; - public ?Account $source = null; + public ?Account $source = null; public string $sourceError = 'No error yet.'; private AccountRepositoryInterface $accountRepository; private array $combinations; @@ -230,6 +230,7 @@ class AccountValidator protected function canCreateType(string $accountType): bool { $canCreate = [AccountTypeEnum::EXPENSE->value, AccountTypeEnum::REVENUE->value, AccountTypeEnum::INITIAL_BALANCE->value, AccountTypeEnum::LIABILITY_CREDIT->value]; + return in_array($accountType, $canCreate, true); } diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php index 380d2e4e48..c613f0064f 100644 --- a/app/Validation/FireflyValidator.php +++ b/app/Validation/FireflyValidator.php @@ -123,6 +123,7 @@ class FireflyValidator extends Validator } $regex = '/^[a-z]{6}[0-9a-z]{2}([0-9a-z]{3})?\z/i'; $result = preg_match($regex, $value); + return 0 !== $result; } diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.php index be8270f264..373df8f9fe 100644 --- a/app/Validation/TransactionValidation.php +++ b/app/Validation/TransactionValidation.php @@ -302,6 +302,7 @@ trait TransactionValidation private function isLiability(Account $account): bool { $type = $account->accountType->type; + return in_array($type, config('firefly.valid_liabilities'), true); } @@ -323,6 +324,7 @@ trait TransactionValidation if ('' === $transaction['foreign_amount']) { return false; } + return 0 !== bccomp('0', (string) $transaction['foreign_amount']); } @@ -750,6 +752,7 @@ trait TransactionValidation // source ID's are equal, return void. return true; } + // source names are equal, return void. return (bool) $this->arrayEqual($comparison['source_name']); } @@ -765,6 +768,7 @@ trait TransactionValidation // destination ID's are equal, return void. return true; } + // destination names are equal, return void. return (bool) $this->arrayEqual($comparison['destination_name']); } @@ -783,6 +787,7 @@ trait TransactionValidation // destination ID's are equal, return void. return true; } + // destination names are equal, return void. return (bool) $this->arrayEqual($comparison['destination_name']); } diff --git a/config/firefly.php b/config/firefly.php index c84ebde36a..6f0e0ba5c9 100644 --- a/config/firefly.php +++ b/config/firefly.php @@ -78,8 +78,8 @@ return [ 'running_balance_column' => env('USE_RUNNING_BALANCE', false), // see cer.php for exchange rates feature flag. ], - 'version' => '6.4.6', - 'build_time' => 1762641809, + 'version' => 'develop/2025-11-09', + 'build_time' => 1762675805, 'api_version' => '2.1.0', // field is no longer used. 'db_version' => 28, // field is no longer used. From 57ea24e73de08d3f6255d49a650ed11cfbd79b73 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 9 Nov 2025 09:15:29 +0100 Subject: [PATCH 05/12] Fix trait compatibility. --- app/Validation/Account/ReconciliationValidation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Validation/Account/ReconciliationValidation.php b/app/Validation/Account/ReconciliationValidation.php index 91514fc092..6bab9e8fec 100644 --- a/app/Validation/Account/ReconciliationValidation.php +++ b/app/Validation/Account/ReconciliationValidation.php @@ -32,8 +32,8 @@ use FireflyIII\Models\Account; */ trait ReconciliationValidation { - public ?Account $destination; - public ?Account $source; + public ?Account $destination = null; + public ?Account $source = null; protected function validateReconciliationDestination(array $array): bool { From db0c7e4d9a99042c5495c2b408a393c4ed31fa0f Mon Sep 17 00:00:00 2001 From: JC5 Date: Sun, 9 Nov 2025 09:19:57 +0100 Subject: [PATCH 06/12] =?UTF-8?q?=F0=9F=A4=96=20Auto=20commit=20for=20rele?= =?UTF-8?q?ase=20'develop'=20on=202025-11-09?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Validation/Account/ReconciliationValidation.php | 2 +- config/firefly.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Validation/Account/ReconciliationValidation.php b/app/Validation/Account/ReconciliationValidation.php index 6bab9e8fec..fd307a05a3 100644 --- a/app/Validation/Account/ReconciliationValidation.php +++ b/app/Validation/Account/ReconciliationValidation.php @@ -33,7 +33,7 @@ use FireflyIII\Models\Account; trait ReconciliationValidation { public ?Account $destination = null; - public ?Account $source = null; + public ?Account $source = null; protected function validateReconciliationDestination(array $array): bool { diff --git a/config/firefly.php b/config/firefly.php index 6f0e0ba5c9..918d4c8139 100644 --- a/config/firefly.php +++ b/config/firefly.php @@ -79,7 +79,7 @@ return [ // see cer.php for exchange rates feature flag. ], 'version' => 'develop/2025-11-09', - 'build_time' => 1762675805, + 'build_time' => 1762676250, 'api_version' => '2.1.0', // field is no longer used. 'db_version' => 28, // field is no longer used. From 0ca814f7180901f6a966846fe47f0a1d0b4f7bad Mon Sep 17 00:00:00 2001 From: JC5 Date: Mon, 10 Nov 2025 04:31:30 +0100 Subject: [PATCH 07/12] =?UTF-8?q?=F0=9F=A4=96=20Auto=20commit=20for=20rele?= =?UTF-8?q?ase=20'develop'=20on=202025-11-10?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/firefly.php | 4 ++-- resources/assets/v1/src/locales/ru.json | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/firefly.php b/config/firefly.php index 918d4c8139..3c5ae15d6d 100644 --- a/config/firefly.php +++ b/config/firefly.php @@ -78,8 +78,8 @@ return [ 'running_balance_column' => env('USE_RUNNING_BALANCE', false), // see cer.php for exchange rates feature flag. ], - 'version' => 'develop/2025-11-09', - 'build_time' => 1762676250, + 'version' => 'develop/2025-11-10', + 'build_time' => 1762745365, 'api_version' => '2.1.0', // field is no longer used. 'db_version' => 28, // field is no longer used. diff --git a/resources/assets/v1/src/locales/ru.json b/resources/assets/v1/src/locales/ru.json index 95532e247c..e6cd8171a4 100644 --- a/resources/assets/v1/src/locales/ru.json +++ b/resources/assets/v1/src/locales/ru.json @@ -107,13 +107,13 @@ "multi_account_warning_withdrawal": "\u0418\u043c\u0435\u0439\u0442\u0435 \u0432 \u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u0441\u0447\u0451\u0442-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0447\u0430\u0441\u0442\u044f\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0438\u043c \u0436\u0435, \u043a\u0430\u043a \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0440\u0430\u0441\u0445\u043e\u0434\u0430.", "multi_account_warning_deposit": "\u0418\u043c\u0435\u0439\u0442\u0435 \u0432 \u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u0441\u0447\u0451\u0442 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0447\u0430\u0441\u0442\u044f\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0438\u043c \u0436\u0435, \u043a\u0430\u043a \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0434\u043e\u0445\u043e\u0434\u0430.", "multi_account_warning_transfer": "\u0418\u043c\u0435\u0439\u0442\u0435 \u0432 \u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u0441\u0447\u0451\u0442-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0438 \u0441\u0447\u0451\u0442 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0447\u0430\u0441\u0442\u044f\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0431\u0443\u0434\u0443\u0442 \u0442\u0430\u043a\u0438\u043c\u0438 \u0436\u0435, \u043a\u0430\u043a \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430.", - "webhook_trigger_ANY": "After any event", + "webhook_trigger_ANY": "\u041f\u043e\u0441\u043b\u0435 \u043b\u044e\u0431\u043e\u0433\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f", "webhook_trigger_STORE_TRANSACTION": "\u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438", "webhook_trigger_UPDATE_TRANSACTION": "\u041f\u043e\u0441\u043b\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438", "webhook_trigger_DESTROY_TRANSACTION": "\u041f\u043e\u0441\u043b\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438", - "webhook_trigger_STORE_BUDGET": "After budget creation", - "webhook_trigger_UPDATE_BUDGET": "After budget update", - "webhook_trigger_DESTROY_BUDGET": "After budget delete", + "webhook_trigger_STORE_BUDGET": "\u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u044e\u0434\u0436\u0435\u0442\u0430", + "webhook_trigger_UPDATE_BUDGET": "\u041f\u043e\u0441\u043b\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0431\u044e\u0434\u0436\u0435\u0442\u0430", + "webhook_trigger_DESTROY_BUDGET": "\u041f\u043e\u0441\u043b\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0431\u044e\u0434\u0436\u0435\u0442\u0430", "webhook_trigger_STORE_UPDATE_BUDGET_LIMIT": "After budgeted amount change", "webhook_response_TRANSACTIONS": "\u0414\u0435\u0442\u0430\u043b\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438", "webhook_response_RELEVANT": "Relevant details", From 55c045c791159c17b5086bb2044f5d3dabaf5643 Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 12 Nov 2025 05:37:33 +0100 Subject: [PATCH 08/12] Fix #11172 --- app/Support/Http/Api/AccountFilter.php | 20 +++++++++++++++++++- app/Support/Http/Api/TransactionFilter.php | 3 +++ changelog.md | 6 ++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/Support/Http/Api/AccountFilter.php b/app/Support/Http/Api/AccountFilter.php index b44dc3df6a..73eecbbd5e 100644 --- a/app/Support/Http/Api/AccountFilter.php +++ b/app/Support/Http/Api/AccountFilter.php @@ -47,6 +47,14 @@ trait AccountFilter AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value, ], + 'normal' => [ + AccountTypeEnum::ASSET->value, + AccountTypeEnum::EXPENSE->value, + AccountTypeEnum::REVENUE->value, + AccountTypeEnum::LOAN->value, + AccountTypeEnum::DEBT->value, + AccountTypeEnum::MORTGAGE->value, + ], 'asset' => [AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value], 'cash' => [AccountTypeEnum::CASH->value], 'expense' => [AccountTypeEnum::EXPENSE->value, AccountTypeEnum::BENEFICIARY->value], @@ -89,6 +97,16 @@ trait AccountFilter */ protected function mapAccountTypes(string $type): array { - return $this->types[$type] ?? $this->types['all']; + $return = []; + $parts = explode(',', $type); + foreach ($parts as $part) { + if (array_key_exists($part, $this->types)) { + $return = array_merge($return, $this->types[$part]); + } + } + if(0 === count($return)) { + $return = $this->types['normal']; + } + return $return; } } diff --git a/app/Support/Http/Api/TransactionFilter.php b/app/Support/Http/Api/TransactionFilter.php index 45734abf75..8ef8e5960d 100644 --- a/app/Support/Http/Api/TransactionFilter.php +++ b/app/Support/Http/Api/TransactionFilter.php @@ -74,6 +74,9 @@ trait TransactionFilter $return = array_merge($return, $this->transactionTypes[$part]); } } + if(0 === count($return)) { + $return = $this->transactionTypes['all']; + } return array_unique($return); } diff --git a/changelog.md b/changelog.md index f5b6cbce9e..b179845987 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## 6.4.7 + +### Fixed + +- #11172 + ## 6.4.6 - 2025-11-09 ### Fixed From 0934de09bbcd1b49334c140b0930896011c95ee0 Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 12 Nov 2025 05:38:31 +0100 Subject: [PATCH 09/12] Fix #11206 --- changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index b179845987..8163d31059 100644 --- a/changelog.md +++ b/changelog.md @@ -7,7 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Fixed -- #11172 +- #11206 ## 6.4.6 - 2025-11-09 From c91845a0f212c22d28cd48bcc83040802eabfd94 Mon Sep 17 00:00:00 2001 From: JC5 Date: Wed, 12 Nov 2025 05:42:49 +0100 Subject: [PATCH 10/12] =?UTF-8?q?=F0=9F=A4=96=20Auto=20commit=20for=20rele?= =?UTF-8?q?ase=20'develop'=20on=202025-11-12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Support/Http/Api/AccountFilter.php | 5 +- app/Support/Http/Api/TransactionFilter.php | 2 +- changelog.md | 2 +- composer.lock | 59 ++--- config/firefly.php | 4 +- package-lock.json | 246 ++++++++++----------- 6 files changed, 160 insertions(+), 158 deletions(-) diff --git a/app/Support/Http/Api/AccountFilter.php b/app/Support/Http/Api/AccountFilter.php index 73eecbbd5e..00033ec5e1 100644 --- a/app/Support/Http/Api/AccountFilter.php +++ b/app/Support/Http/Api/AccountFilter.php @@ -47,7 +47,7 @@ trait AccountFilter AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value, ], - 'normal' => [ + 'normal' => [ AccountTypeEnum::ASSET->value, AccountTypeEnum::EXPENSE->value, AccountTypeEnum::REVENUE->value, @@ -104,9 +104,10 @@ trait AccountFilter $return = array_merge($return, $this->types[$part]); } } - if(0 === count($return)) { + if (0 === count($return)) { $return = $this->types['normal']; } + return $return; } } diff --git a/app/Support/Http/Api/TransactionFilter.php b/app/Support/Http/Api/TransactionFilter.php index 8ef8e5960d..4d75755e29 100644 --- a/app/Support/Http/Api/TransactionFilter.php +++ b/app/Support/Http/Api/TransactionFilter.php @@ -74,7 +74,7 @@ trait TransactionFilter $return = array_merge($return, $this->transactionTypes[$part]); } } - if(0 === count($return)) { + if (0 === count($return)) { $return = $this->transactionTypes['all']; } diff --git a/changelog.md b/changelog.md index 8163d31059..91a10fab2d 100644 --- a/changelog.md +++ b/changelog.md @@ -7,7 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Fixed -- #11206 +- [Issue 11206](https://github.com/firefly-iii/firefly-iii/issues/11206) (New transition shows additional option in input) reported by @zhiiwg ## 6.4.6 - 2025-11-09 diff --git a/composer.lock b/composer.lock index 6a4493981b..8075796e51 100644 --- a/composer.lock +++ b/composer.lock @@ -3015,16 +3015,16 @@ }, { "name": "league/flysystem", - "version": "3.30.1", + "version": "3.30.2", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "c139fd65c1f796b926f4aec0df37f6caa959a8da" + "reference": "5966a8ba23e62bdb518dd9e0e665c2dbd4b5b277" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/c139fd65c1f796b926f4aec0df37f6caa959a8da", - "reference": "c139fd65c1f796b926f4aec0df37f6caa959a8da", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/5966a8ba23e62bdb518dd9e0e665c2dbd4b5b277", + "reference": "5966a8ba23e62bdb518dd9e0e665c2dbd4b5b277", "shasum": "" }, "require": { @@ -3092,22 +3092,22 @@ ], "support": { "issues": "https://github.com/thephpleague/flysystem/issues", - "source": "https://github.com/thephpleague/flysystem/tree/3.30.1" + "source": "https://github.com/thephpleague/flysystem/tree/3.30.2" }, - "time": "2025-10-20T15:35:26+00:00" + "time": "2025-11-10T17:13:11+00:00" }, { "name": "league/flysystem-local", - "version": "3.30.0", + "version": "3.30.2", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem-local.git", - "reference": "6691915f77c7fb69adfb87dcd550052dc184ee10" + "reference": "ab4f9d0d672f601b102936aa728801dd1a11968d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/6691915f77c7fb69adfb87dcd550052dc184ee10", - "reference": "6691915f77c7fb69adfb87dcd550052dc184ee10", + "url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/ab4f9d0d672f601b102936aa728801dd1a11968d", + "reference": "ab4f9d0d672f601b102936aa728801dd1a11968d", "shasum": "" }, "require": { @@ -3141,9 +3141,9 @@ "local" ], "support": { - "source": "https://github.com/thephpleague/flysystem-local/tree/3.30.0" + "source": "https://github.com/thephpleague/flysystem-local/tree/3.30.2" }, - "time": "2025-05-21T10:34:19+00:00" + "time": "2025-11-10T11:23:37+00:00" }, { "name": "league/fractal", @@ -5965,16 +5965,16 @@ }, { "name": "sentry/sentry", - "version": "4.18.0", + "version": "4.18.1", "source": { "type": "git", "url": "https://github.com/getsentry/sentry-php.git", - "reference": "75f7efb7d435d24767c93d0081b8edf228be5772" + "reference": "04dcf20b39742b731b676f8b8d4f02d1db488af8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/getsentry/sentry-php/zipball/75f7efb7d435d24767c93d0081b8edf228be5772", - "reference": "75f7efb7d435d24767c93d0081b8edf228be5772", + "url": "https://api.github.com/repos/getsentry/sentry-php/zipball/04dcf20b39742b731b676f8b8d4f02d1db488af8", + "reference": "04dcf20b39742b731b676f8b8d4f02d1db488af8", "shasum": "" }, "require": { @@ -6037,7 +6037,7 @@ ], "support": { "issues": "https://github.com/getsentry/sentry-php/issues", - "source": "https://github.com/getsentry/sentry-php/tree/4.18.0" + "source": "https://github.com/getsentry/sentry-php/tree/4.18.1" }, "funding": [ { @@ -6049,27 +6049,27 @@ "type": "custom" } ], - "time": "2025-11-05T14:37:07+00:00" + "time": "2025-11-11T09:34:53+00:00" }, { "name": "sentry/sentry-laravel", - "version": "4.18.0", + "version": "4.19.0", "source": { "type": "git", "url": "https://github.com/getsentry/sentry-laravel.git", - "reference": "b9a647f93f9a040eaf6f21d0684f2351310d3360" + "reference": "7fdffd57e8fff0a6f9a18d9a83f32e960af63e3f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/getsentry/sentry-laravel/zipball/b9a647f93f9a040eaf6f21d0684f2351310d3360", - "reference": "b9a647f93f9a040eaf6f21d0684f2351310d3360", + "url": "https://api.github.com/repos/getsentry/sentry-laravel/zipball/7fdffd57e8fff0a6f9a18d9a83f32e960af63e3f", + "reference": "7fdffd57e8fff0a6f9a18d9a83f32e960af63e3f", "shasum": "" }, "require": { "illuminate/support": "^6.0 | ^7.0 | ^8.0 | ^9.0 | ^10.0 | ^11.0 | ^12.0", "nyholm/psr7": "^1.0", "php": "^7.2 | ^8.0", - "sentry/sentry": "^4.16.0", + "sentry/sentry": "^4.18.0", "symfony/psr-http-message-bridge": "^1.0 | ^2.0 | ^6.0 | ^7.0" }, "require-dev": { @@ -6077,6 +6077,7 @@ "guzzlehttp/guzzle": "^7.2", "laravel/folio": "^1.1", "laravel/framework": "^6.0 | ^7.0 | ^8.0 | ^9.0 | ^10.0 | ^11.0 | ^12.0", + "laravel/pennant": "^1.0", "livewire/livewire": "^2.0 | ^3.0", "mockery/mockery": "^1.3", "orchestra/testbench": "^4.7 | ^5.1 | ^6.0 | ^7.0 | ^8.0 | ^9.0 | ^10.0", @@ -6126,7 +6127,7 @@ ], "support": { "issues": "https://github.com/getsentry/sentry-laravel/issues", - "source": "https://github.com/getsentry/sentry-laravel/tree/4.18.0" + "source": "https://github.com/getsentry/sentry-laravel/tree/4.19.0" }, "funding": [ { @@ -6138,7 +6139,7 @@ "type": "custom" } ], - "time": "2025-10-20T12:57:51+00:00" + "time": "2025-11-11T09:01:14+00:00" }, { "name": "spatie/backtrace", @@ -11528,11 +11529,11 @@ }, { "name": "phpstan/phpstan", - "version": "2.1.31", + "version": "2.1.32", "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/ead89849d879fe203ce9292c6ef5e7e76f867b96", - "reference": "ead89849d879fe203ce9292c6ef5e7e76f867b96", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e126cad1e30a99b137b8ed75a85a676450ebb227", + "reference": "e126cad1e30a99b137b8ed75a85a676450ebb227", "shasum": "" }, "require": { @@ -11577,7 +11578,7 @@ "type": "github" } ], - "time": "2025-10-10T14:14:11+00:00" + "time": "2025-11-11T15:18:17+00:00" }, { "name": "phpstan/phpstan-deprecation-rules", diff --git a/config/firefly.php b/config/firefly.php index 3c5ae15d6d..43c812dbee 100644 --- a/config/firefly.php +++ b/config/firefly.php @@ -78,8 +78,8 @@ return [ 'running_balance_column' => env('USE_RUNNING_BALANCE', false), // see cer.php for exchange rates feature flag. ], - 'version' => 'develop/2025-11-10', - 'build_time' => 1762745365, + 'version' => 'develop/2025-11-12', + 'build_time' => 1762922448, 'api_version' => '2.1.0', // field is no longer used. 'db_version' => 28, // field is no longer used. diff --git a/package-lock.json b/package-lock.json index 83896a722d..3b54c8207d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2589,9 +2589,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.53.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.53.1.tgz", - "integrity": "sha512-bxZtughE4VNVJlL1RdoSE545kc4JxL7op57KKoi59/gwuU5rV6jLWFXXc8jwgFoT6vtj+ZjO+Z2C5nrY0Cl6wA==", + "version": "4.53.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.53.2.tgz", + "integrity": "sha512-yDPzwsgiFO26RJA4nZo8I+xqzh7sJTZIWQOxn+/XOdPE31lAvLIYCKqjV+lNH/vxE2L2iH3plKxDCRK6i+CwhA==", "cpu": [ "arm" ], @@ -2603,9 +2603,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.53.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.53.1.tgz", - "integrity": "sha512-44a1hreb02cAAfAKmZfXVercPFaDjqXCK+iKeVOlJ9ltvnO6QqsBHgKVPTu+MJHSLLeMEUbeG2qiDYgbFPU48g==", + "version": "4.53.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.53.2.tgz", + "integrity": "sha512-k8FontTxIE7b0/OGKeSN5B6j25EuppBcWM33Z19JoVT7UTXFSo3D9CdU39wGTeb29NO3XxpMNauh09B+Ibw+9g==", "cpu": [ "arm64" ], @@ -2617,9 +2617,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.53.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.53.1.tgz", - "integrity": "sha512-usmzIgD0rf1syoOZ2WZvy8YpXK5G1V3btm3QZddoGSa6mOgfXWkkv+642bfUUldomgrbiLQGrPryb7DXLovPWQ==", + "version": "4.53.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.53.2.tgz", + "integrity": "sha512-A6s4gJpomNBtJ2yioj8bflM2oogDwzUiMl2yNJ2v9E7++sHrSrsQ29fOfn5DM/iCzpWcebNYEdXpaK4tr2RhfQ==", "cpu": [ "arm64" ], @@ -2631,9 +2631,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.53.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.53.1.tgz", - "integrity": "sha512-is3r/k4vig2Gt8mKtTlzzyaSQ+hd87kDxiN3uDSDwggJLUV56Umli6OoL+/YZa/KvtdrdyNfMKHzL/P4siOOmg==", + "version": "4.53.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.53.2.tgz", + "integrity": "sha512-e6XqVmXlHrBlG56obu9gDRPW3O3hLxpwHpLsBJvuI8qqnsrtSZ9ERoWUXtPOkY8c78WghyPHZdmPhHLWNdAGEw==", "cpu": [ "x64" ], @@ -2645,9 +2645,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-arm64": { - "version": "4.53.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.53.1.tgz", - "integrity": "sha512-QJ1ksgp/bDJkZB4daldVmHaEQkG4r8PUXitCOC2WRmRaSaHx5RwPoI3DHVfXKwDkB+Sk6auFI/+JHacTekPRSw==", + "version": "4.53.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.53.2.tgz", + "integrity": "sha512-v0E9lJW8VsrwPux5Qe5CwmH/CF/2mQs6xU1MF3nmUxmZUCHazCjLgYvToOk+YuuUqLQBio1qkkREhxhc656ViA==", "cpu": [ "arm64" ], @@ -2659,9 +2659,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-x64": { - "version": "4.53.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.53.1.tgz", - "integrity": "sha512-J6ma5xgAzvqsnU6a0+jgGX/gvoGokqpkx6zY4cWizRrm0ffhHDpJKQgC8dtDb3+MqfZDIqs64REbfHDMzxLMqQ==", + "version": "4.53.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.53.2.tgz", + "integrity": "sha512-ClAmAPx3ZCHtp6ysl4XEhWU69GUB1D+s7G9YjHGhIGCSrsg00nEGRRZHmINYxkdoJehde8VIsDC5t9C0gb6yqA==", "cpu": [ "x64" ], @@ -2673,9 +2673,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.53.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.53.1.tgz", - "integrity": "sha512-JzWRR41o2U3/KMNKRuZNsDUAcAVUYhsPuMlx5RUldw0E4lvSIXFUwejtYz1HJXohUmqs/M6BBJAUBzKXZVddbg==", + "version": "4.53.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.53.2.tgz", + "integrity": "sha512-EPlb95nUsz6Dd9Qy13fI5kUPXNSljaG9FiJ4YUGU1O/Q77i5DYFW5KR8g1OzTcdZUqQQ1KdDqsTohdFVwCwjqg==", "cpu": [ "arm" ], @@ -2687,9 +2687,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.53.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.53.1.tgz", - "integrity": "sha512-L8kRIrnfMrEoHLHtHn+4uYA52fiLDEDyezgxZtGUTiII/yb04Krq+vk3P2Try+Vya9LeCE9ZHU8CXD6J9EhzHQ==", + "version": "4.53.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.53.2.tgz", + "integrity": "sha512-BOmnVW+khAUX+YZvNfa0tGTEMVVEerOxN0pDk2E6N6DsEIa2Ctj48FOMfNDdrwinocKaC7YXUZ1pHlKpnkja/Q==", "cpu": [ "arm" ], @@ -2701,9 +2701,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.53.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.53.1.tgz", - "integrity": "sha512-ysAc0MFRV+WtQ8li8hi3EoFi7us6d1UzaS/+Dp7FYZfg3NdDljGMoVyiIp6Ucz7uhlYDBZ/zt6XI0YEZbUO11Q==", + "version": "4.53.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.53.2.tgz", + "integrity": "sha512-Xt2byDZ+6OVNuREgBXr4+CZDJtrVso5woFtpKdGPhpTPHcNG7D8YXeQzpNbFRxzTVqJf7kvPMCub/pcGUWgBjA==", "cpu": [ "arm64" ], @@ -2715,9 +2715,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.53.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.53.1.tgz", - "integrity": "sha512-UV6l9MJpDbDZZ/fJvqNcvO1PcivGEf1AvKuTcHoLjVZVFeAMygnamCTDikCVMRnA+qJe+B3pSbgX2+lBMqgBhA==", + "version": "4.53.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.53.2.tgz", + "integrity": "sha512-+LdZSldy/I9N8+klim/Y1HsKbJ3BbInHav5qE9Iy77dtHC/pibw1SR/fXlWyAk0ThnpRKoODwnAuSjqxFRDHUQ==", "cpu": [ "arm64" ], @@ -2729,9 +2729,9 @@ ] }, "node_modules/@rollup/rollup-linux-loong64-gnu": { - "version": "4.53.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.53.1.tgz", - "integrity": "sha512-UDUtelEprkA85g95Q+nj3Xf0M4hHa4DiJ+3P3h4BuGliY4NReYYqwlc0Y8ICLjN4+uIgCEvaygYlpf0hUj90Yg==", + "version": "4.53.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.53.2.tgz", + "integrity": "sha512-8ms8sjmyc1jWJS6WdNSA23rEfdjWB30LH8Wqj0Cqvv7qSHnvw6kgMMXRdop6hkmGPlyYBdRPkjJnj3KCUHV/uQ==", "cpu": [ "loong64" ], @@ -2743,9 +2743,9 @@ ] }, "node_modules/@rollup/rollup-linux-ppc64-gnu": { - "version": "4.53.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.53.1.tgz", - "integrity": "sha512-vrRn+BYhEtNOte/zbc2wAUQReJXxEx2URfTol6OEfY2zFEUK92pkFBSXRylDM7aHi+YqEPJt9/ABYzmcrS4SgQ==", + "version": "4.53.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.53.2.tgz", + "integrity": "sha512-3HRQLUQbpBDMmzoxPJYd3W6vrVHOo2cVW8RUo87Xz0JPJcBLBr5kZ1pGcQAhdZgX9VV7NbGNipah1omKKe23/g==", "cpu": [ "ppc64" ], @@ -2757,9 +2757,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.53.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.53.1.tgz", - "integrity": "sha512-gto/1CxHyi4A7YqZZNznQYrVlPSaodOBPKM+6xcDSCMVZN/Fzb4K+AIkNz/1yAYz9h3Ng+e2fY9H6bgawVq17w==", + "version": "4.53.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.53.2.tgz", + "integrity": "sha512-fMjKi+ojnmIvhk34gZP94vjogXNNUKMEYs+EDaB/5TG/wUkoeua7p7VCHnE6T2Tx+iaghAqQX8teQzcvrYpaQA==", "cpu": [ "riscv64" ], @@ -2771,9 +2771,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-musl": { - "version": "4.53.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.53.1.tgz", - "integrity": "sha512-KZ6Vx7jAw3aLNjFR8eYVcQVdFa/cvBzDNRFM3z7XhNNunWjA03eUrEwJYPk0G8V7Gs08IThFKcAPS4WY/ybIrQ==", + "version": "4.53.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.53.2.tgz", + "integrity": "sha512-XuGFGU+VwUUV5kLvoAdi0Wz5Xbh2SrjIxCtZj6Wq8MDp4bflb/+ThZsVxokM7n0pcbkEr2h5/pzqzDYI7cCgLQ==", "cpu": [ "riscv64" ], @@ -2785,9 +2785,9 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.53.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.53.1.tgz", - "integrity": "sha512-HvEixy2s/rWNgpwyKpXJcHmE7om1M89hxBTBi9Fs6zVuLU4gOrEMQNbNsN/tBVIMbLyysz/iwNiGtMOpLAOlvA==", + "version": "4.53.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.53.2.tgz", + "integrity": "sha512-w6yjZF0P+NGzWR3AXWX9zc0DNEGdtvykB03uhonSHMRa+oWA6novflo2WaJr6JZakG2ucsyb+rvhrKac6NIy+w==", "cpu": [ "s390x" ], @@ -2799,9 +2799,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.53.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.53.1.tgz", - "integrity": "sha512-E/n8x2MSjAQgjj9IixO4UeEUeqXLtiA7pyoXCFYLuXpBA/t2hnbIdxHfA7kK9BFsYAoNU4st1rHYdldl8dTqGA==", + "version": "4.53.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.53.2.tgz", + "integrity": "sha512-yo8d6tdfdeBArzC7T/PnHd7OypfI9cbuZzPnzLJIyKYFhAQ8SvlkKtKBMbXDxe1h03Rcr7u++nFS7tqXz87Gtw==", "cpu": [ "x64" ], @@ -2813,9 +2813,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.53.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.53.1.tgz", - "integrity": "sha512-IhJ087PbLOQXCN6Ui/3FUkI9pWNZe/Z7rEIVOzMsOs1/HSAECCvSZ7PkIbkNqL/AZn6WbZvnoVZw/qwqYMo4/w==", + "version": "4.53.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.53.2.tgz", + "integrity": "sha512-ah59c1YkCxKExPP8O9PwOvs+XRLKwh/mV+3YdKqQ5AMQ0r4M4ZDuOrpWkUaqO7fzAHdINzV9tEVu8vNw48z0lA==", "cpu": [ "x64" ], @@ -2827,9 +2827,9 @@ ] }, "node_modules/@rollup/rollup-openharmony-arm64": { - "version": "4.53.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.53.1.tgz", - "integrity": "sha512-0++oPNgLJHBblreu0SFM7b3mAsBJBTY0Ksrmu9N6ZVrPiTkRgda52mWR7TKhHAsUb9noCjFvAw9l6ZO1yzaVbA==", + "version": "4.53.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.53.2.tgz", + "integrity": "sha512-4VEd19Wmhr+Zy7hbUsFZ6YXEiP48hE//KPLCSVNY5RMGX2/7HZ+QkN55a3atM1C/BZCGIgqN+xrVgtdak2S9+A==", "cpu": [ "arm64" ], @@ -2841,9 +2841,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.53.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.53.1.tgz", - "integrity": "sha512-VJXivz61c5uVdbmitLkDlbcTk9Or43YC2QVLRkqp86QoeFSqI81bNgjhttqhKNMKnQMWnecOCm7lZz4s+WLGpQ==", + "version": "4.53.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.53.2.tgz", + "integrity": "sha512-IlbHFYc/pQCgew/d5fslcy1KEaYVCJ44G8pajugd8VoOEI8ODhtb/j8XMhLpwHCMB3yk2J07ctup10gpw2nyMA==", "cpu": [ "arm64" ], @@ -2855,9 +2855,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.53.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.53.1.tgz", - "integrity": "sha512-NmZPVTUOitCXUH6erJDzTQ/jotYw4CnkMDjCYRxNHVD9bNyfrGoIse684F9okwzKCV4AIHRbUkeTBc9F2OOH5Q==", + "version": "4.53.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.53.2.tgz", + "integrity": "sha512-lNlPEGgdUfSzdCWU176ku/dQRnA7W+Gp8d+cWv73jYrb8uT7HTVVxq62DUYxjbaByuf1Yk0RIIAbDzp+CnOTFg==", "cpu": [ "ia32" ], @@ -2869,9 +2869,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-gnu": { - "version": "4.53.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.53.1.tgz", - "integrity": "sha512-2SNj7COIdAf6yliSpLdLG8BEsp5lgzRehgfkP0Av8zKfQFKku6JcvbobvHASPJu4f3BFxej5g+HuQPvqPhHvpQ==", + "version": "4.53.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.53.2.tgz", + "integrity": "sha512-S6YojNVrHybQis2lYov1sd+uj7K0Q05NxHcGktuMMdIQ2VixGwAfbJ23NnlvvVV1bdpR2m5MsNBViHJKcA4ADw==", "cpu": [ "x64" ], @@ -2883,9 +2883,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.53.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.53.1.tgz", - "integrity": "sha512-rLarc1Ofcs3DHtgSzFO31pZsCh8g05R2azN1q3fF+H423Co87My0R+tazOEvYVKXSLh8C4LerMK41/K7wlklcg==", + "version": "4.53.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.53.2.tgz", + "integrity": "sha512-k+/Rkcyx//P6fetPoLMb8pBeqJBNGx81uuf7iljX9++yNBVRDQgD04L+SVXmXmh5ZP4/WOp4mWF0kmi06PW2tA==", "cpu": [ "x64" ], @@ -3173,9 +3173,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "24.10.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.0.tgz", - "integrity": "sha512-qzQZRBqkFsYyaSWXuEHc2WR9c0a0CXwiE5FWUvn7ZM+vdy1uZLfCunD38UzhuB7YN/J11ndbDBcTmOdxJo9Q7A==", + "version": "24.10.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.1.tgz", + "integrity": "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ==", "dev": true, "license": "MIT", "dependencies": { @@ -3909,9 +3909,9 @@ "license": "MIT" }, "node_modules/autoprefixer": { - "version": "10.4.21", - "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.21.tgz", - "integrity": "sha512-O+A6LWV5LDHSJD3LjHYoNi4VLsj/Whi7k6zG12xTYaU4cQ8oxQGckXNX8cRHK5yOZ/ppVHe0ZBXGzSV9jXdVbQ==", + "version": "10.4.22", + "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.22.tgz", + "integrity": "sha512-ARe0v/t9gO28Bznv6GgqARmVqcWOV3mfgUPn9becPHMiD3o9BwlRgaeccZnwTpZ7Zwqrm+c1sUSsMxIzQzc8Xg==", "dev": true, "funding": [ { @@ -3929,9 +3929,9 @@ ], "license": "MIT", "dependencies": { - "browserslist": "^4.24.4", - "caniuse-lite": "^1.0.30001702", - "fraction.js": "^4.3.7", + "browserslist": "^4.27.0", + "caniuse-lite": "^1.0.30001754", + "fraction.js": "^5.3.4", "normalize-range": "^0.1.2", "picocolors": "^1.1.1", "postcss-value-parser": "^4.2.0" @@ -4075,9 +4075,9 @@ "license": "MIT" }, "node_modules/baseline-browser-mapping": { - "version": "2.8.25", - "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.8.25.tgz", - "integrity": "sha512-2NovHVesVF5TXefsGX1yzx1xgr7+m9JQenvz6FQY3qd+YXkKkYiv+vTCc7OriP9mcDZpTC5mAOYN4ocd29+erA==", + "version": "2.8.26", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.8.26.tgz", + "integrity": "sha512-73lC1ugzwoaWCLJ1LvOgrR5xsMLTqSKIEoMHVtL9E/HNk0PXtTM76ZIm84856/SF7Nv8mPZxKoBsgpm0tR1u1Q==", "dev": true, "license": "Apache-2.0", "bin": { @@ -4360,9 +4360,9 @@ } }, "node_modules/browserslist": { - "version": "4.27.0", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.27.0.tgz", - "integrity": "sha512-AXVQwdhot1eqLihwasPElhX2tAZiBjWdJ9i/Zcj2S6QYIjkx62OKSfnobkriB81C3l4w0rVy3Nt4jaTBltYEpw==", + "version": "4.28.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.0.tgz", + "integrity": "sha512-tbydkR/CxfMwelN0vwdP/pLkDwyAASZ+VfWm4EOwlB6SWhx1sYnWLqo8N5j0rAzPfzfRaxt0mM/4wPU/Su84RQ==", "dev": true, "funding": [ { @@ -4380,10 +4380,10 @@ ], "license": "MIT", "dependencies": { - "baseline-browser-mapping": "^2.8.19", - "caniuse-lite": "^1.0.30001751", - "electron-to-chromium": "^1.5.238", - "node-releases": "^2.0.26", + "baseline-browser-mapping": "^2.8.25", + "caniuse-lite": "^1.0.30001754", + "electron-to-chromium": "^1.5.249", + "node-releases": "^2.0.27", "update-browserslist-db": "^1.1.4" }, "bin": { @@ -5736,9 +5736,9 @@ "license": "MIT" }, "node_modules/electron-to-chromium": { - "version": "1.5.249", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.249.tgz", - "integrity": "sha512-5vcfL3BBe++qZ5kuFhD/p8WOM1N9m3nwvJPULJx+4xf2usSlZFJ0qoNYO2fOX4hi3ocuDcmDobtA+5SFr4OmBg==", + "version": "1.5.250", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.250.tgz", + "integrity": "sha512-/5UMj9IiGDMOFBnN4i7/Ry5onJrAGSbOGo3s9FEKmwobGq6xw832ccET0CE3CkkMBZ8GJSlUIesZofpyurqDXw==", "dev": true, "license": "ISC" }, @@ -6470,16 +6470,16 @@ } }, "node_modules/fraction.js": { - "version": "4.3.7", - "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.3.7.tgz", - "integrity": "sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==", + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-5.3.4.tgz", + "integrity": "sha512-1X1NTtiJphryn/uLQz3whtY6jK3fTqoE3ohKs0tT+Ujr1W59oopxmoEh7Lu5p6vBaPbgoM0bzveAW4Qi5RyWDQ==", "dev": true, "license": "MIT", "engines": { "node": "*" }, "funding": { - "type": "patreon", + "type": "github", "url": "https://github.com/sponsors/rawify" } }, @@ -7088,9 +7088,9 @@ } }, "node_modules/i18next": { - "version": "25.6.1", - "resolved": "https://registry.npmjs.org/i18next/-/i18next-25.6.1.tgz", - "integrity": "sha512-yUWvdXtalZztmKrKw3yz/AvSP3yKyqIkVPx/wyvoYy9lkLmwzItLxp0iHZLG5hfVQ539Jor4XLO+U+NHIXg7pw==", + "version": "25.6.2", + "resolved": "https://registry.npmjs.org/i18next/-/i18next-25.6.2.tgz", + "integrity": "sha512-0GawNyVUw0yvJoOEBq1VHMAsqdM23XrHkMtl2gKEjviJQSLVXsrPqsoYAxBEugW5AB96I2pZkwRxyl8WZVoWdw==", "funding": [ { "type": "individual", @@ -10110,9 +10110,9 @@ } }, "node_modules/rollup": { - "version": "4.53.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.53.1.tgz", - "integrity": "sha512-n2I0V0lN3E9cxxMqBCT3opWOiQBzRN7UG60z/WDKqdX2zHUS/39lezBcsckZFsV6fUTSnfqI7kHf60jDAPGKug==", + "version": "4.53.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.53.2.tgz", + "integrity": "sha512-MHngMYwGJVi6Fmnk6ISmnk7JAHRNF0UkuucA0CUW3N3a4KnONPEZz+vUanQP/ZC/iY1Qkf3bwPWzyY84wEks1g==", "dev": true, "license": "MIT", "dependencies": { @@ -10126,28 +10126,28 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.53.1", - "@rollup/rollup-android-arm64": "4.53.1", - "@rollup/rollup-darwin-arm64": "4.53.1", - "@rollup/rollup-darwin-x64": "4.53.1", - "@rollup/rollup-freebsd-arm64": "4.53.1", - "@rollup/rollup-freebsd-x64": "4.53.1", - "@rollup/rollup-linux-arm-gnueabihf": "4.53.1", - "@rollup/rollup-linux-arm-musleabihf": "4.53.1", - "@rollup/rollup-linux-arm64-gnu": "4.53.1", - "@rollup/rollup-linux-arm64-musl": "4.53.1", - "@rollup/rollup-linux-loong64-gnu": "4.53.1", - "@rollup/rollup-linux-ppc64-gnu": "4.53.1", - "@rollup/rollup-linux-riscv64-gnu": "4.53.1", - "@rollup/rollup-linux-riscv64-musl": "4.53.1", - "@rollup/rollup-linux-s390x-gnu": "4.53.1", - "@rollup/rollup-linux-x64-gnu": "4.53.1", - "@rollup/rollup-linux-x64-musl": "4.53.1", - "@rollup/rollup-openharmony-arm64": "4.53.1", - "@rollup/rollup-win32-arm64-msvc": "4.53.1", - "@rollup/rollup-win32-ia32-msvc": "4.53.1", - "@rollup/rollup-win32-x64-gnu": "4.53.1", - "@rollup/rollup-win32-x64-msvc": "4.53.1", + "@rollup/rollup-android-arm-eabi": "4.53.2", + "@rollup/rollup-android-arm64": "4.53.2", + "@rollup/rollup-darwin-arm64": "4.53.2", + "@rollup/rollup-darwin-x64": "4.53.2", + "@rollup/rollup-freebsd-arm64": "4.53.2", + "@rollup/rollup-freebsd-x64": "4.53.2", + "@rollup/rollup-linux-arm-gnueabihf": "4.53.2", + "@rollup/rollup-linux-arm-musleabihf": "4.53.2", + "@rollup/rollup-linux-arm64-gnu": "4.53.2", + "@rollup/rollup-linux-arm64-musl": "4.53.2", + "@rollup/rollup-linux-loong64-gnu": "4.53.2", + "@rollup/rollup-linux-ppc64-gnu": "4.53.2", + "@rollup/rollup-linux-riscv64-gnu": "4.53.2", + "@rollup/rollup-linux-riscv64-musl": "4.53.2", + "@rollup/rollup-linux-s390x-gnu": "4.53.2", + "@rollup/rollup-linux-x64-gnu": "4.53.2", + "@rollup/rollup-linux-x64-musl": "4.53.2", + "@rollup/rollup-openharmony-arm64": "4.53.2", + "@rollup/rollup-win32-arm64-msvc": "4.53.2", + "@rollup/rollup-win32-ia32-msvc": "4.53.2", + "@rollup/rollup-win32-x64-gnu": "4.53.2", + "@rollup/rollup-win32-x64-msvc": "4.53.2", "fsevents": "~2.3.2" } }, @@ -10203,9 +10203,9 @@ "license": "MIT" }, "node_modules/sass": { - "version": "1.93.3", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.93.3.tgz", - "integrity": "sha512-elOcIZRTM76dvxNAjqYrucTSI0teAF/L2Lv0s6f6b7FOwcwIuA357bIE871580AjHJuSvLIRUosgV+lIWx6Rgg==", + "version": "1.94.0", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.94.0.tgz", + "integrity": "sha512-Dqh7SiYcaFtdv5Wvku6QgS5IGPm281L+ZtVD1U2FJa7Q0EFRlq8Z3sjYtz6gYObsYThUOz9ArwFqPZx+1azILQ==", "dev": true, "license": "MIT", "dependencies": { From 2e5528167cfafc30a6014d1e96cb7303badfc335 Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 12 Nov 2025 05:46:21 +0100 Subject: [PATCH 11/12] Don't do comment. --- .github/workflows/issues-reply-old-versions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/issues-reply-old-versions.yml b/.github/workflows/issues-reply-old-versions.yml index cf71328096..784292ccb9 100644 --- a/.github/workflows/issues-reply-old-versions.yml +++ b/.github/workflows/issues-reply-old-versions.yml @@ -105,7 +105,7 @@ jobs: Thank you for running the latest version of Firefly III (or the data importer)." - gh issue comment "$NUMBER" --body "$MESSAGE" + # gh issue comment "$NUMBER" --body "$MESSAGE" echo "Triggered on fourth test" exit 0 fi From d9ff71b1a54c380a3fa6138d247db3f269ecdb4d Mon Sep 17 00:00:00 2001 From: JC5 Date: Wed, 12 Nov 2025 05:50:05 +0100 Subject: [PATCH 12/12] =?UTF-8?q?=F0=9F=A4=96=20Auto=20commit=20for=20rele?= =?UTF-8?q?ase=20'v6.4.7'=20on=202025-11-12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/firefly.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/firefly.php b/config/firefly.php index 43c812dbee..d7046fe4f9 100644 --- a/config/firefly.php +++ b/config/firefly.php @@ -78,8 +78,8 @@ return [ 'running_balance_column' => env('USE_RUNNING_BALANCE', false), // see cer.php for exchange rates feature flag. ], - 'version' => 'develop/2025-11-12', - 'build_time' => 1762922448, + 'version' => '6.4.7', + 'build_time' => 1762922901, 'api_version' => '2.1.0', // field is no longer used. 'db_version' => 28, // field is no longer used.