Update code to use php 8.4 code, using Nestor.

This commit is contained in:
James Cole
2025-05-04 12:57:14 +02:00
parent 042e2ba97d
commit abd9260193
79 changed files with 120 additions and 261 deletions

View File

@@ -65,13 +65,11 @@ class BillController extends Controller
$data = $request->getData(); $data = $request->getData();
$result = $this->repository->searchBill($data['query'], $this->parameters->get('limit')); $result = $this->repository->searchBill($data['query'], $this->parameters->get('limit'));
$filtered = $result->map( $filtered = $result->map(
static function (Bill $item) { static fn(Bill $item) => [
return [ 'id' => (string) $item->id,
'id' => (string) $item->id, 'name' => $item->name,
'name' => $item->name, 'active' => $item->active,
'active' => $item->active, ]
];
}
); );
return response()->api($filtered->toArray()); return response()->api($filtered->toArray());

View File

@@ -65,12 +65,10 @@ class BudgetController extends Controller
$data = $request->getData(); $data = $request->getData();
$result = $this->repository->searchBudget($data['query'], $this->parameters->get('limit')); $result = $this->repository->searchBudget($data['query'], $this->parameters->get('limit'));
$filtered = $result->map( $filtered = $result->map(
static function (Budget $item) { static fn(Budget $item) => [
return [ 'id' => (string) $item->id,
'id' => (string) $item->id, 'name' => $item->name,
'name' => $item->name, ]
];
}
); );
return response()->api($filtered->toArray()); return response()->api($filtered->toArray());

View File

@@ -65,12 +65,10 @@ class CategoryController extends Controller
$data = $request->getData(); $data = $request->getData();
$result = $this->repository->searchCategory($data['query'], $this->parameters->get('limit')); $result = $this->repository->searchCategory($data['query'], $this->parameters->get('limit'));
$filtered = $result->map( $filtered = $result->map(
static function (Category $item) { static fn(Category $item) => [
return [ 'id' => (string) $item->id,
'id' => (string) $item->id, 'name' => $item->name,
'name' => $item->name, ]
];
}
); );
return response()->api($filtered->toArray()); return response()->api($filtered->toArray());

View File

@@ -119,9 +119,7 @@ class CategoryController extends Controller
$return = array_values($return); $return = array_values($return);
// order by amount // order by amount
usort($return, static function (array $a, array $b) { usort($return, static fn(array $a, array $b) => (float) $a['amount'] < (float) $b['amount'] ? 1 : -1);
return (float) $a['amount'] < (float) $b['amount'] ? 1 : -1;
});
return response()->json($this->clean($return)); return response()->json($this->clean($return));
} }

View File

@@ -177,9 +177,7 @@ class ListController extends Controller
// filter and paginate list: // filter and paginate list:
$collection = $unfiltered->filter( $collection = $unfiltered->filter(
static function (Bill $bill) use ($currency) { static fn(Bill $bill) => $bill->transaction_currency_id === $currency->id
return $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);

View File

@@ -85,7 +85,7 @@ class ChartRequest extends FormRequest
} }
); );
if ($validator->fails()) { 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());
} }
} }
} }

View File

@@ -74,7 +74,7 @@ class MoveTransactionsRequest extends FormRequest
} }
); );
if ($validator->fails()) { 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());
} }
} }

View File

@@ -74,7 +74,7 @@ class TransactionRequest extends FormRequest
} }
); );
if ($validator->fails()) { 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());
} }
} }
} }

View File

@@ -144,7 +144,7 @@ class UpdateRequest extends FormRequest
} }
); );
if ($validator->fails()) { 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());
} }
} }
} }

View File

@@ -58,9 +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 function (string $className) { static fn(string $className) => str_replace('FireflyIII\Models\\', '', $className),
return str_replace('FireflyIII\Models\\', '', $className);
},
$models $models
); );
$models = implode(',', $models); $models = implode(',', $models);

View File

