Skip to content

[Form] Fix return type of FormErrorIterator::getChildren() #42301

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Symfony/Component/Form/FormErrorIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public function hasChildren()
/**
* Alias of {@link current()}.
*
* @return self
* @return FormError|self
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO self is correct as logically one should only call getChildren() when there are actual child nodes (which in the method above is a check for the current element being an instance of FormErrorIterator.

Maybe the method should throw if the current item is not iterable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the method should throw if the current item is not iterable.

Makes sense. Should this be considered a BC break or rather a bugfix?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would vote for triggering a deprecation in 5.4 and add the exception in 6.0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I will open MRs for 5.4 and 6.0 soon

*/
public function getChildren()
{
Expand Down