@@ -162,22 +162,22 @@ public static function generate(string $namespace, \ApiClients\Tools\OpenApiClie
162162 $ factory ->method ('call ' )->makePublic ()->setDocComment (
163163 new Doc (implode (PHP_EOL , [
164164 '/** ' ,
165- ' * @return ' . (function (string $ namespace , array $ operations ): string {
165+ ' * @return ' . (function (array $ operations ): string {
166166 $ count = count ($ operations );
167167 $ lastItem = $ count - 1 ;
168168 $ left = '' ;
169169 $ right = '' ;
170170 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 )));
172172 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 . ' : ' ;
174174 } else {
175175 $ left .= $ returnType ;
176176 }
177177 $ right .= ') ' ;
178178 }
179179 return $ left . $ right ;
180- })($ namespace , $ operations ),
180+ })($ operations ),
181181 ' */ ' ,
182182 ]))
183183 )->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
203203 $ factory ->method ('callAsync ' )->makePublic ()->setDocComment (
204204 new Doc (implode (PHP_EOL , [
205205 '/** ' ,
206- ' * @return ' . (function (string $ namespace , array $ operations ): string {
206+ ' * @return ' . (function (array $ operations ): string {
207207 $ count = count ($ operations );
208208 $ lastItem = $ count - 1 ;
209209 $ left = '' ;
210210 $ right = '' ;
211211 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 )));
213213 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 . '> ' . ' : ' ;
215215 } else {
216216 $ left .= '\\' . PromiseInterface::class . '< ' . $ returnType . '> ' ;
217217 }
218218 $ right .= ') ' ;
219219 }
220220 return $ left . $ right ;
221- })($ namespace , $ operations ),
221+ })($ operations ),
222222 ' */ ' ,
223223 ]))
224224 )->addParam ((new Param ('call ' ))->setType ('string ' ))->addParam ((new Param ('params ' ))->setType ('array ' )->setDefault ([]))->addStmt (new Node \Stmt \Switch_ (
225225 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 {
227227 foreach ($ paths as $ path ) {
228228 foreach ($ path ->operations as $ operation ) {
229- $ operationClassname = $ namespace . 'Operation \\' . Utils::className (str_replace ('/ ' , '\\' , $ operation ->className ));
229+ $ operationClassname = 'Operation \\' . Utils::className (str_replace ('/ ' , '\\' , $ operation ->className ));
230230 yield new Node \Stmt \Case_ (
231231 new Node \Expr \ClassConstFetch (new Node \Name ($ operationClassname ), 'OPERATION_MATCH ' ),
232232 [
@@ -280,7 +280,7 @@ public static function generate(string $namespace, \ApiClients\Tools\OpenApiClie
280280 new Node \Name ('\array_key_exists ' ),
281281 [
282282 new Arg (new Node \Expr \ClassConstFetch (
283- new Node \Name ($ namespace . 'Hydrator \\' . $ path ->hydrator ->className ),
283+ new Node \Name ('Hydrator \\' . $ path ->hydrator ->className ),
284284 new Node \Name ('class ' ),
285285 )),
286286 new Arg (new Node \Expr \PropertyFetch (
@@ -299,7 +299,7 @@ public static function generate(string $namespace, \ApiClients\Tools\OpenApiClie
299299 new Node \Expr \Variable ('this ' ),
300300 'hydrator '
301301 ), new Node \Expr \ClassConstFetch (
302- new Node \Name ($ namespace . 'Hydrator \\' . $ path ->hydrator ->className ),
302+ new Node \Name ('Hydrator \\' . $ path ->hydrator ->className ),
303303 new Node \Name ('class ' ),
304304 )),
305305 new Node \Expr \MethodCall (
@@ -334,7 +334,7 @@ public static function generate(string $namespace, \ApiClients\Tools\OpenApiClie
334334 new Node \Expr \Variable ('this ' ),
335335 'hydrator '
336336 ), new Node \Expr \ClassConstFetch (
337- new Node \Name ($ namespace . 'Hydrator \\' . $ path ->hydrator ->className ),
337+ new Node \Name ('Hydrator \\' . $ path ->hydrator ->className ),
338338 new Node \Name ('class ' ),
339339 ))),
340340 ]),
@@ -397,7 +397,7 @@ public static function generate(string $namespace, \ApiClients\Tools\OpenApiClie
397397 'uses ' => [
398398 new Node \Expr \Variable ('operation ' ),
399399 ],
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 ,
401401 ]))
402402 ]
403403 )),
@@ -407,7 +407,7 @@ public static function generate(string $namespace, \ApiClients\Tools\OpenApiClie
407407 // yield new Node\Stmt\Echo_([new Node\Scalar\String_('/**' . @var_export($operationCall, true) . '*/')]);
408408 }
409409 }
410- })($ namespace , $ client ->paths ))
410+ })($ client ->paths ))
411411 ))->addStmt (
412412 new Node \Stmt \Throw_ (
413413 new Node \Expr \New_ (
0 commit comments