-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Fix ConstraintViolation#getPropertyPath()
to always return string
#40415
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
Fix ConstraintViolation#getPropertyPath()
to always return string
#40415
Conversation
`ConstraintViolation#getPropertyPath()`'s inherited signature states that `string` is to be returned by it at all times, yet the implementation returns `null` when no property path had been provided at instantiation. This patch obviates it, returning an empty string when the property path is `null`.
Integration test suite failure seems unrelated |
Good catch. We have the same problem with the |
That ship has sailed though, and there's active design around the property path being missing. |
Yeah, for sure, we cannot just change the type now. But if it's a mistake, we could try to correct it for Symfony 6. The parameter types for Our own code ( |
I was copying violations reported from one validator to another, pretty much like |
Thank you. Could you do the same fix for the |
Will send a separate patch |
`ConstraintViolation#getMessageTemplate()`'s inherited signature states that `string` is to be returned by it at all times, yet the implementation returns `null` when no message template had been provided at instantiation. This patch obviates it, returning an empty string when the message template is `null`. Ref: symfony#40415 (comment)
I still think we should perform the string cast inside the constructor though. 🙃 btw: is the 4.4 branch affected as well? |
Hm, the small benefit to cast it to a string in the constructor is that we can remove the cast in the |
You do that, you break subclassing types for little benefit. I can imagine that some subclassing will likely rely on the fact that EDIT: keep in mind that the scope of this is a bugfix, not a refactoring. That would probably target |
Possibly, didn't check, since I'd rather leave 4.4 alone. This is the sort of bugfix that I would never ever want to see in an LTS, since there's a subtle change in behavior. |
|
Ah, true that 👍 |
Thank you @Ocramius. |
`ConstraintViolation#getMessageTemplate()`'s inherited signature states that `string` is to be returned by it at all times, yet the implementation returns `null` when no message template had been provided at instantiation. This patch obviates it, returning an empty string when the message template is `null`. Ref: symfony#40415 (comment)
`ConstraintViolation#getMessageTemplate()`'s inherited signature states that `string` is to be returned by it at all times, yet the implementation returns `null` when no message template had been provided at instantiation. This patch obviates it, returning an empty string when the message template is `null`. Ref: symfony#40415 (comment)
…eturn `string` (Ocramius) This PR was merged into the 5.2 branch. Discussion ---------- Fix `ConstraintViolation#getMessageTemplate()` to always return `string` | Q | A | ------------- | --- | Branch? | 5.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | `ConstraintViolation#getMessageTemplate()`'s inherited signature states that `string` is to be returned by it at all times, yet the implementation returns `null` when no message template had been provided at instantiation. This patch obviates it, returning an empty string when the message template is `null`. Ref: #40415 (comment) Commits ------- 72a464e Fix `ConstraintViolation#getMessageTemplate()` to always return `string`
`ConstraintViolation#getMessageTemplate()`'s inherited signature states that `string` is to be returned by it at all times, yet the implementation returns `null` when no message template had been provided at instantiation. This patch obviates it, returning an empty string when the message template is `null`. Ref: symfony/symfony#40415 (comment)
…eturn `string` (Ocramius) This PR was merged into the 5.2 branch. Discussion ---------- Fix `ConstraintViolation#getMessageTemplate()` to always return `string` | Q | A | ------------- | --- | Branch? | 5.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | `ConstraintViolation#getMessageTemplate()`'s inherited signature states that `string` is to be returned by it at all times, yet the implementation returns `null` when no message template had been provided at instantiation. This patch obviates it, returning an empty string when the message template is `null`. Ref: symfony/symfony#40415 (comment) Commits ------- 72a464e449 Fix `ConstraintViolation#getMessageTemplate()` to always return `string`
ConstraintViolation#getPropertyPath()
's inherited signature states thatstring
isto be returned by it at all times, yet the implementation returns
null
when no propertypath had been provided at instantiation.
This patch obviates it, returning an empty string when the
property path is
null
.