Collection each() function broken, merge with map()?
The each() function in Collection.php is currently broken (doesn't return the map), however the fix is to change the function to exactly match the map() function below it. Should the each function just be removed, or aliased to map?
How is each broken, exactly? The fact that it uses array_map internally is only an implementation detail, the API itself does what it is supposed to do, right?
Maybe we can use array_walk or something but I don't think it matters, really.
array_map() does not change the array passed to it, it returns a new array thats had the callback applied to each element. However in Collection its just called -- the result is not assigned to anything.
There also doesn't appear to be any tests for that method, either. From the docs it seems like it should function the same as filter, which returns the result. But it looks like map does that, not each?
Why do you want each to return anything? It's not the use of each, then you need map. each is there to perform some operations on all items, that's all there is to it and that is what each is already doing.
Each is just a way to manipulate objects in the Collection, and it does work for that purpose. I think you are wanting the map function.