You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try to use explicit typecasting to basic types where possible because i find it clearer and more intuitive. With that in mind I always use (string) $uuid for casting the UUIDs to strings. The problem is that the magic method __toString() is only referenced in the actual implementations so when I try to typehint a variable with UuidInterface I get a warning about an unknown method on every cast I made.
The solution
Add public function __toString(): string; to the Interface (happy to make a pull request, just wanted to know if it doesn't break some adopted convention)
The mic drop
The text was updated successfully, but these errors were encountered:
@kacper-wojtaszczyk, thank you for your suggestion. This has been discussed a great deal already. The short answer is that __toString() has to wait until a 4.0.0 release, since it's a major BC break to add it to the interface.
The __toString() method is already on UuidInterface in the 4.x branch, but the comment here has me rethinking that, since the explicitness of ->toString() has typing and long-term stability benefits: ShittySoft/symfony-live-berlin-2018-doctrine-tutorial#3 (comment)
The problem
I try to use explicit typecasting to basic types where possible because i find it clearer and more intuitive. With that in mind I always use (string) $uuid for casting the UUIDs to strings. The problem is that the magic method __toString() is only referenced in the actual implementations so when I try to typehint a variable with UuidInterface I get a warning about an unknown method on every cast I made.
The solution
Add
public function __toString(): string;
to the Interface (happy to make a pull request, just wanted to know if it doesn't break some adopted convention)The mic drop
The text was updated successfully, but these errors were encountered: