-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
BC break in return type of ConstraintViolationInterface::getMessage() #34710
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
Comments
ref #31083, in general the upgrade path is |
@ro0NL No, converting arbitrary
#31083 is about __toString() but the type information doesn't match this requirement. @xabbuh was right with his concern in #31083:
|
As mentioned by the phpdoc, not any kind of object can be returned there: only stringable ones are allowed. That was already the case before and people (eg Drupal) are using this possibility as a feature. Not BC break here. That's a false-positive from phpstan (which might miss context for sure). |
Frankly by adding PHPStan is correct in this case. Just like Psalm is. We're talking about interface with generic https://phpstan.org/r/14597979-9220-4ce1-8354-14e3954d44ca |
the thing is, phpdoc does not have any way to describe "stringable objects". |
@stof Yes, adding So this is wrong:
This has to be reverted. |
Our BC policy doesn't cover strict mode. Thanks for reporting. |
Reading through Symfony Backward Compatibility Promise document I see no mention of not covering strict mode. Strict mode is part of PHP core for 4 years already, it would be strange if Symfony didn't support it (regardless of whether Symfony itself uses it or not). Can you provide some reference for your statement?
|
@nicolas-grekas Considering most of modern PHP projects (all of my projects included) are written completely in strict mode, this is a very concerning statement. Even more so since there is no mention of this in your BC promise document. Please update it accordingly since this is something the users need to be aware of. |
Strict mode is not compatible with adding type hints in the Symfony code base. Any |
To clarify, the link to the BC policy here is not accurate: what I'm referring to is the continuous upgrade path actually - we cannot provide one to people that enabled strict mode, for cases like the one mentioned in my previous comment. About the BC policy and the issue discussed here, it does not apply to docblocks. That's the more accurate statement that applies here. |
Last note: the |
This PR was merged into the 3.4 branch. Discussion ---------- [Security] Add missing Latvian translations | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Part of #34710, #34749 | License | MIT | Doc PR | N/A Commits ------- 7f2b13b [Security] Add missing Latvian translations
This PR was squashed before being merged into the 3.4 branch. Discussion ---------- [Form] Add missing Latvian translations | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Part of #34710, #34749 | License | MIT | Doc PR | N/A Commits ------- 871c983 [Form] Add missing Latvian translations
This PR was submitted for the 5.x branch but it was merged into the 3.4 branch instead. Discussion ---------- [Validator] Add missing Latvian translations | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Part of #34710, #34749 | License | MIT | Doc PR | N/A Commits ------- 4924b38 [Validator] Add missing Latvian translations
Symfony version(s) affected: 4.4.0
Description
In Symfony 4.3.4
Symfony\Component\Validator\ConstraintViolationInterface::getMessage()
returnsstring
.In Symfony 4.4.0 it returns
string|object
.Widening return types is a BC break that breaks contract for consumers.
Caught by PHPStan:
The text was updated successfully, but these errors were encountered: