-
Notifications
You must be signed in to change notification settings - Fork 0
Replace constants with methods for identity and model version in aggregates. #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,7 +12,6 @@ | |||||||||||||||||
| use TinyBlocks\BuildingBlocks\Event\EventRecords; | ||||||||||||||||||
| use TinyBlocks\BuildingBlocks\Event\Revision; | ||||||||||||||||||
| use TinyBlocks\BuildingBlocks\Event\SequenceNumber; | ||||||||||||||||||
| use TinyBlocks\BuildingBlocks\Internal\Exceptions\MissingIdentityConstant; | ||||||||||||||||||
| use TinyBlocks\BuildingBlocks\Snapshot\Snapshot; | ||||||||||||||||||
|
|
||||||||||||||||||
| trait EventSourcingRootBehavior | ||||||||||||||||||
|
|
@@ -30,12 +29,9 @@ public function recordedEvents(): EventRecords | |||||||||||||||||
|
|
||||||||||||||||||
| public static function blank(Identity $identity): static | ||||||||||||||||||
| { | ||||||||||||||||||
| if (!defined('static::IDENTITY')) { | ||||||||||||||||||
| throw new MissingIdentityConstant(className: static::class); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| $aggregate = new ReflectionClass(objectOrClass: static::class)->newInstanceWithoutConstructor(); | ||||||||||||||||||
| new ReflectionProperty($aggregate, static::IDENTITY)->setValue(objectOrValue: $aggregate, value: $identity); | ||||||||||||||||||
| new ReflectionProperty($aggregate, $aggregate->identityName()) | ||||||||||||||||||
|
||||||||||||||||||
| new ReflectionProperty($aggregate, $aggregate->identityName()) | |
| $identityProperty = $aggregate->identityName(); | |
| if (!property_exists($aggregate, $identityProperty)) { | |
| throw new MissingIdentityProperty($identityProperty); | |
| } | |
| new ReflectionProperty($aggregate, $identityProperty) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phpstan.neon.dist adds an ignore for the Upcasters::chain() return-type error. This reduces static-analysis signal for a real typing issue; it would be better to adjust Upcasters::chain() so PHPStan can infer/guarantee the return type and then drop this suppression.