-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Arrayhelper filter support more than 2 levels #17830
Arrayhelper filter support more than 2 levels #17830
Conversation
… data when passing a filter with more than 2 levels
…ilter` when passing a filter with more than 2 levels
|
||
//We've found a value now let's insert it | ||
$resultNode = &$result; | ||
foreach ($keys as $key) { |
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.
Can you merge this loop with previous?
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.
Nope, let's say we have a filter 'A.B' and the source does have key A but that level does not have key B in it, the resulting array would be set [A => []]
while it should return []
.
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.
Are tests fix this case?
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.
Yes, the test would fail at line 1336 $this->assertEquals(ArrayHelper::filter($array, ['A.X']), []);
.
Merged. Thank you! It would be cool to have it ported to Yii 3 yiisoft/arrays#15 |
…th more than 2 levels Ported from yiisoft/yii2#17830 Thanks, @rhertogh
ArrayHelper::filter
was used in an unexpected way)