File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2127,7 +2127,7 @@ protected function getArrayableItems($items)
21272127 } elseif ($ items instanceof Jsonable) {
21282128 return json_decode ($ items ->toJson (), true );
21292129 } elseif ($ items instanceof JsonSerializable) {
2130- return $ items ->jsonSerialize ();
2130+ return ( array ) $ items ->jsonSerialize ();
21312131 } elseif ($ items instanceof Traversable) {
21322132 return iterator_to_array ($ items );
21332133 }
Original file line number Diff line number Diff line change @@ -178,6 +178,10 @@ public function testGetArrayableItems()
178178 $ array = $ method ->invokeArgs ($ collection , [$ items ]);
179179 $ this ->assertSame (['foo ' => 'bar ' ], $ array );
180180
181+ $ items = new TestJsonSerializeWithScalarValueObject ;
182+ $ array = $ method ->invokeArgs ($ collection , [$ items ]);
183+ $ this ->assertSame (['foo ' ], $ array );
184+
181185 $ items = new Collection (['foo ' => 'bar ' ]);
182186 $ array = $ method ->invokeArgs ($ collection , [$ items ]);
183187 $ this ->assertSame (['foo ' => 'bar ' ], $ array );
@@ -3297,6 +3301,14 @@ public function jsonSerialize()
32973301 }
32983302}
32993303
3304+ class TestJsonSerializeWithScalarValueObject implements JsonSerializable
3305+ {
3306+ public function jsonSerialize ()
3307+ {
3308+ return 'foo ' ;
3309+ }
3310+ }
3311+
33003312class TestCollectionMapIntoObject
33013313{
33023314 public $ value ;
You can’t perform that action at this time.
0 commit comments