AggregateId is not marked as immutable
andrew-demb opened this issue · 3 comments
andrew-demb commented
Is it intended - allow to add side effects/mutations in descendants?
https://github.com/php-service-bus/event-sourcing/blob/v4.2.0/src/AggregateId.php
mmasiukevich commented
An abstract class, by definition, cannot be immutable. You can expand it as you need while maintaining the base contract.
andrew-demb commented
You can force by contract on abstract class info about immutability.
All descendants will be required to be immutable also, if they not - they will violate LSP.
https://psalm.dev/r/4c56e36782 (extends without immutable annotation)
Psalm output (using commit 19f88a2):
ERROR: MissingImmutableAnnotation - 24:25 - AggregateId is marked immutable, but BicycleId is not marked immutable
https://psalm.dev/r/0cd6a289ad (extends and provide side effect)
mmasiukevich commented
Well, maybe that makes sense.