Open bradleybensmith opened 3 years ago
Heya, thanks for submitting this.
This seems like a feature request or an improvement so I'm moving this to the ideas repository instead. It's best to post these in the ideas repository in the future to get support for your idea. After that you may send a PR to the framework. Please only use the laravel/framework
issue tracker to report bugs and issues with the framework.
Thanks!
Description:
Shouldn't
EnumeratesValues::getArrayableItems()
check forTraversable
beforeJsonable
? TheJsonable
andJsonSerializable
result in an array ofstdClass
objects whereTraversable
would preserve the correct class objects.https://github.com/laravel/framework/blob/8.x/src/Illuminate/Collections/Traits/EnumeratesValues.php#L923
As a workaround, I'm currently having to call
iterator_to_array
when instantiating aCollection
since the (3rd party) class I'm using only implementsJsonSerializable
andIteratorAggregate
(Traversable
).