@@ -21,7 +21,7 @@ final class Schema
21
21
* @param OpenAPiSchema $schema
22
22
* @return iterable<Node>
23
23
*/
24
- public static function generate (string $ name , string $ namespace , string $ className , OpenAPiSchema $ schema , array $ schemaClassNameMap ): iterable
24
+ public static function generate (string $ name , string $ namespace , string $ className , OpenAPiSchema $ schema , array $ schemaClassNameMap, string $ rootNamespace ): iterable
25
25
{
26
26
$ factory = new BuilderFactory ();
27
27
$ stmt = $ factory ->namespace ($ namespace );
@@ -80,11 +80,11 @@ public static function generate(string $name, string $namespace, string $classNa
80
80
if (is_string ($ property ->type )) {
81
81
if ($ property ->type === 'array ' && $ property ->items instanceof OpenAPiSchema) {
82
82
if (array_key_exists (spl_object_hash ($ property ->items ), $ schemaClassNameMap )) {
83
- $ methodDocBlock [] = '@return array< \\' . $ namespace . '\\' . $ schemaClassNameMap [spl_object_hash ($ property ->items )] . '> ' ;
84
- $ docBlock [] = '@var array< \\' . $ namespace . '\\' . $ schemaClassNameMap [spl_object_hash ($ property ->items )] . '> ' ;
85
- $ docBlock [] = '@\WyriHaximus\Hydrator\Attribute\HydrateArray( \\' . $ namespace . '\\' . $ schemaClassNameMap [spl_object_hash ($ property ->items )] . '::class) ' ;
83
+ $ methodDocBlock [] = '@return array< \\' . $ rootNamespace . '\\' . $ schemaClassNameMap [spl_object_hash ($ property ->items )] . '> ' ;
84
+ $ docBlock [] = '@var array< \\' . $ rootNamespace . '\\' . $ schemaClassNameMap [spl_object_hash ($ property ->items )] . '> ' ;
85
+ $ docBlock [] = '@\WyriHaximus\Hydrator\Attribute\HydrateArray( \\' . $ rootNamespace . '\\' . $ schemaClassNameMap [spl_object_hash ($ property ->items )] . '::class) ' ;
86
86
} elseif ($ property ->items ->type === 'object ' ) {
87
- yield from self ::generate ($ name . ':: ' . $ propertyName , $ namespace . '\\' . $ className , (new Convert ($ propertyName ))->toPascal (), $ property ->items , $ schemaClassNameMap );
87
+ yield from self ::generate ($ name . ':: ' . $ propertyName , $ namespace . '\\' . $ className , (new Convert ($ propertyName ))->toPascal (), $ property ->items , $ schemaClassNameMap, $ rootNamespace );
88
88
$ methodDocBlock [] = '@return array< \\' . $ namespace . '\\' . $ className . '\\' . (new Convert ($ propertyName ))->toPascal () . '> ' ;
89
89
$ docBlock [] = '@var array< \\' . $ namespace . '\\' . $ className . '\\' . (new Convert ($ propertyName ))->toPascal () . '> ' ;
90
90
$ docBlock [] = '@\WyriHaximus\Hydrator\Attribute\HydrateArray( \\' . $ namespace . '\\' . $ className . '\\' . (new Convert ($ propertyName ))->toPascal () . '::class) ' ;
@@ -113,14 +113,14 @@ public static function generate(string $name, string $namespace, string $classNa
113
113
}
114
114
115
115
if (is_array ($ property ->anyOf ) && $ property ->anyOf [0 ] instanceof OpenAPiSchema && array_key_exists (spl_object_hash ($ property ->anyOf [0 ]), $ schemaClassNameMap )) {
116
- $ fqcnn = '\\' . $ namespace . '\\' . $ schemaClassNameMap [spl_object_hash ($ property ->anyOf [0 ])];
116
+ $ fqcnn = '\\' . $ rootNamespace . '\\' . $ schemaClassNameMap [spl_object_hash ($ property ->anyOf [0 ])];
117
117
$ propertyStmt ->setType ('? ' . $ fqcnn )->setDefault (null );
118
118
$ method ->setReturnType ('? ' . $ fqcnn );
119
119
$ propertyDocBlock [] = '@\WyriHaximus\Hydrator\Attribute\Hydrate( ' . $ fqcnn . '::class) ' ;
120
120
}
121
121
122
122
if ($ property ->type === 'object ' && $ property instanceof OpenAPiSchema && array_key_exists (spl_object_hash ($ property ), $ schemaClassNameMap )) {
123
- $ fqcnn = '\\' . $ namespace . '\\' . $ schemaClassNameMap [spl_object_hash ($ property )];
123
+ $ fqcnn = '\\' . $ rootNamespace . '\\' . $ schemaClassNameMap [spl_object_hash ($ property )];
124
124
$ propertyStmt ->setType ('? ' . $ fqcnn )->setDefault (null );
125
125
$ method ->setReturnType ('? ' . $ fqcnn );
126
126
$ propertyDocBlock [] = '@\WyriHaximus\Hydrator\Attribute\Hydrate( ' . $ fqcnn . '::class) ' ;
0 commit comments