Skip to content

toArray - Documented vs Current Behavior #57

@andysnell

Description

@andysnell

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions