@@ -63,9 +63,11 @@ public static function generate(string $name, string $namespace, string $classNa
6363 '_MINUS_ ' ,
6464 ], $ propertyName );
6565 $ propertyStmt = $ factory ->property ($ propertyName )->makePrivate ();
66- $ docBlock = [];
66+ $ propertyDocBlock = [];
67+ $ methodDocBlock = [];
6768 if (strlen ($ property ->description ) > 0 ) {
68- $ docBlock [] = $ property ->description ;
69+ $ propertyDocBlock [] = $ property ->description ;
70+ $ methodDocBlock [] = $ property ->description ;
6971 }
7072 $ method = $ factory ->method ($ propertyName )->makePublic ()/*->setReturnType('string')*/ ->addStmt (
7173 new Node \Stmt \Return_ (
@@ -78,10 +80,12 @@ public static function generate(string $name, string $namespace, string $classNa
7880 if (is_string ($ property ->type )) {
7981 if ($ property ->type === 'array ' && $ property ->items instanceof OpenAPiSchema) {
8082 if (array_key_exists (spl_object_hash ($ property ->items ), $ schemaClassNameMap )) {
83+ $ methodDocBlock [] = '@return array< \\' . $ namespace . '\\' . $ schemaClassNameMap [spl_object_hash ($ property ->items )] . '> ' ;
8184 $ docBlock [] = '@var array< \\' . $ namespace . '\\' . $ schemaClassNameMap [spl_object_hash ($ property ->items )] . '> ' ;
8285 $ docBlock [] = '@\WyriHaximus\Hydrator\Attribute\HydrateArray( \\' . $ namespace . '\\' . $ schemaClassNameMap [spl_object_hash ($ property ->items )] . '::class) ' ;
8386 } elseif ($ property ->items ->type === 'object ' ) {
8487 yield from self ::generate ($ name . ':: ' . $ propertyName , $ namespace . '\\' . $ className , (new Convert ($ propertyName ))->toPascal (), $ property ->items , $ schemaClassNameMap );
88+ $ methodDocBlock [] = '@return array< \\' . $ namespace . '\\' . $ className . '\\' . (new Convert ($ propertyName ))->toPascal () . '> ' ;
8589 $ docBlock [] = '@var array< \\' . $ namespace . '\\' . $ className . '\\' . (new Convert ($ propertyName ))->toPascal () . '> ' ;
8690 $ docBlock [] = '@\WyriHaximus\Hydrator\Attribute\HydrateArray( \\' . $ namespace . '\\' . $ className . '\\' . (new Convert ($ propertyName ))->toPascal () . '::class) ' ;
8791 }
@@ -112,18 +116,22 @@ public static function generate(string $name, string $namespace, string $classNa
112116 $ fqcnn = '\\' . $ namespace . '\\' . $ schemaClassNameMap [spl_object_hash ($ property ->anyOf [0 ])];
113117 $ propertyStmt ->setType ('? ' . $ fqcnn )->setDefault (null );
114118 $ method ->setReturnType ('? ' . $ fqcnn );
115- $ docBlock [] = '@\WyriHaximus\Hydrator\Attribute\Hydrate( ' . $ fqcnn . '::class) ' ;
119+ $ propertyDocBlock [] = '@\WyriHaximus\Hydrator\Attribute\Hydrate( ' . $ fqcnn . '::class) ' ;
116120 }
117121
118122 if ($ property ->type === 'object ' && $ property instanceof OpenAPiSchema && array_key_exists (spl_object_hash ($ property ), $ schemaClassNameMap )) {
119123 $ fqcnn = '\\' . $ namespace . '\\' . $ schemaClassNameMap [spl_object_hash ($ property )];
120124 $ propertyStmt ->setType ('? ' . $ fqcnn )->setDefault (null );
121125 $ method ->setReturnType ('? ' . $ fqcnn );
122- $ docBlock [] = '@\WyriHaximus\Hydrator\Attribute\Hydrate( ' . $ fqcnn . '::class) ' ;
126+ $ propertyDocBlock [] = '@\WyriHaximus\Hydrator\Attribute\Hydrate( ' . $ fqcnn . '::class) ' ;
123127 }
124128
125- if (count ($ docBlock ) > 0 ) {
126- $ propertyStmt ->setDocComment ('/** ' . PHP_EOL . ' * ' . implode (PHP_EOL . ' * ' , $ docBlock ) . PHP_EOL .' */ ' );
129+ if (count ($ propertyDocBlock ) > 0 ) {
130+ $ propertyStmt ->setDocComment ('/** ' . PHP_EOL . ' * ' . implode (PHP_EOL . ' * ' , $ propertyDocBlock ) . PHP_EOL .' */ ' );
131+ }
132+
133+ if (count ($ methodDocBlock ) > 0 ) {
134+ $ method ->setDocComment ('/** ' . PHP_EOL . ' * ' . implode (PHP_EOL . ' * ' , $ methodDocBlock ) . PHP_EOL .' */ ' );
127135 }
128136
129137 $ class ->addStmt ($ propertyStmt )->addStmt ($ method );
0 commit comments