|
16 | 16 | use ApiClients\Tools\OpenApiClientGenerator\PrivatePromotedPropertyAsParam; |
17 | 17 | use ApiClients\Tools\OpenApiClientGenerator\Representation; |
18 | 18 | use ApiClients\Tools\OpenApiClientGenerator\Utils; |
19 | | -use EventSauce\ObjectHydrator\ObjectMapper; |
20 | 19 | use Jawira\CaseConverter\Convert; |
21 | 20 | use NumberToWords\NumberToWords; |
22 | 21 | use PhpParser\Builder\Method; |
@@ -903,49 +902,6 @@ private static function callOperation(Routers $routers, Representation\Operation |
903 | 902 | } |
904 | 903 | })($operation->parameters), |
905 | 904 | ] : []), |
906 | | - /** @phpstan-ignore-next-line */ |
907 | | - ...(count(array_filter((new ReflectionClass($operation->className->fullyQualified->source))->getConstructor()->getParameters(), static fn (ReflectionParameter $parameter): bool => $parameter->name === 'responseSchemaValidator' || $parameter->name === 'hydrator')) > 0 ? [ |
908 | | - new Node\Stmt\If_( |
909 | | - new Node\Expr\BinaryOp\Equal( |
910 | | - new Node\Expr\FuncCall( |
911 | | - new Node\Name('\array_key_exists'), |
912 | | - [ |
913 | | - new Arg(new Node\Expr\ClassConstFetch( |
914 | | - new Node\Name($path->hydrator->className->relative), |
915 | | - 'class', |
916 | | - )), |
917 | | - new Arg(new Node\Expr\PropertyFetch( |
918 | | - new Node\Expr\Variable('this'), |
919 | | - 'hydrator', |
920 | | - )), |
921 | | - ], |
922 | | - ), |
923 | | - new Node\Expr\ConstFetch(new Node\Name('false')), |
924 | | - ), |
925 | | - [ |
926 | | - 'stmts' => [ |
927 | | - new Node\Stmt\Expression( |
928 | | - new Node\Expr\Assign( |
929 | | - new Node\Expr\ArrayDimFetch(new Node\Expr\PropertyFetch( |
930 | | - new Node\Expr\Variable('this'), |
931 | | - 'hydrator', |
932 | | - ), new Node\Expr\ClassConstFetch( |
933 | | - new Node\Name($path->hydrator->className->relative), |
934 | | - 'class', |
935 | | - )), |
936 | | - new Node\Expr\MethodCall( |
937 | | - new Node\Expr\PropertyFetch( |
938 | | - new Node\Expr\Variable('this'), |
939 | | - 'hydrators', |
940 | | - ), |
941 | | - 'getObjectMapper' . ucfirst($path->hydrator->methodName), |
942 | | - ), |
943 | | - ), |
944 | | - ), |
945 | | - ], |
946 | | - ], |
947 | | - ), |
948 | | - ] : []), |
949 | 905 | ...($operation->matchMethod !== 'LIST' ? self::makeCall( |
950 | 906 | $operation, |
951 | 907 | $path, |
@@ -1115,13 +1071,15 @@ private static function makeCall(Representation\Operation $operation, Representa |
1115 | 1071 | new Node\Expr\Variable('this'), |
1116 | 1072 | 'responseSchemaValidator', |
1117 | 1073 | )), |
1118 | | - new Arg(new Node\Expr\ArrayDimFetch(new Node\Expr\PropertyFetch( |
1119 | | - new Node\Expr\Variable('this'), |
1120 | | - 'hydrator', |
1121 | | - ), new Node\Expr\ClassConstFetch( |
1122 | | - new Node\Name($path->hydrator->className->relative), |
1123 | | - 'class', |
1124 | | - ))), |
| 1074 | + new Arg( |
| 1075 | + new Node\Expr\MethodCall( |
| 1076 | + new Node\Expr\PropertyFetch( |
| 1077 | + new Node\Expr\Variable('this'), |
| 1078 | + 'hydrators', |
| 1079 | + ), |
| 1080 | + 'getObjectMapper' . ucfirst($path->hydrator->methodName), |
| 1081 | + ), |
| 1082 | + ), |
1125 | 1083 | ] : []), |
1126 | 1084 | ], |
1127 | 1085 | ), |
@@ -1150,12 +1108,6 @@ private static function createRouter(string $pathPrefix, string $namespace, Rout |
1150 | 1108 | $factory = new BuilderFactory(); |
1151 | 1109 | $stmt = $factory->namespace(Utils::dirname($namespace . $className)); |
1152 | 1110 | $class = $factory->class(Utils::basename($namespace . $className))->makeFinal()->addStmt( |
1153 | | - $factory->property('hydrator')->setType('array')->setDefault([])->makePrivate()->setDocComment(new Doc(implode(PHP_EOL, [ |
1154 | | - '/**', |
1155 | | - ' * @var array<class-string, \\' . ObjectMapper::class . '>', |
1156 | | - ' */', |
1157 | | - ]))), |
1158 | | - )->addStmt( |
1159 | 1111 | $constructor, |
1160 | 1112 | ); |
1161 | 1113 |
|
|
0 commit comments