Skip to content

Commit 22c9b08

Browse files
authored
Generate the phpdoc for the static create method of objects (#1464)
1 parent f3807d1 commit 22c9b08

File tree

893 files changed

+7948
-9
lines changed

Some content is hidden

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

893 files changed

+7948
-9
lines changed

src/CodeGenerator/src/Generator/InputGenerator.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,16 @@ public function generate(Operation $operation): ClassName
270270
}
271271

272272
// Add named constructor
273-
$classBuilder->addMethod('create')
273+
$createMethod = $classBuilder->addMethod('create')
274274
->setStatic(true)
275275
->setReturnType('self')
276-
->setBody('return $input instanceof self ? $input : new self($input);')
277-
->addParameter('input');
276+
->setBody('return $input instanceof self ? $input : new self($input);');
277+
$createMethod->addParameter('input');
278+
[$doc, $memberClassNames] = $this->typeGenerator->generateDocblock($shape, $className, true, true, false, [' \'@region\'?: string|null,']);
279+
$createMethod->addComment($doc);
280+
foreach ($memberClassNames as $memberClassName) {
281+
$classBuilder->addUse($memberClassName->getFqdn());
282+
}
278283

279284
$constructorBody .= 'parent::__construct($input);';
280285
$constructor = $classBuilder->addMethod('__construct');

src/CodeGenerator/src/Generator/ObjectGenerator.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,20 +147,30 @@ private function isShapeUsedInput(StructureShape $shape): bool
147147
private function namedConstructor(StructureShape $shape, ClassBuilder $classBuilder): void
148148
{
149149
if (empty($shape->getMembers())) {
150-
$classBuilder->addMethod('create')
150+
$createMethod = $classBuilder->addMethod('create')
151151
->setStatic(true)
152152
->setReturnType('self')
153-
->setBody('return $input instanceof self ? $input : new self();')
154-
->addParameter('input');
153+
->setBody('return $input instanceof self ? $input : new self();');
154+
$createMethod->addParameter('input');
155+
[$doc, $memberClassNames] = $this->typeGenerator->generateDocblock($shape, $this->generated[$shape->getName()], true, false, true);
156+
$createMethod->addComment($doc);
157+
foreach ($memberClassNames as $memberClassName) {
158+
$classBuilder->addUse($memberClassName->getFqdn());
159+
}
155160

156161
return;
157162
}
158163

159-
$classBuilder->addMethod('create')
164+
$createMethod = $classBuilder->addMethod('create')
160165
->setStatic(true)
161166
->setReturnType('self')
162-
->setBody('return $input instanceof self ? $input : new self($input);')
163-
->addParameter('input');
167+
->setBody('return $input instanceof self ? $input : new self($input);');
168+
$createMethod->addParameter('input');
169+
[$doc, $memberClassNames] = $this->typeGenerator->generateDocblock($shape, $this->generated[$shape->getName()], true, false, true);
170+
$createMethod->addComment($doc);
171+
foreach ($memberClassNames as $memberClassName) {
172+
$classBuilder->addUse($memberClassName->getFqdn());
173+
}
164174

165175
// We need a constructor
166176
$constructor = $classBuilder->addMethod('__construct');

src/Core/src/Sts/Input/AssumeRoleRequest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,22 @@ public function __construct(array $input = [])
260260
parent::__construct($input);
261261
}
262262

263+
/**
264+
* @param array{
265+
* RoleArn?: string,
266+
* RoleSessionName?: string,
267+
* PolicyArns?: PolicyDescriptorType[],
268+
* Policy?: string,
269+
* DurationSeconds?: int,
270+
* Tags?: Tag[],
271+
* TransitiveTagKeys?: string[],
272+
* ExternalId?: string,
273+
* SerialNumber?: string,
274+
* TokenCode?: string,
275+
* SourceIdentity?: string,
276+
* '@region'?: string|null,
277+
* }|AssumeRoleRequest $input
278+
*/
263279
public static function create($input): self
264280
{
265281
return $input instanceof self ? $input : new self($input);

src/Core/src/Sts/Input/AssumeRoleWithWebIdentityRequest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,18 @@ public function __construct(array $input = [])
153153
parent::__construct($input);
154154
}
155155