@@ -60,9 +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 function (string $className) { static fn(string $className) => str_replace('FireflyIII\Models\\', '', $className),
return str_replace('FireflyIII\Models\\', '', $className);
},
$models $models
); );
$models = implode(',', $models); $models = implode(',', $models);

View File

@@ -90,7 +90,7 @@ class Request extends FormRequest
} }
); );
if ($validator->fails()) { 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());
} }
} }
} }

View File

@@ -129,7 +129,7 @@ class StoreRequest extends FormRequest
$failed = false; $failed = false;
} }
if ($failed) { 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());
} }
} }
} }

View File

@@ -110,7 +110,7 @@ class UpdateRequest extends FormRequest
} }
); );
if ($validator->fails()) { 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());
} }
} }
} }

View File

@@ -94,7 +94,7 @@ class StoreRequest extends FormRequest
} }
); );
if ($validator->fails()) { 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());
} }
} }
} }

View File

@@ -106,7 +106,7 @@ class UpdateRequest extends FormRequest
} }
); );
if ($validator->fails()) { 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());
} }
} }
} }

View File

@@ -96,7 +96,7 @@ class UpdateRequest extends FormRequest
} }
); );
if ($validator->fails()) { 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());
} }
} }
} }

View File

@@ -126,7 +126,7 @@ class StoreRequest extends FormRequest
} }
); );
if ($validator->fails()) { 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());
} }
} }

View File

@@ -193,7 +193,7 @@ class StoreRequest extends FormRequest
} }
); );
if ($validator->fails()) { 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());
} }
} }
} }

View File

@@ -208,7 +208,7 @@ class UpdateRequest extends FormRequest
} }
); );
if ($validator->fails()) { 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());
} }
} }
} }

View File

@@ -148,7 +148,7 @@ class StoreRequest extends FormRequest
} }
); );
if ($validator->fails()) { 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());
} }
} }

View File

@@ -168,7 +168,7 @@ class UpdateRequest extends FormRequest
} }
); );
if ($validator->fails()) { 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());
} }
} }

View File

@@ -300,7 +300,7 @@ class StoreRequest extends FormRequest
} }
); );
if ($validator->fails()) { 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());
} }
} }
} }

View File

@@ -359,7 +359,7 @@ class UpdateRequest extends FormRequest
} }
); );
if ($validator->fails()) { 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());
} }
} }
} }

View File

@@ -80,7 +80,7 @@ class StoreRequest extends FormRequest
} }
); );
if ($validator->fails()) { 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());
} }
} }

View File

@@ -80,7 +80,7 @@ class UpdateRequest extends FormRequest
} }
); );
if ($validator->fails()) { 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());
} }
} }

View File

@@ -99,7 +99,7 @@ class UserUpdateRequest extends FormRequest
} }
); );
if ($validator->fails()) { 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());
} }
} }
} }

View File

@@ -61,13 +61,11 @@ class CategoryController extends Controller
$queryParameters = $request->getParameters(); $queryParameters = $request->getParameters();
$result = $this->repository->searchCategory($queryParameters['query'], $queryParameters['size']); $result = $this->repository->searchCategory($queryParameters['query'], $queryParameters['size']);
$filtered = $result->map( $filtered = $result->map(
static function (Category $item) { static fn(Category $item) => [
return [ 'id' => (string) $item->id,
'id' => (string) $item->id, 'title' => $item->name,
'title' => $item->name, 'meta' => [],
'meta' => [], ]
];
}
); );
return response()->json($filtered); return response()->json($filtered);

View File

@@ -61,15 +61,13 @@ class TagController extends Controller
$queryParameters = $request->getParameters(); $queryParameters = $request->getParameters();
$result = $this->repository->searchTag($queryParameters['query']); $result = $this->repository->searchTag($queryParameters['query']);
$filtered = $result->map( $filtered = $result->map(
static function (Tag $item) { static fn(Tag $item) => [
return [ 'id' => (string) $item->id,
'id' => (string) $item->id, 'title' => $item->tag,
'title' => $item->tag, 'value' => (string) $item->id,
'value' => (string) $item->id, 'label' => $item->tag,
'label' => $item->tag, 'meta' => [],
'meta' => [], ]
];
}
); );
return response()->json($filtered); return response()->json($filtered);

