File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -191,14 +191,19 @@ public function getSerializableData()
191191 $ data [$ k ] = $ v ->getSerializableData ();
192192 } elseif (is_array ($ v )) {
193193 $ toObject = false ;
194- $ j = 0 ;
195- foreach ($ v as $ i => $ d ) {
196- if ($ j ++ !== $ i ) {
197- $ toObject = true ;
198- }
199- if ($ d instanceof SpecObjectInterface) {
200- $ data [$ k ][$ i ] = $ d ->getSerializableData ();
194+ if (!empty ($ v )) {
195+ $ j = 0 ;
196+ foreach ($ v as $ i => $ d ) {
197+ if ($ j ++ !== $ i ) {
198+ $ toObject = true ;
199+ }
200+ if ($ d instanceof SpecObjectInterface) {
201+ $ data [$ k ][$ i ] = $ d ->getSerializableData ();
202+ }
201203 }
204+ } elseif (isset ($ this ->attributes ()[$ k ]) && is_array ($ this ->attributes ()[$ k ]) && 2 === count ($ this ->attributes ()[$ k ])) {
205+ // An empty Map, which is an empty array in PHP but needs to be an empty object in output.
206+ $ toObject = true ;
202207 }
203208 if ($ toObject ) {
204209 $ data [$ k ] = (object ) $ data [$ k ];
You can’t perform that action at this time.
0 commit comments