@@ -162,22 +162,22 @@ public static function generate(string $namespace, \ApiClients\Tools\OpenApiClie
162
162
$ factory ->method ('call ' )->makePublic ()->setDocComment (
163
163
new Doc (implode (PHP_EOL , [
164
164
'/** ' ,
165
- ' * @return ' . (function (string $ namespace , array $ operations ): string {
165
+ ' * @return ' . (function (array $ operations ): string {
166
166
$ count = count ($ operations );
167
167
$ lastItem = $ count - 1 ;
168
168
$ left = '' ;
169
169
$ right = '' ;
170
170
for ($ i = 0 ; $ i < $ count ; $ i ++) {
171
- $ returnType = implode ('| ' , array_map (static fn (string $ className ): string => strpos ($ className , '\\' ) === 0 ? $ className : $ namespace . 'Schema \\' . $ className , array_unique ($ operations [$ i ]->returnType )));
171
+ $ returnType = implode ('| ' , array_map (static fn (string $ className ): string => strpos ($ className , '\\' ) === 0 ? $ className : 'Schema \\' . $ className , array_unique ($ operations [$ i ]->returnType )));
172
172
if ($ i !== $ lastItem ) {
173
- $ left .= '($call is ' . $ namespace . 'Operation \\' . $ operations [$ i ]->classNameSanitized . '::OPERATION_MATCH ? ' . $ returnType . ' : ' ;
173
+ $ left .= '($call is ' . 'Operation \\' . $ operations [$ i ]->classNameSanitized . '::OPERATION_MATCH ? ' . $ returnType . ' : ' ;
174
174
} else {
175
175
$ left .= $ returnType ;
176
176
}
177
177
$ right .= ') ' ;
178
178
}
179
179
return $ left . $ right ;
180
- })($ namespace , $ operations ),
180
+ })($ operations ),
181
181
' */ ' ,
182
182
]))
183
183
)->addParam ((new Param ('call ' ))->setType ('string ' ))->addParam ((new Param ('params ' ))->setType ('array ' )->setDefault ([]))->addStmt (new Node \Stmt \Return_ (
@@ -203,30 +203,30 @@ public static function generate(string $namespace, \ApiClients\Tools\OpenApiClie
203
203
$ factory ->method ('callAsync ' )->makePublic ()->setDocComment (
204
204
new Doc (implode (PHP_EOL , [
205
205
'/** ' ,
206
- ' * @return ' . (function (string $ namespace , array $ operations ): string {
206
+ ' * @return ' . (function (array $ operations ): string {
207
207
$ count = count ($ operations );
208
208
$ lastItem = $ count - 1 ;
209
209
$ left = '' ;
210
210
$ right = '' ;
211
211
for ($ i = 0 ; $ i < $ count ; $ i ++) {
212
- $ returnType = implode ('| ' , array_map (static fn (string $ className ): string => strpos ($ className , '\\' ) === 0 ? $ className : $ namespace . 'Schema \\' . $ className , array_unique ($ operations [$ i ]->returnType )));
212
+ $ returnType = implode ('| ' , array_map (static fn (string $ className ): string => strpos ($ className , '\\' ) === 0 ? $ className : 'Schema \\' . $ className , array_unique ($ operations [$ i ]->returnType )));
213
213
if ($ i !== $ lastItem ) {
214
- $ left .= '($call is ' . $ namespace . 'Operation \\' . $ operations [$ i ]->classNameSanitized . '::OPERATION_MATCH ? ' . '\\' . PromiseInterface::class . '< ' . $ returnType . '> ' . ' : ' ;
214
+ $ left .= '($call is ' . 'Operation \\' . $ operations [$ i ]->classNameSanitized . '::OPERATION_MATCH ? ' . '\\' . PromiseInterface::class . '< ' . $ returnType . '> ' . ' : ' ;
215
215
} else {
216
216
$ left .= '\\' . PromiseInterface::class . '< ' . $ returnType . '> ' ;
217
217
}
218
218
$ right .= ') ' ;
219
219
}
220
220
return $ left . $ right ;
221
- })($ namespace , $ operations ),
221
+ })($ operations ),
222
222
' */ ' ,
223
223
]))
224
224
)->addParam ((new Param ('call ' ))->setType ('string ' ))->addParam ((new Param ('params ' ))->setType ('array ' )->setDefault ([]))->addStmt (new Node \Stmt \Switch_ (
225
225
new Node \Expr \Variable ('call ' ),
226
- iterator_to_array ((function (string $ namespace , array $ paths ) use ($ factory ): iterable {
226
+ iterator_to_array ((function (array $ paths ) use ($ factory ): iterable {
227
227
foreach ($ paths as $ path ) {
228
228
foreach ($ path ->operations as $ operation ) {
229
- $ operationClassname = $ namespace . 'Operation \\' . Utils::className (str_replace ('/ ' , '\\' , $ operation ->className ));
229
+ $ operationClassname = 'Operation \\' . Utils::className (str_replace ('/ ' , '\\' , $ operation ->className ));
230
230
yield new Node \Stmt \Case_ (
231
231
new Node \Expr \ClassConstFetch (new Node \Name ($ operationClassname ), 'OPERATION_MATCH ' ),
232
232
[
@@ -280,7 +280,7 @@ public static function generate(string $namespace, \ApiClients\Tools\OpenApiClie
280
280
new Node \Name ('\array_key_exists ' ),
281
281
[
282
282
new Arg (new Node \Expr \ClassConstFetch (
283
- new Node \Name ($ namespace . 'Hydrator \\' . $ path ->hydrator ->className ),
283
+ new Node \Name ('Hydrator \\' . $ path ->hydrator ->className ),
284
284
new Node \Name ('class ' ),
285
285
)),
286
286
new Arg (new Node \Expr \PropertyFetch (
@@ -299,7 +299,7 @@ public static function generate(string $namespace, \ApiClients\Tools\OpenApiClie
299
299
new Node \Expr \Variable ('this ' ),
300
300
'hydrator '
301
301
), new Node \Expr \ClassConstFetch (
302
- new Node \Name ($ namespace . 'Hydrator \\' . $ path ->hydrator ->className ),
302
+ new Node \Name ('Hydrator \\' . $ path ->hydrator ->className ),
303
303
new Node \Name ('class ' ),
304
304
)),
305
305
new Node \Expr \MethodCall (
@@ -334,7 +334,7 @@ public static function generate(string $namespace, \ApiClients\Tools\OpenApiClie
334
334
new Node \Expr \Variable ('this ' ),
335
335
'hydrator '
336
336
), new Node \Expr \ClassConstFetch (
337
- new Node \Name ($ namespace . 'Hydrator \\' . $ path ->hydrator ->className ),
337
+ new Node \Name ('Hydrator \\' . $ path ->hydrator ->className ),
338
338
new Node \Name ('class ' ),
339
339
))),
340
340
]),
@@ -397,7 +397,7 @@ public static function generate(string $namespace, \ApiClients\Tools\OpenApiClie
397
397
'uses ' => [
398
398
new Node \Expr \Variable ('operation ' ),
399
399
],
400
- 'returnType ' => count ($ operation ->returnType ) > 0 ? new Node \UnionType (array_map (static fn (string $ object ): Node \Name => new Node \Name (strpos ($ object , '\\' ) === 0 ? $ object : $ namespace . 'Schema \\' . $ object ), array_unique ($ operation ->returnType ))) : null ,
400
+ 'returnType ' => count ($ operation ->returnType ) > 0 ? new Node \UnionType (array_map (static fn (string $ object ): Node \Name => new Node \Name (strpos ($ object , '\\' ) === 0 ? $ object : 'Schema \\' . $ object ), array_unique ($ operation ->returnType ))) : null ,
401
401
]))
402
402
]
403
403
)),
@@ -407,7 +407,7 @@ public static function generate(string $namespace, \ApiClients\Tools\OpenApiClie
407
407
// yield new Node\Stmt\Echo_([new Node\Scalar\String_('/**' . @var_export($operationCall, true) . '*/')]);
408
408
}
409
409
}
410
- })($ namespace , $ client ->paths ))
410
+ })($ client ->paths ))
411
411
))->addStmt (
412
412
new Node \Stmt \Throw_ (
413
413
new Node \Expr \New_ (
0 commit comments