View File

@@ -134,9 +134,7 @@ class CategoryController extends Controller
$return = array_values($return); $return = array_values($return);
// order by native amount // order by native amount
usort($return, static function (array $a, array $b) { usort($return, static fn(array $a, array $b) => (float) $a['native_amount'] < (float) $b['native_amount'] ? 1 : -1);
return (float) $a['native_amount'] < (float) $b['native_amount'] ? 1 : -1;
});
$converter->summarize(); $converter->summarize();
return response()->json($this->clean($return)); return response()->json($this->clean($return));

View File

@@ -84,7 +84,7 @@ class BalanceChartRequest extends FormRequest
} }
); );
if ($validator->fails()) { 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());
} }
} }
} }

View File

@@ -86,7 +86,7 @@ class ChartRequest extends FormRequest
} }
); );
if ($validator->fails()) { 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());
} }
} }
} }

View File

@@ -83,7 +83,7 @@ class DashboardChartRequest extends FormRequest
} }
); );
if ($validator->fails()) { 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());
} }
} }
} }

View File

@@ -311,7 +311,7 @@ class StoreRequest extends FormRequest
} }
); );
if ($validator->fails()) { 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());
} }
} }
} }

View File

@@ -64,6 +64,7 @@ class UpdateRequest extends Request
* *
* @throws FireflyException * @throws FireflyException
*/ */
#[\Override]
public function getAll(): array public function getAll(): array
{ {
app('log')->debug(sprintf('Now in %s', __METHOD__)); 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. * The rules that the incoming request must be matched against.
*/ */
#[\Override]
public function rules(): array public function rules(): array
{ {
app('log')->debug(sprintf('Now in %s', __METHOD__)); app('log')->debug(sprintf('Now in %s', __METHOD__));
@@ -330,6 +332,7 @@ class UpdateRequest extends Request
/** /**
* Configure the validator instance. * Configure the validator instance.
*/ */
#[\Override]
public function withValidator(Validator $validator): void public function withValidator(Validator $validator): void
{ {
app('log')->debug('Now in withValidator'); app('log')->debug('Now in withValidator');
@@ -361,7 +364,7 @@ class UpdateRequest extends Request
} }
); );
if ($validator->fails()) { 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());
} }
} }
} }

View File

@@ -175,7 +175,7 @@ class CorrectsAmounts extends Command
{ {
try { try {
$check = bccomp((string) $item->trigger_value, '0'); $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)); $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->active = false;
$item->rule->save(); $item->rule->save();

View File

@@ -115,9 +115,7 @@ class CorrectsCurrencies extends Command
$found = array_values( $found = array_values(
array_filter( array_filter(
$found, $found,
static function (int $currencyId) { static fn(int $currencyId) => 0 !== $currencyId
return 0 !== $currencyId;
}
) )
); );

View File

@@ -128,9 +128,7 @@ class CorrectsNativeAmounts extends Command
$repository->setUserGroup($userGroup); $repository->setUserGroup($userGroup);
$set = $repository->getPiggyBanks(); $set = $repository->getPiggyBanks();
$set = $set->filter( $set = $set->filter(
static function (PiggyBank $piggyBank) use ($currency) { static fn(PiggyBank $piggyBank) => $currency->id !== $piggyBank->transaction_currency_id
return $currency->id !== $piggyBank->transaction_currency_id;
}
); );
foreach ($set as $piggyBank) { foreach ($set as $piggyBank) {
$piggyBank->encrypted = false; $piggyBank->encrypted = false;

View File

@@ -115,9 +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 function (Transaction $transaction) { static fn(Transaction $transaction) => $transaction->amount < 0
return $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));
@@ -144,9 +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 function (Transaction $transaction) { static fn(Transaction $transaction) => $transaction->amount > 0
return $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

@@ -179,9 +179,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 function (Transaction $transaction) { static fn(Transaction $transaction) => $transaction->amount > 0
return $transaction->amount > 0;
}
); );
} }

