Skip to content

Generate the property type for generated objects #1467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
15 changes: 15 additions & 0 deletions psalm.baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,11 @@
<code><![CDATA[list<Reason::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/Route53/src/Result/CreateHostedZoneResponse.php">
<PossiblyNullPropertyAssignmentValue>
<code><![CDATA[$headers['location'][0] ?? null]]></code>
</PossiblyNullPropertyAssignmentValue>
</file>
<file src="src/Service/S3/src/Result/ListObjectsV2Output.php">
<LessSpecificReturnStatement>
<code>$items</code>
Expand All @@ -307,4 +312,14 @@
<code>empty($s3SignerOptions)</code>
</TypeDoesNotContainType>
</file>
<file src="src/Service/StepFunctions/src/Result/StartExecutionOutput.php">
<PossiblyFalsePropertyAssignmentValue>
<code><![CDATA[$d = \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', $data['startDate']))]]></code>
</PossiblyFalsePropertyAssignmentValue>
</file>
<file src="src/Service/StepFunctions/src/Result/StopExecutionOutput.php">
<PossiblyFalsePropertyAssignmentValue>
<code><![CDATA[$d = \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', $data['stopDate']))]]></code>
</PossiblyFalsePropertyAssignmentValue>
</file>
</files>
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ private function generateProperties(StructureShape $shape, ClassBuilder $classBu
$nullable = false;
} elseif ($member->isStreaming()) {
$returnType = ResultStream::class;
$parameterType = ResultStream::class;
$parameterType = 'ResultStream';
$memberClassNames = [];
$classBuilder->addUse(ResultStream::class);
$nullable = false;
}

Expand All @@ -160,6 +161,9 @@ private function generateProperties(StructureShape $shape, ClassBuilder $classBu
$method->addComment('@return ' . $parameterType . ($nullable ? '|null' : ''));
}
$method->setReturnNullable($nullable);
if ($parameterType) {
$property->addComment('@var ' . $parameterType . ($nullable ? '|null' : ''));
}
}

if ($forEndpoint) {
Expand Down
3 changes: 3 additions & 0 deletions src/CodeGenerator/src/Generator/ObjectGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,9 @@ private function addProperties(StructureShape $shape, ClassBuilder $classBuilder
$method->addComment('@return ' . $parameterType . ($getterSetterNullable ? '|null' : ''));
}
$method->setReturnNullable($getterSetterNullable);
if ($parameterType) {
$property->addComment('@var ' . $parameterType . ($nullable ? '|null' : ''));
}
}

foreach ($forEndpointProps as $key => $ok) {
Expand Down
8 changes: 8 additions & 0 deletions src/Core/src/Sts/Result/AssumeRoleResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class AssumeRoleResponse extends Result
*
* > The size of the security token that STS API operations return is not fixed. We strongly recommend that you make no
* > assumptions about the maximum size.
*
* @var Credentials|null
*/
private $credentials;

Expand All @@ -27,13 +29,17 @@ class AssumeRoleResponse extends Result
* resulting temporary security credentials. For example, you can reference these credentials as a principal in a
* resource-based policy by using the ARN or assumed role ID. The ARN and ID include the `RoleSessionName` that you
* specified when you called `AssumeRole`.
*
* @var AssumedRoleUser|null
*/
private $assumedRoleUser;

/**
* A percentage value that indicates the packed size of the session policies and session tags combined passed in the
* request. The request fails if the packed size is greater than 100 percent, which means the policies and tags exceeded
* the allowed space.
*
* @var int|null
*/
private $packedPolicySize;

Expand All @@ -50,6 +56,8 @@ class AssumeRoleResponse extends Result
* characters with no spaces. You can also include underscores or any of the following characters: =,.@-
*
* [^1]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_control-access_monitor.html
*
* @var string|null
*/
private $sourceIdentity;

Expand Down
14 changes: 14 additions & 0 deletions src/Core/src/Sts/Result/AssumeRoleWithWebIdentityResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class AssumeRoleWithWebIdentityResponse extends Result
*
* > The size of the security token that STS API operations return is not fixed. We strongly recommend that you make no
* > assumptions about the maximum size.
*
* @var Credentials|null
*/
private $credentials;

Expand All @@ -26,6 +28,8 @@ class AssumeRoleWithWebIdentityResponse extends Result
* `WebIdentityToken` that was submitted with the `AssumeRoleWithWebIdentity` call. The identifier is typically unique
* to the user and the application that acquired the `WebIdentityToken` (pairwise identifier). For OpenID Connect ID
* tokens, this field contains the value returned by the identity provider as the token's `sub` (Subject) claim.
*
* @var string|null
*/
private $subjectFromWebIdentityToken;

Expand All @@ -34,26 +38,34 @@ class AssumeRoleWithWebIdentityResponse extends Result
* resulting temporary security credentials. For example, you can reference these credentials as a principal in a
* resource-based policy by using the ARN or assumed role ID. The ARN and ID include the `RoleSessionName` that you
* specified when you called `AssumeRole`.
*
* @var AssumedRoleUser|null
*/
private $assumedRoleUser;

/**
* A percentage value that indicates the packed size of the session policies and session tags combined passed in the
* request. The request fails if the packed size is greater than 100 percent, which means the policies and tags exceeded
* the allowed space.
*
* @var int|null
*/
private $packedPolicySize;

/**
* The issuing authority of the web identity token presented. For OpenID Connect ID tokens, this contains the value of
* the `iss` field. For OAuth 2.0 access tokens, this contains the value of the `ProviderId` parameter that was passed
* in the `AssumeRoleWithWebIdentity` request.
*
* @var string|null
*/
private $provider;

/**
* The intended audience (also known as client ID) of the web identity token. This is traditionally the client
* identifier issued to the application that requested the web identity token.
*
* @var string|null
*/
private $audience;

Expand All @@ -76,6 +88,8 @@ class AssumeRoleWithWebIdentityResponse extends Result
* [^1]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts#iam-term-role-chaining
* [^2]: https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-using-tokens-with-identity-providers.html
* [^3]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_control-access_monitor.html
*
* @var string|null
*/
private $sourceIdentity;

Expand Down
6 changes: 6 additions & 0 deletions src/Core/src/Sts/Result/GetCallerIdentityResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,22 @@ class GetCallerIdentityResponse extends Result
* Variables** reference page in the *IAM User Guide*.
*
* [^1]: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_variables.html#principaltable
*
* @var string|null
*/
private $userId;

/**
* The Amazon Web Services account ID number of the account that owns or contains the calling entity.
*
* @var string|null
*/
private $account;

/**
* The Amazon Web Services ARN associated with the calling entity.
*
* @var string|null
*/
private $arn;

Expand Down
4 changes: 4 additions & 0 deletions src/Core/src/Sts/ValueObject/AssumedRoleUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ final class AssumedRoleUser
/**
* A unique identifier that contains the role ID and the role session name of the role that is being assumed. The role
* ID is generated by Amazon Web Services when the role is created.
*
* @var string
*/
private $assumedRoleId;

Expand All @@ -20,6 +22,8 @@ final class AssumedRoleUser
* about ARNs and how to use them in policies, see IAM Identifiers [^1] in the *IAM User Guide*.
*
* [^1]: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html
*
* @var string
*/
private $arn;

Expand Down
8 changes: 8 additions & 0 deletions src/Core/src/Sts/ValueObject/Credentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,29 @@ final class Credentials
{
/**
* The access key ID that identifies the temporary security credentials.
*
* @var string
*/
private $accessKeyId;

/**
* The secret access key that can be used to sign requests.
*
* @var string
*/
private $secretAccessKey;

/**
* The token that users must pass to the service API to use the temporary credentials.
*
* @var string
*/
private $sessionToken;

/**
* The date on which the current credentials expire.
*
* @var \DateTimeImmutable
*/
private $expiration;

Expand Down
2 changes: 2 additions & 0 deletions src/Core/src/Sts/ValueObject/PolicyDescriptorType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ final class PolicyDescriptorType
* *Amazon Web Services General Reference*.
*
* [^1]: https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html
*
* @var string|null
*/
private $arn;

Expand Down
4 changes: 4 additions & 0 deletions src/Core/src/Sts/ValueObject/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ final class Tag
* additional limits, see IAM and STS Character Limits [^1] in the *IAM User Guide*.
*
* [^1]: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-limits.html#reference_iam-limits-entity-length
*
* @var string
*/
private $key;

Expand All @@ -30,6 +32,8 @@ final class Tag
* additional limits, see IAM and STS Character Limits [^1] in the *IAM User Guide*.
*
* [^1]: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-limits.html#reference_iam-limits-entity-length
*
* @var string
*/
private $value;

Expand Down
6 changes: 6 additions & 0 deletions src/Service/AppSync/src/Exception/BadRequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@
*/
final class BadRequestException extends ClientException
{
/**
* @var BadRequestReason::*|null
*/
private $reason;

/**
* @var BadRequestDetail|null
*/
private $detail;

public function getDetail(): ?BadRequestDetail
Expand Down
2 changes: 2 additions & 0 deletions src/Service/AppSync/src/Result/CreateResolverResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class CreateResolverResponse extends Result
{
/**
* The `Resolver` object.
*
* @var Resolver|null
*/
private $resolver;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ class GetSchemaCreationStatusResponse extends Result
/**
* The current state of the schema (PROCESSING, FAILED, SUCCESS, or NOT_APPLICABLE). When the schema is in the ACTIVE
* state, you can add data.
*
* @var SchemaStatus::*|null
*/
private $status;

/**
* Detailed information about the status of the schema creation operation.
*
* @var string|null
*/
private $details;

Expand Down
4 changes: 4 additions & 0 deletions src/Service/AppSync/src/Result/ListApiKeysResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ class ListApiKeysResponse extends Result
{
/**
* The `ApiKey` objects.
*
* @var ApiKey[]
*/
private $apiKeys;

/**
* An identifier to pass in the next request to this operation to return the next set of items in the list.
*
* @var string|null
*/
private $nextToken;

Expand Down
4 changes: 4 additions & 0 deletions src/Service/AppSync/src/Result/ListResolversResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ class ListResolversResponse extends Result
{
/**
* The `Resolver` objects.
*
* @var Resolver[]
*/
private $resolvers;

/**
* An identifier to pass in the next request to this operation to return the next set of items in the list.
*
* @var string|null
*/
private $nextToken;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class StartSchemaCreationResponse extends Result
/**
* The current state of the schema (PROCESSING, FAILED, SUCCESS, or NOT_APPLICABLE). When the schema is in the ACTIVE
* state, you can add data.
*
* @var SchemaStatus::*|null
*/
private $status;

Expand Down
2 changes: 2 additions & 0 deletions src/Service/AppSync/src/Result/UpdateApiKeyResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class UpdateApiKeyResponse extends Result
{
/**
* The API key.
*
* @var ApiKey|null
*/
private $apiKey;

Expand Down
2 changes: 2 additions & 0 deletions src/Service/AppSync/src/Result/UpdateDataSourceResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class UpdateDataSourceResponse extends Result
{
/**
* The updated `DataSource` object.
*
* @var DataSource|null
*/
private $dataSource;

Expand Down
2 changes: 2 additions & 0 deletions src/Service/AppSync/src/Result/UpdateResolverResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class UpdateResolverResponse extends Result
{
/**
* The updated `Resolver` object.
*
* @var Resolver|null
*/
private $resolver;

Expand Down
8 changes: 8 additions & 0 deletions src/Service/AppSync/src/ValueObject/ApiKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,31 @@ final class ApiKey
{
/**
* The API key ID.
*
* @var string|null
*/
private $id;

/**
* A description of the purpose of the API key.
*
* @var string|null
*/
private $description;

/**
* The time after which the API key expires. The date is represented as seconds since the epoch, rounded down to the
* nearest hour.
*
* @var int|null
*/
private $expires;

/**
* The time after which the API key is deleted. The date is represented as seconds since the epoch, rounded down to the
* nearest hour.
*
* @var int|null
*/
private $deletes;

Expand Down
Loading