We are using Symfony UUIDs instead of Ramseys'. Unfortunately Symfony's UUID fromString method has slightly different signature than the AggregateRootId interface - they return static instead of self.
So right now we cannot do this:
class MyId extends Uuid implements AggregateRootId
{
}
Instead we have to wrap the Symfony UUID:
class MyId implements AggregateRootId
{
public function __construct(public readonly Uuid $id)
{
}
public function toString(): string
{
return $this->id->toString();
}
public static function fromString(string $id): AggregateRootId
{
return new self(Uuid::fromString($id));
}
}
which makes reusing it somewhat cumbersome (e.g. subscriptions ...).
The signature would be:
{
public function toString(): string;
public static function fromString(string $id): static;
}
As far as I am concerned this would be a breaking change. Anyone implementing a custom AggregateRootId with the old signature would have to update their implementation. On the up side this would improve typing when calling fromString on a custom root ID (returning the actual implementation, not the interface).
We are using Symfony UUIDs instead of Ramseys'. Unfortunately Symfony's UUID
fromStringmethod has slightly different signature than theAggregateRootIdinterface - they returnstaticinstead ofself.So right now we cannot do this:
Instead we have to wrap the Symfony UUID:
which makes reusing it somewhat cumbersome (e.g. subscriptions ...).
The signature would be:
As far as I am concerned this would be a breaking change. Anyone implementing a custom
AggregateRootIdwith the old signature would have to update their implementation. On the up side this would improve typing when callingfromStringon a custom root ID (returning the actual implementation, not the interface).