-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Make constraint violation interfaces stringable #45484
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
Conversation
Hey! I think @jschaedl has recently worked with this code. Maybe they can help review this? Cheers! Carsonbot |
What's the use case that made you open this? |
The use case is casting the errors to a string for dev messages, which should be legit according to the docs, but then static analysis tools complain, which makes sense since there's no guarantee that the implementation being use is stringable. Adding it to the interface would assure that changing the implantation wont break any code and will satisfy static analysis tools. |
5416369
to
9c9408f
Compare
im not sure docs should rely on a debugging-string, but rather should show a serialized constraint violation list or some manually constructed payload |
9c9408f
to
91bf1b1
Compare
91bf1b1
to
4cead0c
Compare
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.
About UPGRADE-7.0.md
, it's already outdated. We need to clarify how we deal with this file at the policy level. Shouldn't be a blocker for this PR IMHO.
Thank you @HypeMC. |
Currently the
ConstraintViolationInterface
&ConstraintViolationListInterface
don't have a__toString()
method even though their only implementations do. Since thevalidate
method returns aConstraintViolationListInterface
trying to cast the errors into a string doesn't sit well with static analysis tools.Here I've used an example from the docs:

This PR adds a
__toString()
method to the interfaces via an@method
tag. In Symfony 7 theStringable
interface can be implemented instead.