Skip to content

Firefly III: a personal finances manager

Update more code.

James Colee42107c03c07
diff --git a/app/Support/Search/QueryParser/FieldNode.php b/app/Support/Search/QueryParser/FieldNode.php
index a92be2a9f4..6faecc918f 100644
--- a/app/Support/Search/QueryParser/FieldNode.php
+++ b/app/Support/Search/QueryParser/FieldNode.php
@@ -30,13 +30,8 @@ namespace FireflyIII\Support\Search\QueryParser;
*/
class FieldNode extends Node
{
- private string $operator;
- private string $value;
-
- public function __construct(string $operator, string $value, bool $prohibited = false)
+ public function __construct(private readonly string $operator, private readonly string $value, bool $prohibited = false)
{
- $this->operator = $operator;
- $this->value = $value;
$this->prohibited = $prohibited;
}
diff --git a/app/Support/Search/QueryParser/GdbotsQueryParser.php b/app/Support/Search/QueryParser/GdbotsQueryParser.php
index 56dde78b20..a071c972fa 100644
--- a/app/Support/Search/QueryParser/GdbotsQueryParser.php
+++ b/app/Support/Search/QueryParser/GdbotsQueryParser.php
@@ -33,7 +33,7 @@ use Illuminate\Support\Facades\Log;
class GdbotsQueryParser implements QueryParserInterface
{
- private BaseQueryParser $parser;
+ private readonly BaseQueryParser $parser;
public function __construct()
{
@@ -98,7 +98,7 @@ class GdbotsQueryParser implements QueryParserInterface
default:
throw new FireflyException(
- sprintf('Unsupported node type: %s', get_class($node))
+ sprintf('Unsupported node type: %s', $node::class)
);
}
}
diff --git a/app/Support/Search/QueryParser/NodeGroup.php b/app/Support/Search/QueryParser/NodeGroup.php
index 8fcd2d7588..017a5a89c0 100644
--- a/app/Support/Search/QueryParser/NodeGroup.php
+++ b/app/Support/Search/QueryParser/NodeGroup.php
@@ -32,15 +32,11 @@ namespace FireflyIII\Support\Search\QueryParser;
*/
class NodeGroup extends Node
{
- /** @var Node[] */
- private array $nodes;
-
/**
* @param Node[] $nodes
*/
- public function __construct(array $nodes, bool $prohibited = false)
+ public function __construct(private readonly array $nodes, bool $prohibited = false)
{
- $this->nodes = $nodes;
$this->prohibited = $prohibited;
}
diff --git a/app/Support/Search/QueryParser/StringNode.php b/app/Support/Search/QueryParser/StringNode.php
index 37d7bf5401..805334fbf1 100644
--- a/app/Support/Search/QueryParser/StringNode.php
+++ b/app/Support/Search/QueryParser/StringNode.php
@@ -30,11 +30,8 @@ namespace FireflyIII\Support\Search\QueryParser;
*/
class StringNode extends Node
{
- private string $value;
-
- public function __construct(string $value, bool $prohibited = false)
+ public function __construct(private readonly string $value, bool $prohibited = false)
{
- $this->value = $value;
$this->prohibited = $prohibited;
}
diff --git a/app/Support/System/GeneratesInstallationId.php b/app/Support/System/GeneratesInstallationId.php
index e3dde0e793..20cd0a303c 100644
--- a/app/Support/System/GeneratesInstallationId.php
+++ b/app/Support/System/GeneratesInstallationId.php
@@ -36,7 +36,7 @@ trait GeneratesInstallationId
{
try {
$config = app('fireflyconfig')->get('installation_id');
- } catch (FireflyException $e) {
+ } catch (FireflyException) {
app('log')->info('Could not create or generate installation ID. Do not continue.');
return;
diff --git a/app/Support/Twig/AmountFormat.php b/app/Support/Twig/AmountFormat.php
index 9a70e1da0f..7028a04a51 100644
--- a/app/Support/Twig/AmountFormat.php
+++ b/app/Support/Twig/AmountFormat.php
@@ -37,6 +37,7 @@ use Twig\TwigFunction;
*/
class AmountFormat extends AbstractExtension
{
+ #[\Override]
public function getFilters(): array
{
return [
@@ -71,6 +72,7 @@ class AmountFormat extends AbstractExtension
);
}
+ #[\Override]
public function getFunctions(): array
{
return [
diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php
index e0e4a8fdf3..8d3ac12203 100644
--- a/app/Support/Twig/General.php
+++ b/app/Support/Twig/General.php
@@ -43,6 +43,7 @@ use Twig\TwigFunction;
*/
class General extends AbstractExtension
{
+ #[\Override]
public function getFilters(): array
{
return [
@@ -74,7 +75,7 @@ class General extends AbstractExtension
$default = Amount::getNativeCurrency();
$convertToNative = Amount::convertToNative();
$useNative = $convertToNative && $default->id !== $currency->id;
- $currency = null === $currency ? $default : $currency;
+ $currency ??= $default;
$strings = [];
foreach ($info as $key => $balance) {
if ('balance' === $key) {
@@ -137,77 +138,15 @@ class General extends AbstractExtension
{
return new TwigFilter(
'mimeIcon',
- static function (string $string): string {
- switch ($string) {
- default:
- return 'fa-file-o';
-
- case 'application/pdf':
- return 'fa-file-pdf-o';
-
- // image
- case 'image/png':
- case 'image/jpeg':
- case 'image/svg+xml':
- case 'image/heic':
- case 'image/heic-sequence':
- case 'application/vnd.oasis.opendocument.image':
- return 'fa-file-image-o';
-
- // MS word
- case 'application/msword':
- case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
- case 'application/vnd.openxmlformats-officedocument.wordprocessingml.template':
- case 'application/x-iwork-pages-sffpages':
- case 'application/vnd.sun.xml.writer':
- case 'application/vnd.sun.xml.writer.template':
- case 'application/vnd.sun.xml.writer.global':
- case 'application/vnd.stardivision.writer':
- case 'application/vnd.stardivision.writer-global':
- case 'application/vnd.oasis.opendocument.text':
- case 'application/vnd.oasis.opendocument.text-template':
- case 'application/vnd.oasis.opendocument.text-web':
- case 'application/vnd.oasis.opendocument.text-master':
- return 'fa-file-word-o';
-
- // MS excel
- case 'application/vnd.ms-excel':
- case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
- case 'application/vnd.openxmlformats-officedocument.spreadsheetml.template':
- case 'application/vnd.sun.xml.calc':
- case 'application/vnd.sun.xml.calc.template':
- case 'application/vnd.stardivision.calc':
- case 'application/vnd.oasis.opendocument.spreadsheet':
- case 'application/vnd.oasis.opendocument.spreadsheet-template':
- return 'fa-file-excel-o';
-
- // MS powerpoint
- case 'application/vnd.ms-powerpoint':
- case 'application/vnd.openxmlformats-officedocument.presentationml.presentation':
- case 'application/vnd.openxmlformats-officedocument.presentationml.template':
- case 'application/vnd.openxmlformats-officedocument.presentationml.slideshow':
- case 'application/vnd.sun.xml.impress':
- case 'application/vnd.sun.xml.impress.template':
- case 'application/vnd.stardivision.impress':
- case 'application/vnd.oasis.opendocument.presentation':
- case 'application/vnd.oasis.opendocument.presentation-template':
- return 'fa-file-powerpoint-o';
-
- // calc
- case 'application/vnd.sun.xml.draw':
- case 'application/vnd.sun.xml.draw.template':
- case 'application/vnd.stardivision.draw':
- case 'application/vnd.oasis.opendocument.chart':
- return 'fa-paint-brush';
-
- case 'application/vnd.oasis.opendocument.graphics':
- case 'application/vnd.oasis.opendocument.graphics-template':
- case 'application/vnd.sun.xml.math':
- case 'application/vnd.stardivision.math':
- case 'application/vnd.oasis.opendocument.formula':
- case 'application/vnd.oasis.opendocument.database':
- return 'fa-calculator';
- }
+ static fn(string $string): string => match ($string) {
+ 'application/pdf' => 'fa-file-pdf-o',
+ 'image/png', 'image/jpeg', 'image/svg+xml', 'image/heic', 'image/heic-sequence', 'application/vnd.oasis.opendocument.image' => 'fa-file-image-o',
+ 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', 'application/x-iwork-pages-sffpages', 'application/vnd.sun.xml.writer', 'application/vnd.sun.xml.writer.template', 'application/vnd.sun.xml.writer.global', 'application/vnd.stardivision.writer', 'application/vnd.stardivision.writer-global', 'application/vnd.oasis.opendocument.text', 'application/vnd.oasis.opendocument.text-template', 'application/vnd.oasis.opendocument.text-web', 'application/vnd.oasis.opendocument.text-master' => 'fa-file-word-o',
+ 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', 'application/vnd.sun.xml.calc', 'application/vnd.sun.xml.calc.template', 'application/vnd.stardivision.calc', 'application/vnd.oasis.opendocument.spreadsheet', 'application/vnd.oasis.opendocument.spreadsheet-template' => 'fa-file-excel-o',
+ 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/vnd.openxmlformats-officedocument.presentationml.template', 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', 'application/vnd.sun.xml.impress', 'application/vnd.sun.xml.impress.template', 'application/vnd.stardivision.impress', 'application/vnd.oasis.opendocument.presentation', 'application/vnd.oasis.opendocument.presentation-template' => 'fa-file-powerpoint-o',
+ 'application/vnd.sun.xml.draw', 'application/vnd.sun.xml.draw.template', 'application/vnd.stardivision.draw', 'application/vnd.oasis.opendocument.chart' => 'fa-paint-brush',
+ 'application/vnd.oasis.opendocument.graphics', 'application/vnd.oasis.opendocument.graphics-template', 'application/vnd.sun.xml.math', 'application/vnd.stardivision.math', 'application/vnd.oasis.opendocument.formula', 'application/vnd.oasis.opendocument.database' => 'fa-calculator',
+ default => 'fa-file-o',
},
['is_safe' => ['html']]
);
@@ -248,6 +187,7 @@ class General extends AbstractExtension
);
}
+ #[\Override]
public function getFunctions(): array
{
return [
@@ -271,9 +211,7 @@ class General extends AbstractExtension
{
return new TwigFunction(
'phpdate',
- static function (string $str): string {
- return \Safe\date($str);
- }
+ static fn(string $str): string => \Safe\date($str)
);
}
@@ -333,8 +271,8 @@ class General extends AbstractExtension
if ($objectType === $activeObjectType
&& false !== stripos(
- \Route::getCurrentRoute()->getName(),
- $route
+ (string) \Route::getCurrentRoute()->getName(),
+ (string) $route
)) {
return 'active';
}
@@ -435,9 +373,7 @@ class General extends AbstractExtension
{
return new TwigFunction(
'carbonize',
- static function (string $date): Carbon {
- return new Carbon($date, config('app.timezone'));
- }
+ static fn(string $date): Carbon => new Carbon($date, config('app.timezone'))
);
}
}
diff --git a/app/Support/Twig/Rule.php b/app/Support/Twig/Rule.php
index 42ef0f6ff9..1bc13eb461 100644
--- a/app/Support/Twig/Rule.php
+++ b/app/Support/Twig/Rule.php
@@ -31,6 +31,7 @@ use Twig\TwigFunction;
*/
class Rule extends AbstractExtension
{
+ #[\Override]
public function getFunctions(): array
{
return [
@@ -44,13 +45,11 @@ class Rule extends AbstractExtension
{
return new TwigFunction(
'allJournalTriggers',
- static function () {
- return [
- 'store-journal' => (string) trans('firefly.rule_trigger_store_journal'),
- 'update-journal' => (string) trans('firefly.rule_trigger_update_journal'),
- 'manual-activation' => (string) trans('firefly.rule_trigger_manual'),
- ];
- }
+ static fn() => [
+ 'store-journal' => (string) trans('firefly.rule_trigger_store_journal'),
+ 'update-journal' => (string) trans('firefly.rule_trigger_update_journal'),
+ 'manual-activation' => (string) trans('firefly.rule_trigger_manual'),
+ ]
);
}
diff --git a/app/Support/Twig/TransactionGroupTwig.php b/app/Support/Twig/TransactionGroupTwig.php
index b3df2e485a..bc338d4b22 100644
--- a/app/Support/Twig/TransactionGroupTwig.php
+++ b/app/Support/Twig/TransactionGroupTwig.php
@@ -39,6 +39,7 @@ use Twig\TwigFunction;
*/
class TransactionGroupTwig extends AbstractExtension
{
+ #[\Override]
public function getFunctions(): array
{
return [
diff --git a/app/Support/Twig/Translation.php b/app/Support/Twig/Translation.php
index 706dd74221..78781936ca 100644
--- a/app/Support/Twig/Translation.php
+++ b/app/Support/Twig/Translation.php
@@ -32,19 +32,19 @@ use Twig\TwigFunction;
*/
class Translation extends AbstractExtension
{
+ #[\Override]
public function getFilters(): array
{
return [
new TwigFilter(
'_',
- static function ($name) {
- return (string) trans(sprintf('firefly.%s', $name));
- },
+ static fn($name) => (string) trans(sprintf('firefly.%s', $name)),
['is_safe' => ['html']]
),
];
}
+ #[\Override]
public function getFunctions(): array
{
return [
diff --git a/app/TransactionRules/Actions/AddTag.php b/app/TransactionRules/Actions/AddTag.php
index 42330e2655..a7fa14473a 100644
--- a/app/TransactionRules/Actions/AddTag.php
+++ b/app/TransactionRules/Actions/AddTag.php
@@ -36,14 +36,11 @@ use Illuminate\Support\Facades\DB;
*/
class AddTag implements ActionInterface
{
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private readonly RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/AppendDescription.php b/app/TransactionRules/Actions/AppendDescription.php
index fba8df1a58..120ddc591c 100644
--- a/app/TransactionRules/Actions/AppendDescription.php
+++ b/app/TransactionRules/Actions/AppendDescription.php
@@ -37,14 +37,11 @@ class AppendDescription implements ActionInterface
{
use RefreshNotesTrait;
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/AppendDescriptionToNotes.php b/app/TransactionRules/Actions/AppendDescriptionToNotes.php
index 5ca9f9214f..47ecc75a78 100644
--- a/app/TransactionRules/Actions/AppendDescriptionToNotes.php
+++ b/app/TransactionRules/Actions/AppendDescriptionToNotes.php
@@ -39,14 +39,11 @@ class AppendDescriptionToNotes implements ActionInterface
{
use RefreshNotesTrait;
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/AppendNotes.php b/app/TransactionRules/Actions/AppendNotes.php
index c3f06b8ada..d5d1737a05 100644
--- a/app/TransactionRules/Actions/AppendNotes.php
+++ b/app/TransactionRules/Actions/AppendNotes.php
@@ -37,14 +37,11 @@ class AppendNotes implements ActionInterface
{
use RefreshNotesTrait;
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/AppendNotesToDescription.php b/app/TransactionRules/Actions/AppendNotesToDescription.php
index 5d8c4584fb..441b63878a 100644
--- a/app/TransactionRules/Actions/AppendNotesToDescription.php
+++ b/app/TransactionRules/Actions/AppendNotesToDescription.php
@@ -41,14 +41,11 @@ class AppendNotesToDescription implements ActionInterface
use ConvertsDataTypes;
use RefreshNotesTrait;
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/ClearBudget.php b/app/TransactionRules/Actions/ClearBudget.php
index 06275d4bc8..8b227d8252 100644
--- a/app/TransactionRules/Actions/ClearBudget.php
+++ b/app/TransactionRules/Actions/ClearBudget.php
@@ -34,14 +34,11 @@ use Illuminate\Support\Facades\DB;
*/
class ClearBudget implements ActionInterface
{
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private readonly RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/ClearCategory.php b/app/TransactionRules/Actions/ClearCategory.php
index 4831064c9b..bd0e206ef0 100644
--- a/app/TransactionRules/Actions/ClearCategory.php
+++ b/app/TransactionRules/Actions/ClearCategory.php
@@ -34,14 +34,11 @@ use Illuminate\Support\Facades\DB;
*/
class ClearCategory implements ActionInterface
{
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private readonly RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/ClearNotes.php b/app/TransactionRules/Actions/ClearNotes.php
index 0aa0d693df..0ceeb84128 100644
--- a/app/TransactionRules/Actions/ClearNotes.php
+++ b/app/TransactionRules/Actions/ClearNotes.php
@@ -35,14 +35,11 @@ use Illuminate\Support\Facades\DB;
*/
class ClearNotes implements ActionInterface
{
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private readonly RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/ConvertToDeposit.php b/app/TransactionRules/Actions/ConvertToDeposit.php
index d7aa0dfeb0..221aa4dac4 100644
--- a/app/TransactionRules/Actions/ConvertToDeposit.php
+++ b/app/TransactionRules/Actions/ConvertToDeposit.php
@@ -43,14 +43,11 @@ use Illuminate\Support\Facades\DB;
*/
class ConvertToDeposit implements ActionInterface
{
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private readonly RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/ConvertToTransfer.php b/app/TransactionRules/Actions/ConvertToTransfer.php
index a2f6e69317..1b49d0ea20 100644
--- a/app/TransactionRules/Actions/ConvertToTransfer.php
+++ b/app/TransactionRules/Actions/ConvertToTransfer.php
@@ -42,14 +42,11 @@ use Illuminate\Support\Facades\DB;
*/
class ConvertToTransfer implements ActionInterface
{
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private readonly RuleAction $action)
{
- $this->action = $action;
}
/**
diff --git a/app/TransactionRules/Actions/ConvertToWithdrawal.php b/app/TransactionRules/Actions/ConvertToWithdrawal.php
index 05ded624b6..adcf28b6d1 100644
--- a/app/TransactionRules/Actions/ConvertToWithdrawal.php
+++ b/app/TransactionRules/Actions/ConvertToWithdrawal.php
@@ -43,14 +43,11 @@ use Illuminate\Support\Facades\DB;
*/
class ConvertToWithdrawal implements ActionInterface
{
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private readonly RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/DeleteTransaction.php b/app/TransactionRules/Actions/DeleteTransaction.php
index 5863422fa3..ed6d8efbda 100644
--- a/app/TransactionRules/Actions/DeleteTransaction.php
+++ b/app/TransactionRules/Actions/DeleteTransaction.php
@@ -35,14 +35,11 @@ use FireflyIII\Services\Internal\Destroy\TransactionGroupDestroyService;
*/
class DeleteTransaction implements ActionInterface
{
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private readonly RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/LinkToBill.php b/app/TransactionRules/Actions/LinkToBill.php
index 3e114846ac..3266d31a6a 100644
--- a/app/TransactionRules/Actions/LinkToBill.php
+++ b/app/TransactionRules/Actions/LinkToBill.php
@@ -37,14 +37,11 @@ use Illuminate\Support\Facades\DB;
*/
class LinkToBill implements ActionInterface
{
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private readonly RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/MoveDescriptionToNotes.php b/app/TransactionRules/Actions/MoveDescriptionToNotes.php
index 6dae68c34d..4da820269b 100644
--- a/app/TransactionRules/Actions/MoveDescriptionToNotes.php
+++ b/app/TransactionRules/Actions/MoveDescriptionToNotes.php
@@ -36,14 +36,11 @@ use FireflyIII\Models\TransactionJournal;
*/
class MoveDescriptionToNotes implements ActionInterface
{
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private readonly RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/MoveNotesToDescription.php b/app/TransactionRules/Actions/MoveNotesToDescription.php
index 108d3ce499..0732fb2fe2 100644
--- a/app/TransactionRules/Actions/MoveNotesToDescription.php
+++ b/app/TransactionRules/Actions/MoveNotesToDescription.php
@@ -42,14 +42,11 @@ class MoveNotesToDescription implements ActionInterface
{
use ConvertsDataTypes;
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/PrependDescription.php b/app/TransactionRules/Actions/PrependDescription.php
index 8e409b0ee3..9dba455757 100644
--- a/app/TransactionRules/Actions/PrependDescription.php
+++ b/app/TransactionRules/Actions/PrependDescription.php
@@ -34,14 +34,11 @@ use Illuminate\Support\Facades\DB;
*/
class PrependDescription implements ActionInterface
{
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private readonly RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/PrependNotes.php b/app/TransactionRules/Actions/PrependNotes.php
index 12cdacf466..b59230e02a 100644
--- a/app/TransactionRules/Actions/PrependNotes.php
+++ b/app/TransactionRules/Actions/PrependNotes.php
@@ -34,14 +34,11 @@ use FireflyIII\Models\TransactionJournal;
*/
class PrependNotes implements ActionInterface
{
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private readonly RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/RemoveAllTags.php b/app/TransactionRules/Actions/RemoveAllTags.php
index e53a11404f..40a032354a 100644
--- a/app/TransactionRules/Actions/RemoveAllTags.php
+++ b/app/TransactionRules/Actions/RemoveAllTags.php
@@ -34,14 +34,11 @@ use Illuminate\Support\Facades\DB;
*/
class RemoveAllTags implements ActionInterface
{
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private readonly RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/RemoveTag.php b/app/TransactionRules/Actions/RemoveTag.php
index 451ed252d0..528a786d29 100644
--- a/app/TransactionRules/Actions/RemoveTag.php
+++ b/app/TransactionRules/Actions/RemoveTag.php
@@ -35,14 +35,11 @@ use Illuminate\Support\Facades\DB;
*/
class RemoveTag implements ActionInterface
{
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private readonly RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/SetAmount.php b/app/TransactionRules/Actions/SetAmount.php
index d08a2f78f4..db36221472 100644
--- a/app/TransactionRules/Actions/SetAmount.php
+++ b/app/TransactionRules/Actions/SetAmount.php
@@ -35,14 +35,11 @@ class SetAmount implements ActionInterface
{
use RefreshNotesTrait;
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/SetBudget.php b/app/TransactionRules/Actions/SetBudget.php
index cd80f7872b..74b7640a8e 100644
--- a/app/TransactionRules/Actions/SetBudget.php
+++ b/app/TransactionRules/Actions/SetBudget.php
@@ -36,14 +36,11 @@ use Illuminate\Support\Facades\DB;
*/
class SetBudget implements ActionInterface
{
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private readonly RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/SetCategory.php b/app/TransactionRules/Actions/SetCategory.php
index 9f9321a928..b6f8e5b2d5 100644
--- a/app/TransactionRules/Actions/SetCategory.php
+++ b/app/TransactionRules/Actions/SetCategory.php
@@ -36,14 +36,11 @@ use Illuminate\Support\Facades\DB;
*/
class SetCategory implements ActionInterface
{
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private readonly RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/SetDescription.php b/app/TransactionRules/Actions/SetDescription.php
index 805dcd96f0..8897eb0cb1 100644
--- a/app/TransactionRules/Actions/SetDescription.php
+++ b/app/TransactionRules/Actions/SetDescription.php
@@ -36,14 +36,11 @@ class SetDescription implements ActionInterface
{
use RefreshNotesTrait;
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/SetDestinationAccount.php b/app/TransactionRules/Actions/SetDestinationAccount.php
index 810dcbaa3b..6dc903564e 100644
--- a/app/TransactionRules/Actions/SetDestinationAccount.php
+++ b/app/TransactionRules/Actions/SetDestinationAccount.php
@@ -39,15 +39,13 @@ use Illuminate\Support\Facades\DB;
*/
class SetDestinationAccount implements ActionInterface
{
- private RuleAction $action;
private AccountRepositoryInterface $repository;
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private readonly RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/SetDestinationToCashAccount.php b/app/TransactionRules/Actions/SetDestinationToCashAccount.php
index fe88ddc06e..350a097b67 100644
--- a/app/TransactionRules/Actions/SetDestinationToCashAccount.php
+++ b/app/TransactionRules/Actions/SetDestinationToCashAccount.php
@@ -39,14 +39,11 @@ use Illuminate\Support\Facades\DB;
*/
class SetDestinationToCashAccount implements ActionInterface
{
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private readonly RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/SetNotes.php b/app/TransactionRules/Actions/SetNotes.php
index e8e3e92f2c..4962649241 100644
--- a/app/TransactionRules/Actions/SetNotes.php
+++ b/app/TransactionRules/Actions/SetNotes.php
@@ -33,14 +33,11 @@ use FireflyIII\Models\TransactionJournal;
*/
class SetNotes implements ActionInterface
{
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private readonly RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/SetSourceAccount.php b/app/TransactionRules/Actions/SetSourceAccount.php
index 2c656a815b..e2f9420b2d 100644
--- a/app/TransactionRules/Actions/SetSourceAccount.php
+++ b/app/TransactionRules/Actions/SetSourceAccount.php
@@ -39,15 +39,13 @@ use Illuminate\Support\Facades\DB;
*/
class SetSourceAccount implements ActionInterface
{
- private RuleAction $action;
private AccountRepositoryInterface $repository;
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private readonly RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/SetSourceToCashAccount.php b/app/TransactionRules/Actions/SetSourceToCashAccount.php
index af618b44a8..ebc8525005 100644
--- a/app/TransactionRules/Actions/SetSourceToCashAccount.php
+++ b/app/TransactionRules/Actions/SetSourceToCashAccount.php
@@ -39,14 +39,11 @@ use Illuminate\Support\Facades\DB;
*/
class SetSourceToCashAccount implements ActionInterface
{
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private readonly RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/SwitchAccounts.php b/app/TransactionRules/Actions/SwitchAccounts.php
index 585a934281..7cd0579948 100644
--- a/app/TransactionRules/Actions/SwitchAccounts.php
+++ b/app/TransactionRules/Actions/SwitchAccounts.php
@@ -36,14 +36,11 @@ use FireflyIII\Models\TransactionJournal;
*/
class SwitchAccounts implements ActionInterface
{
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private readonly RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Actions/UpdatePiggyBank.php b/app/TransactionRules/Actions/UpdatePiggyBank.php
index 4a4f00f35d..d0dc413a30 100644
--- a/app/TransactionRules/Actions/UpdatePiggyBank.php
+++ b/app/TransactionRules/Actions/UpdatePiggyBank.php
@@ -37,14 +37,11 @@ use Illuminate\Support\Facades\Log;
class UpdatePiggyBank implements ActionInterface
{
- private RuleAction $action;
-
/**
* TriggerInterface constructor.
*/
- public function __construct(RuleAction $action)
+ public function __construct(private readonly RuleAction $action)
{
- $this->action = $action;
}
public function actOnArray(array $journal): bool
diff --git a/app/TransactionRules/Engine/SearchRuleEngine.php b/app/TransactionRules/Engine/SearchRuleEngine.php
index fac43b1d59..fc5b1749d6 100644
--- a/app/TransactionRules/Engine/SearchRuleEngine.php
+++ b/app/TransactionRules/Engine/SearchRuleEngine.php
@@ -44,11 +44,11 @@ use Illuminate\Support\Facades\Log;
*/
class SearchRuleEngine implements RuleEngineInterface
{
- private Collection $groups;
+ private readonly Collection $groups;
private array $operators;
private bool $refreshTriggers;
private array $resultCount;
- private Collection $rules;
+ private readonly Collection $rules;
private User $user;
public function __construct()
diff --git a/app/TransactionRules/Expressions/ActionExpression.php b/app/TransactionRules/Expressions/ActionExpression.php
index fbabc1a3eb..97970c2634 100644
--- a/app/TransactionRules/Expressions/ActionExpression.php
+++ b/app/TransactionRules/Expressions/ActionExpression.php
@@ -82,17 +82,15 @@ class ActionExpression
// 'destination_transaction_id',
'notes',
];
- private string $expr;
- private ExpressionLanguage $expressionLanguage;
- private bool $isExpression;
- private ?SyntaxError $validationError;
+ private readonly ExpressionLanguage $expressionLanguage;
+ private readonly bool $isExpression;
+ private readonly ?SyntaxError $validationError;
- public function __construct(string $expr)
+ public function __construct(private readonly string $expr)
{
$this->expressionLanguage = app(ExpressionLanguage::class);
- $this->expr = $expr;
- $this->isExpression = self::isExpression($expr);
+ $this->isExpression = self::isExpression($this->expr);
$this->validationError = $this->validate();
}
diff --git a/app/TransactionRules/Expressions/ActionExpressionLanguageProvider.php b/app/TransactionRules/Expressions/ActionExpressionLanguageProvider.php
index b80a0eaf50..f215c6097f 100644
--- a/app/TransactionRules/Expressions/ActionExpressionLanguageProvider.php
+++ b/app/TransactionRules/Expressions/ActionExpressionLanguageProvider.php
@@ -45,16 +45,12 @@ class ActionExpressionLanguageProvider implements ExpressionFunctionProviderInte
return [
new ExpressionFunction(
'constant2',
- static function ($str): string {
- return sprintf('(is_string(%1$s) ? strtolower(%1$s) : %1$s)', $str.'!');
- },
+ static fn($str): string => sprintf('(is_string(%1$s) ? strtolower(%1$s) : %1$s)', $str.'!'),
$function
),
new ExpressionFunction(
'constant',
- static function ($str): string {
- return sprintf('(is_string(%1$s) ? strtolower(%1$s) : %1$s)', $str.'!');
- },
+ static fn($str): string => sprintf('(is_string(%1$s) ? strtolower(%1$s) : %1$s)', $str.'!'),
$function
),
diff --git a/app/Transformers/AttachmentTransformer.php b/app/Transformers/AttachmentTransformer.php
index 4bafc977a1..a0a2fa8670 100644
--- a/app/Transformers/AttachmentTransformer.php
+++ b/app/Transformers/AttachmentTransformer.php
@@ -32,7 +32,7 @@ use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
*/
class AttachmentTransformer extends AbstractTransformer
{
- private AttachmentRepositoryInterface $repository;
+ private readonly AttachmentRepositoryInterface $repository;
/**
* BillTransformer constructor.
diff --git a/app/Transformers/AvailableBudgetTransformer.php b/app/Transformers/AvailableBudgetTransformer.php
index 6d8881482e..100138acee 100644
--- a/app/Transformers/AvailableBudgetTransformer.php
+++ b/app/Transformers/AvailableBudgetTransformer.php
@@ -36,11 +36,11 @@ use FireflyIII\Support\Facades\Amount;
*/
class AvailableBudgetTransformer extends AbstractTransformer
{
- private NoBudgetRepositoryInterface $noBudgetRepository;
- private OperationsRepositoryInterface $opsRepository;
- private BudgetRepositoryInterface $repository;
- private TransactionCurrency $default;
- private bool $convertToNative;
+ private readonly NoBudgetRepositoryInterface $noBudgetRepository;
+ private readonly OperationsRepositoryInterface $opsRepository;
+ private readonly BudgetRepositoryInterface $repository;
+ private readonly TransactionCurrency $default;
+ private readonly bool $convertToNative;
/**
* CurrencyTransformer constructor.
diff --git a/app/Transformers/BillTransformer.php b/app/Transformers/BillTransformer.php
index b19fd5615f..e793bc015e 100644
--- a/app/Transformers/BillTransformer.php
+++ b/app/Transformers/BillTransformer.php
@@ -40,10 +40,10 @@ use Illuminate\Support\Collection;
*/
class BillTransformer extends AbstractTransformer
{
- private BillDateCalculator $calculator;
- private BillRepositoryInterface $repository;
- private TransactionCurrency $default;
- private bool $convertToNative;
+ private readonly BillDateCalculator $calculator;
+ private readonly BillRepositoryInterface $repository;
+ private readonly TransactionCurrency $default;
+ private readonly bool $convertToNative;
/**
* BillTransformer constructor.
diff --git a/app/Transformers/BudgetTransformer.php b/app/Transformers/BudgetTransformer.php
index 504520916e..9dac0351bf 100644
--- a/app/Transformers/BudgetTransformer.php
+++ b/app/Transformers/BudgetTransformer.php
@@ -38,10 +38,10 @@ use Symfony\Component\HttpFoundation\ParameterBag;
*/
class BudgetTransformer extends AbstractTransformer
{
- private OperationsRepositoryInterface $opsRepository;
- private BudgetRepositoryInterface $repository;
- private bool $convertToNative;
- private TransactionCurrency $default;
+ private readonly OperationsRepositoryInterface $opsRepository;
+ private readonly BudgetRepositoryInterface $repository;
+ private readonly bool $convertToNative;
+ private readonly TransactionCurrency $default;
/**
* BudgetTransformer constructor.
diff --git a/app/Transformers/CategoryTransformer.php b/app/Transformers/CategoryTransformer.php
index c60d80a3da..90ee854fcb 100644
--- a/app/Transformers/CategoryTransformer.php
+++ b/app/Transformers/CategoryTransformer.php
@@ -36,10 +36,10 @@ use Illuminate\Support\Collection;
*/
class CategoryTransformer extends AbstractTransformer
{
- private OperationsRepositoryInterface $opsRepository;
- private CategoryRepositoryInterface $repository;
- private TransactionCurrency $default;
- private bool $convertToNative;
+ private readonly OperationsRepositoryInterface $opsRepository;
+ private readonly CategoryRepositoryInterface $repository;
+ private readonly TransactionCurrency $default;
+ private readonly bool $convertToNative;
/**
* CategoryTransformer constructor.
diff --git a/app/Transformers/PiggyBankEventTransformer.php b/app/Transformers/PiggyBankEventTransformer.php
index df89869f36..a125415676 100644
--- a/app/Transformers/PiggyBankEventTransformer.php
+++ b/app/Transformers/PiggyBankEventTransformer.php
@@ -34,8 +34,8 @@ use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
*/
class PiggyBankEventTransformer extends AbstractTransformer
{
- private PiggyBankRepositoryInterface $piggyRepos;
- private AccountRepositoryInterface $repository;
+ private readonly PiggyBankRepositoryInterface $piggyRepos;
+ private readonly AccountRepositoryInterface $repository;
/**
* PiggyBankEventTransformer constructor.
diff --git a/app/Transformers/PiggyBankTransformer.php b/app/Transformers/PiggyBankTransformer.php
index a8c0c3d19d..924ccbe43f 100644
--- a/app/Transformers/PiggyBankTransformer.php
+++ b/app/Transformers/PiggyBankTransformer.php
@@ -35,8 +35,8 @@ use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
*/
class PiggyBankTransformer extends AbstractTransformer
{
- private AccountRepositoryInterface $accountRepos;
- private PiggyBankRepositoryInterface $piggyRepos;
+ private readonly AccountRepositoryInterface $accountRepos;
+ private readonly PiggyBankRepositoryInterface $piggyRepos;
/**
* PiggyBankTransformer constructor.
diff --git a/app/Transformers/RecurrenceTransformer.php b/app/Transformers/RecurrenceTransformer.php
index 2bf862a7aa..5abe8b2615 100644
--- a/app/Transformers/RecurrenceTransformer.php
+++ b/app/Transformers/RecurrenceTransformer.php
@@ -42,11 +42,11 @@ use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
*/
class RecurrenceTransformer extends AbstractTransformer
{
- private BillRepositoryInterface $billRepos;
- private BudgetRepositoryInterface $budgetRepos;
- private CategoryFactory $factory;
- private PiggyBankRepositoryInterface $piggyRepos;
- private RecurringRepositoryInterface $repository;
+ private readonly BillRepositoryInterface $billRepos;
+ private readonly BudgetRepositoryInterface $budgetRepos;
+ private readonly CategoryFactory $factory;
+ private readonly PiggyBankRepositoryInterface $piggyRepos;
+ private readonly RecurringRepositoryInterface $repository;
/**
* RecurrenceTransformer constructor.
diff --git a/app/Transformers/RuleTransformer.php b/app/Transformers/RuleTransformer.php
index 313521ce50..8e58a519cb 100644
--- a/app/Transformers/RuleTransformer.php
+++ b/app/Transformers/RuleTransformer.php
@@ -35,7 +35,7 @@ use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
*/
class RuleTransformer extends AbstractTransformer
{
- private RuleRepositoryInterface $ruleRepository;
+ private readonly RuleRepositoryInterface $ruleRepository;
/**
* CurrencyTransformer constructor.
diff --git a/app/Transformers/TransactionGroupTransformer.php b/app/Transformers/TransactionGroupTransformer.php
index d670901ada..e8239ac828 100644
--- a/app/Transformers/TransactionGroupTransformer.php
+++ b/app/Transformers/TransactionGroupTransformer.php
@@ -44,9 +44,9 @@ use Illuminate\Support\Facades\Log;
*/
class TransactionGroupTransformer extends AbstractTransformer
{
- private TransactionGroupRepositoryInterface $groupRepos;
- private array $metaDateFields;
- private array $metaFields;
+ private readonly TransactionGroupRepositoryInterface $groupRepos;
+ private readonly array $metaDateFields;
+ private readonly array $metaFields;
/**
* Constructor.
diff --git a/app/Transformers/V2/BillTransformer.php b/app/Transformers/V2/BillTransformer.php
index e0a63cf4f2..b19da5f420 100644
--- a/app/Transformers/V2/BillTransformer.php
+++ b/app/Transformers/V2/BillTransformer.php
@@ -325,9 +325,7 @@ class BillTransformer extends AbstractTransformer
}
}
$simple = $set->map( // @phpstan-ignore-line
- static function (Carbon $date) {
- return $date->toAtomString();
- }
+ static fn(Carbon $date) => $date->toAtomString()
);
return $simple->toArray();
diff --git a/routes/channels.php b/routes/channels.php
index e67e782c51..8fee79356b 100644
--- a/routes/channels.php
+++ b/routes/channels.php
@@ -35,7 +35,5 @@ declare(strict_types=1);
Broadcast::channel(
'App.User.{id}',
- static function ($user, $id) {
- return (int)$user->id === (int)$id;
- }
+ static fn($user, $id) => (int)$user->id === (int)$id
);