@@ -248,6 +248,30 @@ function (PhpDocChildNode $child): string {
248248 if ($ node instanceof DoctrineArrayItem) {
249249 return (string ) $ node ;
250250 }
251+ if ($ node instanceof ArrayShapeItemNode) {
252+ if ($ node ->keyName !== null ) {
253+ return sprintf (
254+ '%s%s: %s ' ,
255+ $ this ->print ($ node ->keyName ),
256+ $ node ->optional ? '? ' : '' ,
257+ $ this ->printType ($ node ->valueType ),
258+ );
259+ }
260+
261+ return $ this ->printType ($ node ->valueType );
262+ }
263+ if ($ node instanceof ObjectShapeItemNode) {
264+ if ($ node ->keyName !== null ) {
265+ return sprintf (
266+ '%s%s: %s ' ,
267+ $ this ->print ($ node ->keyName ),
268+ $ node ->optional ? '? ' : '' ,
269+ $ this ->printType ($ node ->valueType ),
270+ );
271+ }
272+
273+ return $ this ->printType ($ node ->valueType );
274+ }
251275
252276 throw new LogicException (sprintf ('Unknown node type %s ' , get_class ($ node )));
253277 }
@@ -364,26 +388,14 @@ private function printTagValue(PhpDocTagValueNode $node): string
364388 private function printType (TypeNode $ node ): string
365389 {
366390 if ($ node instanceof ArrayShapeNode) {
367- $ items = array_map (fn (ArrayShapeItemNode $ item ): string => $ this ->printType ($ item ), $ node ->items );
391+ $ items = array_map (fn (ArrayShapeItemNode $ item ): string => $ this ->print ($ item ), $ node ->items );
368392
369393 if (! $ node ->sealed ) {
370394 $ items [] = '... ' . ($ node ->unsealedType === null ? '' : $ this ->print ($ node ->unsealedType ));
371395 }
372396
373397 return $ node ->kind . '{ ' . implode (', ' , $ items ) . '} ' ;
374398 }
375- if ($ node instanceof ArrayShapeItemNode) {
376- if ($ node ->keyName !== null ) {
377- return sprintf (
378- '%s%s: %s ' ,
379- $ this ->print ($ node ->keyName ),
380- $ node ->optional ? '? ' : '' ,
381- $ this ->printType ($ node ->valueType ),
382- );
383- }
384-
385- return $ this ->printType ($ node ->valueType );
386- }
387399 if ($ node instanceof ArrayTypeNode) {
388400 return $ this ->printOffsetAccessType ($ node ->type ) . '[] ' ;
389401 }
@@ -469,22 +481,10 @@ private function printType(TypeNode $node): string
469481 return '? ' . $ this ->printType ($ node ->type );
470482 }
471483 if ($ node instanceof ObjectShapeNode) {
472- $ items = array_map (fn (ObjectShapeItemNode $ item ): string => $ this ->printType ($ item ), $ node ->items );
484+ $ items = array_map (fn (ObjectShapeItemNode $ item ): string => $ this ->print ($ item ), $ node ->items );
473485
474486 return 'object{ ' . implode (', ' , $ items ) . '} ' ;
475487 }
476- if ($ node instanceof ObjectShapeItemNode) {
477- if ($ node ->keyName !== null ) {
478- return sprintf (
479- '%s%s: %s ' ,
480- $ this ->print ($ node ->keyName ),
481- $ node ->optional ? '? ' : '' ,
482- $ this ->printType ($ node ->valueType ),
483- );
484- }
485-
486- return $ this ->printType ($ node ->valueType );
487- }
488488 if ($ node instanceof OffsetAccessTypeNode) {
489489 return $ this ->printOffsetAccessType ($ node ->type ) . '[ ' . $ this ->printType ($ node ->offset ) . '] ' ;
490490 }
0 commit comments