- Issue created by @kalpaitch
- last update
over 1 year ago 30,341 pass - @kalpaitch opened merge request.
- Status changed to Needs work
over 1 year ago 1:18pm 17 August 2023 - π¬π§United Kingdom joachim
This depends on whether the recursive traversal is top-to-bottom or bottom-to-top, and the current documentation doesn't specify that. So there is definitely a bug here, but it's either a code AND documentation bug (behaviour is wrong, should be fixed and documented) or just a documentation bug (behaviour is correct, should be documented).
'second' => [ ['', ''], '', ],
The value of 'second' is not empty, so it's not filtered -- that's consistent with a top-to-bottom recursion.
- π©πͺGermany donquixote
I encountered this myself while working on another core issue.
To me, clearing out all empty arrays after their children have been cleaned up would be the preferable behavior.
Unlike the current behavior, this would be idempotent, which is generally nice to have.However, this would be a change of existing behavior that we could consider a BC break.
An alternative would be to introduce a separate method which has the desired behavior.
Like NestedArray::filterRecursive() or NestedArray::filterCompletely().The solution proposed in the issue summary is correct either way: We filter the parent array _after_ filtering the children.