DusanKasan / Knapsack

Collection pipeline library for PHP

Home Page:http://dusankasan.github.io/Knapsack/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

toArray - Documented vs Current Behavior

andysnell opened this issue · comments

I'm looking for some clarification about the intended behavior for toArray(). As per the current project documentation, the toArray() method (emphasis mine):

Converts the collection to array recursively.

A recursive operation implies that a collection of collections would be converted into an array of arrays; however, the current behavior just calls iterator_to_array on the top level, so that an array of collections is returned. If this is the intended behavior, the documentation should be updated to indicate that the operation is not actually recursive.

I can see places where the current behavior is desirable, but it would be nice to be able to reliable cast a whole collection into an array in a single operation without having to manually recurse the iterator. I could see this functionally added in a BC friendly way as toArray($recursive = false);

Happy to help, just need to know what direction this method is supposed to go in.