-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Changed DataMapperInterface $forms parameter type to \Traversable #39317
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
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.
Thank you! We also need to document this change in UPGRADE-5.3.md and UPGRADE-6.0.md.
That's a BC break, isn't it? |
Can't the classes also be updated to use |
Last comment: can't we fix this right away in 5.1? |
The PR as it is right now is not a BC break, as far as I can tell. We can change the parameter type declaration on the interface from
That's technically a BC break because they wouldn't accept arrays anymore. So if there is existing code that calls those classes with an array (for what reason ever), those calls would fail.
The issue gives a good example: The sample code from the documentation would break if you passed an array.
I think we need that deprecation layer which would be a show-stopper for 5.1. |
How are we going to change their type hint then, since we'd like to do it, isn't it? |
Trigger a deprecation on 5.3 if we get an array and change the type declaration on 6.0. |
Hm, and type widening will mean we won't break classes that extend/override these methods. Shouldn't we improve the deprecation message to tell about the type change? At least something that will ensure we won't forget how to clean the deprecation when preparing 6.0? Eg "method foo() will only accept Traversable, array give." |
My understanding is that userland code is supposed to implement |
We cannot forbid users to widen parameter types in subclasses/implementations, they can keep |
4556b7e
to
ce77be2
Compare
Thank you @vudaltsov. |
…versable (vudaltsov) This PR was merged into the 5.3-dev branch. Discussion ---------- [Form] Changed data mapper $forms parameter type to \Traversable Closes #14656 See symfony/symfony#39317 Commits ------- 4677e42 Changed iterable $forms to Traversable in the data mapper implementation example
Didn't touch
PropertyPathMapper
because it's deprecated anyway.