Fix code quality with rector [skip ci]

This commit is contained in:
James Cole
2025-11-09 09:07:14 +01:00
parent 38691d6fdf
commit d2610be790
262 changed files with 873 additions and 1186 deletions

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Models\Transaction; namespace FireflyIII\Api\V1\Controllers\Models\Transaction;
use Illuminate\Http\Request;
use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Models\Transaction\StoreRequest; use FireflyIII\Api\V1\Requests\Models\Transaction\StoreRequest;
use FireflyIII\Enums\UserRoleEnum; use FireflyIII\Enums\UserRoleEnum;
@@ -61,7 +62,7 @@ class StoreController extends Controller
{ {
parent::__construct(); parent::__construct();
$this->middleware( $this->middleware(
function ($request, $next) { function (Request $request, $next) {
/** @var User $admin */ /** @var User $admin */
$admin = auth()->user(); $admin = auth()->user();
$userGroup = $this->validateUserGroup($request); $userGroup = $this->validateUserGroup($request);

View File

@@ -90,7 +90,7 @@ class ListController extends Controller
// filter list on currency preference: // filter list on currency preference:
$collection = $unfiltered->filter( $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'); $currencyId = (int) $accountRepository->getMetaValue($account, 'currency_id');
return $currencyId === $currency->id; return $currencyId === $currency->id;
@@ -178,7 +178,7 @@ class ListController extends Controller
// filter and paginate list: // filter and paginate list:
$collection = $unfiltered->filter( $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(); $count = $collection->count();
$bills = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize); $bills = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
@@ -261,8 +261,8 @@ class ListController extends Controller
// filter selection // filter selection
$collection = $unfiltered->filter( $collection = $unfiltered->filter(
static function (Recurrence $recurrence) use ($currency) { // @phpstan-ignore-line static function (Recurrence $recurrence) use ($currency): ?Recurrence { // @phpstan-ignore-line
if (array_any($recurrence->recurrenceTransactions, fn ($transaction) => $transaction->transaction_currency_id === $currency->id || $transaction->foreign_currency_id === $currency->id)) { if (array_any($recurrence->recurrenceTransactions, fn ($transaction): bool => $transaction->transaction_currency_id === $currency->id || $transaction->foreign_currency_id === $currency->id)) {
return $recurrence; return $recurrence;
} }
@@ -310,8 +310,8 @@ class ListController extends Controller
$unfiltered = $ruleRepos->getAll(); $unfiltered = $ruleRepos->getAll();
$collection = $unfiltered->filter( $collection = $unfiltered->filter(
static function (Rule $rule) use ($currency) { // @phpstan-ignore-line static function (Rule $rule) use ($currency): ?Rule { // @phpstan-ignore-line
if (array_any($rule->ruleTriggers, fn ($trigger) => 'currency_is' === $trigger->trigger_type && $currency->name === $trigger->trigger_value)) { if (array_any($rule->ruleTriggers, fn ($trigger): bool => 'currency_is' === $trigger->trigger_type && $currency->name === $trigger->trigger_value)) {
return $rule; return $rule;
} }

View File

@@ -45,18 +45,17 @@ class AccountController extends Controller
{ {
use AccountFilter; 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() public function __construct()
{ {
parent::__construct(); parent::__construct();
$this->validFields = [
AccountSearch::SEARCH_ALL,
AccountSearch::SEARCH_ID,
AccountSearch::SEARCH_NAME,
AccountSearch::SEARCH_IBAN,
AccountSearch::SEARCH_NUMBER,
];
} }
/** /**

View File

@@ -591,7 +591,7 @@ class BasicController extends Controller
// filter list on preference of being included. // filter list on preference of being included.
$filtered = $allAccounts->filter( $filtered = $allAccounts->filter(
function (Account $account) { function (Account $account): bool {
$includeNetWorth = $this->accountRepository->getMetaValue($account, 'include_net_worth'); $includeNetWorth = $this->accountRepository->getMetaValue($account, 'include_net_worth');
return null === $includeNetWorth || '1' === $includeNetWorth; return null === $includeNetWorth || '1' === $includeNetWorth;
@@ -652,10 +652,6 @@ class BasicController extends Controller
return true; return true;
} }
// start and end in the past? use $end // start and end in the past? use $end
if ($start->lessThanOrEqualTo($date) && $end->lessThanOrEqualTo($date)) { return $start->lessThanOrEqualTo($date) && $end->lessThanOrEqualTo($date);
return true;
}
return false;
} }
} }

View File

@@ -23,10 +23,11 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests; namespace FireflyIII\Api\V1\Requests;
use Override;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
use RuntimeException; use RuntimeException;
abstract class AggregateFormRequest extends ApiRequest abstract class AggregateFormRequest extends ApiRequest
@@ -39,6 +40,7 @@ abstract class AggregateFormRequest extends ApiRequest
/** @return array<array|string> */ /** @return array<array|string> */
abstract protected function getRequests(): 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 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); 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 // check all subrequests for rules and combine them
return array_reduce( return array_reduce(
$this->requests, $this->requests,
static fn (array $rules, FormRequest $request) => $rules static fn (array $rules, FormRequest $request): array => $rules
+ ( + (
method_exists($request, 'rules') method_exists($request, 'rules')
? $request->rules() ? $request->rules()
@@ -91,7 +93,7 @@ abstract class AggregateFormRequest extends ApiRequest
// register all subrequests' validators // register all subrequests' validators
foreach ($this->requests as $request) { foreach ($this->requests as $request) {
if (method_exists($request, 'withValidator')) { 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); $request->withValidator($validator);
} }
} }

View File

@@ -24,13 +24,13 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Chart; namespace FireflyIII\Api\V1\Requests\Chart;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Enums\UserRoleEnum; use FireflyIII\Enums\UserRoleEnum;
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait; use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
/** /**
* Class ChartRequest * Class ChartRequest

View File

@@ -24,12 +24,12 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Data\Bulk; namespace FireflyIII\Api\V1\Requests\Data\Bulk;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
/** /**
* Class MoveTransactionsRequest * Class MoveTransactionsRequest

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Data\Bulk; namespace FireflyIII\Api\V1\Requests\Data\Bulk;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Enums\ClauseType; use FireflyIII\Enums\ClauseType;
use FireflyIII\Rules\IsValidBulkClause; use FireflyIII\Rules\IsValidBulkClause;
use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ChecksLogin;
@@ -31,7 +32,6 @@ use FireflyIII\Support\Request\ConvertsDataTypes;
use FireflyIII\Validation\Api\Data\Bulk\ValidatesBulkTransactionQuery; use FireflyIII\Validation\Api\Data\Bulk\ValidatesBulkTransactionQuery;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
use JsonException; use JsonException;
use function Safe\json_decode; use function Safe\json_decode;

View File

@@ -23,7 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests; namespace FireflyIII\Api\V1\Requests;
use Illuminate\Validation\Validator; use Illuminate\Contracts\Validation\Validator;
class DateRangeRequest extends ApiRequest class DateRangeRequest extends ApiRequest
{ {

View File

@@ -23,8 +23,8 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests; namespace FireflyIII\Api\V1\Requests;
use Illuminate\Contracts\Validation\Validator;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Validation\Validator;
class DateRequest extends ApiRequest class DateRequest extends ApiRequest
{ {

View File

@@ -23,6 +23,8 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Generic; namespace FireflyIII\Api\V1\Requests\Generic;
use Override;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Api\V1\Requests\ApiRequest; use FireflyIII\Api\V1\Requests\ApiRequest;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
@@ -30,7 +32,6 @@ use FireflyIII\Rules\Account\IsValidAccountTypeList;
use FireflyIII\Rules\TransactionType\IsValidTransactionTypeList; use FireflyIII\Rules\TransactionType\IsValidTransactionTypeList;
use FireflyIII\Support\Http\Api\AccountFilter; use FireflyIII\Support\Http\Api\AccountFilter;
use FireflyIII\Support\Http\Api\TransactionFilter; use FireflyIII\Support\Http\Api\TransactionFilter;
use Illuminate\Validation\Validator;
use RuntimeException; use RuntimeException;
class ObjectTypeApiRequest extends ApiRequest class ObjectTypeApiRequest extends ApiRequest
@@ -40,6 +41,7 @@ class ObjectTypeApiRequest extends ApiRequest
private ?string $objectType = null; private ?string $objectType = null;
#[Override]
public function handleConfig(array $config): void public function handleConfig(array $config): void
{ {
parent::handleConfig($config); parent::handleConfig($config);

View File

@@ -23,10 +23,10 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Generic; namespace FireflyIII\Api\V1\Requests\Generic;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Api\V1\Requests\ApiRequest; use FireflyIII\Api\V1\Requests\ApiRequest;
use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Validation\Validator;
class QueryRequest extends ApiRequest class QueryRequest extends ApiRequest
{ {

View File

@@ -23,9 +23,9 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\Account; namespace FireflyIII\Api\V1\Requests\Models\Account;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Api\V1\Requests\ApiRequest; use FireflyIII\Api\V1\Requests\ApiRequest;
use FireflyIII\Support\Http\Api\AccountFilter; use FireflyIII\Support\Http\Api\AccountFilter;
use Illuminate\Validation\Validator;
class AccountTypeApiRequest extends ApiRequest class AccountTypeApiRequest extends ApiRequest
{ {

View File

@@ -23,10 +23,10 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\Account; namespace FireflyIII\Api\V1\Requests\Models\Account;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Api\V1\Requests\ApiRequest; use FireflyIII\Api\V1\Requests\ApiRequest;
use FireflyIII\Rules\Account\IsValidAccountTypeList; use FireflyIII\Rules\Account\IsValidAccountTypeList;
use FireflyIII\Support\Http\Api\AccountFilter; use FireflyIII\Support\Http\Api\AccountFilter;
use Illuminate\Validation\Validator;
class AccountTypesApiRequest extends ApiRequest class AccountTypesApiRequest extends ApiRequest
{ {

View File

@@ -26,7 +26,6 @@ namespace FireflyIII\Api\V1\Requests\Models\Account;
use FireflyIII\Api\V1\Requests\AggregateFormRequest; use FireflyIII\Api\V1\Requests\AggregateFormRequest;
use FireflyIII\Api\V1\Requests\DateRangeRequest; use FireflyIII\Api\V1\Requests\DateRangeRequest;
use FireflyIII\Api\V1\Requests\DateRequest; use FireflyIII\Api\V1\Requests\DateRequest;
use FireflyIII\Api\V1\Requests\Generic\ObjectTypeApiRequest;
use FireflyIII\Api\V1\Requests\PaginationRequest; use FireflyIII\Api\V1\Requests\PaginationRequest;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\Account; namespace FireflyIII\Api\V1\Requests\Models\Account;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\Location; use FireflyIII\Models\Location;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
@@ -35,7 +36,6 @@ use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
/** /**
* Class UpdateRequest * Class UpdateRequest

View File

@@ -58,7 +58,7 @@ class StoreRequest extends FormRequest
{ {
$models = config('firefly.valid_attachment_models'); $models = config('firefly.valid_attachment_models');
$models = array_map( $models = array_map(
static fn (string $className) => str_replace('FireflyIII\Models\\', '', $className), static fn (string $className): string => str_replace('FireflyIII\Models\\', '', $className),
$models $models
); );
$models = implode(',', $models); $models = implode(',', $models);

View File

@@ -60,7 +60,7 @@ class UpdateRequest extends FormRequest
{ {
$models = config('firefly.valid_attachment_models'); $models = config('firefly.valid_attachment_models');
$models = array_map( $models = array_map(
static fn (string $className) => str_replace('FireflyIII\Models\\', '', $className), static fn (string $className): string => str_replace('FireflyIII\Models\\', '', $className),
$models $models
); );
$models = implode(',', $models); $models = implode(',', $models);

View File

@@ -24,13 +24,13 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\AvailableBudget; namespace FireflyIII\Api\V1\Requests\Models\AvailableBudget;
use Illuminate\Contracts\Validation\Validator;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Rules\IsValidPositiveAmount; use FireflyIII\Rules\IsValidPositiveAmount;
use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
/** /**
* Class Request * Class Request

View File

@@ -24,13 +24,13 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\Bill; namespace FireflyIII\Api\V1\Requests\Models\Bill;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Rules\IsBoolean; use FireflyIII\Rules\IsBoolean;
use FireflyIII\Rules\IsValidPositiveAmount; use FireflyIII\Rules\IsValidPositiveAmount;
use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
use TypeError; use TypeError;
use ValueError; use ValueError;

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\Bill; namespace FireflyIII\Api\V1\Requests\Models\Bill;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Models\Bill; use FireflyIII\Models\Bill;
use FireflyIII\Rules\IsBoolean; use FireflyIII\Rules\IsBoolean;
use FireflyIII\Rules\IsValidPositiveAmount; use FireflyIII\Rules\IsValidPositiveAmount;
@@ -31,7 +32,6 @@ use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
/** /**
* Class UpdateRequest * Class UpdateRequest

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\Budget; namespace FireflyIII\Api\V1\Requests\Models\Budget;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Rules\IsBoolean; use FireflyIII\Rules\IsBoolean;
use FireflyIII\Rules\IsValidPositiveAmount; use FireflyIII\Rules\IsValidPositiveAmount;
use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ChecksLogin;
@@ -31,7 +32,6 @@ use FireflyIII\Support\Request\ConvertsDataTypes;
use FireflyIII\Validation\AutoBudget\ValidatesAutoBudgetRequest; use FireflyIII\Validation\AutoBudget\ValidatesAutoBudgetRequest;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
/** /**
* Class StoreRequest * Class StoreRequest

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\Budget; namespace FireflyIII\Api\V1\Requests\Models\Budget;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Models\Budget; use FireflyIII\Models\Budget;
use FireflyIII\Rules\IsBoolean; use FireflyIII\Rules\IsBoolean;
use FireflyIII\Rules\IsValidPositiveAmount; use FireflyIII\Rules\IsValidPositiveAmount;
@@ -32,7 +33,6 @@ use FireflyIII\Support\Request\ConvertsDataTypes;
use FireflyIII\Validation\AutoBudget\ValidatesAutoBudgetRequest; use FireflyIII\Validation\AutoBudget\ValidatesAutoBudgetRequest;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
/** /**
* Class UpdateRequest * Class UpdateRequest

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\BudgetLimit; namespace FireflyIII\Api\V1\Requests\Models\BudgetLimit;
use Illuminate\Contracts\Validation\Validator;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Factory\TransactionCurrencyFactory; use FireflyIII\Factory\TransactionCurrencyFactory;
use FireflyIII\Rules\IsBoolean; use FireflyIII\Rules\IsBoolean;
@@ -33,7 +34,6 @@ use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
/** /**
* Class StoreRequest * Class StoreRequest

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\BudgetLimit; namespace FireflyIII\Api\V1\Requests\Models\BudgetLimit;
use Illuminate\Contracts\Validation\Validator;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Rules\IsBoolean; use FireflyIII\Rules\IsBoolean;
use FireflyIII\Rules\IsValidPositiveAmount; use FireflyIII\Rules\IsValidPositiveAmount;
@@ -31,7 +32,6 @@ use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
/** /**
* Class UpdateRequest * Class UpdateRequest

View File

@@ -24,12 +24,12 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\CurrencyExchangeRate; namespace FireflyIII\Api\V1\Requests\Models\CurrencyExchangeRate;
use Illuminate\Contracts\Validation\Validator;
use Carbon\Carbon; use Carbon\Carbon;
use Carbon\Exceptions\InvalidFormatException; use Carbon\Exceptions\InvalidFormatException;
use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Validator;
class StoreByCurrenciesRequest extends FormRequest class StoreByCurrenciesRequest extends FormRequest
{ {

View File

@@ -24,13 +24,13 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\CurrencyExchangeRate; namespace FireflyIII\Api\V1\Requests\Models\CurrencyExchangeRate;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Support\Facades\Amount; use FireflyIII\Support\Facades\Amount;
use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Validator;
class StoreByDateRequest extends FormRequest class StoreByDateRequest extends FormRequest
{ {

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\PiggyBank; namespace FireflyIII\Api\V1\Requests\Models\PiggyBank;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Rules\IsValidZeroOrMoreAmount; use FireflyIII\Rules\IsValidZeroOrMoreAmount;
@@ -32,7 +33,6 @@ use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
/** /**
* Class StoreRequest * Class StoreRequest

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\Recurrence; namespace FireflyIII\Api\V1\Requests\Models\Recurrence;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Rules\BelongsUser; use FireflyIII\Rules\BelongsUser;
use FireflyIII\Rules\IsBoolean; use FireflyIII\Rules\IsBoolean;
use FireflyIII\Rules\IsValidPositiveAmount; use FireflyIII\Rules\IsValidPositiveAmount;
@@ -35,7 +36,6 @@ use FireflyIII\Validation\RecurrenceValidation;
use FireflyIII\Validation\TransactionValidation; use FireflyIII\Validation\TransactionValidation;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
/** /**
* Class StoreRequest * Class StoreRequest

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\Recurrence; namespace FireflyIII\Api\V1\Requests\Models\Recurrence;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Models\Recurrence; use FireflyIII\Models\Recurrence;
use FireflyIII\Rules\BelongsUser; use FireflyIII\Rules\BelongsUser;
use FireflyIII\Rules\IsBoolean; use FireflyIII\Rules\IsBoolean;
@@ -36,7 +37,6 @@ use FireflyIII\Validation\RecurrenceValidation;
use FireflyIII\Validation\TransactionValidation; use FireflyIII\Validation\TransactionValidation;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
/** /**
* Class UpdateRequest * Class UpdateRequest

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\Rule; namespace FireflyIII\Api\V1\Requests\Models\Rule;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Rules\IsBoolean; use FireflyIII\Rules\IsBoolean;
use FireflyIII\Rules\IsValidActionExpression; use FireflyIII\Rules\IsValidActionExpression;
use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ChecksLogin;
@@ -31,7 +32,6 @@ use FireflyIII\Support\Request\ConvertsDataTypes;
use FireflyIII\Support\Request\GetRuleConfiguration; use FireflyIII\Support\Request\GetRuleConfiguration;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
/** /**
* Class StoreRequest * Class StoreRequest
@@ -202,7 +202,7 @@ class StoreRequest extends FormRequest
$inactiveIndex = $index; $inactiveIndex = $index;
} }
} }
if (true === $allInactive) { if ($allInactive) {
$validator->errors()->add(sprintf('triggers.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_trigger')); $validator->errors()->add(sprintf('triggers.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_trigger'));
} }
} }
@@ -231,7 +231,7 @@ class StoreRequest extends FormRequest
$inactiveIndex = $index; $inactiveIndex = $index;
} }
} }
if (true === $allInactive) { if ($allInactive) {
$validator->errors()->add(sprintf('actions.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_action')); $validator->errors()->add(sprintf('actions.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_action'));
} }
} }

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\Rule; namespace FireflyIII\Api\V1\Requests\Models\Rule;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Models\Rule; use FireflyIII\Models\Rule;
use FireflyIII\Rules\IsBoolean; use FireflyIII\Rules\IsBoolean;
use FireflyIII\Rules\IsValidActionExpression; use FireflyIII\Rules\IsValidActionExpression;
@@ -32,7 +33,6 @@ use FireflyIII\Support\Request\ConvertsDataTypes;
use FireflyIII\Support\Request\GetRuleConfiguration; use FireflyIII\Support\Request\GetRuleConfiguration;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
/** /**
* Class UpdateRequest * Class UpdateRequest
@@ -207,7 +207,7 @@ class UpdateRequest extends FormRequest
$inactiveIndex = $index; $inactiveIndex = $index;
} }
} }
if (true === $allInactive) { if ($allInactive) {
$validator->errors()->add(sprintf('triggers.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_trigger')); $validator->errors()->add(sprintf('triggers.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_trigger'));
} }
} }
@@ -248,7 +248,7 @@ class UpdateRequest extends FormRequest
$inactiveIndex = $index; $inactiveIndex = $index;
} }
} }
if (true === $allInactive) { if ($allInactive) {
$validator->errors()->add(sprintf('actions.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_action')); $validator->errors()->add(sprintf('actions.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_action'));
} }
} }

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\Transaction; namespace FireflyIII\Api\V1\Requests\Models\Transaction;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Models\Location; use FireflyIII\Models\Location;
use FireflyIII\Rules\BelongsUser; use FireflyIII\Rules\BelongsUser;
use FireflyIII\Rules\IsBoolean; use FireflyIII\Rules\IsBoolean;
@@ -39,7 +40,6 @@ use FireflyIII\Validation\GroupValidation;
use FireflyIII\Validation\TransactionValidation; use FireflyIII\Validation\TransactionValidation;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
/** /**
* Class StoreRequest * Class StoreRequest

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\Transaction; namespace FireflyIII\Api\V1\Requests\Models\Transaction;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\TransactionGroup; use FireflyIII\Models\TransactionGroup;
use FireflyIII\Rules\BelongsUser; use FireflyIII\Rules\BelongsUser;
@@ -37,7 +38,6 @@ use FireflyIII\Validation\GroupValidation;
use FireflyIII\Validation\TransactionValidation; use FireflyIII\Validation\TransactionValidation;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
/** /**
* Class UpdateRequest * Class UpdateRequest

View File

@@ -23,8 +23,8 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\TransactionCurrency; namespace FireflyIII\Api\V1\Requests\Models\TransactionCurrency;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Api\V1\Requests\ApiRequest; use FireflyIII\Api\V1\Requests\ApiRequest;
use Illuminate\Validation\Validator;
class CurrencyCodeRequest extends ApiRequest class CurrencyCodeRequest extends ApiRequest
{ {

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\TransactionLink; namespace FireflyIII\Api\V1\Requests\Models\TransactionLink;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface; use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ChecksLogin;
@@ -31,7 +32,6 @@ use FireflyIII\Support\Request\ConvertsDataTypes;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
/** /**
* Class StoreRequest * Class StoreRequest

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\TransactionLink; namespace FireflyIII\Api\V1\Requests\Models\TransactionLink;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Models\TransactionJournalLink; use FireflyIII\Models\TransactionJournalLink;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface; use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
@@ -31,7 +32,6 @@ use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
/** /**
* Class UpdateRequest * Class UpdateRequest

View File

@@ -52,7 +52,7 @@ class CreateRequest extends FormRequest
$responses = $this->get('responses', []); $responses = $this->get('responses', []);
$deliveries = $this->get('deliveries', []); $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.'); throw new FireflyException('Unexpectedly got no responses, triggers or deliveries.');
} }

View File

@@ -53,7 +53,7 @@ class UpdateRequest extends FormRequest
$responses = $this->get('responses', []); $responses = $this->get('responses', []);
$deliveries = $this->get('deliveries', []); $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.'); throw new FireflyException('Unexpectedly got no responses, triggers or deliveries.');
} }

View File

@@ -23,16 +23,18 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests; namespace FireflyIII\Api\V1\Requests;
use Override;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Rules\IsValidSortInstruction; use FireflyIII\Rules\IsValidSortInstruction;
use FireflyIII\Support\Facades\Preferences; use FireflyIII\Support\Facades\Preferences;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Validation\Validator;
use RuntimeException; use RuntimeException;
class PaginationRequest extends ApiRequest class PaginationRequest extends ApiRequest
{ {
private ?string $sortClass = null; private ?string $sortClass = null;
#[Override]
public function handleConfig(array $config): void public function handleConfig(array $config): void
{ {
parent::handleConfig($config); parent::handleConfig($config);

View File

@@ -24,13 +24,13 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\System; namespace FireflyIII\Api\V1\Requests\System;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Rules\IsBoolean; use FireflyIII\Rules\IsBoolean;
use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\ConvertsDataTypes;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
/** /**
* Class UserUpdateRequest * Class UserUpdateRequest

View File

@@ -220,7 +220,7 @@ class CorrectsAmounts extends Command
/** @var RuleTrigger $item */ /** @var RuleTrigger $item */
foreach ($set as $item) { foreach ($set as $item) {
$result = $this->fixRuleTrigger($item); $result = $this->fixRuleTrigger($item);
if (true === $result) { if ($result) {
++$fixed; ++$fixed;
} }
} }

View File

@@ -115,7 +115,7 @@ class CorrectsCurrencies extends Command
$found = array_values( $found = array_values(
array_filter( array_filter(
$found, $found,
static fn (int $currencyId) => 0 !== $currencyId static fn (int $currencyId): bool => 0 !== $currencyId
) )
); );

View File

@@ -55,10 +55,8 @@ class CorrectsGroupInformation extends Command
/** /**
* Execute the console 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 // objects: accounts, attachments, available budgets, bills, budgets, categories, currency_exchange_rates
// recurrences, rule groups, rules, tags, transaction groups, transaction journals, webhooks // recurrences, rule groups, rules, tags, transaction groups, transaction journals, webhooks

View File

@@ -93,25 +93,20 @@ class CorrectsIbans extends Command
if (in_array($type, [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value], true)) { if (in_array($type, [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value], true)) {
$type = 'liabilities'; $type = 'liabilities';
} }
if (array_key_exists($iban, $set[$userId])) { // iban already in use! two exceptions exist:
// 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))) {
if ( $this->friendlyWarning(
!(AccountTypeEnum::EXPENSE->value === $set[$userId][$iban] && AccountTypeEnum::REVENUE->value === $type) // allowed combination sprintf(
&& !(AccountTypeEnum::REVENUE->value === $set[$userId][$iban] && AccountTypeEnum::EXPENSE->value === $type) // also allowed combination. 'IBAN "%s" is used more than once and will be removed from %s #%d ("%s")',
) { $iban,
$this->friendlyWarning( $account->accountType->type,
sprintf( $account->id,
'IBAN "%s" is used more than once and will be removed from %s #%d ("%s")', $account->name
$iban, )
$account->accountType->type, );
$account->id, $account->iban = null;
$account->name $account->save();
) ++$this->count;
);
$account->iban = null;
$account->save();
++$this->count;
}
} }
if (!array_key_exists($iban, $set[$userId])) { if (!array_key_exists($iban, $set[$userId])) {

View File

@@ -130,7 +130,7 @@ class CorrectsPrimaryCurrencyAmounts extends Command
$repository->setUserGroup($userGroup); $repository->setUserGroup($userGroup);
$set = $repository->getPiggyBanks(); $set = $repository->getPiggyBanks();
$set = $set->filter( $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) { foreach ($set as $piggyBank) {
$piggyBank->encrypted = false; $piggyBank->encrypted = false;

View File

@@ -53,7 +53,7 @@ class CorrectsTransactionTypes extends Command
/** @var TransactionJournal $journal */ /** @var TransactionJournal $journal */
foreach ($journals as $journal) { foreach ($journals as $journal) {
$fixed = $this->fixJournal($journal); $fixed = $this->fixJournal($journal);
if (true === $fixed) { if ($fixed) {
++$count; ++$count;
} }
} }
@@ -115,7 +115,7 @@ class CorrectsTransactionTypes extends Command
private function getSourceAccount(TransactionJournal $journal): Account private function getSourceAccount(TransactionJournal $journal): Account
{ {
$collection = $journal->transactions->filter( $collection = $journal->transactions->filter(
static fn (Transaction $transaction) => $transaction->amount < 0 static fn (Transaction $transaction): bool => $transaction->amount < 0
); );
if (0 === $collection->count()) { if (0 === $collection->count()) {
throw new FireflyException(sprintf('300001: Journal #%d has no source transaction.', $journal->id)); 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 private function getDestinationAccount(TransactionJournal $journal): Account
{ {
$collection = $journal->transactions->filter( $collection = $journal->transactions->filter(
static fn (Transaction $transaction) => $transaction->amount > 0 static fn (Transaction $transaction): bool => $transaction->amount > 0
); );
if (0 === $collection->count()) { if (0 === $collection->count()) {
throw new FireflyException(sprintf('300004: Journal #%d has no destination transaction.', $journal->id)); throw new FireflyException(sprintf('300004: Journal #%d has no destination transaction.', $journal->id));

View File

@@ -251,27 +251,19 @@ class CorrectsUnevenAmount extends Command
/** @var Transaction $source */ /** @var Transaction $source */
$source = $journal->transactions()->where('amount', '<', 0)->first(); $source = $journal->transactions()->where('amount', '<', 0)->first();
// safety catch on NULL should not be necessary, we just had that catch. // safety catch on NULL should not be necessary, we just had that catch.
// source amount = dest foreign amount // source amount = dest foreign amount
// source currency = dest foreign currency // source currency = dest foreign currency
// dest amount = source foreign currency // dest amount = source foreign currency
// dest currency = 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('[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('[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('[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))); // Log::debug(sprintf('[d] %s', var_export((int) $destination->transaction_currency_id ===(int) $source->foreign_currency_id, true)));
return 0 === bccomp(Steam::positive($source->amount), Steam::positive($destination->foreign_amount))
if (0 === bccomp(Steam::positive($source->amount), Steam::positive($destination->foreign_amount))
&& $source->transaction_currency_id === $destination->foreign_currency_id && $source->transaction_currency_id === $destination->foreign_currency_id
&& 0 === bccomp(Steam::positive($destination->amount), Steam::positive($source->foreign_amount)) && 0 === bccomp(Steam::positive($destination->amount), Steam::positive($source->foreign_amount))
&& (int) $destination->transaction_currency_id === (int) $source->foreign_currency_id && (int) $destination->transaction_currency_id === (int) $source->foreign_currency_id;
) {
return true;
}
return false;
} }
private function matchCurrencies(): void private function matchCurrencies(): void

View File

@@ -56,7 +56,7 @@ class RestoresOAuthKeys extends Command
} }
if ($this->keysInDatabase() && !$this->keysOnDrive()) { if ($this->keysInDatabase() && !$this->keysOnDrive()) {
$result = $this->restoreKeysFromDB(); $result = $this->restoreKeysFromDB();
if (true === $result) { if ($result) {
$this->friendlyInfo('Restored OAuth keys from database.'); $this->friendlyInfo('Restored OAuth keys from database.');
return; return;

View File

@@ -206,7 +206,7 @@ class ExportsData extends Command
$error = true; $error = true;
} }
if (true === $error && 'start' === $field) { if ($error && 'start' === $field) {
$journal = $this->journalRepository->firstNull(); $journal = $this->journalRepository->firstNull();
$date = $journal instanceof TransactionJournal ? $journal->date : today(config('app.timezone'))->subYear(); $date = $journal instanceof TransactionJournal ? $journal->date : today(config('app.timezone'))->subYear();
$date->startOfDay(); $date->startOfDay();
@@ -214,7 +214,7 @@ class ExportsData extends Command
return $date; return $date;
} }
// field can only be 'end' at this point, so no need to include it in the check. // 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 = today(config('app.timezone'));
$date->endOfDay(); $date->endOfDay();

View File

@@ -86,7 +86,7 @@ class CreatesDatabase extends Command
$pdo->exec(sprintf('CREATE DATABASE `%s` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;', env('DB_DATABASE'))); $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'))); $this->friendlyInfo(sprintf('Created database "%s"', env('DB_DATABASE')));
} }
if (true === $exists) { if ($exists) {
$this->friendlyInfo(sprintf('Database "%s" exists.', env('DB_DATABASE'))); $this->friendlyInfo(sprintf('Database "%s" exists.', env('DB_DATABASE')));
} }

View File

@@ -132,11 +132,11 @@ class ForcesDecimalSize extends Command
{ {
// if sqlite, add function? // if sqlite, add function?
if ('sqlite' === (string) config('database.default')) { 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'); mb_regex_encoding('UTF-8');
$pattern = trim($pattern, '"'); $pattern = trim($pattern, '"');
return (false !== mb_ereg($pattern, (string) $value)) ? 1 : 0; return (mb_ereg($pattern, (string) $value)) ? 1 : 0;
}); });
} }

View File

@@ -314,7 +314,7 @@ class ApplyRules extends Command
foreach ($rules as $rule) { foreach ($rules as $rule) {
// if in rule selection, or group in selection or all rules, it's included. // if in rule selection, or group in selection or all rules, it's included.
$test = $this->includeRule($rule, $group); $test = $this->includeRule($rule, $group);
if (true === $test) { if ($test) {
Log::debug(sprintf('Will include rule #%d "%s"', $rule->id, $rule->title)); Log::debug(sprintf('Will include rule #%d "%s"', $rule->id, $rule->title));
$rulesToApply->push($rule); $rulesToApply->push($rule);
} }

View File

@@ -136,11 +136,7 @@ class UpgradesLiabilitiesEight extends Command
if (null === $liabilityJournal) { if (null === $liabilityJournal) {
return false; return false;
} }
if (!$openingJournal->date->isSameDay($liabilityJournal->date)) { return (bool) $openingJournal->date->isSameDay($liabilityJournal->date);
return false;
}
return true;
} }
private function deleteCreditTransaction(Account $account): void private function deleteCreditTransaction(Account $account): void

View File

@@ -77,7 +77,7 @@ class UpgradesTagLocations extends Command
private function hasLocationDetails(Tag $tag): bool 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 private function migrateLocationDetails(Tag $tag): void

View File

@@ -180,7 +180,7 @@ class UpgradesToGroups extends Command
private function getDestinationTransactions(TransactionJournal $journal): Collection private function getDestinationTransactions(TransactionJournal $journal): Collection
{ {
return $journal->transactions->filter( 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 private function findOpposingTransaction(TransactionJournal $journal, Transaction $transaction): ?Transaction
{ {
$set = $journal->transactions->filter( $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 $amount = (float) $transaction->amount * -1 === (float) $subject->amount; // intentional float
$identifier = $transaction->identifier === $subject->identifier; $identifier = $transaction->identifier === $subject->identifier;
Log::debug(sprintf('Amount the same? %s', var_export($amount, true))); Log::debug(sprintf('Amount the same? %s', var_export($amount, true)));

View File

@@ -211,7 +211,6 @@ class UpgradesVariousCurrencyInformation extends Command
break; break;
} }
/** @var null|Transaction */
return $lead; return $lead;
} }

View File

@@ -84,7 +84,7 @@ class UpgradesWebhooks extends Command
$delivery = WebhookDelivery::tryFrom((int)$webhook->delivery); $delivery = WebhookDelivery::tryFrom((int)$webhook->delivery);
$response = WebhookResponse::tryFrom((int)$webhook->response); $response = WebhookResponse::tryFrom((int)$webhook->response);
$trigger = WebhookTrigger::tryFrom((int)$webhook->trigger); $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)); $this->friendlyError(sprintf('[a] Webhook #%d has an invalid delivery, response or trigger value. Will not upgrade.', $webhook->id));
return; return;
@@ -92,7 +92,7 @@ class UpgradesWebhooks extends Command
$deliveryModel = WebhookDeliveryModel::where('key', $delivery->value)->first(); $deliveryModel = WebhookDeliveryModel::where('key', $delivery->value)->first();
$responseModel = WebhookResponseModel::where('key', $response->value)->first(); $responseModel = WebhookResponseModel::where('key', $response->value)->first();
$triggerModel = WebhookTriggerModel::where('key', $trigger->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)); $this->friendlyError(sprintf('[b] Webhook #%d has an invalid delivery, response or trigger model. Will not upgrade.', $webhook->id));
return; return;

View File

@@ -50,10 +50,8 @@ class RequestedReportOnJournals
/** /**
* Get the channels the event should broadcast on. * Get the channels the event should broadcast on.
*
* @return PrivateChannel
*/ */
public function broadcastOn() public function broadcastOn(): PrivateChannel
{ {
return new PrivateChannel('channel-name'); return new PrivateChannel('channel-name');
} }

View File

@@ -194,7 +194,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
$user = auth()->user(); $user = auth()->user();
$route = $request->route(); $route = $request->route();
$param = $route->parameter('transactionGroup'); $param = $route->parameter('transactionGroup');
$groupId = !is_object($param) ? (int) $param : 0; $groupId = is_object($param) ? 0 : (int) $param;
/** @var null|TransactionGroup $group */ /** @var null|TransactionGroup $group */
$group = $user->transactionGroups()->withTrashed()->find($groupId); $group = $user->transactionGroups()->withTrashed()->find($groupId);

View File

@@ -274,7 +274,7 @@ class Handler extends ExceptionHandler
{ {
return null !== Arr::first( return null !== Arr::first(
$this->dontReport, $this->dontReport,
static fn ($type) => $e instanceof $type static fn ($type): bool => $e instanceof $type
); );
} }

View File

@@ -33,8 +33,8 @@ use Throwable;
*/ */
final class IntervalException extends Exception final class IntervalException extends Exception
{ {
public array $availableIntervals; public array $availableIntervals = [];
public Periodicity $periodicity; public Periodicity $periodicity = Periodicity::Monthly;
/** @var mixed */ /** @var mixed */
protected $message = 'The periodicity %s is unknown. Choose one of available periodicity: %s'; protected $message = 'The periodicity %s is unknown. Choose one of available periodicity: %s';
@@ -42,8 +42,6 @@ final class IntervalException extends Exception
public function __construct(string $message = '', int $code = 0, ?Throwable $previous = null) public function __construct(string $message = '', int $code = 0, ?Throwable $previous = null)
{ {
parent::__construct($message, $code, $previous); parent::__construct($message, $code, $previous);
$this->availableIntervals = [];
$this->periodicity = Periodicity::Monthly;
} }
public static function unavailable( public static function unavailable(

View File

@@ -130,7 +130,7 @@ class AccountFactory
protected function getAccountType(array $data): ?AccountType protected function getAccountType(array $data): ?AccountType
{ {
$accountTypeId = array_key_exists('account_type_id', $data) ? (int) $data['account_type_id'] : 0; $accountTypeId = array_key_exists('account_type_id', $data) ? (int) $data['account_type_id'] : 0;
$accountTypeName = array_key_exists('account_type_name', $data) ? $data['account_type_name'] : null; $accountTypeName = $data['account_type_name'] ?? null;
$result = null; $result = null;
// find by name or ID // find by name or ID
if ($accountTypeId > 0) { if ($accountTypeId > 0) {
@@ -174,7 +174,7 @@ class AccountFactory
$this->accountRepository->resetAccountOrder(); $this->accountRepository->resetAccountOrder();
// create it: // 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; $active = array_key_exists('active', $data) ? $data['active'] : true;
$databaseData = [ $databaseData = [
'user_id' => $this->user->id, 'user_id' => $this->user->id,

View File

@@ -44,8 +44,8 @@ class AttachmentFactory
public function create(array $data): ?Attachment public function create(array $data): ?Attachment
{ {
// append if necessary. // append if necessary.
$model = !str_contains((string) $data['attachable_type'], 'FireflyIII') ? sprintf('FireflyIII\Models\%s', $data['attachable_type']) $model = str_contains((string) $data['attachable_type'], 'FireflyIII') ? $data['attachable_type']
: $data['attachable_type']; : sprintf('FireflyIII\Models\%s', $data['attachable_type']);
// get journal instead of transaction. // get journal instead of transaction.
if (Transaction::class === $model) { if (Transaction::class === $model) {

View File

@@ -89,7 +89,7 @@ class TagFactory
/** @var null|Tag $tag */ /** @var null|Tag $tag */
$tag = Tag::create($array); $tag = Tag::create($array);
if (null !== $tag && null !== $latitude && null !== $longitude) { if (!in_array(null, [$tag, $latitude, $longitude], true)) {
// create location object. // create location object.
$location = new Location(); $location = new Location();
$location->latitude = $latitude; $location->latitude = $latitude;

View File

@@ -41,20 +41,11 @@ use Illuminate\Support\Facades\Log;
class TransactionFactory class TransactionFactory
{ {
private Account $account; private Account $account;
private array $accountInformation; private array $accountInformation = [];
private TransactionCurrency $currency; private TransactionCurrency $currency;
private ?TransactionCurrency $foreignCurrency = null; private ?TransactionCurrency $foreignCurrency = null;
private TransactionJournal $journal; private TransactionJournal $journal;
private bool $reconciled; private bool $reconciled = false;
/**
* Constructor.
*/
public function __construct()
{
$this->reconciled = false;
$this->accountInformation = [];
}
/** /**
* Create transaction with negative amount (for source accounts). * Create transaction with negative amount (for source accounts).

View File

@@ -71,7 +71,7 @@ class TransactionJournalFactory
private AccountValidator $accountValidator; private AccountValidator $accountValidator;
private BillRepositoryInterface $billRepository; private BillRepositoryInterface $billRepository;
private CurrencyRepositoryInterface $currencyRepository; private CurrencyRepositoryInterface $currencyRepository;
private bool $errorOnHash; private bool $errorOnHash = false;
private array $fields; private array $fields;
private PiggyBankEventFactory $piggyEventFactory; private PiggyBankEventFactory $piggyEventFactory;
private PiggyBankRepositoryInterface $piggyRepository; private PiggyBankRepositoryInterface $piggyRepository;
@@ -86,7 +86,6 @@ class TransactionJournalFactory
*/ */
public function __construct() public function __construct()
{ {
$this->errorOnHash = false;
$this->fields = config('firefly.journal_meta_fields'); $this->fields = config('firefly.journal_meta_fields');
$this->currencyRepository = app(CurrencyRepositoryInterface::class); $this->currencyRepository = app(CurrencyRepositoryInterface::class);
$this->typeRepository = app(TransactionTypeRepositoryInterface::class); $this->typeRepository = app(TransactionTypeRepositoryInterface::class);
@@ -237,7 +236,7 @@ class TransactionJournalFactory
Log::debug('Done with getAccount(2x)'); 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. // 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.'); Log::warning('Destination account is NULL, will replace with cash account.');
$destinationAccount = $this->accountRepository->getCashAccount(); $destinationAccount = $this->accountRepository->getCashAccount();
} }
@@ -615,7 +614,7 @@ class TransactionJournalFactory
private function storeLocation(TransactionJournal $journal, NullArrayObject $data): void 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 = new Location();
$location->longitude = $data['longitude']; $location->longitude = $data['longitude'];
$location->latitude = $data['latitude']; $location->latitude = $data['latitude'];
@@ -628,7 +627,7 @@ class TransactionJournalFactory
public function setErrorOnHash(bool $errorOnHash): void public function setErrorOnHash(bool $errorOnHash): void
{ {
$this->errorOnHash = $errorOnHash; $this->errorOnHash = $errorOnHash;
if (true === $errorOnHash) { if ($errorOnHash) {
Log::info('Will trigger duplication alert for this journal.'); Log::info('Will trigger duplication alert for this journal.');
} }
} }

View File

@@ -53,7 +53,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
$preferredPeriod = $this->preferredPeriod(); $preferredPeriod = $this->preferredPeriod();
try { 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('start', $this->start)->with('end', $this->end)
->with('doubles', $this->expense) ->with('doubles', $this->expense)
->render() ->render()

View File

@@ -100,7 +100,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
]; ];
try { 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) ->with('start', $this->start)->with('end', $this->end)->with('accounts', $this->accounts)
->render() ->render()
; ;

View File

@@ -41,17 +41,9 @@ class MonthReportGenerator implements ReportGeneratorInterface
private Collection $accounts; private Collection $accounts;
private Collection $budgets; private Collection $budgets;
private Carbon $end; private Carbon $end;
private array $expenses; private array $expenses = [];
private Carbon $start; private Carbon $start;
/**
* MonthReportGenerator constructor.
*/
public function __construct()
{
$this->expenses = [];
}
/** /**
* Generates the report. * Generates the report.
* *
@@ -65,7 +57,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
try { try {
$result = view( $result = view(
'reports.budget.month', 'reports.budget.month',
compact('accountIds', 'budgetIds') ['accountIds' => $accountIds, 'budgetIds' => $budgetIds]
) )
->with('start', $this->start)->with('end', $this->end) ->with('start', $this->start)->with('end', $this->end)
->with('budgets', $this->budgets) ->with('budgets', $this->budgets)

View File

@@ -41,19 +41,10 @@ class MonthReportGenerator implements ReportGeneratorInterface
private Collection $accounts; private Collection $accounts;
private Collection $categories; private Collection $categories;
private Carbon $end; private Carbon $end;
private array $expenses; private array $expenses = [];
private array $income; private array $income = [];
private Carbon $start; private Carbon $start;
/**
* MonthReportGenerator constructor.
*/
public function __construct()
{
$this->income = [];
$this->expenses = [];
}
/** /**
* Generates the report. * Generates the report.
* *
@@ -67,7 +58,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
// render! // render!
try { 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('start', $this->start)->with('end', $this->end)
->with('categories', $this->categories) ->with('categories', $this->categories)
->with('accounts', $this->accounts) ->with('accounts', $this->accounts)

View File

@@ -36,13 +36,13 @@ use Illuminate\Support\Facades\Log;
class MonthReportGenerator implements ReportGeneratorInterface class MonthReportGenerator implements ReportGeneratorInterface
{ {
/** @var Collection The accounts involved in the report. */ /** @var Collection The accounts involved in the report. */
private $accounts; private ?Collection $accounts = null;
/** @var Carbon The end date. */ /** @var Carbon The end date. */
private $end; private ?Carbon $end = null;
/** @var Carbon The start date. */ /** @var Carbon The start date. */
private $start; private ?Carbon $start = null;
/** /**
* Generates the report. * Generates the report.
@@ -55,7 +55,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
$reportType = 'default'; $reportType = 'default';
try { 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) { } catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.default.month: %s', $e->getMessage())); Log::error(sprintf('Cannot render reports.default.month: %s', $e->getMessage()));
Log::error($e->getTraceAsString()); Log::error($e->getTraceAsString());

View File

@@ -36,13 +36,13 @@ use Illuminate\Support\Facades\Log;
class MultiYearReportGenerator implements ReportGeneratorInterface class MultiYearReportGenerator implements ReportGeneratorInterface
{ {
/** @var Collection The accounts involved. */ /** @var Collection The accounts involved. */
private $accounts; private ?Collection $accounts = null;
/** @var Carbon The end date. */ /** @var Carbon The end date. */
private $end; private ?Carbon $end = null;
/** @var Carbon The start date. */ /** @var Carbon The start date. */
private $start; private ?Carbon $start = null;
/** /**
* Generates the report. * Generates the report.
@@ -58,7 +58,7 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
try { try {
return view( return view(
'reports.default.multi-year', 'reports.default.multi-year',
compact('accountIds', 'reportType') ['accountIds' => $accountIds, 'reportType' => $reportType]
)->with('start', $this->start)->with('end', $this->end)->render(); )->with('start', $this->start)->with('end', $this->end)->render();
} catch (Throwable $e) { } catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.default.multi-year: %s', $e->getMessage())); Log::error(sprintf('Cannot render reports.default.multi-year: %s', $e->getMessage()));

View File

@@ -36,13 +36,13 @@ use Illuminate\Support\Facades\Log;
class YearReportGenerator implements ReportGeneratorInterface class YearReportGenerator implements ReportGeneratorInterface
{ {
/** @var Collection The accounts involved. */ /** @var Collection The accounts involved. */
private $accounts; private ?Collection $accounts = null;
/** @var Carbon The end date. */ /** @var Carbon The end date. */
private $end; private ?Carbon $end = null;
/** @var Carbon The start date. */ /** @var Carbon The start date. */
private $start; private ?Carbon $start = null;
/** /**
* Generates the report. * Generates the report.
@@ -58,7 +58,7 @@ class YearReportGenerator implements ReportGeneratorInterface
try { try {
$result = view( $result = view(
'reports.default.year', 'reports.default.year',
compact('accountIds', 'reportType') ['accountIds' => $accountIds, 'reportType' => $reportType]
)->with('start', $this->start)->with('end', $this->end)->render(); )->with('start', $this->start)->with('end', $this->end)->render();
} catch (Throwable $e) { } catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.account.report: %s', $e->getMessage())); Log::error(sprintf('Cannot render reports.account.report: %s', $e->getMessage()));

View File

@@ -65,7 +65,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
try { try {
$result = view( $result = view(
'reports.tag.month', '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(); )->with('start', $this->start)->with('end', $this->end)->with('tags', $this->tags)->with('accounts', $this->accounts)->render();
} catch (Throwable $e) { } catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.tag.month: %s', $e->getMessage())); Log::error(sprintf('Cannot render reports.tag.month: %s', $e->getMessage()));

View File

@@ -130,7 +130,7 @@ class StandardMessageGenerator implements MessageGeneratorInterface
/** @var WebhookResponseModel $response */ /** @var WebhookResponseModel $response */
$response = $webhook->webhookResponses()->first(); $response = $webhook->webhookResponses()->first();
$triggers = $this->getTriggerTitles($webhook->webhookTriggers()->get()); $this->getTriggerTitles($webhook->webhookTriggers()->get());
$basicMessage = [ $basicMessage = [
'uuid' => $uuid->toString(), 'uuid' => $uuid->toString(),
'user_id' => 0, 'user_id' => 0,
@@ -171,7 +171,7 @@ class StandardMessageGenerator implements MessageGeneratorInterface
break; break;
} }
$responseTitle = $this->getRelevantResponse($triggers, $response, $class); $responseTitle = $this->getRelevantResponse($response, $class);
switch ($responseTitle) { switch ($responseTitle) {
default: default:
@@ -298,7 +298,7 @@ class StandardMessageGenerator implements MessageGeneratorInterface
$this->webhooks = $webhooks; $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. // return none if none.
if (WebhookResponse::NONE->name === $response->title) { if (WebhookResponse::NONE->name === $response->title) {

View File

@@ -133,7 +133,7 @@ class UserEventHandler
$group = null; $group = null;
// create a new group. // create a new group.
while (true === $groupExists) { // @phpstan-ignore-line while ($groupExists) { // @phpstan-ignore-line
$groupExists = UserGroup::where('title', $groupTitle)->count() > 0; $groupExists = UserGroup::where('title', $groupTitle)->count() > 0;
if (false === $groupExists) { if (false === $groupExists) {
$group = UserGroup::create(['title' => $groupTitle]); $group = UserGroup::create(['title' => $groupTitle]);

View File

@@ -49,7 +49,7 @@ class WebhookEventHandler
$messages = WebhookMessage::where('webhook_messages.sent', false) $messages = WebhookMessage::where('webhook_messages.sent', false)
->get(['webhook_messages.*']) ->get(['webhook_messages.*'])
->filter( ->filter(
static fn (WebhookMessage $message) => $message->webhookAttempts()->count() <= 2 static fn (WebhookMessage $message): bool => $message->webhookAttempts()->count() <= 2
)->splice(0, 5) )->splice(0, 5)
; ;
Log::debug(sprintf('Found %d webhook message(s) ready to be send.', $messages->count())); Log::debug(sprintf('Found %d webhook message(s) ready to be send.', $messages->count()));

View File

@@ -39,11 +39,9 @@ class TransactionObserver
public function created(Transaction $transaction): void public function created(Transaction $transaction): void
{ {
Log::debug('Observe "created" of a transaction.'); Log::debug('Observe "created" of a transaction.');
if (true === config('firefly.feature_flags.running_balance_column')) { if (true === config('firefly.feature_flags.running_balance_column') && (1 === bccomp($transaction->amount, '0') && self::$recalculate)) {
if (1 === bccomp($transaction->amount, '0') && true === self::$recalculate) { Log::debug('Trigger recalculateForJournal');
Log::debug('Trigger recalculateForJournal'); AccountBalanceCalculator::recalculateForJournal($transaction->transactionJournal);
AccountBalanceCalculator::recalculateForJournal($transaction->transactionJournal);
}
} }
$this->updatePrimaryCurrencyAmount($transaction); $this->updatePrimaryCurrencyAmount($transaction);
} }
@@ -84,11 +82,9 @@ class TransactionObserver
public function updated(Transaction $transaction): void public function updated(Transaction $transaction): void
{ {
// Log::debug('Observe "updated" of a transaction.'); // Log::debug('Observe "updated" of a transaction.');
if (true === config('firefly.feature_flags.running_balance_column') && true === self::$recalculate) { if (true === config('firefly.feature_flags.running_balance_column') && self::$recalculate && 1 === bccomp($transaction->amount, '0')) {
if (1 === bccomp($transaction->amount, '0')) { Log::debug('Trigger recalculateForJournal');
Log::debug('Trigger recalculateForJournal'); AccountBalanceCalculator::recalculateForJournal($transaction->transactionJournal);
AccountBalanceCalculator::recalculateForJournal($transaction->transactionJournal);
}
} }
$this->updatePrimaryCurrencyAmount($transaction); $this->updatePrimaryCurrencyAmount($transaction);
} }

View File

@@ -229,7 +229,7 @@ class AttachmentHelper implements AttachmentHelperInterface
Log::debug('Now in processFile()'); Log::debug('Now in processFile()');
$validation = $this->validateUpload($file, $model); $validation = $this->validateUpload($file, $model);
$attachment = null; $attachment = null;
if (false !== $validation) { if ($validation) {
$user = $model->user; $user = $model->user;
// ignore lines about polymorphic calls. // ignore lines about polymorphic calls.
if ($model instanceof PiggyBank) { if ($model instanceof PiggyBank) {
@@ -289,11 +289,11 @@ class AttachmentHelper implements AttachmentHelperInterface
} }
// can't seem to reach this point. // can't seem to reach this point.
if (true === $result && !$this->validSize($file)) { if ($result && !$this->validSize($file)) {
$result = false; $result = false;
} }
if (true === $result && $this->hasFile($file, $model)) { if ($result && $this->hasFile($file, $model)) {
return false; return false;
} }

View File

@@ -27,7 +27,6 @@ namespace FireflyIII\Helpers\Collector\Extensions;
use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\Attachment; use FireflyIII\Models\Attachment;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder; use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
@@ -55,7 +54,7 @@ trait AttachmentCollection
strtolower((string) $attachment['title']), strtolower((string) $attachment['title']),
strtolower($name) strtolower($name)
); );
if (true === $result) { if ($result) {
return true; return true;
} }
} }
@@ -135,7 +134,7 @@ trait AttachmentCollection
strtolower((string) $attachment['title']), strtolower((string) $attachment['title']),
strtolower($name) strtolower($name)
); );
if (true === $result) { if ($result) {
return true; return true;
} }
} }
@@ -169,7 +168,7 @@ trait AttachmentCollection
strtolower((string) $attachment['title']), strtolower((string) $attachment['title']),
strtolower($name) strtolower($name)
); );
if (true === $result) { if ($result) {
return true; return true;
} }
} }
@@ -203,7 +202,7 @@ trait AttachmentCollection
strtolower((string) $attachment['title']), strtolower((string) $attachment['title']),
strtolower($name) strtolower($name)
); );
if (true === $result) { if ($result) {
return true; return true;
} }
} }
@@ -229,7 +228,7 @@ trait AttachmentCollection
strtolower((string) $attachment['title']), strtolower((string) $attachment['title']),
strtolower($name) strtolower($name)
); );
if (true === $result) { if ($result) {
return true; return true;
} }
} }
@@ -252,7 +251,7 @@ trait AttachmentCollection
/** @var array $attachment */ /** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) { foreach ($transaction['attachments'] as $attachment) {
$result = $attachment['filename'] === $name || $attachment['title'] === $name; $result = $attachment['filename'] === $name || $attachment['title'] === $name;
if (true === $result) { if ($result) {
return true; return true;
} }
} }
@@ -275,7 +274,7 @@ trait AttachmentCollection
/** @var array $attachment */ /** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) { foreach ($transaction['attachments'] as $attachment) {
$result = $attachment['filename'] !== $name && $attachment['title'] !== $name; $result = $attachment['filename'] !== $name && $attachment['title'] !== $name;
if (true === $result) { if ($result) {
return true; return true;
} }
} }
@@ -301,7 +300,7 @@ trait AttachmentCollection
strtolower((string) $attachment['title']), strtolower((string) $attachment['title']),
strtolower($name) strtolower($name)
); );
if (true === $result) { if ($result) {
return true; return true;
} }
} }
@@ -514,10 +513,10 @@ trait AttachmentCollection
Log::debug('Add filter on no attachments.'); Log::debug('Add filter on no attachments.');
$this->joinAttachmentTables(); $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 $q1
->whereNull('attachments.attachable_id') ->whereNull('attachments.attachable_id')
->orWhere(static function (Builder $q2): void { ->orWhere(static function (EloquentBuilder $q2): void {
$q2 $q2
->whereNotNull('attachments.attachable_id') ->whereNotNull('attachments.attachable_id')
->whereNotNull('attachments.deleted_at') ->whereNotNull('attachments.deleted_at')

View File

@@ -31,7 +31,6 @@ use FireflyIII\Models\Budget;
use FireflyIII\Models\Category; use FireflyIII\Models\Category;
use FireflyIII\Models\Tag; use FireflyIII\Models\Tag;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder; use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Query\JoinClause; use Illuminate\Database\Query\JoinClause;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
@@ -170,7 +169,7 @@ trait MetaCollection
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'external_id'); $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'); $this->query->whereNull('journal_meta.deleted_at');
return $this; return $this;
@@ -214,7 +213,7 @@ trait MetaCollection
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'recurrence_id'); $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; return $this;
} }
@@ -511,7 +510,7 @@ trait MetaCollection
public function notesDoNotContain(string $value): GroupCollectorInterface public function notesDoNotContain(string $value): GroupCollectorInterface
{ {
$this->withNotes(); $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->whereNull('notes.text');
$q->orWhereNotLike('notes.text', sprintf('%%%s%%', $value)); $q->orWhereNotLike('notes.text', sprintf('%%%s%%', $value));
}); });
@@ -522,7 +521,7 @@ trait MetaCollection
public function notesDontEndWith(string $value): GroupCollectorInterface public function notesDontEndWith(string $value): GroupCollectorInterface
{ {
$this->withNotes(); $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->whereNull('notes.text');
$q->orWhereNotLike('notes.text', sprintf('%%%s', $value)); $q->orWhereNotLike('notes.text', sprintf('%%%s', $value));
}); });
@@ -533,7 +532,7 @@ trait MetaCollection
public function notesDontStartWith(string $value): GroupCollectorInterface public function notesDontStartWith(string $value): GroupCollectorInterface
{ {
$this->withNotes(); $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->whereNull('notes.text');
$q->orWhereNotLike('notes.text', sprintf('%s%%', $value)); $q->orWhereNotLike('notes.text', sprintf('%s%%', $value));
}); });
@@ -552,7 +551,7 @@ trait MetaCollection
public function notesExactly(string $value): GroupCollectorInterface public function notesExactly(string $value): GroupCollectorInterface
{ {
$this->withNotes(); $this->withNotes();
$this->query->where('notes.text', '=', sprintf('%s', $value)); $this->query->where('notes.text', '=', $value);
return $this; return $this;
} }
@@ -560,9 +559,9 @@ trait MetaCollection
public function notesExactlyNot(string $value): GroupCollectorInterface public function notesExactlyNot(string $value): GroupCollectorInterface
{ {
$this->withNotes(); $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->whereNull('notes.text');
$q->orWhere('notes.text', '!=', sprintf('%s', $value)); $q->orWhere('notes.text', '!=', $value);
}); });
return $this; return $this;
@@ -587,7 +586,7 @@ trait MetaCollection
// this method adds a "postFilter" to the collector. // this method adds a "postFilter" to the collector.
$list = $tags->pluck('tag')->toArray(); $list = $tags->pluck('tag')->toArray();
$list = array_map('strtolower', $list); $list = array_map(strtolower(...), $list);
$filter = static function (array $object) use ($list): bool|array { $filter = static function (array $object) use ($list): bool|array {
$includedJournals = []; $includedJournals = [];
$return = $object; $return = $object;
@@ -622,7 +621,7 @@ trait MetaCollection
// found at least the expected tags. // found at least the expected tags.
$result = $foundTagCount >= $expectedTagCount; $result = $foundTagCount >= $expectedTagCount;
if (true === $result) { if ($result) {
return $return; return $return;
} }
@@ -707,7 +706,7 @@ trait MetaCollection
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'external_id'); $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'); $this->query->whereNull('journal_meta.deleted_at');
return $this; return $this;
@@ -730,7 +729,7 @@ trait MetaCollection
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'internal_reference'); $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'); $this->query->whereNull('journal_meta.deleted_at');
return $this; return $this;
@@ -740,7 +739,7 @@ trait MetaCollection
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'recurrence_id'); $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'); $this->query->whereNull('journal_meta.deleted_at');
return $this; return $this;
@@ -750,7 +749,7 @@ trait MetaCollection
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'sepa_ct_id'); $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'); $this->query->whereNull('journal_meta.deleted_at');
return $this; return $this;
@@ -781,7 +780,7 @@ trait MetaCollection
// this method adds a "postFilter" to the collector. // this method adds a "postFilter" to the collector.
$list = $tags->pluck('tag')->toArray(); $list = $tags->pluck('tag')->toArray();
$list = array_map('strtolower', $list); $list = array_map(strtolower(...), $list);
$filter = static function (array $object) use ($list): bool { $filter = static function (array $object) use ($list): bool {
Log::debug(sprintf('Now in setTags(%s) filter', implode(', ', $list))); Log::debug(sprintf('Now in setTags(%s) filter', implode(', ', $list)));
foreach ($object['transactions'] as $transaction) { foreach ($object['transactions'] as $transaction) {
@@ -812,7 +811,7 @@ trait MetaCollection
// this method adds a "postFilter" to the collector. // this method adds a "postFilter" to the collector.
$list = $tags->pluck('tag')->toArray(); $list = $tags->pluck('tag')->toArray();
$list = array_map('strtolower', $list); $list = array_map(strtolower(...), $list);
$filter = static function (array $object) use ($list): bool { $filter = static function (array $object) use ($list): bool {
Log::debug(sprintf('Now in setWithoutSpecificTags(%s) filter', implode(', ', $list))); Log::debug(sprintf('Now in setWithoutSpecificTags(%s) filter', implode(', ', $list)));
foreach ($object['transactions'] as $transaction) { foreach ($object['transactions'] as $transaction) {
@@ -933,15 +932,15 @@ trait MetaCollection
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
// TODO not sure if this will work properly. // TODO not sure if this will work properly.
$this->query->where(static function (Builder $q1): void { // @phpstan-ignore-line $this->query->where(static function (EloquentBuilder $q1): void { // @phpstan-ignore-line
$q1->where(static function (Builder $q2): void { $q1->where(static function (EloquentBuilder $q2): void {
$q2->where('journal_meta.name', '=', 'external_id'); $q2->where('journal_meta.name', '=', 'external_id');
$q2->whereNull('journal_meta.data'); $q2->whereNull('journal_meta.data');
$q2->whereNull('journal_meta.deleted_at'); $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->where('journal_meta.name', '!=', 'external_id');
$q3->whereNull('journal_meta.deleted_at'); $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.name');
$q4->whereNull('journal_meta.deleted_at'); $q4->whereNull('journal_meta.deleted_at');
}); });
@@ -954,15 +953,15 @@ trait MetaCollection
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
// TODO not sure if this will work properly. // TODO not sure if this will work properly.
$this->query->where(static function (Builder $q1): void { // @phpstan-ignore-line $this->query->where(static function (EloquentBuilder $q1): void { // @phpstan-ignore-line
$q1->where(static function (Builder $q2): void { $q1->where(static function (EloquentBuilder $q2): void {
$q2->where('journal_meta.name', '=', 'external_url'); $q2->where('journal_meta.name', '=', 'external_url');
$q2->whereNull('journal_meta.data'); $q2->whereNull('journal_meta.data');
$q2->whereNull('journal_meta.deleted_at'); $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->where('journal_meta.name', '!=', 'external_url');
$q3->whereNull('journal_meta.deleted_at'); $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.name');
$q4->whereNull('journal_meta.deleted_at'); $q4->whereNull('journal_meta.deleted_at');
}); });
@@ -974,7 +973,7 @@ trait MetaCollection
public function withoutNotes(): GroupCollectorInterface public function withoutNotes(): GroupCollectorInterface
{ {
$this->withNotes(); $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->whereNull('notes.text');
$q->orWhere('notes.text', ''); $q->orWhere('notes.text', '');
}); });

View File

@@ -371,7 +371,7 @@ class GroupCollector implements GroupCollectorInterface
{ {
if (0 !== count($journalIds)) { if (0 !== count($journalIds)) {
// make all integers. // make all integers.
$integerIDs = array_map('intval', $journalIds); $integerIDs = array_map(intval(...), $journalIds);
$this->query->whereNotIn('transaction_journals.id', $integerIDs); $this->query->whereNotIn('transaction_journals.id', $integerIDs);
} }
@@ -779,7 +779,6 @@ class GroupCollector implements GroupCollectorInterface
{ {
$currentCollection = $collection; $currentCollection = $collection;
$countFilters = count($this->postFilters); $countFilters = count($this->postFilters);
$countCollection = count($currentCollection);
if (0 === $countFilters) { if (0 === $countFilters) {
return $currentCollection; return $currentCollection;
} }
@@ -947,7 +946,7 @@ class GroupCollector implements GroupCollectorInterface
{ {
if (0 !== count($journalIds)) { if (0 !== count($journalIds)) {
// make all integers. // make all integers.
$integerIDs = array_map('intval', $journalIds); $integerIDs = array_map(intval(...), $journalIds);
Log::debug(sprintf('GroupCollector: setJournalIds: %s', implode(', ', $integerIDs))); Log::debug(sprintf('GroupCollector: setJournalIds: %s', implode(', ', $integerIDs)));
$this->query->whereIn('transaction_journals.id', $integerIDs); $this->query->whereIn('transaction_journals.id', $integerIDs);

View File

@@ -27,15 +27,13 @@ use Carbon\Carbon;
use FireflyIII\Support\Facades\Preferences; use FireflyIII\Support\Facades\Preferences;
use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface; use Psr\Container\NotFoundExceptionInterface;
use Illuminate\Support\Facades\Log;
/** /**
* Class FiscalHelper. * Class FiscalHelper.
*/ */
class FiscalHelper implements FiscalHelperInterface class FiscalHelper implements FiscalHelperInterface
{ {
/** @var bool */ protected bool $useCustomFiscalYear;
protected $useCustomFiscalYear;
/** /**
* FiscalHelper constructor. * FiscalHelper constructor.
@@ -52,7 +50,7 @@ class FiscalHelper implements FiscalHelperInterface
{ {
// Log::debug(sprintf('Now in endOfFiscalYear(%s).', $date->format('Y-m-d'))); // Log::debug(sprintf('Now in endOfFiscalYear(%s).', $date->format('Y-m-d')));
$endDate = $this->startOfFiscalYear($date); $endDate = $this->startOfFiscalYear($date);
if (true === $this->useCustomFiscalYear) { if ($this->useCustomFiscalYear) {
// add 1 year and sub 1 day // add 1 year and sub 1 day
$endDate->addYear(); $endDate->addYear();
$endDate->subDay(); $endDate->subDay();
@@ -75,7 +73,7 @@ class FiscalHelper implements FiscalHelperInterface
{ {
// get start mm-dd. Then create a start date in the year passed. // get start mm-dd. Then create a start date in the year passed.
$startDate = clone $date; $startDate = clone $date;
if (true === $this->useCustomFiscalYear) { if ($this->useCustomFiscalYear) {
$prefStartStr = Preferences::get('fiscalYearStart', '01-01')->data; $prefStartStr = Preferences::get('fiscalYearStart', '01-01')->data;
if (is_array($prefStartStr)) { if (is_array($prefStartStr)) {
$prefStartStr = '01-01'; $prefStartStr = '01-01';

View File

@@ -46,8 +46,6 @@ use Illuminate\Support\Facades\Log;
class NetWorth implements NetWorthInterface class NetWorth implements NetWorthInterface
{ {
private AccountRepositoryInterface $accountRepository; 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 * 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) { if (!$user instanceof User) {
return; return;
} }
$this->user = $user;
$this->setUserGroup($user->userGroup); $this->setUserGroup($user->userGroup);
} }
public function setUserGroup(UserGroup $userGroup): void public function setUserGroup(UserGroup $userGroup): void
{ {
$this->userGroup = $userGroup;
$this->accountRepository = app(AccountRepositoryInterface::class); $this->accountRepository = app(AccountRepositoryInterface::class);
$this->accountRepository->setUserGroup($userGroup); $this->accountRepository->setUserGroup($userGroup);

View File

@@ -36,15 +36,14 @@ use Illuminate\Support\Collection;
*/ */
class ReportHelper implements ReportHelperInterface class ReportHelper implements ReportHelperInterface
{ {
/** @var BudgetRepositoryInterface The budget repository */
protected $budgetRepository;
/** /**
* ReportHelper constructor. * ReportHelper constructor.
*/ */
public function __construct(BudgetRepositoryInterface $budgetRepository) public function __construct(
/** @var BudgetRepositoryInterface The budget repository */
protected BudgetRepositoryInterface $budgetRepository
)
{ {
$this->budgetRepository = $budgetRepository;
} }
/** /**

View File

@@ -75,7 +75,7 @@ class CreateController extends Controller
* *
* @return Factory|View * @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)); $subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
$subTitle = (string) trans(sprintf('firefly.make_new_%s_account', $objectType)); $subTitle = (string) trans(sprintf('firefly.make_new_%s_account', $objectType));
@@ -124,7 +124,7 @@ class CreateController extends Controller
return view( return view(
'accounts.create', '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]
); );
} }

View File

@@ -66,7 +66,7 @@ class DeleteController extends Controller
* *
* @return Factory|Redirector|RedirectResponse|View * @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)) { if (!$this->isEditableAccount($account)) {
return $this->redirectAccountToAccount($account); return $this->redirectAccountToAccount($account);
@@ -81,15 +81,13 @@ class DeleteController extends Controller
// put previous url in session // put previous url in session
$this->rememberPreviousUrl('accounts.delete.url'); $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. * 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)) { if (!$this->isEditableAccount($account)) {
return $this->redirectAccountToAccount($account); return $this->redirectAccountToAccount($account);

View File

@@ -76,7 +76,7 @@ class EditController extends Controller
* *
* @return Factory|Redirector|RedirectResponse|View * @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)) { if (!$this->isEditableAccount($account)) {
return $this->redirectAccountToAccount($account); return $this->redirectAccountToAccount($account);
@@ -163,7 +163,7 @@ class EditController extends Controller
$request->session()->flash('preFilled', $preFilled); $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]);
} }
/** /**

View File

@@ -72,7 +72,7 @@ class IndexController extends Controller
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function inactive(Request $request, string $objectType) public function inactive(Request $request, string $objectType): Factory|\Illuminate\Contracts\View\View
{ {
$inactivePage = true; $inactivePage = true;
$subTitle = (string) trans(sprintf('firefly.%s_accounts_inactive', $objectType)); $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 = new LengthAwarePaginator($accounts, $total, $pageSize, $page);
$accounts->setPath(route('accounts.inactive.index', [$objectType])); $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 private function subtract(array $startBalances, array $endBalances): array
@@ -141,9 +141,9 @@ class IndexController extends Controller
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @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)); $subTitle = (string) trans(sprintf('firefly.%s_accounts', $objectType));
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType)); $subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
$types = config(sprintf('firefly.accountTypesByIdentifier.%s', $objectType)); $types = config(sprintf('firefly.accountTypesByIdentifier.%s', $objectType));
@@ -157,7 +157,7 @@ class IndexController extends Controller
$accounts = $collection->slice(($page - 1) * $pageSize, $pageSize); $accounts = $collection->slice(($page - 1) * $pageSize, $pageSize);
$inactiveCount = $this->repository->getInactiveAccountsByType($types)->count(); $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); unset($collection);
@@ -187,9 +187,7 @@ class IndexController extends Controller
$account->differences = $this->subtract($account->startBalances, $account->endBalances); $account->differences = $this->subtract($account->startBalances, $account->endBalances);
$account->lastActivityDate = $this->isInArrayDate($activities, $account->id); $account->lastActivityDate = $this->isInArrayDate($activities, $account->id);
$account->interest = Steam::bcround($interest, 4); $account->interest = Steam::bcround($interest, 4);
$account->interestPeriod = (string) trans( $account->interestPeriod = (string) trans(sprintf('firefly.interest_calc_%s', $this->repository->getMetaValue($account, 'interest_period')));
sprintf('firefly.interest_calc_%s', $this->repository->getMetaValue($account, 'interest_period'))
);
$account->accountTypeString = (string) trans(sprintf('firefly.account_type_%s', $account->accountType->type)); $account->accountTypeString = (string) trans(sprintf('firefly.account_type_%s', $account->accountType->type));
$account->location = $this->repository->getLocation($account); $account->location = $this->repository->getLocation($account);
$account->liability_direction = $this->repository->getMetaValue($account, 'liability_direction'); $account->liability_direction = $this->repository->getMetaValue($account, 'liability_direction');
@@ -201,15 +199,15 @@ class IndexController extends Controller
} }
); );
// make paginator: // 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 */ /** @var LengthAwarePaginator $accounts */
$accounts = new LengthAwarePaginator($accounts, $total, $pageSize, $page); $accounts = new LengthAwarePaginator($accounts, $total, $pageSize, $page);
$accounts->setPath(route('accounts.index', [$objectType])); $accounts->setPath(route('accounts.index', [$objectType]));
app('log')->debug(sprintf('Count of accounts after LAP (1): %d', $accounts->count())); 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 (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]);
} }
} }

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Account; namespace FireflyIII\Http\Controllers\Account;
use Illuminate\Support\Facades\Log;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Enums\TransactionTypeEnum;
@@ -40,7 +41,6 @@ use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Routing\Redirector; use Illuminate\Routing\Redirector;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Illuminate\View\View; use Illuminate\View\View;
/** /**
@@ -78,7 +78,7 @@ class ReconcileController extends Controller
* *
* @throws FireflyException * @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)) { if (!$this->isEditableAccount($account)) {
return $this->redirectAccountToAccount($account); return $this->redirectAccountToAccount($account);
@@ -139,44 +139,30 @@ class ReconcileController extends Controller
return view( return view(
'accounts.reconcile.index', 'accounts.reconcile.index',
compact( ['account' => $account, 'currency' => $currency, 'objectType' => $objectType, 'subTitleIcon' => $subTitleIcon, 'start' => $start, 'end' => $end, 'subTitle' => $subTitle, 'startBalance' => $startBalance, 'endBalance' => $endBalance, 'transactionsUrl' => $transactionsUrl, 'overviewUrl' => $overviewUrl, 'indexUrl' => $indexUrl]
'account',
'currency',
'objectType',
'subTitleIcon',
'start',
'end',
'subTitle',
'startBalance',
'endBalance',
'transactionsUrl',
'overviewUrl',
'indexUrl'
)
); );
} }
/** /**
* Submit a new reconciliation. * Submit a new reconciliation.
* *
* @return Redirector|RedirectResponse
* *
* @throws DuplicateTransactionException * @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)) { if (!$this->isEditableAccount($account)) {
return $this->redirectAccountToAccount($account); return $this->redirectAccountToAccount($account);
} }
app('log')->debug('In ReconcileController::submit()'); Log::debug('In ReconcileController::submit()');
$data = $request->getAll(); $data = $request->getAll();
/** @var string $journalId */ /** @var string $journalId */
foreach ($data['journals'] as $journalId) { foreach ($data['journals'] as $journalId) {
$this->repository->reconcileById((int) $journalId); $this->repository->reconcileById((int) $journalId);
} }
app('log')->debug('Reconciled all transactions.'); Log::debug('Reconciled all transactions.');
// switch dates if necessary // switch dates if necessary
if ($end->lt($start)) { if ($end->lt($start)) {
@@ -188,7 +174,7 @@ class ReconcileController extends Controller
if ('create' === $data['reconcile']) { if ('create' === $data['reconcile']) {
$result = $this->createReconciliation($account, $start, $end, $data['difference']); $result = $this->createReconciliation($account, $start, $end, $data['difference']);
} }
app('log')->debug('End of routine.'); Log::debug('End of routine.');
app('preferences')->mark(); app('preferences')->mark();
if ('' === $result) { if ('' === $result) {
session()->flash('success', (string) trans('firefly.reconciliation_stored')); session()->flash('success', (string) trans('firefly.reconciliation_stored'));

View File

@@ -84,7 +84,7 @@ class ShowController extends Controller
* @throws FireflyException * @throws FireflyException
* @throws NotFoundExceptionInterface * @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) { if (0 === $account->id) {
throw new NotFoundHttpException(); throw new NotFoundHttpException();
@@ -175,23 +175,7 @@ class ShowController extends Controller
return view( return view(
'accounts.show', 'accounts.show',
compact( ['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]
'account',
'showAll',
'objectType',
'currency',
'today',
'periods',
'subTitleIcon',
'groups',
'attachments',
'subTitle',
'start',
'end',
'chartUrl',
'location',
'balances'
)
); );
} }
@@ -203,7 +187,7 @@ class ShowController extends Controller
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @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)) { if (!$this->isEditableAccount($account)) {
return $this->redirectAccountToAccount($account); return $this->redirectAccountToAccount($account);
@@ -214,7 +198,7 @@ class ShowController extends Controller
$objectType = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type)); $objectType = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type));
$end = today(config('app.timezone')); $end = today(config('app.timezone'));
$today = 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(); $start = $this->repository->oldestJournalDate($account) ?? today(config('app.timezone'))->startOfMonth();
$subTitleIcon = config('firefly.subIconsByIdentifier.'.$account->accountType->type); $subTitleIcon = config('firefly.subIconsByIdentifier.'.$account->accountType->type);
$page = (int) $request->get('page'); $page = (int) $request->get('page');
@@ -247,24 +231,7 @@ class ShowController extends Controller
return view( return view(
'accounts.show', 'accounts.show',
compact( ['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]
'account',
'showAll',
'location',
'objectType',
'isLiability',
'attachments',
'currency',
'today',
'chartUrl',
'periods',
'subTitleIcon',
'groups',
'subTitle',
'start',
'end',
'balances'
)
); );
} }
} }

View File

@@ -60,7 +60,7 @@ class ConfigurationController extends Controller
* *
* @return Factory|View * @return Factory|View
*/ */
public function index() public function index(): Factory|\Illuminate\Contracts\View\View
{ {
$subTitle = (string) trans('firefly.instance_configuration'); $subTitle = (string) trans('firefly.instance_configuration');
$subTitleIcon = 'fa-wrench'; $subTitleIcon = 'fa-wrench';
@@ -75,7 +75,7 @@ class ConfigurationController extends Controller
return view( return view(
'settings.configuration.index', 'settings.configuration.index',
compact('subTitle', 'subTitleIcon', 'singleUserMode', 'isDemoSite', 'siteOwner') ['subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon, 'singleUserMode' => $singleUserMode, 'isDemoSite' => $isDemoSite, 'siteOwner' => $siteOwner]
); );
} }

View File

@@ -53,7 +53,7 @@ class HomeController extends Controller
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function index() public function index(): Factory|\Illuminate\Contracts\View\View
{ {
Log::channel('audit')->info('User visits admin index.'); Log::channel('audit')->info('User visits admin index.');
$title = (string) trans('firefly.system_settings'); $title = (string) trans('firefly.system_settings');
@@ -64,6 +64,6 @@ class HomeController extends Controller
$email = $pref->data; $email = $pref->data;
} }
return view('settings.index', compact('title', 'mainTitleIcon', 'email')); return view('settings.index', ['title' => $title, 'mainTitleIcon' => $mainTitleIcon, 'email' => $email]);
} }
} }

View File

@@ -66,7 +66,7 @@ class LinkController extends Controller
* *
* @return Factory|View * @return Factory|View
*/ */
public function create() public function create(): Factory|\Illuminate\Contracts\View\View
{ {
Log::channel('audit')->info('User visits link index.'); Log::channel('audit')->info('User visits link index.');
@@ -78,7 +78,7 @@ class LinkController extends Controller
$this->rememberPreviousUrl('link-types.create.url'); $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 * @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) { if (false === $linkType->editable) {
$request->session()->flash('error', (string) trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)])); $request->session()->flash('error', (string) trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)]));
@@ -111,15 +111,13 @@ class LinkController extends Controller
// put previous url in session // put previous url in session
$this->rememberPreviousUrl('link-types.delete.url'); $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. * 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)); Log::channel('audit')->info(sprintf('User destroyed link type #%d', $linkType->id));
$name = $linkType->name; $name = $linkType->name;
@@ -137,7 +135,7 @@ class LinkController extends Controller
* *
* @return Factory|Redirector|RedirectResponse|View * @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) { if (false === $linkType->editable) {
$request->session()->flash('error', (string) trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)])); $request->session()->flash('error', (string) trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)]));
@@ -155,7 +153,7 @@ class LinkController extends Controller
} }
$request->session()->forget('link-types.edit.fromUpdate'); $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 * @return Factory|View
*/ */
public function index() public function index(): Factory|\Illuminate\Contracts\View\View
{ {
$subTitle = (string) trans('firefly.journal_link_configuration'); $subTitle = (string) trans('firefly.journal_link_configuration');
$subTitleIcon = 'fa-link'; $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 * @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]); $subTitle = (string) trans('firefly.overview_for_link', ['name' => $linkType->name]);
$subTitleIcon = 'fa-link'; $subTitleIcon = 'fa-link';
@@ -192,7 +190,7 @@ class LinkController extends Controller
Log::channel('audit')->info(sprintf('User viewing link type #%d', $linkType->id)); 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]);
} }
/** /**

View File

@@ -74,23 +74,7 @@ class NotificationController extends Controller
return view( return view(
'settings.notifications.index', 'settings.notifications.index',
compact( ['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]
'title',
'subTitle',
'forcedAvailability',
'mainTitleIcon',
'subTitleIcon',
'channels',
'slackUrl',
'notifications',
'pushoverAppToken',
'pushoverUserToken',
'ntfyServer',
'ntfyTopic',
'ntfyAuth',
'ntfyUser',
'ntfyPass'
)
); );
} }
@@ -142,7 +126,7 @@ class NotificationController extends Controller
case 'pushover': case 'pushover':
case 'ntfy': case 'ntfy':
$owner = new OwnerNotifiable(); $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)); event(new OwnerTestNotificationChannel($channel, $owner));
session()->flash('success', (string) trans('firefly.notification_test_executed', ['channel' => $channel])); session()->flash('success', (string) trans('firefly.notification_test_executed', ['channel' => $channel]));
} }

View File

@@ -63,7 +63,7 @@ class UpdateController extends Controller
* *
* @return Factory|View * @return Factory|View
*/ */
public function index() public function index(): Factory|\Illuminate\Contracts\View\View
{ {
$subTitle = (string) trans('firefly.update_check_title'); $subTitle = (string) trans('firefly.update_check_title');
$subTitleIcon = 'fa-star'; $subTitleIcon = 'fa-star';
@@ -83,15 +83,13 @@ class UpdateController extends Controller
'alpha' => (string) trans('firefly.update_channel_alpha'), '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. * 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'); $checkForUpdates = (int) $request->get('check_for_updates');
$channel = $request->get('update_channel'); $channel = $request->get('update_channel');

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Admin; namespace FireflyIII\Http\Controllers\Admin;
use Illuminate\Support\Facades\Log;
use FireflyIII\Events\Admin\InvitationCreated; use FireflyIII\Events\Admin\InvitationCreated;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
@@ -72,7 +73,7 @@ class UserController extends Controller
/** /**
* @return Application|Factory|Redirector|RedirectResponse|View * @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) { if ($this->externalIdentity) {
request()->session()->flash('error', trans('firefly.external_user_mgt_disabled')); 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]); $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 public function deleteInvite(InvitedUser $invitedUser): JsonResponse
{ {
app('log')->debug('Will now delete invitation'); Log::debug('Will now delete invitation');
if (true === $invitedUser->redeemed) { 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])); session()->flash('error', trans('firefly.invite_is_already_redeemed', ['address' => $invitedUser->email]));
return response()->json(['success' => false]); return response()->json(['success' => false]);
} }
app('log')->debug('Delete!'); Log::debug('Delete!');
session()->flash('success', trans('firefly.invite_is_deleted', ['address' => $invitedUser->email])); session()->flash('success', trans('firefly.invite_is_deleted', ['address' => $invitedUser->email]));
$this->repository->deleteInvite($invitedUser); $this->repository->deleteInvite($invitedUser);
@@ -103,10 +104,8 @@ class UserController extends Controller
/** /**
* Destroy a user. * Destroy a user.
*
* @return Redirector|RedirectResponse
*/ */
public function destroy(User $user) public function destroy(User $user): Redirector|RedirectResponse
{ {
if ($this->externalIdentity) { if ($this->externalIdentity) {
request()->session()->flash('error', trans('firefly.external_user_mgt_disabled')); request()->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
@@ -124,7 +123,7 @@ class UserController extends Controller
* *
* @return Factory|View * @return Factory|View
*/ */
public function edit(User $user) public function edit(User $user): Factory|\Illuminate\Contracts\View\View
{ {
$canEditDetails = true; $canEditDetails = true;
if ($this->externalIdentity) { if ($this->externalIdentity) {
@@ -147,7 +146,7 @@ class UserController extends Controller
'email_changed' => (string) trans('firefly.block_code_email_changed'), '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 FireflyException
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function index() public function index(): Factory|\Illuminate\Contracts\View\View
{ {
$subTitle = (string) trans('firefly.user_administration'); $subTitle = (string) trans('firefly.user_administration');
$subTitleIcon = 'fa-users'; $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 public function invite(InviteUserFormRequest $request): RedirectResponse
@@ -201,7 +200,7 @@ class UserController extends Controller
* *
* @return Factory|View * @return Factory|View
*/ */
public function show(User $user) public function show(User $user): Factory|\Illuminate\Contracts\View\View
{ {
$title = (string) trans('firefly.system_settings'); $title = (string) trans('firefly.system_settings');
$mainTitleIcon = 'fa-hand-spock-o'; $mainTitleIcon = 'fa-hand-spock-o';
@@ -211,14 +210,7 @@ class UserController extends Controller
return view( return view(
'settings.users.show', 'settings.users.show',
compact( ['title' => $title, 'mainTitleIcon' => $mainTitleIcon, 'subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon, 'information' => $information, 'user' => $user]
'title',
'mainTitleIcon',
'subTitle',
'subTitleIcon',
'information',
'user'
)
); );
} }
@@ -229,7 +221,7 @@ class UserController extends Controller
*/ */
public function update(UserFormRequest $request, User $user) public function update(UserFormRequest $request, User $user)
{ {
app('log')->debug('Actually here'); Log::debug('Actually here');
$data = $request->getUserData(); $data = $request->getUserData();
// var_dump($data); // var_dump($data);

View File

@@ -65,22 +65,20 @@ class AttachmentController extends Controller
* *
* @return Factory|View * @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]); $subTitle = (string) trans('firefly.delete_attachment', ['name' => $attachment->filename]);
// put previous url in session // put previous url in session
$this->rememberPreviousUrl('attachments.delete.url'); $this->rememberPreviousUrl('attachments.delete.url');
return view('attachments.delete', compact('attachment', 'subTitle')); return view('attachments.delete', ['attachment' => $attachment, 'subTitle' => $subTitle]);
} }
/** /**
* Destroy attachment. * Destroy attachment.
*
* @return Redirector|RedirectResponse
*/ */
public function destroy(Request $request, Attachment $attachment) public function destroy(Request $request, Attachment $attachment): Redirector|RedirectResponse
{ {
$name = $attachment->filename; $name = $attachment->filename;
@@ -123,7 +121,7 @@ class AttachmentController extends Controller
} }
$message = 'Could not find the indicated attachment. The file is no longer there.'; $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 * @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'; $subTitleIcon = 'fa-pencil';
$subTitle = (string) trans('firefly.edit_attachment', ['name' => $attachment->filename]); $subTitle = (string) trans('firefly.edit_attachment', ['name' => $attachment->filename]);
@@ -146,7 +144,7 @@ class AttachmentController extends Controller
]; ];
$request->session()->flash('preFilled', $preFilled); $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 * @return Factory|View
*/ */
public function index() public function index(): Factory|\Illuminate\Contracts\View\View
{ {
$set = $this->repository->get()->reverse(); $set = $this->repository->get()->reverse();
$set = $set->each( $set = $set->each(
function (Attachment $attachment) { function (Attachment $attachment): Attachment {
$attachment->file_exists = $this->repository->exists($attachment); $attachment->file_exists = $this->repository->exists($attachment);
return $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.'; $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]);
} }
} }

View File

@@ -73,7 +73,7 @@ class ForgotPasswordController extends Controller
$message = sprintf('Cannot reset password when authenticating over "%s".', config('firefly.authentication_guard')); $message = sprintf('Cannot reset password when authenticating over "%s".', config('firefly.authentication_guard'));
Log::error($message); Log::error($message);
return view('errors.error', compact('message')); return view('errors.error', ['message' => $message]);
} }
// validate host header. // validate host header.
@@ -138,7 +138,7 @@ class ForgotPasswordController extends Controller
if ('web' !== config('firefly.authentication_guard')) { if ('web' !== config('firefly.authentication_guard')) {
$message = sprintf('Cannot reset password when authenticating over "%s".', 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? // is allowed to?
@@ -150,6 +150,6 @@ class ForgotPasswordController extends Controller
$allowRegistration = false; $allowRegistration = false;
} }
return view('auth.passwords.email')->with(compact('allowRegistration', 'pageTitle')); return view('auth.passwords.email')->with(['allowRegistration' => $allowRegistration, 'pageTitle' => $pageTitle]);
} }
} }

Some files were not shown because too many files have changed in this diff Show More