156+
/**
157+
* @param array{
158+
* RoleArn?: string,
159+
* RoleSessionName?: string,
160+
* WebIdentityToken?: string,
161+
* ProviderId?: string,
162+
* PolicyArns?: PolicyDescriptorType[],
163+
* Policy?: string,
164+
* DurationSeconds?: int,
165+
* '@region'?: string|null,
166+
* }|AssumeRoleWithWebIdentityRequest $input
167+
*/
156168
public static function create($input): self
157169
{
158170
return $input instanceof self ? $input : new self($input);

src/Core/src/Sts/Input/GetCallerIdentityRequest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ public function __construct(array $input = [])
1818
parent::__construct($input);
1919
}
2020

21+
/**
22+
* @param array{
23+
* '@region'?: string|null,
24+
* }|GetCallerIdentityRequest $input
25+
*/
2126
public static function create($input): self
2227
{
2328
return $input instanceof self ? $input : new self($input);

src/Core/src/Sts/ValueObject/AssumedRoleUser.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ public function __construct(array $input)
3333
$this->arn = $input['Arn'] ?? null;
3434
}
3535

36+
/**
37+
* @param array{
38+
* AssumedRoleId: string,
39+
* Arn: string,
40+
* }|AssumedRoleUser $input
41+
*/
3642
public static function create($input): self
3743
{
3844
return $input instanceof self ? $input : new self($input);

src/Core/src/Sts/ValueObject/Credentials.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ public function __construct(array $input)
4343
$this->expiration = $input['Expiration'] ?? null;
4444
}
4545

46+
/**
47+
* @param array{
48+
* AccessKeyId: string,
49+
* SecretAccessKey: string,
50+
* SessionToken: string,
51+
* Expiration: \DateTimeImmutable,
52+
* }|Credentials $input
53+
*/
4654
public static function create($input): self
4755
{
4856
return $input instanceof self ? $input : new self($input);

src/Core/src/Sts/ValueObject/PolicyDescriptorType.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ public function __construct(array $input)
2727
$this->arn = $input['arn'] ?? null;
2828
}
2929

30+
/**
31+
* @param array{
32+
* arn?: null|string,
33+
* }|PolicyDescriptorType $input
34+
*/
3035
public static function create($input): self
3136
{
3237
return $input instanceof self ? $input : new self($input);

src/Core/src/Sts/ValueObject/Tag.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ public function __construct(array $input)
4545
$this->value = $input['Value'] ?? null;
4646
}
4747

48+
/**
49+
* @param array{
50+
* Key: string,
51+
* Value: string,
52+
* }|Tag $input
53+
*/
4854
public static function create($input): self
4955
{
5056
return $input instanceof self ? $input : new self($input);

src/Service/AppSync/src/Input/CreateResolverRequest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,24 @@ public function __construct(array $input = [])
157157
parent::__construct($input);
158158
}
159159

160+
/**
161+
* @param array{
162+
* apiId?: string,
163+
* typeName?: string,
164+
* fieldName?: string,
165+
* dataSourceName?: string,
166+
* requestMappingTemplate?: string,
167+
* responseMappingTemplate?: string,
168+
* kind?: ResolverKind::*,
169+
* pipelineConfig?: PipelineConfig|array,
170+
* syncConfig?: SyncConfig|array,
171+
* cachingConfig?: CachingConfig|array,
172+
* maxBatchSize?: int,
173+
* runtime?: AppSyncRuntime|array,
174+
* code?: string,
175+
* '@region'?: string|null,
176+
* }|CreateResolverRequest $input
177+
*/
160178
public static function create($input): self
161179
{
162180
return $input instanceof self ? $input : new self($input);

0 commit comments

Comments
 (0)