View File

@@ -46,12 +46,12 @@ class UpgradesTransferCurrencies extends Command
private JournalCLIRepositoryInterface $cliRepos; private JournalCLIRepositoryInterface $cliRepos;
private int $count; private int $count;
private ?Account $destinationAccount; private ?Account $destinationAccount = null;
private ?TransactionCurrency $destinationCurrency; private ?TransactionCurrency $destinationCurrency = null;
private ?Transaction $destinationTransaction; private ?Transaction $destinationTransaction = null;
private ?Account $sourceAccount; private ?Account $sourceAccount = null;
private ?TransactionCurrency $sourceCurrency; private ?TransactionCurrency $sourceCurrency = null;
private ?Transaction $sourceTransaction; private ?Transaction $sourceTransaction = null;
/** /**
* Execute the console command. * Execute the console command.

View File

@@ -35,6 +35,7 @@ class Kernel extends ConsoleKernel
/** /**
* Register the commands for the application. * Register the commands for the application.
*/ */
#[\Override]
protected function commands(): void protected function commands(): void
{ {
$this->load(__DIR__.'/Commands'); $this->load(__DIR__.'/Commands');
@@ -45,6 +46,7 @@ class Kernel extends ConsoleKernel
/** /**
* Define the application's command schedule. * Define the application's command schedule.
*/ */
#[\Override]
protected function schedule(Schedule $schedule): void protected function schedule(Schedule $schedule): void
{ {
$schedule->call( $schedule->call(

View File

@@ -36,15 +36,12 @@ class InvitationCreated extends Event
{ {
use SerializesModels; use SerializesModels;
public InvitedUser $invitee;
public TransactionGroup $transactionGroup; public TransactionGroup $transactionGroup;
/** /**
* Create a new event instance. * Create a new event instance.
*/ */
public function __construct(InvitedUser $invitee) public function __construct(public InvitedUser $invitee)
{ {
$this->invitee = $invitee;
} }
} }

View File

@@ -34,14 +34,11 @@ class DestroyedTransactionGroup extends Event
{ {
use SerializesModels; use SerializesModels;
public TransactionGroup $transactionGroup;
/** /**
* Create a new event instance. * Create a new event instance.
*/ */
public function __construct(TransactionGroup $transactionGroup) public function __construct(public TransactionGroup $transactionGroup)
{ {
app('log')->debug(sprintf('Now in %s', __METHOD__)); app('log')->debug(sprintf('Now in %s', __METHOD__));
$this->transactionGroup = $transactionGroup;
} }
} }

View File

@@ -32,15 +32,12 @@ use Illuminate\Queue\SerializesModels;
*/ */
class DestroyedTransactionLink extends Event class DestroyedTransactionLink extends Event
{ {
use SerializesModels; use SerializesModels; // @phpstan-ignore-line
private TransactionJournalLink $link; // @phpstan-ignore-line
/** /**
* DestroyedTransactionLink constructor. * DestroyedTransactionLink constructor.
*/ */
public function __construct(TransactionJournalLink $link) public function __construct(private TransactionJournalLink $link)
{ {
$this->link = $link;
} }
} }

View File

@@ -34,13 +34,10 @@ class DetectedNewIPAddress extends Event
{ {
use SerializesModels; use SerializesModels;
public User $user;
/** /**
* Create a new event instance. This event is triggered when a new user registers. * 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;
} }
} }

View File

@@ -31,10 +31,7 @@ class Updated
{ {
use SerializesModels; use SerializesModels;
public Account $account; public function __construct(public Account $account)
public function __construct(Account $account)
{ {
$this->account = $account;
} }
} }

View File

@@ -35,10 +35,7 @@ class Created extends Event
{ {
use SerializesModels; use SerializesModels;
public BudgetLimit $budgetLimit; public function __construct(public BudgetLimit $budgetLimit)
public function __construct(BudgetLimit $budgetLimit)
{ {
$this->budgetLimit = $budgetLimit;
} }
} }

View File

@@ -35,10 +35,7 @@ class Deleted extends Event
{ {
use SerializesModels; use SerializesModels;
public BudgetLimit $budgetLimit; public function __construct(public BudgetLimit $budgetLimit)
public function __construct(BudgetLimit $budgetLimit)
{ {
$this->budgetLimit = $budgetLimit;
} }
} }

View File

@@ -35,10 +35,7 @@ class Updated extends Event
{ {
use SerializesModels; use SerializesModels;
public BudgetLimit $budgetLimit; public function __construct(public BudgetLimit $budgetLimit)
public function __construct(BudgetLimit $budgetLimit)
{ {
$this->budgetLimit = $budgetLimit;
} }
} }

View File

@@ -39,18 +39,14 @@ class ChangedAmount extends Event
public string $amount; public string $amount;
public PiggyBank $piggyBank; public PiggyBank $piggyBank;
public ?TransactionGroup $transactionGroup;
public ?TransactionJournal $transactionJournal;
/** /**
* Create a new event instance. * 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)); app('log')->debug(sprintf('Created piggy bank event for piggy bank #%d with amount %s', $piggyBank->id, $amount));
$this->piggyBank = $piggyBank; $this->piggyBank = $piggyBank;
$this->transactionJournal = $transactionJournal;
$this->transactionGroup = $transactionGroup;
$this->amount = $amount; $this->amount = $amount;
} }
} }

View File

@@ -34,15 +34,8 @@ class RuleActionFailedOnArray
{ {
use SerializesModels; use SerializesModels;
public string $error; public function __construct(public RuleAction $ruleAction, public array $journal, public string $error)
public array $journal;
public RuleAction $ruleAction;
public function __construct(RuleAction $ruleAction, array $journal, string $error)
{ {
app('log')->debug('Created new RuleActionFailedOnArray'); app('log')->debug('Created new RuleActionFailedOnArray');
$this->ruleAction = $ruleAction;
$this->journal = $journal;
$this->error = $error;
} }
} }

View File

@@ -35,15 +35,8 @@ class RuleActionFailedOnObject
{ {
use SerializesModels; use SerializesModels;
public string $error; public function __construct(public RuleAction $ruleAction, public TransactionJournal $journal, public string $error)
public TransactionJournal $journal;
public RuleAction $ruleAction;
public function __construct(RuleAction $ruleAction, TransactionJournal $journal, string $error)
{ {
app('log')->debug('Created new RuleActionFailedOnObject'); app('log')->debug('Created new RuleActionFailedOnObject');
$this->ruleAction = $ruleAction;
$this->journal = $journal;
$this->error = $error;
} }
} }

View File

@@ -34,14 +34,11 @@ class NewVersionAvailable extends Event
{ {
use SerializesModels; use SerializesModels;
public string $message;
/** /**
* Create a new event instance. This event is triggered when a new version is available. * 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__); Log::debug(__METHOD__);
$this->message = $message;
} }
} }

View File

@@ -33,11 +33,8 @@ class UserGroupChangedDefaultCurrency extends Event
{ {
use SerializesModels; use SerializesModels;
public UserGroup $userGroup; public function __construct(public UserGroup $userGroup)
public function __construct(UserGroup $userGroup)
{ {
Log::debug('User group changed default currency.'); Log::debug('User group changed default currency.');
$this->userGroup = $userGroup;
} }
} }

View File

@@ -35,15 +35,10 @@ class RegisteredUser extends Event
{ {
use SerializesModels; use SerializesModels;
public OwnerNotifiable $owner;
public User $user;
/** /**
* Create a new event instance. This event is triggered when a new user registers. * 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;
} }
} }

View File

@@ -39,17 +39,12 @@ class RequestedReportOnJournals
use InteractsWithSockets; use InteractsWithSockets;
use SerializesModels; use SerializesModels;
public Collection $groups;
public int $userId;
/** /**
* Create a new event instance. * 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.'); app('log')->debug('In event RequestedReportOnJournals.');
$this->userId = $userId;
$this->groups = $groups;
} }
/** /**

View File

@@ -34,14 +34,11 @@ class RequestedVersionCheckStatus extends Event
{ {
use SerializesModels; use SerializesModels;
public User $user;
/** /**
* Create a new event instance. This event is triggered when Firefly III wants to know * Create a new event instance. This event is triggered when Firefly III wants to know
* what the deal is with the version checker. * what the deal is with the version checker.
*/ */
public function __construct(User $user) public function __construct(public User $user)
{ {
$this->user = $user;
} }
} }

View File

@@ -32,15 +32,12 @@ use Illuminate\Queue\SerializesModels;
class MFABackupFewLeft extends Event class MFABackupFewLeft extends Event
{ {
use SerializesModels; use SerializesModels;
public int $count;
public User $user; 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) { if ($user instanceof User) {
$this->user = $user; $this->user = $user;
} }
$this->count = $count;
} }
} }

View File

@@ -32,15 +32,12 @@ use Illuminate\Queue\SerializesModels;
class MFAManyFailedAttempts extends Event class MFAManyFailedAttempts extends Event
{ {
use SerializesModels; use SerializesModels;
public int $count;
public User $user; 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) { if ($user instanceof User) {
$this->user = $user; $this->user = $user;
} }
$this->count = $count;
} }
} }

