Closed andrew-demb closed 3 years ago
An abstract class, by definition, cannot be immutable. You can expand it as you need while maintaining the base contract.
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)
Well, maybe that makes sense.
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