Closed thomasvargiu closed 2 years ago
Looks like a clear bug to me :+1:
For a next major release I would suggest to make the method simplier without to handle objects with
toArray()
methods.
Totally agree: restricting inputs will help a lot here. We can most certainly design a separate utility that works with iterators, if needed.
@thomasvargiu Do you have an example of an object that I could try ?
Handled in #42
ArrayUtils::iteratorToArray()
has a different behaviour when$iterator
is aTraversable
object with atoArray()
method.When
$recursive === false
the method returns the result of its iterator, but when$recursive === true
it returns the result of itstoArray()
method.For a next major release I would suggest to make the method simplier without to handle objects with
toArray()
methods. Another solution could be to return thetoArray()
even when$recursive === false
.https://github.com/laminas/laminas-stdlib/blob/f0b299de11700203c4a9644c97aa869613743f4b/src/ArrayUtils.php#L233-L247