View File

@@ -30,10 +30,7 @@ class UnknownUserAttemptedLogin
{ {
use SerializesModels; use SerializesModels;
public string $address; public function __construct(public string $address)
public function __construct(string $address)
{ {
$this->address = $address;
} }
} }

View File

@@ -34,13 +34,10 @@ class StoredAccount extends Event
{ {
use SerializesModels; use SerializesModels;
public Account $account;
/** /**
* Create a new event instance. * Create a new event instance.
*/ */
public function __construct(Account $account) public function __construct(public Account $account)
{ {
$this->account = $account;
} }
} }

View File

@@ -34,17 +34,10 @@ class StoredTransactionGroup extends Event
{ {
use SerializesModels; use SerializesModels;
public bool $applyRules;
public bool $fireWebhooks;
public TransactionGroup $transactionGroup;
/** /**
* Create a new event instance. * 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;
} }
} }

View File

@@ -32,15 +32,13 @@ class OwnerTestNotificationChannel
use SerializesModels; use SerializesModels;
public string $channel; public string $channel;
public OwnerNotifiable $owner;
/** /**
* Create a new event instance. * 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)); app('log')->debug(sprintf('Triggered OwnerTestNotificationChannel("%s")', $channel));
$this->owner = $owner;
$this->channel = $channel; $this->channel = $channel;
} }
} }

View File

@@ -32,15 +32,13 @@ class UserTestNotificationChannel
use SerializesModels; use SerializesModels;
public string $channel; public string $channel;
public User $user;
/** /**
* Create a new event instance. * 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)); app('log')->debug(sprintf('Triggered UserTestNotificationChannel("%s")', $channel));
$this->user = $user;
$this->channel = $channel; $this->channel = $channel;
} }
} }

View File

@@ -34,23 +34,12 @@ class TriggeredAuditLog extends Event
{ {
use SerializesModels; use SerializesModels;
public mixed $after;
public Model $auditable;
public mixed $before;
public Model $changer;
public string $field;
/** /**
* Create a new event instance. * Create a new event instance.
* *
* @SuppressWarnings("PHPMD.ExcessiveParameterList") * @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;
} }
} }

View File

@@ -34,13 +34,10 @@ class UpdatedAccount extends Event
{ {
use SerializesModels; use SerializesModels;
public Account $account;
/** /**
* Create a new event instance. * Create a new event instance.
*/ */
public function __construct(Account $account) public function __construct(public Account $account)
{ {
$this->account = $account;
} }
} }

