Skip to content

Commit

Permalink
Fix the generated param types for maps and lists (#1466)
Browse files Browse the repository at this point in the history
The constructor are not enforcing the usage of value objects. They also
support passing an array accepted by the create method.
  • Loading branch information
stof authored Jun 26, 2023
1 parent 22c9b08 commit 77ebc34
Show file tree
Hide file tree
Showing 178 changed files with 551 additions and 551 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ public function generateDocblock(StructureShape $shape, ClassName $shapeClassNam
// is the list item an object?
if ($listMemberShape instanceof StructureShape) {
$classNames[] = $className = $this->namespaceRegistry->getObject($listMemberShape);
$param = $className->getName() . '[]';
$param = 'array<' . $className->getName() . '|array>';
} elseif (!empty($listMemberShape->getEnum())) {
$classNames[] = $className = $this->namespaceRegistry->getEnum($listMemberShape);
$param = 'list<' . $className->getName() . '::*>';
$param = 'array<' . $className->getName() . '::*>';
} else {
$param = $this->getNativePhpType($listMemberShape->getType()) . '[]';
}
Expand All @@ -74,7 +74,7 @@ public function generateDocblock(StructureShape $shape, ClassName $shapeClassNam
// is the map item an object?
if ($mapValueShape instanceof StructureShape) {
$classNames[] = $className = $this->namespaceRegistry->getObject($mapValueShape);
$param = $className->getName();
$param = $className->getName() . '|array';
} elseif (!empty($mapValueShape->getEnum())) {
$classNames[] = $className = $this->namespaceRegistry->getEnum($mapValueShape);
$param = $className->getName() . '::*';
Expand Down
8 changes: 4 additions & 4 deletions src/Core/src/Sts/Input/AssumeRoleRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ final class AssumeRoleRequest extends Input
* @param array{
* RoleArn?: string,
* RoleSessionName?: string,
* PolicyArns?: PolicyDescriptorType[],
* PolicyArns?: array<PolicyDescriptorType|array>,
* Policy?: string,
* DurationSeconds?: int,
* Tags?: Tag[],
* Tags?: array<Tag|array>,
* TransitiveTagKeys?: string[],
* ExternalId?: string,
* SerialNumber?: string,
Expand Down Expand Up @@ -264,10 +264,10 @@ public function __construct(array $input = [])
* @param array{
* RoleArn?: string,
* RoleSessionName?: string,
* PolicyArns?: PolicyDescriptorType[],
* PolicyArns?: array<PolicyDescriptorType|array>,
* Policy?: string,
* DurationSeconds?: int,
* Tags?: Tag[],
* Tags?: array<Tag|array>,
* TransitiveTagKeys?: string[],
* ExternalId?: string,
* SerialNumber?: string,
Expand Down
4 changes: 2 additions & 2 deletions src/Core/src/Sts/Input/AssumeRoleWithWebIdentityRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ final class AssumeRoleWithWebIdentityRequest extends Input
* RoleSessionName?: string,
* WebIdentityToken?: string,
* ProviderId?: string,
* PolicyArns?: PolicyDescriptorType[],
* PolicyArns?: array<PolicyDescriptorType|array>,
* Policy?: string,
* DurationSeconds?: int,
* '@region'?: string|null,
Expand All @@ -159,7 +159,7 @@ public function __construct(array $input = [])
* RoleSessionName?: string,
* WebIdentityToken?: string,
* ProviderId?: string,
* PolicyArns?: PolicyDescriptorType[],
* PolicyArns?: array<PolicyDescriptorType|array>,
* Policy?: string,
* DurationSeconds?: int,
* '@region'?: string|null,
Expand Down
6 changes: 3 additions & 3 deletions src/Core/src/Sts/StsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ class StsClient extends AbstractApi
* @param array{
* RoleArn: string,
* RoleSessionName: string,
* PolicyArns?: PolicyDescriptorType[],
* PolicyArns?: array<PolicyDescriptorType|array>,
* Policy?: string,
* DurationSeconds?: int,
* Tags?: Tag[],
* Tags?: array<Tag|array>,
* TransitiveTagKeys?: string[],
* ExternalId?: string,
* SerialNumber?: string,
Expand Down Expand Up @@ -273,7 +273,7 @@ public function assumeRole($input): AssumeRoleResponse
* RoleSessionName: string,
* WebIdentityToken: string,
* ProviderId?: string,
* PolicyArns?: PolicyDescriptorType[],
* PolicyArns?: array<PolicyDescriptorType|array>,
* Policy?: string,
* DurationSeconds?: int,
* '@region'?: string|null,
Expand Down
4 changes: 2 additions & 2 deletions src/Service/AppSync/src/ValueObject/BadRequestDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class BadRequestDetail

/**
* @param array{
* codeErrors?: null|CodeError[],
* codeErrors?: null|array<CodeError|array>,
* } $input
*/
public function __construct(array $input)
Expand All @@ -25,7 +25,7 @@ public function __construct(array $input)

/**
* @param array{
* codeErrors?: null|CodeError[],
* codeErrors?: null|array<CodeError|array>,
* }|BadRequestDetail $input
*/
public static function create($input): self
Expand Down
4 changes: 2 additions & 2 deletions src/Service/Athena/src/ValueObject/ResultSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class ResultSet

/**
* @param array{
* Rows?: null|Row[],
* Rows?: null|array<Row|array>,
* ResultSetMetadata?: null|ResultSetMetadata|array,
* } $input
*/
Expand All @@ -32,7 +32,7 @@ public function __construct(array $input)

/**
* @param array{
* Rows?: null|Row[],
* Rows?: null|array<Row|array>,
* ResultSetMetadata?: null|ResultSetMetadata|array,
* }|ResultSet $input
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Service/Athena/src/ValueObject/ResultSetMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class ResultSetMetadata

/**
* @param array{
* ColumnInfo?: null|ColumnInfo[],
* ColumnInfo?: null|array<ColumnInfo|array>,
* } $input
*/
public function __construct(array $input)
Expand All @@ -25,7 +25,7 @@ public function __construct(array $input)

/**
* @param array{
* ColumnInfo?: null|ColumnInfo[],
* ColumnInfo?: null|array<ColumnInfo|array>,
* }|ResultSetMetadata $input
*/
public static function create($input): self
Expand Down
4 changes: 2 additions & 2 deletions src/Service/Athena/src/ValueObject/Row.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class Row

/**
* @param array{
* Data?: null|Datum[],
* Data?: null|array<Datum|array>,
* } $input
*/
public function __construct(array $input)
Expand All @@ -24,7 +24,7 @@ public function __construct(array $input)

/**
* @param array{
* Data?: null|Datum[],
* Data?: null|array<Datum|array>,
* }|Row $input
*/
public static function create($input): self
Expand Down
8 changes: 4 additions & 4 deletions src/Service/Athena/src/ValueObject/TableMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ final class TableMetadata
* CreateTime?: null|\DateTimeImmutable,
* LastAccessTime?: null|\DateTimeImmutable,
* TableType?: null|string,
* Columns?: null|Column[],
* PartitionKeys?: null|Column[],
* Columns?: null|array<Column|array>,
* PartitionKeys?: null|array<Column|array>,
* Parameters?: null|array<string, string>,
* } $input
*/
Expand All @@ -70,8 +70,8 @@ public function __construct(array $input)
* CreateTime?: null|\DateTimeImmutable,
* LastAccessTime?: null|\DateTimeImmutable,
* TableType?: null|string,
* Columns?: null|Column[],
* PartitionKeys?: null|Column[],
* Columns?: null|array<Column|array>,
* PartitionKeys?: null|array<Column|array>,
* Parameters?: null|array<string, string>,
* }|TableMetadata $input
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ final class RollbackConfiguration

/**
* @param array{
* RollbackTriggers?: null|RollbackTrigger[],
* RollbackTriggers?: null|array<RollbackTrigger|array>,
* MonitoringTimeInMinutes?: null|int,
* } $input
*/
Expand All @@ -64,7 +64,7 @@ public function __construct(array $input)

/**
* @param array{
* RollbackTriggers?: null|RollbackTrigger[],
* RollbackTriggers?: null|array<RollbackTrigger|array>,
* MonitoringTimeInMinutes?: null|int,
* }|RollbackConfiguration $input
*/
Expand Down
16 changes: 8 additions & 8 deletions src/Service/CloudFormation/src/ValueObject/Stack.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ final class Stack
* StackName: string,
* ChangeSetId?: null|string,
* Description?: null|string,
* Parameters?: null|Parameter[],
* Parameters?: null|array<Parameter|array>,
* CreationTime: \DateTimeImmutable,
* DeletionTime?: null|\DateTimeImmutable,
* LastUpdatedTime?: null|\DateTimeImmutable,
Expand All @@ -161,10 +161,10 @@ final class Stack
* DisableRollback?: null|bool,
* NotificationARNs?: null|string[],
* TimeoutInMinutes?: null|int,
* Capabilities?: null|list<Capability::*>,
* Outputs?: null|Output[],
* Capabilities?: null|array<Capability::*>,
* Outputs?: null|array<Output|array>,
* RoleARN?: null|string,
* Tags?: null|Tag[],
* Tags?: null|array<Tag|array>,
* EnableTerminationProtection?: null|bool,
* ParentId?: null|string,
* RootId?: null|string,
Expand Down Expand Up @@ -203,7 +203,7 @@ public function __construct(array $input)
* StackName: string,
* ChangeSetId?: null|string,
* Description?: null|string,
* Parameters?: null|Parameter[],
* Parameters?: null|array<Parameter|array>,
* CreationTime: \DateTimeImmutable,
* DeletionTime?: null|\DateTimeImmutable,
* LastUpdatedTime?: null|\DateTimeImmutable,
Expand All @@ -213,10 +213,10 @@ public function __construct(array $input)
* DisableRollback?: null|bool,
* NotificationARNs?: null|string[],
* TimeoutInMinutes?: null|int,
* Capabilities?: null|list<Capability::*>,
* Outputs?: null|Output[],
* Capabilities?: null|array<Capability::*>,
* Outputs?: null|array<Output|array>,
* RoleARN?: null|string,
* Tags?: null|Tag[],
* Tags?: null|array<Tag|array>,
* EnableTerminationProtection?: null|bool,
* ParentId?: null|string,
* RootId?: null|string,
Expand Down
10 changes: 5 additions & 5 deletions src/Service/CloudWatch/src/CloudWatchClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class CloudWatchClient extends AbstractApi
* @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-monitoring-2010-08-01.html#getmetricdata
*
* @param array{
* MetricDataQueries: MetricDataQuery[],
* MetricDataQueries: array<MetricDataQuery|array>,
* StartTime: \DateTimeImmutable|string,
* EndTime: \DateTimeImmutable|string,
* NextToken?: string,
Expand Down Expand Up @@ -154,11 +154,11 @@ public function getMetricData($input): GetMetricDataOutput
* @param array{
* Namespace: string,
* MetricName: string,
* Dimensions?: Dimension[],
* Dimensions?: array<Dimension|array>,
* StartTime: \DateTimeImmutable|string,
* EndTime: \DateTimeImmutable|string,
* Period: int,
* Statistics?: list<Statistic::*>,
* Statistics?: array<Statistic::*>,
* ExtendedStatistics?: string[],
* Unit?: StandardUnit::*,
* '@region'?: string|null,
Expand Down Expand Up @@ -212,7 +212,7 @@ public function getMetricStatistics($input): GetMetricStatisticsOutput
* @param array{
* Namespace?: string,
* MetricName?: string,
* Dimensions?: DimensionFilter[],
* Dimensions?: array<DimensionFilter|array>,
* NextToken?: string,
* RecentlyActive?: RecentlyActive::*,
* IncludeLinkedAccounts?: bool,
Expand Down Expand Up @@ -281,7 +281,7 @@ public function listMetrics($input = []): ListMetricsOutput
*
* @param array{
* Namespace: string,
* MetricData: MetricDatum[],
* MetricData: array<MetricDatum|array>,
* '@region'?: string|null,
* }|PutMetricDataInput $input
*
Expand Down
4 changes: 2 additions & 2 deletions src/Service/CloudWatch/src/Input/GetMetricDataInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ final class GetMetricDataInput extends Input

/**
* @param array{
* MetricDataQueries?: MetricDataQuery[],
* MetricDataQueries?: array<MetricDataQuery|array>,
* StartTime?: \DateTimeImmutable|string,
* EndTime?: \DateTimeImmutable|string,
* NextToken?: string,
Expand All @@ -128,7 +128,7 @@ public function __construct(array $input = [])

/**
* @param array{
* MetricDataQueries?: MetricDataQuery[],
* MetricDataQueries?: array<MetricDataQuery|array>,
* StartTime?: \DateTimeImmutable|string,
* EndTime?: \DateTimeImmutable|string,
* NextToken?: string,
Expand Down
8 changes: 4 additions & 4 deletions src/Service/CloudWatch/src/Input/GetMetricStatisticsInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ final class GetMetricStatisticsInput extends Input
* @param array{
* Namespace?: string,
* MetricName?: string,
* Dimensions?: Dimension[],
* Dimensions?: array<Dimension|array>,
* StartTime?: \DateTimeImmutable|string,
* EndTime?: \DateTimeImmutable|string,
* Period?: int,
* Statistics?: list<Statistic::*>,
* Statistics?: array<Statistic::*>,
* ExtendedStatistics?: string[],
* Unit?: StandardUnit::*,
* '@region'?: string|null,
Expand All @@ -162,11 +162,11 @@ public function __construct(array $input = [])
* @param array{
* Namespace?: string,
* MetricName?: string,
* Dimensions?: Dimension[],
* Dimensions?: array<Dimension|array>,
* StartTime?: \DateTimeImmutable|string,
* EndTime?: \DateTimeImmutable|string,
* Period?: int,
* Statistics?: list<Statistic::*>,
* Statistics?: array<Statistic::*>,
* ExtendedStatistics?: string[],
* Unit?: StandardUnit::*,
* '@region'?: string|null,
Expand Down
4 changes: 2 additions & 2 deletions src/Service/CloudWatch/src/Input/ListMetricsInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ final class ListMetricsInput extends Input
* @param array{
* Namespace?: string,
* MetricName?: string,
* Dimensions?: DimensionFilter[],
* Dimensions?: array<DimensionFilter|array>,
* NextToken?: string,
* RecentlyActive?: RecentlyActive::*,
* IncludeLinkedAccounts?: bool,
Expand All @@ -97,7 +97,7 @@ public function __construct(array $input = [])
* @param array{
* Namespace?: string,
* MetricName?: string,
* Dimensions?: DimensionFilter[],
* Dimensions?: array<DimensionFilter|array>,
* NextToken?: string,
* RecentlyActive?: RecentlyActive::*,
* IncludeLinkedAccounts?: bool,
Expand Down
4 changes: 2 additions & 2 deletions src/Service/CloudWatch/src/Input/PutMetricDataInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class PutMetricDataInput extends Input
/**
* @param array{
* Namespace?: string,
* MetricData?: MetricDatum[],
* MetricData?: array<MetricDatum|array>,
* '@region'?: string|null,
* } $input
*/
Expand All @@ -49,7 +49,7 @@ public function __construct(array $input = [])
/**
* @param array{
* Namespace?: string,
* MetricData?: MetricDatum[],
* MetricData?: array<MetricDatum|array>,
* '@region'?: string|null,
* }|PutMetricDataInput $input
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Service/CloudWatch/src/ValueObject/Metric.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class Metric
* @param array{
* Namespace?: null|string,
* MetricName?: null|string,
* Dimensions?: null|Dimension[],
* Dimensions?: null|array<Dimension|array>,
* } $input
*/
public function __construct(array $input)
Expand All @@ -40,7 +40,7 @@ public function __construct(array $input)
* @param array{
* Namespace?: null|string,
* MetricName?: null|string,
* Dimensions?: null|Dimension[],
* Dimensions?: null|array<Dimension|array>,
* }|Metric $input
*/
public static function create($input): self
Expand Down
Loading

0 comments on commit 77ebc34

Please sign in to comment.