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, ); } }