diff --git a/app/Commands/Review.php b/app/Commands/Review.php index 8c39b63..55e9657 100644 --- a/app/Commands/Review.php +++ b/app/Commands/Review.php @@ -98,7 +98,7 @@ private function summary(TaxYearSummaryRepository $repository, string $taxYear, return self::SUCCESS; } - $taxYear = $this->presenter->choice('Review another tax year?', array_merge(['No'], $availableTaxYears), 'No'); + $taxYear = $this->presenter->choice('Review another tax year?', ['No', ...$availableTaxYears], 'No'); if ($taxYear === 'No') { return self::SUCCESS; diff --git a/app/Services/CommandRunner/CommandRunner.php b/app/Services/CommandRunner/CommandRunner.php index b63fea0..3d883fa 100644 --- a/app/Services/CommandRunner/CommandRunner.php +++ b/app/Services/CommandRunner/CommandRunner.php @@ -4,7 +4,7 @@ use Illuminate\Contracts\Console\Kernel; -final class CommandRunner implements CommandRunnerContract +final readonly class CommandRunner implements CommandRunnerContract { public function __construct(private Kernel $artisan) { diff --git a/app/Services/DatabaseManager/DatabaseManager.php b/app/Services/DatabaseManager/DatabaseManager.php index 2c95fa3..f6ee727 100644 --- a/app/Services/DatabaseManager/DatabaseManager.php +++ b/app/Services/DatabaseManager/DatabaseManager.php @@ -9,7 +9,7 @@ use Illuminate\Process\PendingProcess; use Symfony\Component\Console\Output\NullOutput; -final class DatabaseManager implements DatabaseManagerContract +final readonly class DatabaseManager implements DatabaseManagerContract { public function __construct( private Repository $config, diff --git a/app/Services/Presenter/Presenter.php b/app/Services/Presenter/Presenter.php index cca5133..ea718fa 100644 --- a/app/Services/Presenter/Presenter.php +++ b/app/Services/Presenter/Presenter.php @@ -8,7 +8,7 @@ final class Presenter implements PresenterContract { - private SymfonyStyle $ui; + private readonly SymfonyStyle $ui; public function __construct(InputInterface $input, OutputInterface $output) { diff --git a/app/Services/TransactionProcessor/TransactionProcessor.php b/app/Services/TransactionProcessor/TransactionProcessor.php index d5f3bd1..ae1390f 100644 --- a/app/Services/TransactionProcessor/TransactionProcessor.php +++ b/app/Services/TransactionProcessor/TransactionProcessor.php @@ -19,9 +19,9 @@ use Domain\ValueObjects\Transactions\Swap; use Domain\ValueObjects\Transactions\Transfer; -final class TransactionProcessor implements TransactionProcessorContract +final readonly class TransactionProcessor implements TransactionProcessorContract { - public function __construct(private readonly TransactionDispatcherContract $transactionDispatcher) + public function __construct(private TransactionDispatcherContract $transactionDispatcher) { } diff --git a/composer.json b/composer.json index b1338d9..9ded7a9 100644 --- a/composer.json +++ b/composer.json @@ -22,9 +22,9 @@ "ext-bcmath": "*" }, "require-dev": { - "brick/date-time": "^0.4.2", + "brick/date-time": "^0.5.1", "eventsauce/eventsauce": "^3.4", - "eventsauce/message-repository-for-illuminate": "^0.4.2", + "eventsauce/message-repository-for-illuminate": "^1.0", "eventsauce/object-hydrator": "^1.3", "eventsauce/pest-utilities": "^3.4", "fakerphp/faker": "^1.21.0", @@ -40,8 +40,8 @@ "phpoffice/phpspreadsheet": "^1.28", "phpstan/extension-installer": "^1.2", "phpstan/phpstan": "^1.10.6", - "rector/rector": "^0.15.21", - "tomasvotruba/type-coverage": "^0.1.0" + "rector/rector": "^0.18.0", + "tomasvotruba/type-coverage": "^0.2.0" }, "autoload": { "psr-4": { diff --git a/domain/src/Actions/UpdateSummary.php b/domain/src/Actions/UpdateSummary.php index 1f6b15b..50d632c 100644 --- a/domain/src/Actions/UpdateSummary.php +++ b/domain/src/Actions/UpdateSummary.php @@ -7,9 +7,9 @@ use Domain\Projections\Summary; use Domain\ValueObjects\FiatAmount; -final class UpdateSummary +final readonly class UpdateSummary { - final public function __construct(public readonly FiatAmount $fiatBalanceUpdate) + final public function __construct(public FiatAmount $fiatBalanceUpdate) { } diff --git a/domain/src/Aggregates/SharePoolingAsset/Entities/SharePoolingAssetDisposal.php b/domain/src/Aggregates/SharePoolingAsset/Entities/SharePoolingAssetDisposal.php index e45138b..fa2a0ce 100644 --- a/domain/src/Aggregates/SharePoolingAsset/Entities/SharePoolingAssetDisposal.php +++ b/domain/src/Aggregates/SharePoolingAsset/Entities/SharePoolingAssetDisposal.php @@ -14,18 +14,14 @@ final class SharePoolingAssetDisposal extends SharePoolingAssetTransaction { - public readonly QuantityAllocation $sameDayQuantityAllocation; - - public readonly QuantityAllocation $thirtyDayQuantityAllocation; - public function __construct( LocalDate $date, Quantity $quantity, FiatAmount $costBasis, public readonly FiatAmount $proceeds, public readonly bool $forFiat, - ?QuantityAllocation $sameDayQuantityAllocation = null, - ?QuantityAllocation $thirtyDayQuantityAllocation = null, + public readonly QuantityAllocation $sameDayQuantityAllocation = new QuantityAllocation(), + public readonly QuantityAllocation $thirtyDayQuantityAllocation = new QuantityAllocation(), bool $processed = true, ?SharePoolingAssetTransactionId $id = null, ) { @@ -34,9 +30,6 @@ public function __construct( $costBasis->currency === $proceeds->currency || throw SharePoolingAssetDisposalException::currencyMismatch($costBasis->currency, $proceeds->currency); - $this->sameDayQuantityAllocation = $sameDayQuantityAllocation ?? new QuantityAllocation(); - $this->thirtyDayQuantityAllocation = $thirtyDayQuantityAllocation ?? new QuantityAllocation(); - $allocatedQuantity = $this->sameDayQuantityAllocation->quantity()->plus($this->thirtyDayQuantityAllocation->quantity()); $this->quantity->isGreaterThanOrEqualTo($allocatedQuantity) diff --git a/domain/src/Aggregates/SharePoolingAsset/ValueObjects/SharePoolingAssetTransactionId.php b/domain/src/Aggregates/SharePoolingAsset/ValueObjects/SharePoolingAssetTransactionId.php index 0d3961a..a96ac45 100644 --- a/domain/src/Aggregates/SharePoolingAsset/ValueObjects/SharePoolingAssetTransactionId.php +++ b/domain/src/Aggregates/SharePoolingAsset/ValueObjects/SharePoolingAssetTransactionId.php @@ -7,9 +7,9 @@ use Ramsey\Uuid\Uuid; use Stringable; -final class SharePoolingAssetTransactionId implements Stringable +final readonly class SharePoolingAssetTransactionId implements Stringable { - final private function __construct(public readonly string $id) + final private function __construct(public string $id) { } diff --git a/domain/src/Aggregates/TaxYear/Actions/RevertCapitalGainUpdate.php b/domain/src/Aggregates/TaxYear/Actions/RevertCapitalGainUpdate.php index b2132c7..a1f965a 100644 --- a/domain/src/Aggregates/TaxYear/Actions/RevertCapitalGainUpdate.php +++ b/domain/src/Aggregates/TaxYear/Actions/RevertCapitalGainUpdate.php @@ -10,11 +10,11 @@ use Domain\Aggregates\TaxYear\ValueObjects\TaxYearId; use Stringable; -final class RevertCapitalGainUpdate implements Stringable +final readonly class RevertCapitalGainUpdate implements Stringable { final public function __construct( - public readonly LocalDate $date, - public readonly CapitalGain $capitalGainUpdate, + public LocalDate $date, + public CapitalGain $capitalGainUpdate, ) { } diff --git a/domain/src/Aggregates/TaxYear/Actions/UpdateCapitalGain.php b/domain/src/Aggregates/TaxYear/Actions/UpdateCapitalGain.php index e75d471..d288e02 100644 --- a/domain/src/Aggregates/TaxYear/Actions/UpdateCapitalGain.php +++ b/domain/src/Aggregates/TaxYear/Actions/UpdateCapitalGain.php @@ -10,11 +10,11 @@ use Domain\Aggregates\TaxYear\ValueObjects\TaxYearId; use Stringable; -final class UpdateCapitalGain implements Stringable +final readonly class UpdateCapitalGain implements Stringable { final public function __construct( - public readonly LocalDate $date, - public readonly CapitalGain $capitalGainUpdate, + public LocalDate $date, + public CapitalGain $capitalGainUpdate, ) { } diff --git a/domain/src/Aggregates/TaxYear/Actions/UpdateIncome.php b/domain/src/Aggregates/TaxYear/Actions/UpdateIncome.php index 3d5b0df..550c358 100644 --- a/domain/src/Aggregates/TaxYear/Actions/UpdateIncome.php +++ b/domain/src/Aggregates/TaxYear/Actions/UpdateIncome.php @@ -10,11 +10,11 @@ use Domain\ValueObjects\FiatAmount; use Stringable; -final class UpdateIncome implements Stringable +final readonly class UpdateIncome implements Stringable { public function __construct( - public readonly LocalDate $date, - public readonly FiatAmount $incomeUpdate, + public LocalDate $date, + public FiatAmount $incomeUpdate, ) { } diff --git a/domain/src/Aggregates/TaxYear/Actions/UpdateNonAttributableAllowableCost.php b/domain/src/Aggregates/TaxYear/Actions/UpdateNonAttributableAllowableCost.php index 51b2da5..ae034e8 100644 --- a/domain/src/Aggregates/TaxYear/Actions/UpdateNonAttributableAllowableCost.php +++ b/domain/src/Aggregates/TaxYear/Actions/UpdateNonAttributableAllowableCost.php @@ -10,11 +10,11 @@ use Domain\ValueObjects\FiatAmount; use Stringable; -final class UpdateNonAttributableAllowableCost implements Stringable +final readonly class UpdateNonAttributableAllowableCost implements Stringable { public function __construct( - public readonly LocalDate $date, - public readonly FiatAmount $nonAttributableAllowableCostChange, + public LocalDate $date, + public FiatAmount $nonAttributableAllowableCostChange, ) { } diff --git a/domain/src/Aggregates/TaxYear/Events/CapitalGainUpdateReverted.php b/domain/src/Aggregates/TaxYear/Events/CapitalGainUpdateReverted.php index 10d40fb..cd24479 100644 --- a/domain/src/Aggregates/TaxYear/Events/CapitalGainUpdateReverted.php +++ b/domain/src/Aggregates/TaxYear/Events/CapitalGainUpdateReverted.php @@ -7,12 +7,12 @@ use Brick\DateTime\LocalDate; use Domain\Aggregates\TaxYear\ValueObjects\CapitalGain; -final class CapitalGainUpdateReverted +final readonly class CapitalGainUpdateReverted { final public function __construct( - public readonly LocalDate $date, - public readonly CapitalGain $capitalGainUpdate, - public readonly CapitalGain $newCapitalGain, + public LocalDate $date, + public CapitalGain $capitalGainUpdate, + public CapitalGain $newCapitalGain, ) { } } diff --git a/domain/src/Aggregates/TaxYear/Events/CapitalGainUpdated.php b/domain/src/Aggregates/TaxYear/Events/CapitalGainUpdated.php index 266bb8e..c438530 100644 --- a/domain/src/Aggregates/TaxYear/Events/CapitalGainUpdated.php +++ b/domain/src/Aggregates/TaxYear/Events/CapitalGainUpdated.php @@ -7,12 +7,12 @@ use Brick\DateTime\LocalDate; use Domain\Aggregates\TaxYear\ValueObjects\CapitalGain; -final class CapitalGainUpdated +final readonly class CapitalGainUpdated { final public function __construct( - public readonly LocalDate $date, - public readonly CapitalGain $capitalGainUpdate, - public readonly CapitalGain $newCapitalGain, + public LocalDate $date, + public CapitalGain $capitalGainUpdate, + public CapitalGain $newCapitalGain, ) { } } diff --git a/domain/src/Aggregates/TaxYear/Events/IncomeUpdated.php b/domain/src/Aggregates/TaxYear/Events/IncomeUpdated.php index 3497bfa..14a99b2 100644 --- a/domain/src/Aggregates/TaxYear/Events/IncomeUpdated.php +++ b/domain/src/Aggregates/TaxYear/Events/IncomeUpdated.php @@ -7,12 +7,12 @@ use Brick\DateTime\LocalDate; use Domain\ValueObjects\FiatAmount; -final class IncomeUpdated +final readonly class IncomeUpdated { public function __construct( - public readonly LocalDate $date, - public readonly FiatAmount $incomeUpdate, - public readonly FiatAmount $newIncome, + public LocalDate $date, + public FiatAmount $incomeUpdate, + public FiatAmount $newIncome, ) { } } diff --git a/domain/src/Aggregates/TaxYear/Events/NonAttributableAllowableCostUpdated.php b/domain/src/Aggregates/TaxYear/Events/NonAttributableAllowableCostUpdated.php index 3ec9618..45a20c5 100644 --- a/domain/src/Aggregates/TaxYear/Events/NonAttributableAllowableCostUpdated.php +++ b/domain/src/Aggregates/TaxYear/Events/NonAttributableAllowableCostUpdated.php @@ -7,12 +7,12 @@ use Brick\DateTime\LocalDate; use Domain\ValueObjects\FiatAmount; -final class NonAttributableAllowableCostUpdated +final readonly class NonAttributableAllowableCostUpdated { public function __construct( - public readonly LocalDate $date, - public readonly FiatAmount $nonAttributableAllowableCostChange, - public readonly FiatAmount $newNonAttributableAllowableCost, + public LocalDate $date, + public FiatAmount $nonAttributableAllowableCostChange, + public FiatAmount $newNonAttributableAllowableCost, ) { } } diff --git a/domain/src/Aggregates/TaxYear/Projections/TaxYearSummary.php b/domain/src/Aggregates/TaxYear/Projections/TaxYearSummary.php index fb192c2..3d7c38c 100644 --- a/domain/src/Aggregates/TaxYear/Projections/TaxYearSummary.php +++ b/domain/src/Aggregates/TaxYear/Projections/TaxYearSummary.php @@ -67,7 +67,7 @@ protected function capitalGain(): Attribute { return Attribute::make( get: function (?string $value) { - $values = is_null($value) ? [] : json_decode($value, true); + $values = is_null($value) ? [] : json_decode($value, true, 512, JSON_THROW_ON_ERROR); assert(is_array($values)); @@ -76,7 +76,7 @@ protected function capitalGain(): Attribute proceeds: new FiatAmount($values['proceeds'] ?? '0', $this->currency), ); }, - set: fn (CapitalGain $value) => json_encode($value), + set: fn (CapitalGain $value) => json_encode($value, JSON_THROW_ON_ERROR), ); } diff --git a/domain/src/Services/TransactionDispatcher/TransactionDispatcher.php b/domain/src/Services/TransactionDispatcher/TransactionDispatcher.php index 3ec9d6f..244d65d 100644 --- a/domain/src/Services/TransactionDispatcher/TransactionDispatcher.php +++ b/domain/src/Services/TransactionDispatcher/TransactionDispatcher.php @@ -15,13 +15,13 @@ use Domain\ValueObjects\Transactions\Transaction; use Domain\ValueObjects\Transactions\Transfer; -final class TransactionDispatcher implements TransactionDispatcherContract +final readonly class TransactionDispatcher implements TransactionDispatcherContract { public function __construct( - private readonly IncomeHandler $incomeHandler, - private readonly TransferHandler $transferHandler, - private readonly NonFungibleAssetHandler $nonFungibleAssetHandler, - private readonly SharePoolingAssetHandler $sharePoolingAssetHandler, + private IncomeHandler $incomeHandler, + private TransferHandler $transferHandler, + private NonFungibleAssetHandler $nonFungibleAssetHandler, + private SharePoolingAssetHandler $sharePoolingAssetHandler, ) { }