-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[5.7] [WIP] Support iterable objects as targets for data_get() #25892
Conversation
- The underlying Arr::pluck() currently supports iterable objects, so that no change was needed. - Add tests by copying those for nested arrays, as this code is only called if there are "*" segments.
- It shows that the code is actually simple. - It removes the "yo-yo calls" between data_get() and Arr::pluck(). - It prevents breakage if the Arr::pluck() implementation changes.
- The method Arr::collapse() being used in data_get(), maybe this change is needed for some target structures in data_get(). - We are just doing the array_merge() manually. Better than nothing.
Mmmm, see how I just removed the Interesting :) edit: The question is now about support of Traversable in ping @JosephSilber |
Not formal, just some intuition, as: - the tests were nonetheless passing without the previous commit, - and data_get() is actually a recursive function.
Didn't notice the tests were broken... The tests should pass again now. So the situation is: - either Arr::collapse() doesn't need to support Traversable for them to fully work in data_get(), - or the tests are incomplete.
Ok, I have thought more on it, and I'm almost sure there is no need to add support of Traversable in Basically, the I have confirmed by trying with some "triple nested" data and some other cases like "several intermediate keys" (e.g. "*.foo.bar.baz.*") or "several consecutive wildcards" (e.g. "foo.*.*.*.bar"). I someone could give confirmation this would be great, then I'll shorten back this PR which is quite simple actually. |
No plans on changing this function. |
A follow-up to the quite old #12638.
if ($value instanceof Collection) { $value = $value->all(); }
are not mandatory but for performances (iterate on plain array).