Skip to content
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

Support for iterable-agnostic functions #1

Open
sjadema opened this issue Aug 11, 2021 · 2 comments
Open

Support for iterable-agnostic functions #1

sjadema opened this issue Aug 11, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@sjadema
Copy link

sjadema commented Aug 11, 2021

Nice package! So annoying that PHP doesn't provide this logic in their standard libs. However, even with these functions i still have to type check before calling them: $iterable instanceof \Traversable ? iterator_xxx : array_xxx. Would be epic if agnostic variants where introduced (e.g. iterable_map, iterable_keys, iterable_flip. Then you could just pas an iterable and the function would do the rest. I think they should return what they where fed so array if is_array($iterable), otherwise \Traversable.

@doekenorg doekenorg added the enhancement New feature or request label Aug 11, 2021
@dgoosens
Copy link

dgoosens commented Sep 7, 2021

just came across this very same issue with collections...
Doctrine Collections or Knapsack Collections use IteratorAggregate, not Iterator... so that is not working out well...
They all boil down to \iterable though

@doekenorg
Copy link
Owner

I'm thinking of using iterable instead of Iterator. But the functions will always return an Iterator. I feel like this makes the most sense for this package. Just piping stuff through to the array equivalent doesn't feel right..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants