Skip to content
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

__toString() in UuidInterface #278

Closed
kacper-wojtaszczyk opened this issue Dec 5, 2019 · 3 comments
Closed

__toString() in UuidInterface #278

kacper-wojtaszczyk opened this issue Dec 5, 2019 · 3 comments

Comments

@kacper-wojtaszczyk
Copy link

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

@ramsey
Copy link
Owner

ramsey commented Dec 7, 2019

@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.

Please take a look at the conversations on #272, #238, #111, the discussion at 4c467ce#commitcomment-31174263, and the commit feb3eb5.

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)

@ramsey ramsey closed this as completed Dec 7, 2019
@kacper-wojtaszczyk
Copy link
Author

Any ETA on 4.0?

@ramsey
Copy link
Owner

ramsey commented Dec 9, 2019

No ETA yet. Sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants