Skip to content
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
  •  
  •  
  •  
248 changes: 0 additions & 248 deletions psalm.baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,238 +54,6 @@
<code><![CDATA[scalarNode]]></code>
</UndefinedInterfaceMethod>
</file>
<file src="src/Service/CloudFormation/src/Result/DescribeStacksOutput.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<Capability::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/CloudWatchLogs/src/Result/DescribeLogGroupsResponse.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<InheritedProperty::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/CodeBuild/src/Result/BatchGetBuildsOutput.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<CacheMode::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/CodeBuild/src/Result/StartBuildOutput.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<CacheMode::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/CodeBuild/src/Result/StopBuildOutput.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<CacheMode::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/CodeDeploy/src/Result/GetDeploymentOutput.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<AutoRollbackEvent::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/CognitoIdentityProvider/src/Result/AdminInitiateAuthResponse.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<ChallengeNameType::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/CognitoIdentityProvider/src/Result/InitiateAuthResponse.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<ChallengeNameType::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/Kinesis/src/Result/DescribeStreamOutput.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<MetricsName::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/Kinesis/src/Result/DescribeStreamSummaryOutput.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<MetricsName::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/Kinesis/src/Result/EnhancedMonitoringOutput.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<MetricsName::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/Kms/src/Result/CreateKeyResponse.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
<code><![CDATA[$items]]></code>
<code><![CDATA[$items]]></code>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<EncryptionAlgorithmSpec::*>]]></code>
<code><![CDATA[list<KeyAgreementAlgorithmSpec::*>]]></code>
<code><![CDATA[list<MacAlgorithmSpec::*>]]></code>
<code><![CDATA[list<SigningAlgorithmSpec::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/Kms/src/Result/GetPublicKeyResponse.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
<code><![CDATA[$items]]></code>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<EncryptionAlgorithmSpec::*>]]></code>
<code><![CDATA[list<KeyAgreementAlgorithmSpec::*>]]></code>
<code><![CDATA[list<SigningAlgorithmSpec::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/Lambda/src/Result/FunctionConfiguration.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<Architecture::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/Lambda/src/Result/ListFunctionsResponse.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<Architecture::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/Lambda/src/Result/ListLayerVersionsResponse.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<Architecture::*>]]></code>
<code><![CDATA[list<Runtime::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/Lambda/src/Result/ListVersionsByFunctionResponse.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<Architecture::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/Lambda/src/Result/PublishLayerVersionResponse.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<Architecture::*>]]></code>
<code><![CDATA[list<Runtime::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/MediaConvert/src/Result/CreateJobResponse.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
<code><![CDATA[$items]]></code>
<code><![CDATA[$items]]></code>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<AudioChannelTag::*>]]></code>
<code><![CDATA[list<FrameMetricType::*>]]></code>
<code><![CDATA[list<HlsAdMarkers::*>]]></code>
<code><![CDATA[list<TeletextPageType::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/MediaConvert/src/Result/GetJobResponse.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
<code><![CDATA[$items]]></code>
<code><![CDATA[$items]]></code>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<AudioChannelTag::*>]]></code>
<code><![CDATA[list<FrameMetricType::*>]]></code>
<code><![CDATA[list<HlsAdMarkers::*>]]></code>
<code><![CDATA[list<TeletextPageType::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/MediaConvert/src/Result/ListJobsResponse.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
<code><![CDATA[$items]]></code>
<code><![CDATA[$items]]></code>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<AudioChannelTag::*>]]></code>
<code><![CDATA[list<FrameMetricType::*>]]></code>
<code><![CDATA[list<HlsAdMarkers::*>]]></code>
<code><![CDATA[list<TeletextPageType::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/Rekognition/src/Result/IndexFacesResponse.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<Reason::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/S3/src/Result/GetBucketEncryptionOutput.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<EncryptionType::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/S3/src/Result/ListObjectVersionsOutput.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<ChecksumAlgorithm::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/S3/src/Result/ListObjectsV2Output.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<ChecksumAlgorithm::*>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/S3/src/Signer/SignerV4ForS3.php">
<InvalidArgument>
<code><![CDATA[array_keys($s3SignerOptions)]]></code>
Expand All @@ -294,22 +62,6 @@
<code><![CDATA[$s3SignerOptions]]></code>
</NoValue>
</file>
<file src="src/Service/Sqs/src/Result/GetQueueAttributesResult.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[array<QueueAttributeName::*, string>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/Sqs/src/Result/ReceiveMessageResult.php">
<LessSpecificReturnStatement>
<code><![CDATA[$items]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[array<MessageSystemAttributeName::*, string>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Service/StepFunctions/src/Result/StartExecutionOutput.php">
<PossiblyFalsePropertyAssignmentValue>
<code><![CDATA[$d = \DateTimeImmutable::createFromFormat('U.u', \sprintf('%.6F', $data['startDate']))]]></code>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ class PopulatorGenerator
*/
private $parserProvider;

public function __construct(ClassRegistry $classRegistry, NamespaceRegistry $namespaceRegistry, RequirementsRegistry $requirementsRegistry, ObjectGenerator $objectGenerator, ?TypeGenerator $typeGenerator = null, ?EnumGenerator $enumGenerator = null, ?ParserProvider $parserProvider = null)
public function __construct(ClassRegistry $classRegistry, NamespaceRegistry $namespaceRegistry, RequirementsRegistry $requirementsRegistry, ObjectGenerator $objectGenerator, array $managedMethods, ?TypeGenerator $typeGenerator = null, ?EnumGenerator $enumGenerator = null, ?ParserProvider $parserProvider = null)
{
$this->objectGenerator = $objectGenerator;
$this->requirementsRegistry = $requirementsRegistry;
$this->typeGenerator = $typeGenerator ?? new TypeGenerator($namespaceRegistry);
$this->enumGenerator = $enumGenerator ?? new EnumGenerator($classRegistry, $namespaceRegistry);
$this->enumGenerator = $enumGenerator ?? new EnumGenerator($classRegistry, $namespaceRegistry, $managedMethods);
$this->parserProvider = $parserProvider ?? new ParserProvider($namespaceRegistry, $requirementsRegistry, $this->typeGenerator);
}

Expand Down Expand Up @@ -279,7 +279,7 @@ private function generatePopulator(Operation $operation, StructureShape $shape,
foreach ($parserResult->getUsedClasses() as $className) {
$classBuilder->addUse($className->getFqdn());
}
$classBuilder->setMethods($parserResult->getExtraMethods());
$classBuilder->addMethods($parserResult->getExtraMethods());
}
if (empty(trim($body))) {
return;
Expand Down
69 changes: 68 additions & 1 deletion src/CodeGenerator/src/Generator/EnumGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

namespace AsyncAws\CodeGenerator\Generator;

use AsyncAws\CodeGenerator\Definition\ListShape;
use AsyncAws\CodeGenerator\Definition\MapShape;
use AsyncAws\CodeGenerator\Definition\Shape;
use AsyncAws\CodeGenerator\Definition\StructureShape;
use AsyncAws\CodeGenerator\Generator\Naming\ClassName;
use AsyncAws\CodeGenerator\Generator\Naming\NamespaceRegistry;
use AsyncAws\CodeGenerator\Generator\PhpGenerator\ClassRegistry;
Expand All @@ -19,6 +22,8 @@
*/
class EnumGenerator
{
public const UNKNOWN_VALUE = 'UNKNOWN_TO_SDK';

/**
* @var ClassRegistry
*/
Expand All @@ -34,10 +39,21 @@ class EnumGenerator
*/
private $generated = [];

public function __construct(ClassRegistry $classRegistry, NamespaceRegistry $namespaceRegistry)
/**
* @var list<string>
*/
private $managedMethods;

/**
* @var array<string, bool>|null
*/
private $usedShapedOutput;

public function __construct(ClassRegistry $classRegistry, NamespaceRegistry $namespaceRegistry, array $managedMethods)
{
$this->classRegistry = $classRegistry;
$this->namespaceRegistry = $namespaceRegistry;
$this->managedMethods = $managedMethods;
}

/**
Expand All @@ -63,13 +79,19 @@ public function generate(Shape $shape): ClassName
}
ksort($consts);
$availableConsts = [];

foreach ($consts as $constName => $constValue) {
$classBuilder->addConstant($constName, $constValue)->setVisibility(Visibility::Public);
$availableConsts[] = 'self::' . $constName . ' => true';
}

if ($this->isShapeUsedOutput($shape)) {
$classBuilder->addConstant(self::UNKNOWN_VALUE, self::UNKNOWN_VALUE)->setVisibility(Visibility::Public);
}
$classBuilder->addMethod('exists')
->setStatic(true)
->setReturnType('bool')
->setComment('@psalm-assert-if-true self::* $value')
->setBody('
return isset([
' . implode(",\n", $availableConsts) . '
Expand Down Expand Up @@ -103,4 +125,49 @@ public static function canonicalizeName(string $name): string

return $name;
}

private function isShapeUsedOutput(Shape $shape): bool
{
if (null === $this->usedShapedOutput) {
$service = $shape->getService();
$walk = function (?Shape $shape) use (&$walk) {
if (null === $shape) {
return;
}
if (isset($this->usedShapedOutput[$shape->getName()])) {
// Node already visited
return;
}

$this->usedShapedOutput[$shape->getName()] = true;
if ($shape instanceof StructureShape) {
foreach ($shape->getMembers() as $member) {
$walk($member->getShape());
}
} elseif ($shape instanceof ListShape) {
$walk($shape->getMember()->getShape());
} elseif ($shape instanceof MapShape) {
$walk($shape->getKey()->getShape());
$walk($shape->getValue()->getShape());
}
};

foreach ($this->managedMethods as $method) {
if (null !== $operation = $service->getOperation($method)) {
$walk($operation->getOutput());
foreach ($operation->getErrors() as $error) {
$walk($error);
}
}
if (null !== $waiter = $service->getWaiter($method)) {
$walk($waiter->getOperation()->getOutput());
foreach ($waiter->getOperation()->getErrors() as $error) {
$walk($error);
}
}
}
}

return $this->usedShapedOutput[$shape->getName()] ?? false;
}
}
Loading