fluent-traversable
fluent-traversable copied to clipboard
strict FluentComposer factories
The name of FluentComposer::forArray is misleading because it does not only accept arrays but also Traversable. I would expect a type hint array for the parameter.
FluentComposer::forValue should assert that a value has been passed instead of hiding the wrong call by using no values [] (source).
Further, a non-strict version FluentComposer::forIterable or FluentComposer::forTraversable might be added.
the iterable pseudo-type [...] is an array or an object implementing Traversable see http://php.net/manual/en/function.is-iterable.php
is_iterable (introduced in PHP 7) is similar to FluentTraversable::isTraversable. Since the term Traversable is used for different types (built-in Traversable vs. FluentTraversable) FluentComposer::forIterable might be more accurate than FluentComposer::forTraversable.
Actually, FluentTraversable::from accepts also FluentTraversable which is not an Iterable but that could be fixed by implementing IteratorAggregate or Iterator.