View File

@@ -34,17 +34,10 @@ class UpdatedTransactionGroup extends Event
{ {
use SerializesModels; use SerializesModels;
public bool $applyRules;
public bool $fireWebhooks;
public TransactionGroup $transactionGroup;
/** /**
* Create a new event instance. * 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;
} }
} }

View File

@@ -34,17 +34,10 @@ class UserChangedEmail extends Event
{ {
use SerializesModels; use SerializesModels;
public string $newEmail;
public string $oldEmail;
public User $user;
/** /**
* UserChangedEmail constructor. * 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;
} }
} }

View File

@@ -34,14 +34,7 @@ class WarnUserAboutBill extends Event
{ {
use SerializesModels; use SerializesModels;
public Bill $bill; public function __construct(public Bill $bill, public string $field, public int $diff)
public int $diff;
public string $field;
public function __construct(Bill $bill, string $field, int $diff)
{ {
$this->bill = $bill;
$this->field = $field;
$this->diff = $diff;
} }
} }

View File

@@ -49,6 +49,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
* *
* @SuppressWarnings("PHPMD.CyclomaticComplexity") * @SuppressWarnings("PHPMD.CyclomaticComplexity")
*/ */
#[\Override]
public function render($request, \Throwable $e): Response public function render($request, \Throwable $e): Response
{ {
$route = $request->route(); $route = $request->route();

View File

@@ -69,6 +69,7 @@ class Handler extends ExceptionHandler
/** /**
* Register the exception handling callbacks for the application. * Register the exception handling callbacks for the application.
*/ */
#[\Override]
public function register(): void {} public function register(): void {}
/** /**
@@ -82,6 +83,7 @@ class Handler extends ExceptionHandler
* @SuppressWarnings("PHPMD.NPathComplexity") * @SuppressWarnings("PHPMD.NPathComplexity")
* @SuppressWarnings("PHPMD.CyclomaticComplexity") * @SuppressWarnings("PHPMD.CyclomaticComplexity")
*/ */
#[\Override]
public function render($request, \Throwable $e): Response public function render($request, \Throwable $e): Response
{ {
$expectsJson = $request->expectsJson(); $expectsJson = $request->expectsJson();
@@ -149,12 +151,12 @@ class Handler extends ExceptionHandler
$isDebug = (bool) config('app.debug', false); $isDebug = (bool) config('app.debug', false);
if ($isDebug) { 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( return response()->json(
[ [
'message' => $e->getMessage(), 'message' => $e->getMessage(),
'exception' => get_class($e), 'exception' => $e::class,
'line' => $e->getLine(), 'line' => $e->getLine(),
'file' => $e->getFile(), 'file' => $e->getFile(),
'trace' => $e->getTrace(), 'trace' => $e->getTrace(),
@@ -162,7 +164,7 @@ class Handler extends ExceptionHandler
$errorCode $errorCode
); );
} }
app('log')->debug(sprintf('Return JSON %s.', get_class($e))); app('log')->debug(sprintf('Return JSON %s.', $e::class));
return response()->json( return response()->json(
['message' => sprintf('Internal Firefly III Exception: %s', $e->getMessage()), 'exception' => 'UndisclosedException'], ['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); 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); return parent::render($request, $e);
} }
@@ -202,6 +204,7 @@ class Handler extends ExceptionHandler
* *
* @throws \Throwable * @throws \Throwable
*/ */
#[\Override]
public function report(\Throwable $e): void public function report(\Throwable $e): void
{ {
$doMailError = (bool) config('firefly.send_error_message'); $doMailError = (bool) config('firefly.send_error_message');
@@ -222,7 +225,7 @@ class Handler extends ExceptionHandler
$headers = request()->headers->all(); $headers = request()->headers->all();
$data = [ $data = [
'class' => get_class($e), 'class' => $e::class,
'errorMessage' => $e->getMessage(), 'errorMessage' => $e->getMessage(),
'time' => \Safe\date('r'), 'time' => \Safe\date('r'),
'stackTrace' => $e->getTraceAsString(), 'stackTrace' => $e->getTraceAsString(),
@@ -250,9 +253,7 @@ class Handler extends ExceptionHandler
{ {
return null !== Arr::first( return null !== Arr::first(
$this->dontReport, $this->dontReport,
static function ($type) use ($e) { static fn($type) => $e instanceof $type
return $e instanceof $type;
}
); );
} }
@@ -261,6 +262,7 @@ class Handler extends ExceptionHandler
* *
* @param Request $request * @param Request $request
*/ */
#[\Override]
protected function invalid($request, LaravelValidationException $exception): \Illuminate\Http\Response|JsonResponse|RedirectResponse protected function invalid($request, LaravelValidationException $exception): \Illuminate\Http\Response|JsonResponse|RedirectResponse
{ {
// protect against open redirect when submitting invalid forms. // protect against open redirect when submitting invalid forms.

View File

@@ -41,7 +41,7 @@ class TransactionFactory
private Account $account; private Account $account;
private array $accountInformation; private array $accountInformation;
private TransactionCurrency $currency; private TransactionCurrency $currency;
private ?TransactionCurrency $foreignCurrency; private ?TransactionCurrency $foreignCurrency = null;
private TransactionJournal $journal; private TransactionJournal $journal;
private bool $reconciled; private bool $reconciled;

View File

@@ -35,7 +35,7 @@ use FireflyIII\User;
*/ */
class TransactionGroupFactory class TransactionGroupFactory
{ {
private TransactionJournalFactory $journalFactory; private readonly TransactionJournalFactory $journalFactory;
private User $user; private User $user;
private UserGroup $userGroup; private UserGroup $userGroup;

View File

@@ -31,6 +31,7 @@ class MultiYearReportGenerator extends MonthReportGenerator
/** /**
* Returns the preferred period. * Returns the preferred period.
*/ */
#[\Override]
protected function preferredPeriod(): string protected function preferredPeriod(): string
{ {
return 'year'; return 'year';

View File

@@ -31,6 +31,7 @@ class YearReportGenerator extends MonthReportGenerator
/** /**
* Returns the preferred period. * Returns the preferred period.
*/ */
#[\Override]
protected function preferredPeriod(): string protected function preferredPeriod(): string
{ {
return 'month'; return 'month';

View File

@@ -106,7 +106,7 @@ class StandardMessageGenerator implements MessageGeneratorInterface
*/ */
private function generateMessage(Webhook $webhook, Model $model): void 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. // 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)); app('log')->debug(sprintf('Now in generateMessage(#%d, %s#%d)', $webhook->id, $class, $model->id));

View File

@@ -42,9 +42,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 function (WebhookMessage $message) { static fn(WebhookMessage $message) => $message->webhookAttempts()->count() <= 2
return $message->webhookAttempts()->count() <= 2;
}
)->splice(0, 5) )->splice(0, 5)
; ;
app('log')->debug(sprintf('Found %d webhook message(s) ready to be send.', $messages->count())); app('log')->debug(sprintf('Found %d webhook message(s) ready to be send.', $messages->count()));

View File

@@ -114,8 +114,8 @@ return [
*/ */
'extra' => [ 'extra' => [
'Eloquent' => ['Illuminate\Database\Eloquent\Builder', 'Illuminate\Database\Query\Builder'], 'Eloquent' => [\Illuminate\Database\Eloquent\Builder::class, \Illuminate\Database\Query\Builder::class],
'Session' => ['Illuminate\Session\Store'], 'Session' => [\Illuminate\Session\Store::class],
], ],
'magic' => [ 'magic' => [