Skip to content

Commit 411b4f4

Browse files
committed
Return type inconsistencies
1 parent 61580aa commit 411b4f4

File tree

173 files changed

+18551
-662
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

173 files changed

+18551
-662
lines changed

etc/openapi-generator-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@ spec: https://raw.githubusercontent.com/github/rest-api-description/main/descrip
22
namespace: ApiClients\Client\GitHubAE
33
destination: ../src
44
voter:
5+
listOperation:
6+
- ApiClients\Tools\OpenApiClientGenerator\Voter\ListOperation\PageAndPerPageInQuery
57
streamOperation:
68
- ApiClients\Tools\OpenApiClientGenerator\Voter\StreamOperation\DownloadInOperationId

src/Client.php

Lines changed: 6335 additions & 641 deletions
Large diffs are not rendered by default.

src/ClientInterface.php

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.
Lines changed: 336 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,336 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ApiClients\Client\GitHubAE\Hydrator\Operation\Repos\CbOwnerRcb\CbRepoRcb\Actions;
6+
7+
use EventSauce\ObjectHydrator\IterableList;
8+
use EventSauce\ObjectHydrator\ObjectMapper;
9+
use EventSauce\ObjectHydrator\UnableToHydrateObject;
10+
use EventSauce\ObjectHydrator\UnableToSerializeObject;
11+
use Generator;
12+
13+
class OrganizationSecrets implements ObjectMapper
14+
{
15+
private array $hydrationStack = [];
16+
public function __construct() {}
17+
18+
/**
19+
* @template T of object
20+
* @param class-string<T> $className
21+
* @return T
22+
*/
23+
public function hydrateObject(string $className, array $payload): object
24+
{
25+
return match($className) {
26+
'ApiClients\Client\GitHubAE\Schema\Operation\Actions\ListRepoOrganizationSecrets\Response\Applicationjson\H200' => $this->hydrateApiClients⚡️Client⚡️GitHubAE⚡️Schema⚡️Operation⚡️Actions⚡️ListRepoOrganizationSecrets⚡️Response⚡️Applicationjson⚡️H200($payload),
27+
'ApiClients\Client\GitHubAE\Schema\ActionsSecret' => $this->hydrateApiClients⚡️Client⚡️GitHubAE⚡️Schema⚡️ActionsSecret($payload),
28+
default => throw UnableToHydrateObject::noHydrationDefined($className, $this->hydrationStack),
29+
};
30+
}
31+
32+
33+
private function hydrateApiClients⚡️Client⚡️GitHubAE⚡️Schema⚡️Operation⚡️Actions⚡️ListRepoOrganizationSecrets⚡️Response⚡️Applicationjson⚡️H200(array $payload): \ApiClients\Client\GitHubAE\Schema\Operation\Actions\ListRepoOrganizationSecrets\Response\Applicationjson\H200
34+
{
35+
$properties = [];
36+
$missingFields = [];
37+
try {
38+
$value = $payload['total_count'] ?? null;
39+
40+
if ($value === null) {
41+
$missingFields[] = 'total_count';
42+
goto after_total_count;
43+
}
44+
45+
$properties['total_count'] = $value;
46+
47+
after_total_count:
48+
49+
$value = $payload['secrets'] ?? null;
50+
51+
if ($value === null) {
52+
$missingFields[] = 'secrets';
53+
goto after_secrets;
54+
}
55+
56+
static $secretsCaster1;
57+
58+
if ($secretsCaster1 === null) {
59+
$secretsCaster1 = new \EventSauce\ObjectHydrator\PropertyCasters\CastListToType(...array (
60+
0 => 'ApiClients\\Client\\GitHubAE\\Schema\\ActionsSecret',
61+
));
62+
}
63+
64+
$value = $secretsCaster1->cast($value, $this);
65+
66+
$properties['secrets'] = $value;
67+
68+
after_secrets:
69+
70+
} catch (\Throwable $exception) {
71+
throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHubAE\Schema\Operation\Actions\ListRepoOrganizationSecrets\Response\Applicationjson\H200', $exception, stack: $this->hydrationStack);
72+
}
73+
74+
if (count($missingFields) > 0) {
75+
throw UnableToHydrateObject::dueToMissingFields(\ApiClients\Client\GitHubAE\Schema\Operation\Actions\ListRepoOrganizationSecrets\Response\Applicationjson\H200::class, $missingFields, stack: $this->hydrationStack);
76+
}
77+
78+
try {
79+
return new \ApiClients\Client\GitHubAE\Schema\Operation\Actions\ListRepoOrganizationSecrets\Response\Applicationjson\H200(...$properties);
80+
} catch (\Throwable $exception) {
81+
throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHubAE\Schema\Operation\Actions\ListRepoOrganizationSecrets\Response\Applicationjson\H200', $exception, stack: $this->hydrationStack);
82+
}
83+
}
84+
85+
86+
private function hydrateApiClients⚡️Client⚡️GitHubAE⚡️Schema⚡️ActionsSecret(array $payload): \ApiClients\Client\GitHubAE\Schema\ActionsSecret
87+
{
88+
$properties = [];
89+
$missingFields = [];
90+
try {
91+
$value = $payload['name'] ?? null;
92+
93+
if ($value === null) {
94+
$missingFields[] = 'name';
95+
goto after_name;
96+
}
97+
98+
$properties['name'] = $value;
99+
100+
after_name:
101+
102+
$value = $payload['created_at'] ?? null;
103+
104+
if ($value === null) {
105+
$missingFields[] = 'created_at';
106+
goto after_created_at;
107+
}
108+
109+
$properties['created_at'] = $value;
110+
111+
after_created_at:
112+
113+
$value = $payload['updated_at'] ?? null;
114+
115+
if ($value === null) {
116+
$missingFields[] = 'updated_at';
117+
goto after_updated_at;
118+
}
119+
120+
$properties['updated_at'] = $value;
121+
122+
after_updated_at:
123+
124+
} catch (\Throwable $exception) {
125+
throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHubAE\Schema\ActionsSecret', $exception, stack: $this->hydrationStack);
126+
}
127+
128+
if (count($missingFields) > 0) {
129+
throw UnableToHydrateObject::dueToMissingFields(\ApiClients\Client\GitHubAE\Schema\ActionsSecret::class, $missingFields, stack: $this->hydrationStack);
130+
}
131+
132+
try {
133+
return new \ApiClients\Client\GitHubAE\Schema\ActionsSecret(...$properties);
134+
} catch (\Throwable $exception) {
135+
throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHubAE\Schema\ActionsSecret', $exception, stack: $this->hydrationStack);
136+
}
137+
}
138+
139+
private function serializeViaTypeMap(string $accessor, object $object, array $payloadToTypeMap): array
140+
{
141+
foreach ($payloadToTypeMap as $payloadType => [$valueType, $method]) {
142+
if (is_a($object, $valueType)) {
143+
return [$accessor => $payloadType] + $this->{$method}($object);
144+
}
145+
}
146+
147+
throw new \LogicException('No type mapped for object of class: ' . get_class($object));
148+
}
149+
150+
public function serializeObject(object $object): mixed
151+
{
152+
return $this->serializeObjectOfType($object, get_class($object));
153+
}
154+
155+
/**
156+
* @template T
157+
*
158+
* @param T $object
159+
* @param class-string<T> $className
160+
*/
161+
public function serializeObjectOfType(object $object, string $className): mixed
162+
{
163+
try {
164+
return match($className) {
165+
'array' => $this->serializeValuearray($object),
166+
'Ramsey\Uuid\UuidInterface' => $this->serializeValueRamsey⚡️Uuid⚡️UuidInterface($object),
167+
'DateTime' => $this->serializeValueDateTime($object),
168+
'DateTimeImmutable' => $this->serializeValueDateTimeImmutable($object),
169+
'DateTimeInterface' => $this->serializeValueDateTimeInterface($object),
170+
'ApiClients\Client\GitHubAE\Schema\Operation\Actions\ListRepoOrganizationSecrets\Response\Applicationjson\H200' => $this->serializeObjectApiClients⚡️Client⚡️GitHubAE⚡️Schema⚡️Operation⚡️Actions⚡️ListRepoOrganizationSecrets⚡️Response⚡️Applicationjson⚡️H200($object),
171+
'ApiClients\Client\GitHubAE\Schema\ActionsSecret' => $this->serializeObjectApiClients⚡️Client⚡️GitHubAE⚡️Schema⚡️ActionsSecret($object),
172+
default => throw new \LogicException('No serialization defined for $className'),
173+
};
174+
} catch (\Throwable $exception) {
175+
throw UnableToSerializeObject::dueToError($className, $exception);
176+
}
177+
}
178+
179+
180+
private function serializeValuearray(mixed $value): mixed
181+
{
182+
static $serializer;
183+
184+
if ($serializer === null) {
185+
$serializer = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeArrayItems(...array (
186+
));
187+
}
188+
189+
return $serializer->serialize($value, $this);
190+
}
191+
192+
193+
private function serializeValueRamsey⚡️Uuid⚡️UuidInterface(mixed $value): mixed
194+
{
195+
static $serializer;
196+
197+
if ($serializer === null) {
198+
$serializer = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeUuidToString(...array (
199+
));
200+
}
201+
202+
return $serializer->serialize($value, $this);
203+
}
204+
205+
206+
private function serializeValueDateTime(mixed $value): mixed
207+
{
208+
static $serializer;
209+
210+
if ($serializer === null) {
211+
$serializer = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeDateTime(...array (
212+
));
213+
}
214+
215+
return $serializer->serialize($value, $this);
216+
}
217+
218+
219+
private function serializeValueDateTimeImmutable(mixed $value): mixed
220+
{
221+
static $serializer;
222+
223+
if ($serializer === null) {
224+
$serializer = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeDateTime(...array (
225+
));
226+
}
227+
228+
return $serializer->serialize($value, $this);
229+
}
230+
231+
232+
private function serializeValueDateTimeInterface(mixed $value): mixed
233+
{
234+
static $serializer;
235+
236+
if ($serializer === null) {
237+
$serializer = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeDateTime(...array (
238+
));
239+
}
240+
241+
return $serializer->serialize($value, $this);
242+
}
243+
244+
245+
private function serializeObjectApiClients⚡️Client⚡️GitHubAE⚡️Schema⚡️Operation⚡️Actions⚡️ListRepoOrganizationSecrets⚡️Response⚡️Applicationjson⚡️H200(mixed $object): mixed
246+
{
247+
\assert($object instanceof \ApiClients\Client\GitHubAE\Schema\Operation\Actions\ListRepoOrganizationSecrets\Response\Applicationjson\H200);
248+
$result = [];
249+
250+
$total_count = $object->total_count;
251+
after_total_count: $result['total_count'] = $total_count;
252+
253+
254+
$secrets = $object->secrets;
255+
static $secretsSerializer0;
256+
257+
if ($secretsSerializer0 === null) {
258+
$secretsSerializer0 = new \EventSauce\ObjectHydrator\PropertyCasters\CastListToType(...array (
259+
0 => 'ApiClients\\Client\\GitHubAE\\Schema\\ActionsSecret',
260+
));
261+
}
262+
263+
$secrets = $secretsSerializer0->serialize($secrets, $this);
264+
after_secrets: $result['secrets'] = $secrets;
265+
266+
267+
return $result;
268+
}
269+
270+
271+
private function serializeObjectApiClients⚡️Client⚡️GitHubAE⚡️Schema⚡️ActionsSecret(mixed $object): mixed
272+
{
273+
\assert($object instanceof \ApiClients\Client\GitHubAE\Schema\ActionsSecret);
274+
$result = [];
275+
276+
$name = $object->name;
277+
after_name: $result['name'] = $name;
278+
279+
280+
$created_at = $object->created_at;
281+
after_created_at: $result['created_at'] = $created_at;
282+
283+
284+
$updated_at = $object->updated_at;
285+
after_updated_at: $result['updated_at'] = $updated_at;
286+
287+
288+
return $result;
289+
}
290+
291+
292+
293+
/**
294+
* @template T
295+
*
296+
* @param class-string<T> $className
297+
* @param iterable<array> $payloads;
298+
*
299+
* @return IterableList<T>
300+
*
301+
* @throws UnableToHydrateObject
302+
*/
303+
public function hydrateObjects(string $className, iterable $payloads): IterableList
304+
{
305+
return new IterableList($this->doHydrateObjects($className, $payloads));
306+
}
307+
308+
private function doHydrateObjects(string $className, iterable $payloads): Generator
309+
{
310+
foreach ($payloads as $index => $payload) {
311+
yield $index => $this->hydrateObject($className, $payload);
312+
}
313+
}
314+
315+
/**
316+
* @template T
317+
*
318+
* @param class-string<T> $className
319+
* @param iterable<array> $payloads;
320+
*
321+
* @return IterableList<T>
322+
*
323+
* @throws UnableToSerializeObject
324+
*/
325+
public function serializeObjects(iterable $payloads): IterableList
326+
{
327+
return new IterableList($this->doSerializeObjects($payloads));
328+
}
329+
330+
private function doSerializeObjects(iterable $objects): Generator
331+
{
332+
foreach ($objects as $index => $object) {
333+
yield $index => $this->serializeObject($object);
334+
}
335+
}
336+
}

0 commit comments

Comments
 (0)