mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-02 19:16:39 +00:00
Update code to use php 8.4 code, using Nestor.
This commit is contained in:
@@ -65,13 +65,11 @@ class BillController extends Controller
|
||||
$data = $request->getData();
|
||||
$result = $this->repository->searchBill($data['query'], $this->parameters->get('limit'));
|
||||
$filtered = $result->map(
|
||||
static function (Bill $item) {
|
||||
return [
|
||||
'id' => (string) $item->id,
|
||||
'name' => $item->name,
|
||||
'active' => $item->active,
|
||||
];
|
||||
}
|
||||
static fn(Bill $item) => [
|
||||
'id' => (string) $item->id,
|
||||
'name' => $item->name,
|
||||
'active' => $item->active,
|
||||
]
|
||||
);
|
||||
|
||||
return response()->api($filtered->toArray());
|
||||
|
@@ -65,12 +65,10 @@ class BudgetController extends Controller
|
||||
$data = $request->getData();
|
||||
$result = $this->repository->searchBudget($data['query'], $this->parameters->get('limit'));
|
||||
$filtered = $result->map(
|
||||
static function (Budget $item) {
|
||||
return [
|
||||
'id' => (string) $item->id,
|
||||
'name' => $item->name,
|
||||
];
|
||||
}
|
||||
static fn(Budget $item) => [
|
||||
'id' => (string) $item->id,
|
||||
'name' => $item->name,
|
||||
]
|
||||
);
|
||||
|
||||
return response()->api($filtered->toArray());
|
||||
|
@@ -65,12 +65,10 @@ class CategoryController extends Controller
|
||||
$data = $request->getData();
|
||||
$result = $this->repository->searchCategory($data['query'], $this->parameters->get('limit'));
|
||||
$filtered = $result->map(
|
||||
static function (Category $item) {
|
||||
return [
|
||||
'id' => (string) $item->id,
|
||||
'name' => $item->name,
|
||||
];
|
||||
}
|
||||
static fn(Category $item) => [
|
||||
'id' => (string) $item->id,
|
||||
'name' => $item->name,
|
||||
]
|
||||
);
|
||||
|
||||
return response()->api($filtered->toArray());
|
||||
|
@@ -119,9 +119,7 @@ class CategoryController extends Controller
|
||||
$return = array_values($return);
|
||||
|
||||
// order by amount
|
||||
usort($return, static function (array $a, array $b) {
|
||||
return (float) $a['amount'] < (float) $b['amount'] ? 1 : -1;
|
||||
});
|
||||
usort($return, static fn(array $a, array $b) => (float) $a['amount'] < (float) $b['amount'] ? 1 : -1);
|
||||
|
||||
return response()->json($this->clean($return));
|
||||
}
|
||||
|
@@ -177,9 +177,7 @@ class ListController extends Controller
|
||||
|
||||
// filter and paginate list:
|
||||
$collection = $unfiltered->filter(
|
||||
static function (Bill $bill) use ($currency) {
|
||||
return $bill->transaction_currency_id === $currency->id;
|
||||
}
|
||||
static fn(Bill $bill) => $bill->transaction_currency_id === $currency->id
|
||||
);
|
||||
$count = $collection->count();
|
||||
$bills = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||
|
@@ -85,7 +85,7 @@ class ChartRequest extends FormRequest
|
||||
}
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', self::class), $validator->errors()->toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -74,7 +74,7 @@ class MoveTransactionsRequest extends FormRequest
|
||||
}
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', self::class), $validator->errors()->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -74,7 +74,7 @@ class TransactionRequest extends FormRequest
|
||||
}
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', self::class), $validator->errors()->toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -144,7 +144,7 @@ class UpdateRequest extends FormRequest
|
||||
}
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', self::class), $validator->errors()->toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -58,9 +58,7 @@ class StoreRequest extends FormRequest
|
||||
{
|
||||
$models = config('firefly.valid_attachment_models');
|
||||
$models = array_map(
|
||||
static function (string $className) {
|
||||
return str_replace('FireflyIII\Models\\', '', $className);
|
||||
},
|
||||
static fn(string $className) => str_replace('FireflyIII\Models\\', '', $className),
|
||||
$models
|
||||
);
|
||||
$models = implode(',', $models);
|
||||
|
@@ -60,9 +60,7 @@ class UpdateRequest extends FormRequest
|
||||
{
|
||||
$models = config('firefly.valid_attachment_models');
|
||||
$models = array_map(
|
||||
static function (string $className) {
|
||||
return str_replace('FireflyIII\Models\\', '', $className);
|
||||
},
|
||||
static fn(string $className) => str_replace('FireflyIII\Models\\', '', $className),
|
||||
$models
|
||||
);
|
||||
$models = implode(',', $models);
|
||||
|
@@ -90,7 +90,7 @@ class Request extends FormRequest
|
||||
}
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', self::class), $validator->errors()->toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -129,7 +129,7 @@ class StoreRequest extends FormRequest
|
||||
$failed = false;
|
||||
}
|
||||
if ($failed) {
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', self::class), $validator->errors()->toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -110,7 +110,7 @@ class UpdateRequest extends FormRequest
|
||||
}
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', self::class), $validator->errors()->toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -94,7 +94,7 @@ class StoreRequest extends FormRequest
|
||||
}
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', self::class), $validator->errors()->toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -106,7 +106,7 @@ class UpdateRequest extends FormRequest
|
||||
}
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', self::class), $validator->errors()->toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -96,7 +96,7 @@ class UpdateRequest extends FormRequest
|
||||
}
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', self::class), $validator->errors()->toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -126,7 +126,7 @@ class StoreRequest extends FormRequest
|
||||
}
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', self::class), $validator->errors()->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -193,7 +193,7 @@ class StoreRequest extends FormRequest
|
||||
}
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', self::class), $validator->errors()->toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -208,7 +208,7 @@ class UpdateRequest extends FormRequest
|
||||
}
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', self::class), $validator->errors()->toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -148,7 +148,7 @@ class StoreRequest extends FormRequest
|
||||
}
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', self::class), $validator->errors()->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -168,7 +168,7 @@ class UpdateRequest extends FormRequest
|
||||
}
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', self::class), $validator->errors()->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -300,7 +300,7 @@ class StoreRequest extends FormRequest
|
||||
}
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', self::class), $validator->errors()->toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -359,7 +359,7 @@ class UpdateRequest extends FormRequest
|
||||
}
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', self::class), $validator->errors()->toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -80,7 +80,7 @@ class StoreRequest extends FormRequest
|
||||
}
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', self::class), $validator->errors()->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -80,7 +80,7 @@ class UpdateRequest extends FormRequest
|
||||
}
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', self::class), $validator->errors()->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -99,7 +99,7 @@ class UserUpdateRequest extends FormRequest
|
||||
}
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', self::class), $validator->errors()->toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -61,13 +61,11 @@ class CategoryController extends Controller
|
||||
$queryParameters = $request->getParameters();
|
||||
$result = $this->repository->searchCategory($queryParameters['query'], $queryParameters['size']);
|
||||
$filtered = $result->map(
|
||||
static function (Category $item) {
|
||||
return [
|
||||
'id' => (string) $item->id,
|
||||
'title' => $item->name,
|
||||
'meta' => [],
|
||||
];
|
||||
}
|
||||
static fn(Category $item) => [
|
||||
'id' => (string) $item->id,
|
||||
'title' => $item->name,
|
||||
'meta' => [],
|
||||
]
|
||||
);
|
||||
|
||||
return response()->json($filtered);
|
||||
|
@@ -61,15 +61,13 @@ class TagController extends Controller
|
||||
$queryParameters = $request->getParameters();
|
||||
$result = $this->repository->searchTag($queryParameters['query']);
|
||||
$filtered = $result->map(
|
||||
static function (Tag $item) {
|
||||
return [
|
||||
'id' => (string) $item->id,
|
||||
'title' => $item->tag,
|
||||
'value' => (string) $item->id,
|
||||
'label' => $item->tag,
|
||||
'meta' => [],
|
||||
];
|
||||
}
|
||||
static fn(Tag $item) => [
|
||||
'id' => (string) $item->id,
|
||||
'title' => $item->tag,
|
||||
'value' => (string) $item->id,
|
||||
'label' => $item->tag,
|
||||
'meta' => [],
|
||||
]
|
||||
);
|
||||
|
||||
return response()->json($filtered);
|
||||
|
@@ -134,9 +134,7 @@ class CategoryController extends Controller
|
||||
$return = array_values($return);
|
||||
|
||||
// order by native amount
|
||||
usort($return, static function (array $a, array $b) {
|
||||
return (float) $a['native_amount'] < (float) $b['native_amount'] ? 1 : -1;
|
||||
});
|
||||
usort($return, static fn(array $a, array $b) => (float) $a['native_amount'] < (float) $b['native_amount'] ? 1 : -1);
|
||||
$converter->summarize();
|
||||
|
||||
return response()->json($this->clean($return));
|
||||
|
@@ -84,7 +84,7 @@ class BalanceChartRequest extends FormRequest
|
||||
}
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', self::class), $validator->errors()->toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -86,7 +86,7 @@ class ChartRequest extends FormRequest
|
||||
}
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', self::class), $validator->errors()->toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -83,7 +83,7 @@ class DashboardChartRequest extends FormRequest
|
||||
}
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', self::class), $validator->errors()->toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -311,7 +311,7 @@ class StoreRequest extends FormRequest
|
||||
}
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', self::class), $validator->errors()->toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -64,6 +64,7 @@ class UpdateRequest extends Request
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
#[\Override]
|
||||
public function getAll(): array
|
||||
{
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
@@ -247,6 +248,7 @@ class UpdateRequest extends Request
|
||||
/**
|
||||
* The rules that the incoming request must be matched against.
|
||||
*/
|
||||
#[\Override]
|
||||
public function rules(): array
|
||||
{
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
@@ -330,6 +332,7 @@ class UpdateRequest extends Request
|
||||
/**
|
||||
* Configure the validator instance.
|
||||
*/
|
||||
#[\Override]
|
||||
public function withValidator(Validator $validator): void
|
||||
{
|
||||
app('log')->debug('Now in withValidator');
|
||||
@@ -361,7 +364,7 @@ class UpdateRequest extends Request
|
||||
}
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
|
||||
Log::channel('audit')->error(sprintf('Validation errors in %s', self::class), $validator->errors()->toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -175,7 +175,7 @@ class CorrectsAmounts extends Command
|
||||
{
|
||||
try {
|
||||
$check = bccomp((string) $item->trigger_value, '0');
|
||||
} catch (\ValueError $e) {
|
||||
} catch (\ValueError) {
|
||||
$this->friendlyError(sprintf('Rule #%d contained invalid %s-trigger "%s". The trigger has been removed, and the rule is disabled.', $item->rule_id, $item->trigger_type, $item->trigger_value));
|
||||
$item->rule->active = false;
|
||||
$item->rule->save();
|
||||
|
@@ -115,9 +115,7 @@ class CorrectsCurrencies extends Command
|
||||
$found = array_values(
|
||||
array_filter(
|
||||
$found,
|
||||
static function (int $currencyId) {
|
||||
return 0 !== $currencyId;
|
||||
}
|
||||
static fn(int $currencyId) => 0 !== $currencyId
|
||||
)
|
||||
);
|
||||
|
||||
|
@@ -128,9 +128,7 @@ class CorrectsNativeAmounts extends Command
|
||||
$repository->setUserGroup($userGroup);
|
||||
$set = $repository->getPiggyBanks();
|
||||
$set = $set->filter(
|
||||
static function (PiggyBank $piggyBank) use ($currency) {
|
||||
return $currency->id !== $piggyBank->transaction_currency_id;
|
||||
}
|
||||
static fn(PiggyBank $piggyBank) => $currency->id !== $piggyBank->transaction_currency_id
|
||||
);
|
||||
foreach ($set as $piggyBank) {
|
||||
$piggyBank->encrypted = false;
|
||||
|
@@ -115,9 +115,7 @@ class CorrectsTransactionTypes extends Command
|
||||
private function getSourceAccount(TransactionJournal $journal): Account
|
||||
{
|
||||
$collection = $journal->transactions->filter(
|
||||
static function (Transaction $transaction) {
|
||||
return $transaction->amount < 0;
|
||||
}
|
||||
static fn(Transaction $transaction) => $transaction->amount < 0
|
||||
);
|
||||
if (0 === $collection->count()) {
|
||||
throw new FireflyException(sprintf('300001: Journal #%d has no source transaction.', $journal->id));
|
||||
@@ -144,9 +142,7 @@ class CorrectsTransactionTypes extends Command
|
||||
private function getDestinationAccount(TransactionJournal $journal): Account
|
||||
{
|
||||
$collection = $journal->transactions->filter(
|
||||
static function (Transaction $transaction) {
|
||||
return $transaction->amount > 0;
|
||||
}
|
||||
static fn(Transaction $transaction) => $transaction->amount > 0
|
||||
);
|
||||
if (0 === $collection->count()) {
|
||||
throw new FireflyException(sprintf('300004: Journal #%d has no destination transaction.', $journal->id));
|
||||
|
@@ -179,9 +179,7 @@ class UpgradesToGroups extends Command
|
||||
private function getDestinationTransactions(TransactionJournal $journal): Collection
|
||||
{
|
||||
return $journal->transactions->filter(
|
||||
static function (Transaction $transaction) {
|
||||
return $transaction->amount > 0;
|
||||
}
|
||||
static fn(Transaction $transaction) => $transaction->amount > 0
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -46,12 +46,12 @@ class UpgradesTransferCurrencies extends Command
|
||||
private JournalCLIRepositoryInterface $cliRepos;
|
||||
private int $count;
|
||||
|
||||
private ?Account $destinationAccount;
|
||||
private ?TransactionCurrency $destinationCurrency;
|
||||
private ?Transaction $destinationTransaction;
|
||||
private ?Account $sourceAccount;
|
||||
private ?TransactionCurrency $sourceCurrency;
|
||||
private ?Transaction $sourceTransaction;
|
||||
private ?Account $destinationAccount = null;
|
||||
private ?TransactionCurrency $destinationCurrency = null;
|
||||
private ?Transaction $destinationTransaction = null;
|
||||
private ?Account $sourceAccount = null;
|
||||
private ?TransactionCurrency $sourceCurrency = null;
|
||||
private ?Transaction $sourceTransaction = null;
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
|
@@ -35,6 +35,7 @@ class Kernel extends ConsoleKernel
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*/
|
||||
#[\Override]
|
||||
protected function commands(): void
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
@@ -45,6 +46,7 @@ class Kernel extends ConsoleKernel
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*/
|
||||
#[\Override]
|
||||
protected function schedule(Schedule $schedule): void
|
||||
{
|
||||
$schedule->call(
|
||||
|
@@ -36,15 +36,12 @@ class InvitationCreated extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public InvitedUser $invitee;
|
||||
|
||||
public TransactionGroup $transactionGroup;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(InvitedUser $invitee)
|
||||
public function __construct(public InvitedUser $invitee)
|
||||
{
|
||||
$this->invitee = $invitee;
|
||||
}
|
||||
}
|
||||
|
@@ -34,14 +34,11 @@ class DestroyedTransactionGroup extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public TransactionGroup $transactionGroup;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(TransactionGroup $transactionGroup)
|
||||
public function __construct(public TransactionGroup $transactionGroup)
|
||||
{
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
$this->transactionGroup = $transactionGroup;
|
||||
}
|
||||
}
|
||||
|
@@ -32,15 +32,12 @@ use Illuminate\Queue\SerializesModels;
|
||||
*/
|
||||
class DestroyedTransactionLink extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
private TransactionJournalLink $link; // @phpstan-ignore-line
|
||||
use SerializesModels; // @phpstan-ignore-line
|
||||
|
||||
/**
|
||||
* DestroyedTransactionLink constructor.
|
||||
*/
|
||||
public function __construct(TransactionJournalLink $link)
|
||||
public function __construct(private TransactionJournalLink $link)
|
||||
{
|
||||
$this->link = $link;
|
||||
}
|
||||
}
|
||||
|
@@ -34,13 +34,10 @@ class DetectedNewIPAddress extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public User $user;
|
||||
|
||||
/**
|
||||
* Create a new event instance. This event is triggered when a new user registers.
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
public function __construct(public User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
||||
|
@@ -31,10 +31,7 @@ class Updated
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public Account $account;
|
||||
|
||||
public function __construct(Account $account)
|
||||
public function __construct(public Account $account)
|
||||
{
|
||||
$this->account = $account;
|
||||
}
|
||||
}
|
||||
|
@@ -35,10 +35,7 @@ class Created extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public BudgetLimit $budgetLimit;
|
||||
|
||||
public function __construct(BudgetLimit $budgetLimit)
|
||||
public function __construct(public BudgetLimit $budgetLimit)
|
||||
{
|
||||
$this->budgetLimit = $budgetLimit;
|
||||
}
|
||||
}
|
||||
|
@@ -35,10 +35,7 @@ class Deleted extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public BudgetLimit $budgetLimit;
|
||||
|
||||
public function __construct(BudgetLimit $budgetLimit)
|
||||
public function __construct(public BudgetLimit $budgetLimit)
|
||||
{
|
||||
$this->budgetLimit = $budgetLimit;
|
||||
}
|
||||
}
|
||||
|
@@ -35,10 +35,7 @@ class Updated extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public BudgetLimit $budgetLimit;
|
||||
|
||||
public function __construct(BudgetLimit $budgetLimit)
|
||||
public function __construct(public BudgetLimit $budgetLimit)
|
||||
{
|
||||
$this->budgetLimit = $budgetLimit;
|
||||
}
|
||||
}
|
||||
|
@@ -39,18 +39,14 @@ class ChangedAmount extends Event
|
||||
|
||||
public string $amount;
|
||||
public PiggyBank $piggyBank;
|
||||
public ?TransactionGroup $transactionGroup;
|
||||
public ?TransactionJournal $transactionJournal;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(PiggyBank $piggyBank, string $amount, ?TransactionJournal $transactionJournal, ?TransactionGroup $transactionGroup)
|
||||
public function __construct(PiggyBank $piggyBank, string $amount, public ?TransactionJournal $transactionJournal, public ?TransactionGroup $transactionGroup)
|
||||
{
|
||||
app('log')->debug(sprintf('Created piggy bank event for piggy bank #%d with amount %s', $piggyBank->id, $amount));
|
||||
$this->piggyBank = $piggyBank;
|
||||
$this->transactionJournal = $transactionJournal;
|
||||
$this->transactionGroup = $transactionGroup;
|
||||
$this->amount = $amount;
|
||||
}
|
||||
}
|
||||
|
@@ -34,15 +34,8 @@ class RuleActionFailedOnArray
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public string $error;
|
||||
public array $journal;
|
||||
public RuleAction $ruleAction;
|
||||
|
||||
public function __construct(RuleAction $ruleAction, array $journal, string $error)
|
||||
public function __construct(public RuleAction $ruleAction, public array $journal, public string $error)
|
||||
{
|
||||
app('log')->debug('Created new RuleActionFailedOnArray');
|
||||
$this->ruleAction = $ruleAction;
|
||||
$this->journal = $journal;
|
||||
$this->error = $error;
|
||||
}
|
||||
}
|
||||
|
@@ -35,15 +35,8 @@ class RuleActionFailedOnObject
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public string $error;
|
||||
public TransactionJournal $journal;
|
||||
public RuleAction $ruleAction;
|
||||
|
||||
public function __construct(RuleAction $ruleAction, TransactionJournal $journal, string $error)
|
||||
public function __construct(public RuleAction $ruleAction, public TransactionJournal $journal, public string $error)
|
||||
{
|
||||
app('log')->debug('Created new RuleActionFailedOnObject');
|
||||
$this->ruleAction = $ruleAction;
|
||||
$this->journal = $journal;
|
||||
$this->error = $error;
|
||||
}
|
||||
}
|
||||
|
@@ -34,14 +34,11 @@ class NewVersionAvailable extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public string $message;
|
||||
|
||||
/**
|
||||
* Create a new event instance. This event is triggered when a new version is available.
|
||||
*/
|
||||
public function __construct(string $message)
|
||||
public function __construct(public string $message)
|
||||
{
|
||||
Log::debug(__METHOD__);
|
||||
$this->message = $message;
|
||||
}
|
||||
}
|
||||
|
@@ -33,11 +33,8 @@ class UserGroupChangedDefaultCurrency extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public UserGroup $userGroup;
|
||||
|
||||
public function __construct(UserGroup $userGroup)
|
||||
public function __construct(public UserGroup $userGroup)
|
||||
{
|
||||
Log::debug('User group changed default currency.');
|
||||
$this->userGroup = $userGroup;
|
||||
}
|
||||
}
|
||||
|
@@ -35,15 +35,10 @@ class RegisteredUser extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public OwnerNotifiable $owner;
|
||||
public User $user;
|
||||
|
||||
/**
|
||||
* Create a new event instance. This event is triggered when a new user registers.
|
||||
*/
|
||||
public function __construct(OwnerNotifiable $owner, User $user)
|
||||
public function __construct(public OwnerNotifiable $owner, public User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->owner = $owner;
|
||||
}
|
||||
}
|
||||
|
@@ -39,17 +39,12 @@ class RequestedReportOnJournals
|
||||
use InteractsWithSockets;
|
||||
use SerializesModels;
|
||||
|
||||
public Collection $groups;
|
||||
public int $userId;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(int $userId, Collection $groups)
|
||||
public function __construct(public int $userId, public Collection $groups)
|
||||
{
|
||||
app('log')->debug('In event RequestedReportOnJournals.');
|
||||
$this->userId = $userId;
|
||||
$this->groups = $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -34,14 +34,11 @@ class RequestedVersionCheckStatus extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public User $user;
|
||||
|
||||
/**
|
||||
* Create a new event instance. This event is triggered when Firefly III wants to know
|
||||
* what the deal is with the version checker.
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
public function __construct(public User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
||||
|
@@ -32,15 +32,12 @@ use Illuminate\Queue\SerializesModels;
|
||||
class MFABackupFewLeft extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public int $count;
|
||||
public User $user;
|
||||
|
||||
public function __construct(null|Authenticatable|User $user, int $count)
|
||||
public function __construct(null|Authenticatable|User $user, public int $count)
|
||||
{
|
||||
if ($user instanceof User) {
|
||||
$this->user = $user;
|
||||
}
|
||||
$this->count = $count;
|
||||
}
|
||||
}
|
||||
|
@@ -32,15 +32,12 @@ use Illuminate\Queue\SerializesModels;
|
||||
class MFAManyFailedAttempts extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public int $count;
|
||||
public User $user;
|
||||
|
||||
public function __construct(null|Authenticatable|User $user, int $count)
|
||||
public function __construct(null|Authenticatable|User $user, public int $count)
|
||||
{
|
||||
if ($user instanceof User) {
|
||||
$this->user = $user;
|
||||
}
|
||||
$this->count = $count;
|
||||
}
|
||||
}
|
||||
|
@@ -30,10 +30,7 @@ class UnknownUserAttemptedLogin
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public string $address;
|
||||
|
||||
public function __construct(string $address)
|
||||
public function __construct(public string $address)
|
||||
{
|
||||
$this->address = $address;
|
||||
}
|
||||
}
|
||||
|
@@ -34,13 +34,10 @@ class StoredAccount extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public Account $account;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(Account $account)
|
||||
public function __construct(public Account $account)
|
||||
{
|
||||
$this->account = $account;
|
||||
}
|
||||
}
|
||||
|
@@ -34,17 +34,10 @@ class StoredTransactionGroup extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public bool $applyRules;
|
||||
public bool $fireWebhooks;
|
||||
public TransactionGroup $transactionGroup;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(TransactionGroup $transactionGroup, bool $applyRules, bool $fireWebhooks)
|
||||
public function __construct(public TransactionGroup $transactionGroup, public bool $applyRules, public bool $fireWebhooks)
|
||||
{
|
||||
$this->transactionGroup = $transactionGroup;
|
||||
$this->fireWebhooks = $fireWebhooks;
|
||||
$this->applyRules = $applyRules;
|
||||
}
|
||||
}
|
||||
|
@@ -32,15 +32,13 @@ class OwnerTestNotificationChannel
|
||||
use SerializesModels;
|
||||
|
||||
public string $channel;
|
||||
public OwnerNotifiable $owner;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(string $channel, OwnerNotifiable $owner)
|
||||
public function __construct(string $channel, public OwnerNotifiable $owner)
|
||||
{
|
||||
app('log')->debug(sprintf('Triggered OwnerTestNotificationChannel("%s")', $channel));
|
||||
$this->owner = $owner;
|
||||
$this->channel = $channel;
|
||||
}
|
||||
}
|
||||
|
@@ -32,15 +32,13 @@ class UserTestNotificationChannel
|
||||
use SerializesModels;
|
||||
|
||||
public string $channel;
|
||||
public User $user;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(string $channel, User $user)
|
||||
public function __construct(string $channel, public User $user)
|
||||
{
|
||||
app('log')->debug(sprintf('Triggered UserTestNotificationChannel("%s")', $channel));
|
||||
$this->user = $user;
|
||||
$this->channel = $channel;
|
||||
}
|
||||
}
|
||||
|
@@ -34,23 +34,12 @@ class TriggeredAuditLog extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public mixed $after;
|
||||
public Model $auditable;
|
||||
public mixed $before;
|
||||
public Model $changer;
|
||||
public string $field;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @SuppressWarnings("PHPMD.ExcessiveParameterList")
|
||||
*/
|
||||
public function __construct(Model $changer, Model $auditable, string $field, mixed $before, mixed $after)
|
||||
public function __construct(public Model $changer, public Model $auditable, public string $field, public mixed $before, public mixed $after)
|
||||
{
|
||||
$this->changer = $changer;
|
||||
$this->auditable = $auditable;
|
||||
$this->field = $field;
|
||||
$this->before = $before;
|
||||
$this->after = $after;
|
||||
}
|
||||
}
|
||||
|
@@ -34,13 +34,10 @@ class UpdatedAccount extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public Account $account;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(Account $account)
|
||||
public function __construct(public Account $account)
|
||||
{
|
||||
$this->account = $account;
|
||||
}
|
||||
}
|
||||
|
@@ -34,17 +34,10 @@ class UpdatedTransactionGroup extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public bool $applyRules;
|
||||
public bool $fireWebhooks;
|
||||
public TransactionGroup $transactionGroup;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(TransactionGroup $transactionGroup, bool $applyRules, bool $fireWebhooks)
|
||||
public function __construct(public TransactionGroup $transactionGroup, public bool $applyRules, public bool $fireWebhooks)
|
||||
{
|
||||
$this->transactionGroup = $transactionGroup;
|
||||
$this->fireWebhooks = $fireWebhooks;
|
||||
$this->applyRules = $applyRules;
|
||||
}
|
||||
}
|
||||
|
@@ -34,17 +34,10 @@ class UserChangedEmail extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public string $newEmail;
|
||||
public string $oldEmail;
|
||||
public User $user;
|
||||
|
||||
/**
|
||||
* UserChangedEmail constructor.
|
||||
*/
|
||||
public function __construct(User $user, string $newEmail, string $oldEmail)
|
||||
public function __construct(public User $user, public string $newEmail, public string $oldEmail)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->oldEmail = $oldEmail;
|
||||
$this->newEmail = $newEmail;
|
||||
}
|
||||
}
|
||||
|
@@ -34,14 +34,7 @@ class WarnUserAboutBill extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public Bill $bill;
|
||||
public int $diff;
|
||||
public string $field;
|
||||
|
||||
public function __construct(Bill $bill, string $field, int $diff)
|
||||
public function __construct(public Bill $bill, public string $field, public int $diff)
|
||||
{
|
||||
$this->bill = $bill;
|
||||
$this->field = $field;
|
||||
$this->diff = $diff;
|
||||
}
|
||||
}
|
||||
|
@@ -49,6 +49,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
||||
*
|
||||
* @SuppressWarnings("PHPMD.CyclomaticComplexity")
|
||||
*/
|
||||
#[\Override]
|
||||
public function render($request, \Throwable $e): Response
|
||||
{
|
||||
$route = $request->route();
|
||||
|
@@ -69,6 +69,7 @@ class Handler extends ExceptionHandler
|
||||
/**
|
||||
* Register the exception handling callbacks for the application.
|
||||
*/
|
||||
#[\Override]
|
||||
public function register(): void {}
|
||||
|
||||
/**
|
||||
@@ -82,6 +83,7 @@ class Handler extends ExceptionHandler
|
||||
* @SuppressWarnings("PHPMD.NPathComplexity")
|
||||
* @SuppressWarnings("PHPMD.CyclomaticComplexity")
|
||||
*/
|
||||
#[\Override]
|
||||
public function render($request, \Throwable $e): Response
|
||||
{
|
||||
$expectsJson = $request->expectsJson();
|
||||
@@ -149,12 +151,12 @@ class Handler extends ExceptionHandler
|
||||
|
||||
$isDebug = (bool) config('app.debug', false);
|
||||
if ($isDebug) {
|
||||
app('log')->debug(sprintf('Return JSON %s with debug.', get_class($e)));
|
||||
app('log')->debug(sprintf('Return JSON %s with debug.', $e::class));
|
||||
|
||||
return response()->json(
|
||||
[
|
||||
'message' => $e->getMessage(),
|
||||
'exception' => get_class($e),
|
||||
'exception' => $e::class,
|
||||
'line' => $e->getLine(),
|
||||
'file' => $e->getFile(),
|
||||
'trace' => $e->getTrace(),
|
||||
@@ -162,7 +164,7 @@ class Handler extends ExceptionHandler
|
||||
$errorCode
|
||||
);
|
||||
}
|
||||
app('log')->debug(sprintf('Return JSON %s.', get_class($e)));
|
||||
app('log')->debug(sprintf('Return JSON %s.', $e::class));
|
||||
|
||||
return response()->json(
|
||||
['message' => sprintf('Internal Firefly III Exception: %s', $e->getMessage()), 'exception' => 'UndisclosedException'],
|
||||
@@ -192,7 +194,7 @@ class Handler extends ExceptionHandler
|
||||
return response()->view('errors.FireflyException', ['exception' => $e, 'debug' => $isDebug], 500);
|
||||
}
|
||||
|
||||
app('log')->debug(sprintf('Error "%s" has no Firefly III treatment, parent will handle.', get_class($e)));
|
||||
app('log')->debug(sprintf('Error "%s" has no Firefly III treatment, parent will handle.', $e::class));
|
||||
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
@@ -202,6 +204,7 @@ class Handler extends ExceptionHandler
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
#[\Override]
|
||||
public function report(\Throwable $e): void
|
||||
{
|
||||
$doMailError = (bool) config('firefly.send_error_message');
|
||||
@@ -222,7 +225,7 @@ class Handler extends ExceptionHandler
|
||||
$headers = request()->headers->all();
|
||||
|
||||
$data = [
|
||||
'class' => get_class($e),
|
||||
'class' => $e::class,
|
||||
'errorMessage' => $e->getMessage(),
|
||||
'time' => \Safe\date('r'),
|
||||
'stackTrace' => $e->getTraceAsString(),
|
||||
@@ -250,9 +253,7 @@ class Handler extends ExceptionHandler
|
||||
{
|
||||
return null !== Arr::first(
|
||||
$this->dontReport,
|
||||
static function ($type) use ($e) {
|
||||
return $e instanceof $type;
|
||||
}
|
||||
static fn($type) => $e instanceof $type
|
||||
);
|
||||
}
|
||||
|
||||
@@ -261,6 +262,7 @@ class Handler extends ExceptionHandler
|
||||
*
|
||||
* @param Request $request
|
||||
*/
|
||||
#[\Override]
|
||||
protected function invalid($request, LaravelValidationException $exception): \Illuminate\Http\Response|JsonResponse|RedirectResponse
|
||||
{
|
||||
// protect against open redirect when submitting invalid forms.
|
||||
|
@@ -41,7 +41,7 @@ class TransactionFactory
|
||||
private Account $account;
|
||||
private array $accountInformation;
|
||||
private TransactionCurrency $currency;
|
||||
private ?TransactionCurrency $foreignCurrency;
|
||||
private ?TransactionCurrency $foreignCurrency = null;
|
||||
private TransactionJournal $journal;
|
||||
private bool $reconciled;
|
||||
|
||||
|
@@ -35,7 +35,7 @@ use FireflyIII\User;
|
||||
*/
|
||||
class TransactionGroupFactory
|
||||
{
|
||||
private TransactionJournalFactory $journalFactory;
|
||||
private readonly TransactionJournalFactory $journalFactory;
|
||||
private User $user;
|
||||
private UserGroup $userGroup;
|
||||
|
||||
|
@@ -31,6 +31,7 @@ class MultiYearReportGenerator extends MonthReportGenerator
|
||||
/**
|
||||
* Returns the preferred period.
|
||||
*/
|
||||
#[\Override]
|
||||
protected function preferredPeriod(): string
|
||||
{
|
||||
return 'year';
|
||||
|
@@ -31,6 +31,7 @@ class YearReportGenerator extends MonthReportGenerator
|
||||
/**
|
||||
* Returns the preferred period.
|
||||
*/
|
||||
#[\Override]
|
||||
protected function preferredPeriod(): string
|
||||
{
|
||||
return 'month';
|
||||
|
@@ -106,7 +106,7 @@ class StandardMessageGenerator implements MessageGeneratorInterface
|
||||
*/
|
||||
private function generateMessage(Webhook $webhook, Model $model): void
|
||||
{
|
||||
$class = get_class($model);
|
||||
$class = $model::class;
|
||||
// Line is ignored because all of Firefly III's Models have an id property.
|
||||
app('log')->debug(sprintf('Now in generateMessage(#%d, %s#%d)', $webhook->id, $class, $model->id));
|
||||
|
||||
|
@@ -42,9 +42,7 @@ class WebhookEventHandler
|
||||
$messages = WebhookMessage::where('webhook_messages.sent', false)
|
||||
->get(['webhook_messages.*'])
|
||||
->filter(
|
||||
static function (WebhookMessage $message) {
|
||||
return $message->webhookAttempts()->count() <= 2;
|
||||
}
|
||||
static fn(WebhookMessage $message) => $message->webhookAttempts()->count() <= 2
|
||||
)->splice(0, 5)
|
||||
;
|
||||
app('log')->debug(sprintf('Found %d webhook message(s) ready to be send.', $messages->count()));
|
||||
|
@@ -114,8 +114,8 @@ return [
|
||||
*/
|
||||
|
||||
'extra' => [
|
||||
'Eloquent' => ['Illuminate\Database\Eloquent\Builder', 'Illuminate\Database\Query\Builder'],
|
||||
'Session' => ['Illuminate\Session\Store'],
|
||||
'Eloquent' => [\Illuminate\Database\Eloquent\Builder::class, \Illuminate\Database\Query\Builder::class],
|
||||
'Session' => [\Illuminate\Session\Store::class],
|
||||
],
|
||||
|
||||
'magic' => [
|
||||
|
Reference in New Issue
Block a user