@@ -137,17 +137,21 @@ private static function propertiesToFlat(array $properties, $parent = null): arr
137137 {
138138 $ result = [];
139139
140+ $ innerTypes = [
141+ MappingFieldType::NESTED ,
142+ MappingFieldType::OBJECT ,
143+ ];
144+
140145 if (! isset ($ parent )) {
141146 $ result ['root ' ] =
142147 [
143148 'map ' => \array_flip (\array_keys (\array_filter (
144149 $ properties ,
145- function ($ item ) {
146- if (isset ($ item ['type ' ]) && $ item ['type ' ] === MappingFieldType::NESTED ) {
147- return false ;
148- }
149-
150- return true ;
150+ function ($ item ) use ($ innerTypes ) {
151+ return ! (
152+ isset ($ item ['type ' ])
153+ || (isset ($ item ['properties ' ]) && (\is_array ($ item ['properties ' ])))
154+ );
151155 }
152156 ))),
153157 ];
@@ -157,16 +161,24 @@ function ($item) {
157161 $ pKey = ! isset ($ parent ) ? $ key : ($ parent . '. ' . $ key );
158162 $ type = isset ($ value ['type ' ]) ? $ value ['type ' ] : null ;
159163
164+ if (
165+ ! isset ($ type )
166+ && isset ($ value ['properties ' ])
167+ && (\is_array ($ value ['properties ' ]))
168+ ) {
169+ $ type = MappingFieldType::OBJECT ;
170+ }
171+
160172 $ result [$ pKey ] = [
161173 'key ' => $ key ,
162174 'type ' => $ type ,
163- 'map ' => ($ type === MappingFieldType:: NESTED ) ? \array_flip (\array_keys ($ value ['properties ' ])) : [],
175+ 'map ' => \in_array ($ type, $ innerTypes ) ? \array_flip (\array_keys ($ value ['properties ' ])) : [],
164176 ];
165177
166- if ($ type === MappingFieldType:: NESTED ) {
178+ if (\in_array ( $ type, $ innerTypes ) ) {
167179 $ result = \array_merge ($ result , self ::propertiesToFlat ($ value ['properties ' ], $ pKey ));
168180 }
169- }
181+ }//end foreach
170182
171183 return $ result ;
172184 }
@@ -247,6 +259,7 @@ protected static function buildMap(array $data, array $mapping, $parent = null)
247259 }
248260 break ;
249261
262+ case MappingFieldType::OBJECT :
250263 case MappingFieldType::NESTED :
251264 // Check if $value is associative.
252265 if (\is_array (\current ($ value ))) {
0 commit comments