diff --git a/src/CodeGenerator/src/Generator/PaginationGenerator.php b/src/CodeGenerator/src/Generator/PaginationGenerator.php index f89faad3f..90a63e5a1 100644 --- a/src/CodeGenerator/src/Generator/PaginationGenerator.php +++ b/src/CodeGenerator/src/Generator/PaginationGenerator.php @@ -207,7 +207,9 @@ private function generateOutputPaginationLoader(string $iterator, string $common if (!$moreResult) { $moreCondition = ''; foreach ($outputToken as $property) { - $moreCondition .= $this->generateGetter('$page', $property, (bool) $common); + $moreCondition .= 'null !== ' . $this->generateGetter('$page', $property, (bool) $common); + + break; } } else { $moreCondition = $this->generateGetter('$page', $moreResult, (bool) $common); diff --git a/src/CodeGenerator/src/Generator/ResponseParser/RestXmlParser.php b/src/CodeGenerator/src/Generator/ResponseParser/RestXmlParser.php index 0ec320257..0913abe9e 100644 --- a/src/CodeGenerator/src/Generator/ResponseParser/RestXmlParser.php +++ b/src/CodeGenerator/src/Generator/ResponseParser/RestXmlParser.php @@ -50,6 +50,11 @@ class RestXmlParser implements Parser */ private $imports = []; + /** + * @var array + */ + private $generatedFunctions = []; + public function __construct(NamespaceRegistry $namespaceRegistry, RequirementsRegistry $requirementsRegistry, TypeGenerator $typeGenerator) { $this->namespaceRegistry = $namespaceRegistry; @@ -61,6 +66,7 @@ public function generate(StructureShape $shape, bool $throwOnError = true): Pars { $properties = []; $this->functions = []; + $this->generatedFunctions = []; $this->imports = []; if (null !== $payload = $shape->getPayload()) { $member = $shape->getMember($payload); @@ -80,19 +86,10 @@ public function generate(StructureShape $shape, bool $throwOnError = true): Pars continue; } - if (!$member->isNullable() && !$member->isRequired()) { - $properties[] = strtr('if (null !== $v = (PROPERTY_ACCESSOR)) { - $this->PROPERTY_NAME = $v; - }', [ - 'PROPERTY_NAME' => GeneratorHelper::normalizeName($member->getName()), - 'PROPERTY_ACCESSOR' => $this->parseXmlElement($this->getInputAccessor('$data', $member), $member->getShape(), $member->isRequired(), false), - ]); - } else { - $properties[] = strtr('$this->PROPERTY_NAME = PROPERTY_ACCESSOR;', [ - 'PROPERTY_NAME' => GeneratorHelper::normalizeName($member->getName()), - 'PROPERTY_ACCESSOR' => $this->parseXmlElement($this->getInputAccessor('$data', $member), $member->getShape(), $member->isRequired(), false), - ]); - } + $properties[] = strtr('$this->PROPERTY_NAME = PROPERTY_ACCESSOR;', [ + 'PROPERTY_NAME' => GeneratorHelper::normalizeName($member->getName()), + 'PROPERTY_ACCESSOR' => $this->parseXmlElement($this->getInputAccessor('$data', $member), $member->getShape(), $member->isRequired(), false), + ]); } } @@ -204,20 +201,35 @@ private function parseXmlElement(string $input, Shape $shape, bool $required, bo private function parseXmlResponseStructure(StructureShape $shape, string $input, bool $required): string { - $properties = []; - foreach ($shape->getMembers() as $member) { - $properties[] = strtr('PROPERTY_NAME => PROPERTY_ACCESSOR,', [ - 'PROPERTY_NAME' => var_export($member->getName(), true), - 'PROPERTY_ACCESSOR' => $this->parseXmlElement($this->getInputAccessor($input, $member), $member->getShape(), $member->isRequired(), true), - ]); + $functionName = 'populateResult' . ucfirst($shape->getName()); + if (!isset($this->generatedFunctions[$functionName])) { + // prevent recursion + $this->generatedFunctions[$functionName] = true; + + $properties = []; + foreach ($shape->getMembers() as $member) { + $properties[] = strtr('PROPERTY_NAME => PROPERTY_ACCESSOR,', [ + 'PROPERTY_NAME' => var_export($member->getName(), true), + 'PROPERTY_ACCESSOR' => $this->parseXmlElement($this->getInputAccessor('$xml', $member), $member->getShape(), $member->isRequired(), true), + ]); + } + + $body = 'return new CLASS_NAME([ + PROPERTIES + ]);'; + + $className = $this->namespaceRegistry->getObject($shape); + $this->imports[] = $className; + + $this->functions[$functionName] = $this->createPopulateMethod($functionName, strtr($body, [ + 'CLASS_NAME' => $className->getName(), + 'PROPERTIES' => implode("\n", $properties), + ]), $shape); } - return strtr('REQUIRED new CLASS_NAME([ - PROPERTIES - ])', [ - 'REQUIRED' => $required ? '' : '!' . $input . ' ? null : ', - 'CLASS_NAME' => $this->namespaceRegistry->getObject($shape)->getName(), - 'PROPERTIES' => implode("\n", $properties), + return strtr($required ? '$this->FUNCTION_NAME(INPUT)' : '0 === INPUT->count() ? null : $this->FUNCTION_NAME(INPUT)', [ + 'INPUT' => $input, + 'FUNCTION_NAME' => $functionName, ]); } @@ -227,7 +239,7 @@ private function parseXmlResponseString(string $input, bool $required): string return strtr('(string) INPUT', ['INPUT' => $input]); } - return strtr('($v = INPUT) ? (string) $v : null', ['INPUT' => $input]); + return strtr('(null !== $v = INPUT[0]) ? (string) $v : null', ['INPUT' => $input]); } private function parseXmlResponseInteger(string $input, bool $required): string @@ -236,7 +248,7 @@ private function parseXmlResponseInteger(string $input, bool $required): string return strtr('(int) (string) INPUT', ['INPUT' => $input]); } - return strtr('($v = INPUT) ? (int) (string) $v : null', ['INPUT' => $input]); + return strtr('(null !== $v = INPUT[0]) ? (int) (string) $v : null', ['INPUT' => $input]); } private function parseXmlResponseFloat(string $input, bool $required): string @@ -245,7 +257,7 @@ private function parseXmlResponseFloat(string $input, bool $required): string return strtr('(float) (string) INPUT', ['INPUT' => $input]); } - return strtr('($v = INPUT) ? (float) (string) $v : null', ['INPUT' => $input]); + return strtr('(null !== $v = INPUT[0]) ? (float) (string) $v : null', ['INPUT' => $input]); } private function parseXmlResponseBool(string $input, bool $required): string @@ -256,7 +268,7 @@ private function parseXmlResponseBool(string $input, bool $required): string return strtr('filter_var((string) INPUT, FILTER_VALIDATE_BOOLEAN)', ['INPUT' => $input]); } - return strtr('($v = INPUT) ? filter_var((string) $v, FILTER_VALIDATE_BOOLEAN) : null', ['INPUT' => $input]); + return strtr('(null !== $v = INPUT[0]) ? filter_var((string) $v, FILTER_VALIDATE_BOOLEAN) : null', ['INPUT' => $input]); } private function parseXmlResponseBlob(string $input, bool $required): string @@ -265,7 +277,7 @@ private function parseXmlResponseBlob(string $input, bool $required): string return strtr('base64_decode((string) INPUT)', ['INPUT' => $input]); } - return strtr('($v = INPUT) ? base64_decode((string) $v) : null', ['INPUT' => $input]); + return strtr('(null !== $v = INPUT[0]) ? base64_decode((string) $v) : null', ['INPUT' => $input]); } private function parseXmlResponseTimestamp(Shape $shape, string $input, bool $required): string @@ -281,7 +293,7 @@ private function parseXmlResponseTimestamp(Shape $shape, string $input, bool $re } if (!$required) { - $body = '($v = INPUT) ? ' . strtr($body, ['INPUT' => '$v']) . ' : null'; + $body = '(null !== $v = INPUT[0]) ? ' . strtr($body, ['INPUT' => '$v']) . ' : null'; } return strtr($body, ['INPUT' => $input]); @@ -289,39 +301,44 @@ private function parseXmlResponseTimestamp(Shape $shape, string $input, bool $re private function parseXmlResponseList(ListShape $shape, string $input, bool $required, bool $inObject): string { - $shapeMember = $shape->getMember(); - if ($shapeMember->getShape() instanceof StructureShape) { - $listAccessorRequired = true; - $body = ' - $items = []; - foreach (INPUT_PROPERTY as $item) { - $items[] = LIST_ACCESSOR; - } + $functionName = 'populateResult' . ucfirst($shape->getName()); + if (!isset($this->generatedFunctions[$functionName])) { + // prevent recursion + $this->generatedFunctions[$functionName] = true; + + $shapeMember = $shape->getMember(); + if ($shapeMember->getShape() instanceof ListShape || $shapeMember->getShape() instanceof MapShape) { + $listAccessorRequired = false; + $body = ' + $items = []; + foreach (INPUT_PROPERTY as $item) { + $a = LIST_ACCESSOR; + if (null !== $a) { + $items[] = $a; + } + } - return $items; - '; - } else { - $listAccessorRequired = false; - $body = ' - $items = []; - foreach (INPUT_PROPERTY as $item) { - $a = LIST_ACCESSOR; - if (null !== $a) { - $items[] = $a; + return $items; + '; + } else { + $listAccessorRequired = true; + $body = ' + $items = []; + foreach (INPUT_PROPERTY as $item) { + $items[] = LIST_ACCESSOR; } - } - return $items; - '; - } + return $items; + '; + } - $functionName = 'populateResult' . ucfirst($shape->getName()); - $this->functions[$functionName] = $this->createPopulateMethod($functionName, strtr($body, [ - 'LIST_ACCESSOR' => $this->parseXmlElement('$item', $shapeMember->getShape(), $listAccessorRequired, $inObject), - 'INPUT_PROPERTY' => $shape->isFlattened() ? '$xml' : ('$xml->' . ($shapeMember->getLocationName() ? $shapeMember->getLocationName() : 'member')), - ]), $shape); + $this->functions[$functionName] = $this->createPopulateMethod($functionName, strtr($body, [ + 'LIST_ACCESSOR' => $this->parseXmlElement('$item', $shapeMember->getShape(), $listAccessorRequired, $inObject), + 'INPUT_PROPERTY' => $shape->isFlattened() ? '$xml' : ('$xml->' . ($shapeMember->getLocationName() ? $shapeMember->getLocationName() : 'member')), + ]), $shape); + } - return strtr($required ? '$this->FUNCTION_NAME(INPUT)' : '!INPUT ? EMPTY : $this->FUNCTION_NAME(INPUT)', [ + return strtr($required ? '$this->FUNCTION_NAME(INPUT)' : '(0 === ($v = INPUT)->count()) ? EMPTY : $this->FUNCTION_NAME($v)', [ 'EMPTY' => !$inObject ? '[]' : 'null', 'INPUT' => $input, 'FUNCTION_NAME' => $functionName, @@ -330,26 +347,31 @@ private function parseXmlResponseList(ListShape $shape, string $input, bool $req private function parseXmlResponseMap(MapShape $shape, string $input, bool $required, bool $inObject): string { - $shapeValue = $shape->getValue(); - $body = ' - $items = []; - foreach (INPUT as $item) { - $a = $item->MAP_VALUE; - $items[$item->MAP_KEY->__toString()] = MAP_ACCESSOR; - } + $functionName = 'populateResult' . ucfirst($shape->getName()); + if (!isset($this->generatedFunctions[$functionName])) { + // prevent recursion + $this->generatedFunctions[$functionName] = true; - return $items; - '; + $shapeValue = $shape->getValue(); + $body = ' + $items = []; + foreach (INPUT as $item) { + $a = $item->MAP_VALUE; + $items[$item->MAP_KEY->__toString()] = MAP_ACCESSOR; + } - $functionName = 'populateResult' . ucfirst($shape->getName()); - $this->functions[$functionName] = $this->createPopulateMethod($functionName, strtr($body, [ - 'INPUT' => $shape->isFlattened() ? '$xml' : '$xml->entry', - 'MAP_KEY' => $shape->getKey()->getLocationName() ?? 'key', - 'MAP_VALUE' => $shape->getValue()->getLocationName() ?? 'value', - 'MAP_ACCESSOR' => $this->parseXmlElement('$a', $shapeValue->getShape(), true, $inObject), - ]), $shape); - - return strtr($required ? '$this->FUNCTION_NAME(INPUT)' : '!INPUT ? EMPTY : $this->FUNCTION_NAME(INPUT)', [ + return $items; + '; + + $this->functions[$functionName] = $this->createPopulateMethod($functionName, strtr($body, [ + 'INPUT' => $shape->isFlattened() ? '$xml' : '$xml->entry', + 'MAP_KEY' => $shape->getKey()->getLocationName() ?? 'key', + 'MAP_VALUE' => $shape->getValue()->getLocationName() ?? 'value', + 'MAP_ACCESSOR' => $this->parseXmlElement('$a', $shapeValue->getShape(), true, $inObject), + ]), $shape); + } + + return strtr($required ? '$this->FUNCTION_NAME(INPUT)' : '(0 === ($v = INPUT)->count()) ? EMPTY : $this->FUNCTION_NAME($v)', [ 'EMPTY' => !$inObject ? '[]' : 'null', 'INPUT' => $input, 'FUNCTION_NAME' => $functionName, @@ -368,6 +390,7 @@ private function createPopulateMethod(string $functionName, string $body, Shape [$returnType, $parameterType, $memberClassNames] = $this->typeGenerator->getPhpType($shape); $method + ->setReturnType($returnType) ->setComment('@return ' . $parameterType); $this->imports = array_merge($this->imports, $memberClassNames); diff --git a/src/Core/CHANGELOG.md b/src/Core/CHANGELOG.md index 282c71f6b..af91d0f9c 100644 --- a/src/Core/CHANGELOG.md +++ b/src/Core/CHANGELOG.md @@ -8,6 +8,7 @@ ### Changed +- use strict comparison `null !==` instead of `!` - Fix CS ## 1.22.1 diff --git a/src/Core/src/Signer/SignerV4.php b/src/Core/src/Signer/SignerV4.php index 84875e2b3..602999076 100644 --- a/src/Core/src/Signer/SignerV4.php +++ b/src/Core/src/Signer/SignerV4.php @@ -317,7 +317,7 @@ private function buildCanonicalQuery(Request $request): string $query = $request->getQuery(); unset($query['X-Amz-Signature']); - if (!$query) { + if (empty($query)) { return ''; } diff --git a/src/Core/src/Sts/Result/AssumeRoleResponse.php b/src/Core/src/Sts/Result/AssumeRoleResponse.php index cb4ac1cd2..335d40c24 100644 --- a/src/Core/src/Sts/Result/AssumeRoleResponse.php +++ b/src/Core/src/Sts/Result/AssumeRoleResponse.php @@ -94,17 +94,27 @@ protected function populateResult(Response $response): void $data = new \SimpleXMLElement($response->getContent()); $data = $data->AssumeRoleResult; - $this->credentials = !$data->Credentials ? null : new Credentials([ - 'AccessKeyId' => (string) $data->Credentials->AccessKeyId, - 'SecretAccessKey' => (string) $data->Credentials->SecretAccessKey, - 'SessionToken' => (string) $data->Credentials->SessionToken, - 'Expiration' => new \DateTimeImmutable((string) $data->Credentials->Expiration), + $this->credentials = 0 === $data->Credentials->count() ? null : $this->populateResultCredentials($data->Credentials); + $this->assumedRoleUser = 0 === $data->AssumedRoleUser->count() ? null : $this->populateResultAssumedRoleUser($data->AssumedRoleUser); + $this->packedPolicySize = (null !== $v = $data->PackedPolicySize[0]) ? (int) (string) $v : null; + $this->sourceIdentity = (null !== $v = $data->SourceIdentity[0]) ? (string) $v : null; + } + + private function populateResultAssumedRoleUser(\SimpleXMLElement $xml): AssumedRoleUser + { + return new AssumedRoleUser([ + 'AssumedRoleId' => (string) $xml->AssumedRoleId, + 'Arn' => (string) $xml->Arn, ]); - $this->assumedRoleUser = !$data->AssumedRoleUser ? null : new AssumedRoleUser([ - 'AssumedRoleId' => (string) $data->AssumedRoleUser->AssumedRoleId, - 'Arn' => (string) $data->AssumedRoleUser->Arn, + } + + private function populateResultCredentials(\SimpleXMLElement $xml): Credentials + { + return new Credentials([ + 'AccessKeyId' => (string) $xml->AccessKeyId, + 'SecretAccessKey' => (string) $xml->SecretAccessKey, + 'SessionToken' => (string) $xml->SessionToken, + 'Expiration' => new \DateTimeImmutable((string) $xml->Expiration), ]); - $this->packedPolicySize = ($v = $data->PackedPolicySize) ? (int) (string) $v : null; - $this->sourceIdentity = ($v = $data->SourceIdentity) ? (string) $v : null; } } diff --git a/src/Core/src/Sts/Result/AssumeRoleWithWebIdentityResponse.php b/src/Core/src/Sts/Result/AssumeRoleWithWebIdentityResponse.php index 6eb109477..5e6c1f8eb 100644 --- a/src/Core/src/Sts/Result/AssumeRoleWithWebIdentityResponse.php +++ b/src/Core/src/Sts/Result/AssumeRoleWithWebIdentityResponse.php @@ -147,20 +147,30 @@ protected function populateResult(Response $response): void $data = new \SimpleXMLElement($response->getContent()); $data = $data->AssumeRoleWithWebIdentityResult; - $this->credentials = !$data->Credentials ? null : new Credentials([ - 'AccessKeyId' => (string) $data->Credentials->AccessKeyId, - 'SecretAccessKey' => (string) $data->Credentials->SecretAccessKey, - 'SessionToken' => (string) $data->Credentials->SessionToken, - 'Expiration' => new \DateTimeImmutable((string) $data->Credentials->Expiration), + $this->credentials = 0 === $data->Credentials->count() ? null : $this->populateResultCredentials($data->Credentials); + $this->subjectFromWebIdentityToken = (null !== $v = $data->SubjectFromWebIdentityToken[0]) ? (string) $v : null; + $this->assumedRoleUser = 0 === $data->AssumedRoleUser->count() ? null : $this->populateResultAssumedRoleUser($data->AssumedRoleUser); + $this->packedPolicySize = (null !== $v = $data->PackedPolicySize[0]) ? (int) (string) $v : null; + $this->provider = (null !== $v = $data->Provider[0]) ? (string) $v : null; + $this->audience = (null !== $v = $data->Audience[0]) ? (string) $v : null; + $this->sourceIdentity = (null !== $v = $data->SourceIdentity[0]) ? (string) $v : null; + } + + private function populateResultAssumedRoleUser(\SimpleXMLElement $xml): AssumedRoleUser + { + return new AssumedRoleUser([ + 'AssumedRoleId' => (string) $xml->AssumedRoleId, + 'Arn' => (string) $xml->Arn, ]); - $this->subjectFromWebIdentityToken = ($v = $data->SubjectFromWebIdentityToken) ? (string) $v : null; - $this->assumedRoleUser = !$data->AssumedRoleUser ? null : new AssumedRoleUser([ - 'AssumedRoleId' => (string) $data->AssumedRoleUser->AssumedRoleId, - 'Arn' => (string) $data->AssumedRoleUser->Arn, + } + + private function populateResultCredentials(\SimpleXMLElement $xml): Credentials + { + return new Credentials([ + 'AccessKeyId' => (string) $xml->AccessKeyId, + 'SecretAccessKey' => (string) $xml->SecretAccessKey, + 'SessionToken' => (string) $xml->SessionToken, + 'Expiration' => new \DateTimeImmutable((string) $xml->Expiration), ]); - $this->packedPolicySize = ($v = $data->PackedPolicySize) ? (int) (string) $v : null; - $this->provider = ($v = $data->Provider) ? (string) $v : null; - $this->audience = ($v = $data->Audience) ? (string) $v : null; - $this->sourceIdentity = ($v = $data->SourceIdentity) ? (string) $v : null; } } diff --git a/src/Core/src/Sts/Result/GetCallerIdentityResponse.php b/src/Core/src/Sts/Result/GetCallerIdentityResponse.php index 1be671113..9c5929254 100644 --- a/src/Core/src/Sts/Result/GetCallerIdentityResponse.php +++ b/src/Core/src/Sts/Result/GetCallerIdentityResponse.php @@ -62,8 +62,8 @@ protected function populateResult(Response $response): void $data = new \SimpleXMLElement($response->getContent()); $data = $data->GetCallerIdentityResult; - $this->userId = ($v = $data->UserId) ? (string) $v : null; - $this->account = ($v = $data->Account) ? (string) $v : null; - $this->arn = ($v = $data->Arn) ? (string) $v : null; + $this->userId = (null !== $v = $data->UserId[0]) ? (string) $v : null; + $this->account = (null !== $v = $data->Account[0]) ? (string) $v : null; + $this->arn = (null !== $v = $data->Arn[0]) ? (string) $v : null; } } diff --git a/src/Service/AppSync/CHANGELOG.md b/src/Service/AppSync/CHANGELOG.md index 799d1cb85..10d299581 100644 --- a/src/Service/AppSync/CHANGELOG.md +++ b/src/Service/AppSync/CHANGELOG.md @@ -2,6 +2,10 @@ ## NOT RELEASED +### Changed + +- use strict comparison `null !==` instead of `!` + ## 3.0.0 ### BC-BREAK diff --git a/src/Service/AppSync/src/Result/ListApiKeysResponse.php b/src/Service/AppSync/src/Result/ListApiKeysResponse.php index db7d13bd0..7968685eb 100644 --- a/src/Service/AppSync/src/Result/ListApiKeysResponse.php +++ b/src/Service/AppSync/src/Result/ListApiKeysResponse.php @@ -53,7 +53,7 @@ public function getApiKeys(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->listApiKeys($input)); diff --git a/src/Service/AppSync/src/Result/ListResolversResponse.php b/src/Service/AppSync/src/Result/ListResolversResponse.php index cc3e57b8c..7587f7f72 100644 --- a/src/Service/AppSync/src/Result/ListResolversResponse.php +++ b/src/Service/AppSync/src/Result/ListResolversResponse.php @@ -75,7 +75,7 @@ public function getResolvers(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->listResolvers($input)); diff --git a/src/Service/Athena/CHANGELOG.md b/src/Service/Athena/CHANGELOG.md index 1162ecd3f..2c9f93d39 100644 --- a/src/Service/Athena/CHANGELOG.md +++ b/src/Service/Athena/CHANGELOG.md @@ -6,6 +6,10 @@ - AWS api-change: Removing FEDERATED from Create/List/Delete/GetDataCatalog API +### Changed + +- use strict comparison `null !==` instead of `!` + ## 2.3.0 ### Added diff --git a/src/Service/Athena/src/Result/GetQueryResultsOutput.php b/src/Service/Athena/src/Result/GetQueryResultsOutput.php index d94994ceb..399756985 100644 --- a/src/Service/Athena/src/Result/GetQueryResultsOutput.php +++ b/src/Service/Athena/src/Result/GetQueryResultsOutput.php @@ -59,7 +59,7 @@ public function getIterator(): \Traversable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->getQueryResults($input)); diff --git a/src/Service/Athena/src/Result/ListDatabasesOutput.php b/src/Service/Athena/src/Result/ListDatabasesOutput.php index 2a1c28c20..84bf5cb0b 100644 --- a/src/Service/Athena/src/Result/ListDatabasesOutput.php +++ b/src/Service/Athena/src/Result/ListDatabasesOutput.php @@ -54,7 +54,7 @@ public function getDatabaseList(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->listDatabases($input)); diff --git a/src/Service/Athena/src/Result/ListNamedQueriesOutput.php b/src/Service/Athena/src/Result/ListNamedQueriesOutput.php index aac92489a..935f3e99f 100644 --- a/src/Service/Athena/src/Result/ListNamedQueriesOutput.php +++ b/src/Service/Athena/src/Result/ListNamedQueriesOutput.php @@ -64,7 +64,7 @@ public function getNamedQueryIds(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->listNamedQueries($input)); diff --git a/src/Service/Athena/src/Result/ListQueryExecutionsOutput.php b/src/Service/Athena/src/Result/ListQueryExecutionsOutput.php index 09cbb1fbc..0add5c4e8 100644 --- a/src/Service/Athena/src/Result/ListQueryExecutionsOutput.php +++ b/src/Service/Athena/src/Result/ListQueryExecutionsOutput.php @@ -69,7 +69,7 @@ public function getQueryExecutionIds(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->listQueryExecutions($input)); diff --git a/src/Service/Athena/src/Result/ListTableMetadataOutput.php b/src/Service/Athena/src/Result/ListTableMetadataOutput.php index 34b484015..5eaa8360a 100644 --- a/src/Service/Athena/src/Result/ListTableMetadataOutput.php +++ b/src/Service/Athena/src/Result/ListTableMetadataOutput.php @@ -72,7 +72,7 @@ public function getTableMetadataList(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->listTableMetadata($input)); diff --git a/src/Service/CloudFormation/CHANGELOG.md b/src/Service/CloudFormation/CHANGELOG.md index 0483caf5c..243edbb6c 100644 --- a/src/Service/CloudFormation/CHANGELOG.md +++ b/src/Service/CloudFormation/CHANGELOG.md @@ -4,6 +4,7 @@ ### Changed +- use strict comparison `null !==` instead of `!` - AWS enhancement: Documentation updates. ## 1.7.1 diff --git a/src/Service/CloudFormation/src/Result/DescribeStackDriftDetectionStatusOutput.php b/src/Service/CloudFormation/src/Result/DescribeStackDriftDetectionStatusOutput.php index dcef38747..252659b28 100644 --- a/src/Service/CloudFormation/src/Result/DescribeStackDriftDetectionStatusOutput.php +++ b/src/Service/CloudFormation/src/Result/DescribeStackDriftDetectionStatusOutput.php @@ -139,10 +139,10 @@ protected function populateResult(Response $response): void $this->stackId = (string) $data->StackId; $this->stackDriftDetectionId = (string) $data->StackDriftDetectionId; - $this->stackDriftStatus = ($v = $data->StackDriftStatus) ? (string) $v : null; + $this->stackDriftStatus = (null !== $v = $data->StackDriftStatus[0]) ? (string) $v : null; $this->detectionStatus = (string) $data->DetectionStatus; - $this->detectionStatusReason = ($v = $data->DetectionStatusReason) ? (string) $v : null; - $this->driftedStackResourceCount = ($v = $data->DriftedStackResourceCount) ? (int) (string) $v : null; + $this->detectionStatusReason = (null !== $v = $data->DetectionStatusReason[0]) ? (string) $v : null; + $this->driftedStackResourceCount = (null !== $v = $data->DriftedStackResourceCount[0]) ? (int) (string) $v : null; $this->timestamp = new \DateTimeImmutable((string) $data->Timestamp); } } diff --git a/src/Service/CloudFormation/src/Result/DescribeStackEventsOutput.php b/src/Service/CloudFormation/src/Result/DescribeStackEventsOutput.php index 5636c29a1..2f055d80c 100644 --- a/src/Service/CloudFormation/src/Result/DescribeStackEventsOutput.php +++ b/src/Service/CloudFormation/src/Result/DescribeStackEventsOutput.php @@ -73,7 +73,7 @@ public function getStackEvents(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->describeStackEvents($input)); @@ -97,8 +97,31 @@ protected function populateResult(Response $response): void $data = new \SimpleXMLElement($response->getContent()); $data = $data->DescribeStackEventsResult; - $this->stackEvents = !$data->StackEvents ? [] : $this->populateResultStackEvents($data->StackEvents); - $this->nextToken = ($v = $data->NextToken) ? (string) $v : null; + $this->stackEvents = (0 === ($v = $data->StackEvents)->count()) ? [] : $this->populateResultStackEvents($v); + $this->nextToken = (null !== $v = $data->NextToken[0]) ? (string) $v : null; + } + + private function populateResultStackEvent(\SimpleXMLElement $xml): StackEvent + { + return new StackEvent([ + 'StackId' => (string) $xml->StackId, + 'EventId' => (string) $xml->EventId, + 'StackName' => (string) $xml->StackName, + 'LogicalResourceId' => (null !== $v = $xml->LogicalResourceId[0]) ? (string) $v : null, + 'PhysicalResourceId' => (null !== $v = $xml->PhysicalResourceId[0]) ? (string) $v : null, + 'ResourceType' => (null !== $v = $xml->ResourceType[0]) ? (string) $v : null, + 'Timestamp' => new \DateTimeImmutable((string) $xml->Timestamp), + 'ResourceStatus' => (null !== $v = $xml->ResourceStatus[0]) ? (string) $v : null, + 'ResourceStatusReason' => (null !== $v = $xml->ResourceStatusReason[0]) ? (string) $v : null, + 'ResourceProperties' => (null !== $v = $xml->ResourceProperties[0]) ? (string) $v : null, + 'ClientRequestToken' => (null !== $v = $xml->ClientRequestToken[0]) ? (string) $v : null, + 'HookType' => (null !== $v = $xml->HookType[0]) ? (string) $v : null, + 'HookStatus' => (null !== $v = $xml->HookStatus[0]) ? (string) $v : null, + 'HookStatusReason' => (null !== $v = $xml->HookStatusReason[0]) ? (string) $v : null, + 'HookInvocationPoint' => (null !== $v = $xml->HookInvocationPoint[0]) ? (string) $v : null, + 'HookFailureMode' => (null !== $v = $xml->HookFailureMode[0]) ? (string) $v : null, + 'DetailedStatus' => (null !== $v = $xml->DetailedStatus[0]) ? (string) $v : null, + ]); } /** @@ -108,25 +131,7 @@ private function populateResultStackEvents(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->member as $item) { - $items[] = new StackEvent([ - 'StackId' => (string) $item->StackId, - 'EventId' => (string) $item->EventId, - 'StackName' => (string) $item->StackName, - 'LogicalResourceId' => ($v = $item->LogicalResourceId) ? (string) $v : null, - 'PhysicalResourceId' => ($v = $item->PhysicalResourceId) ? (string) $v : null, - 'ResourceType' => ($v = $item->ResourceType) ? (string) $v : null, - 'Timestamp' => new \DateTimeImmutable((string) $item->Timestamp), - 'ResourceStatus' => ($v = $item->ResourceStatus) ? (string) $v : null, - 'ResourceStatusReason' => ($v = $item->ResourceStatusReason) ? (string) $v : null, - 'ResourceProperties' => ($v = $item->ResourceProperties) ? (string) $v : null, - 'ClientRequestToken' => ($v = $item->ClientRequestToken) ? (string) $v : null, - 'HookType' => ($v = $item->HookType) ? (string) $v : null, - 'HookStatus' => ($v = $item->HookStatus) ? (string) $v : null, - 'HookStatusReason' => ($v = $item->HookStatusReason) ? (string) $v : null, - 'HookInvocationPoint' => ($v = $item->HookInvocationPoint) ? (string) $v : null, - 'HookFailureMode' => ($v = $item->HookFailureMode) ? (string) $v : null, - 'DetailedStatus' => ($v = $item->DetailedStatus) ? (string) $v : null, - ]); + $items[] = $this->populateResultStackEvent($item); } return $items; diff --git a/src/Service/CloudFormation/src/Result/DescribeStacksOutput.php b/src/Service/CloudFormation/src/Result/DescribeStacksOutput.php index 8a75216ea..ff4fa1c91 100644 --- a/src/Service/CloudFormation/src/Result/DescribeStacksOutput.php +++ b/src/Service/CloudFormation/src/Result/DescribeStacksOutput.php @@ -80,7 +80,7 @@ public function getStacks(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->describeStacks($input)); @@ -104,8 +104,8 @@ protected function populateResult(Response $response): void $data = new \SimpleXMLElement($response->getContent()); $data = $data->DescribeStacksResult; - $this->stacks = !$data->Stacks ? [] : $this->populateResultStacks($data->Stacks); - $this->nextToken = ($v = $data->NextToken) ? (string) $v : null; + $this->stacks = (0 === ($v = $data->Stacks)->count()) ? [] : $this->populateResultStacks($v); + $this->nextToken = (null !== $v = $data->NextToken[0]) ? (string) $v : null; } /** @@ -115,10 +115,7 @@ private function populateResultCapabilities(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->member as $item) { - $a = ($v = $item) ? (string) $v : null; - if (null !== $a) { - $items[] = $a; - } + $items[] = (string) $item; } return $items; @@ -131,15 +128,22 @@ private function populateResultNotificationARNs(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->member as $item) { - $a = ($v = $item) ? (string) $v : null; - if (null !== $a) { - $items[] = $a; - } + $items[] = (string) $item; } return $items; } + private function populateResultOutput(\SimpleXMLElement $xml): Output + { + return new Output([ + 'OutputKey' => (null !== $v = $xml->OutputKey[0]) ? (string) $v : null, + 'OutputValue' => (null !== $v = $xml->OutputValue[0]) ? (string) $v : null, + 'Description' => (null !== $v = $xml->Description[0]) ? (string) $v : null, + 'ExportName' => (null !== $v = $xml->ExportName[0]) ? (string) $v : null, + ]); + } + /** * @return Output[] */ @@ -147,17 +151,22 @@ private function populateResultOutputs(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->member as $item) { - $items[] = new Output([ - 'OutputKey' => ($v = $item->OutputKey) ? (string) $v : null, - 'OutputValue' => ($v = $item->OutputValue) ? (string) $v : null, - 'Description' => ($v = $item->Description) ? (string) $v : null, - 'ExportName' => ($v = $item->ExportName) ? (string) $v : null, - ]); + $items[] = $this->populateResultOutput($item); } return $items; } + private function populateResultParameter(\SimpleXMLElement $xml): Parameter + { + return new Parameter([ + 'ParameterKey' => (null !== $v = $xml->ParameterKey[0]) ? (string) $v : null, + 'ParameterValue' => (null !== $v = $xml->ParameterValue[0]) ? (string) $v : null, + 'UsePreviousValue' => (null !== $v = $xml->UsePreviousValue[0]) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, + 'ResolvedValue' => (null !== $v = $xml->ResolvedValue[0]) ? (string) $v : null, + ]); + } + /** * @return Parameter[] */ @@ -165,17 +174,28 @@ private function populateResultParameters(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->member as $item) { - $items[] = new Parameter([ - 'ParameterKey' => ($v = $item->ParameterKey) ? (string) $v : null, - 'ParameterValue' => ($v = $item->ParameterValue) ? (string) $v : null, - 'UsePreviousValue' => ($v = $item->UsePreviousValue) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, - 'ResolvedValue' => ($v = $item->ResolvedValue) ? (string) $v : null, - ]); + $items[] = $this->populateResultParameter($item); } return $items; } + private function populateResultRollbackConfiguration(\SimpleXMLElement $xml): RollbackConfiguration + { + return new RollbackConfiguration([ + 'RollbackTriggers' => (0 === ($v = $xml->RollbackTriggers)->count()) ? null : $this->populateResultRollbackTriggers($v), + 'MonitoringTimeInMinutes' => (null !== $v = $xml->MonitoringTimeInMinutes[0]) ? (int) (string) $v : null, + ]); + } + + private function populateResultRollbackTrigger(\SimpleXMLElement $xml): RollbackTrigger + { + return new RollbackTrigger([ + 'Arn' => (string) $xml->Arn, + 'Type' => (string) $xml->Type, + ]); + } + /** * @return RollbackTrigger[] */ @@ -183,15 +203,51 @@ private function populateResultRollbackTriggers(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->member as $item) { - $items[] = new RollbackTrigger([ - 'Arn' => (string) $item->Arn, - 'Type' => (string) $item->Type, - ]); + $items[] = $this->populateResultRollbackTrigger($item); } return $items; } + private function populateResultStack(\SimpleXMLElement $xml): Stack + { + return new Stack([ + 'StackId' => (null !== $v = $xml->StackId[0]) ? (string) $v : null, + 'StackName' => (string) $xml->StackName, + 'ChangeSetId' => (null !== $v = $xml->ChangeSetId[0]) ? (string) $v : null, + 'Description' => (null !== $v = $xml->Description[0]) ? (string) $v : null, + 'Parameters' => (0 === ($v = $xml->Parameters)->count()) ? null : $this->populateResultParameters($v), + 'CreationTime' => new \DateTimeImmutable((string) $xml->CreationTime), + 'DeletionTime' => (null !== $v = $xml->DeletionTime[0]) ? new \DateTimeImmutable((string) $v) : null, + 'LastUpdatedTime' => (null !== $v = $xml->LastUpdatedTime[0]) ? new \DateTimeImmutable((string) $v) : null, + 'RollbackConfiguration' => 0 === $xml->RollbackConfiguration->count() ? null : $this->populateResultRollbackConfiguration($xml->RollbackConfiguration), + 'StackStatus' => (string) $xml->StackStatus, + 'StackStatusReason' => (null !== $v = $xml->StackStatusReason[0]) ? (string) $v : null, + 'DisableRollback' => (null !== $v = $xml->DisableRollback[0]) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, + 'NotificationARNs' => (0 === ($v = $xml->NotificationARNs)->count()) ? null : $this->populateResultNotificationARNs($v), + 'TimeoutInMinutes' => (null !== $v = $xml->TimeoutInMinutes[0]) ? (int) (string) $v : null, + 'Capabilities' => (0 === ($v = $xml->Capabilities)->count()) ? null : $this->populateResultCapabilities($v), + 'Outputs' => (0 === ($v = $xml->Outputs)->count()) ? null : $this->populateResultOutputs($v), + 'RoleARN' => (null !== $v = $xml->RoleARN[0]) ? (string) $v : null, + 'Tags' => (0 === ($v = $xml->Tags)->count()) ? null : $this->populateResultTags($v), + 'EnableTerminationProtection' => (null !== $v = $xml->EnableTerminationProtection[0]) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, + 'ParentId' => (null !== $v = $xml->ParentId[0]) ? (string) $v : null, + 'RootId' => (null !== $v = $xml->RootId[0]) ? (string) $v : null, + 'DriftInformation' => 0 === $xml->DriftInformation->count() ? null : $this->populateResultStackDriftInformation($xml->DriftInformation), + 'RetainExceptOnCreate' => (null !== $v = $xml->RetainExceptOnCreate[0]) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, + 'DeletionMode' => (null !== $v = $xml->DeletionMode[0]) ? (string) $v : null, + 'DetailedStatus' => (null !== $v = $xml->DetailedStatus[0]) ? (string) $v : null, + ]); + } + + private function populateResultStackDriftInformation(\SimpleXMLElement $xml): StackDriftInformation + { + return new StackDriftInformation([ + 'StackDriftStatus' => (string) $xml->StackDriftStatus, + 'LastCheckTimestamp' => (null !== $v = $xml->LastCheckTimestamp[0]) ? new \DateTimeImmutable((string) $v) : null, + ]); + } + /** * @return Stack[] */ @@ -199,44 +255,20 @@ private function populateResultStacks(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->member as $item) { - $items[] = new Stack([ - 'StackId' => ($v = $item->StackId) ? (string) $v : null, - 'StackName' => (string) $item->StackName, - 'ChangeSetId' => ($v = $item->ChangeSetId) ? (string) $v : null, - 'Description' => ($v = $item->Description) ? (string) $v : null, - 'Parameters' => !$item->Parameters ? null : $this->populateResultParameters($item->Parameters), - 'CreationTime' => new \DateTimeImmutable((string) $item->CreationTime), - 'DeletionTime' => ($v = $item->DeletionTime) ? new \DateTimeImmutable((string) $v) : null, - 'LastUpdatedTime' => ($v = $item->LastUpdatedTime) ? new \DateTimeImmutable((string) $v) : null, - 'RollbackConfiguration' => !$item->RollbackConfiguration ? null : new RollbackConfiguration([ - 'RollbackTriggers' => !$item->RollbackConfiguration->RollbackTriggers ? null : $this->populateResultRollbackTriggers($item->RollbackConfiguration->RollbackTriggers), - 'MonitoringTimeInMinutes' => ($v = $item->RollbackConfiguration->MonitoringTimeInMinutes) ? (int) (string) $v : null, - ]), - 'StackStatus' => (string) $item->StackStatus, - 'StackStatusReason' => ($v = $item->StackStatusReason) ? (string) $v : null, - 'DisableRollback' => ($v = $item->DisableRollback) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, - 'NotificationARNs' => !$item->NotificationARNs ? null : $this->populateResultNotificationARNs($item->NotificationARNs), - 'TimeoutInMinutes' => ($v = $item->TimeoutInMinutes) ? (int) (string) $v : null, - 'Capabilities' => !$item->Capabilities ? null : $this->populateResultCapabilities($item->Capabilities), - 'Outputs' => !$item->Outputs ? null : $this->populateResultOutputs($item->Outputs), - 'RoleARN' => ($v = $item->RoleARN) ? (string) $v : null, - 'Tags' => !$item->Tags ? null : $this->populateResultTags($item->Tags), - 'EnableTerminationProtection' => ($v = $item->EnableTerminationProtection) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, - 'ParentId' => ($v = $item->ParentId) ? (string) $v : null, - 'RootId' => ($v = $item->RootId) ? (string) $v : null, - 'DriftInformation' => !$item->DriftInformation ? null : new StackDriftInformation([ - 'StackDriftStatus' => (string) $item->DriftInformation->StackDriftStatus, - 'LastCheckTimestamp' => ($v = $item->DriftInformation->LastCheckTimestamp) ? new \DateTimeImmutable((string) $v) : null, - ]), - 'RetainExceptOnCreate' => ($v = $item->RetainExceptOnCreate) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, - 'DeletionMode' => ($v = $item->DeletionMode) ? (string) $v : null, - 'DetailedStatus' => ($v = $item->DetailedStatus) ? (string) $v : null, - ]); + $items[] = $this->populateResultStack($item); } return $items; } + private function populateResultTag(\SimpleXMLElement $xml): Tag + { + return new Tag([ + 'Key' => (string) $xml->Key, + 'Value' => (string) $xml->Value, + ]); + } + /** * @return Tag[] */ @@ -244,10 +276,7 @@ private function populateResultTags(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->member as $item) { - $items[] = new Tag([ - 'Key' => (string) $item->Key, - 'Value' => (string) $item->Value, - ]); + $items[] = $this->populateResultTag($item); } return $items; diff --git a/src/Service/CloudFront/CHANGELOG.md b/src/Service/CloudFront/CHANGELOG.md index 010f1adf9..dd6826637 100644 --- a/src/Service/CloudFront/CHANGELOG.md +++ b/src/Service/CloudFront/CHANGELOG.md @@ -2,6 +2,10 @@ ## NOT RELEASED +### Changed + +- use strict comparison `null !==` instead of `!` + ## 1.0.2 ### Changed diff --git a/src/Service/CloudFront/src/Result/CreateInvalidationResult.php b/src/Service/CloudFront/src/Result/CreateInvalidationResult.php index 0558ea599..b45d5300d 100644 --- a/src/Service/CloudFront/src/Result/CreateInvalidationResult.php +++ b/src/Service/CloudFront/src/Result/CreateInvalidationResult.php @@ -48,17 +48,24 @@ protected function populateResult(Response $response): void $this->location = $headers['location'][0] ?? null; $data = new \SimpleXMLElement($response->getContent()); - $this->invalidation = new Invalidation([ - 'Id' => (string) $data->Id, - 'Status' => (string) $data->Status, - 'CreateTime' => new \DateTimeImmutable((string) $data->CreateTime), - 'InvalidationBatch' => new InvalidationBatch([ - 'Paths' => new Paths([ - 'Quantity' => (int) (string) $data->InvalidationBatch->Paths->Quantity, - 'Items' => !$data->InvalidationBatch->Paths->Items ? null : $this->populateResultPathList($data->InvalidationBatch->Paths->Items), - ]), - 'CallerReference' => (string) $data->InvalidationBatch->CallerReference, - ]), + $this->invalidation = $this->populateResultInvalidation($data); + } + + private function populateResultInvalidation(\SimpleXMLElement $xml): Invalidation + { + return new Invalidation([ + 'Id' => (string) $xml->Id, + 'Status' => (string) $xml->Status, + 'CreateTime' => new \DateTimeImmutable((string) $xml->CreateTime), + 'InvalidationBatch' => $this->populateResultInvalidationBatch($xml->InvalidationBatch), + ]); + } + + private function populateResultInvalidationBatch(\SimpleXMLElement $xml): InvalidationBatch + { + return new InvalidationBatch([ + 'Paths' => $this->populateResultPaths($xml->Paths), + 'CallerReference' => (string) $xml->CallerReference, ]); } @@ -69,12 +76,17 @@ private function populateResultPathList(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->Path as $item) { - $a = ($v = $item) ? (string) $v : null; - if (null !== $a) { - $items[] = $a; - } + $items[] = (string) $item; } return $items; } + + private function populateResultPaths(\SimpleXMLElement $xml): Paths + { + return new Paths([ + 'Quantity' => (int) (string) $xml->Quantity, + 'Items' => (0 === ($v = $xml->Items)->count()) ? null : $this->populateResultPathList($v), + ]); + } } diff --git a/src/Service/CloudWatch/CHANGELOG.md b/src/Service/CloudWatch/CHANGELOG.md index 9536f5559..dc216f016 100644 --- a/src/Service/CloudWatch/CHANGELOG.md +++ b/src/Service/CloudWatch/CHANGELOG.md @@ -2,6 +2,10 @@ ## NOT RELEASED +### Changed + +- use strict comparison `null !==` instead of `!` + ## 1.0.3 ### Changed diff --git a/src/Service/CloudWatch/src/Result/GetMetricDataOutput.php b/src/Service/CloudWatch/src/Result/GetMetricDataOutput.php index 2b4d14b3c..e3367c5f2 100644 --- a/src/Service/CloudWatch/src/Result/GetMetricDataOutput.php +++ b/src/Service/CloudWatch/src/Result/GetMetricDataOutput.php @@ -59,7 +59,7 @@ public function getIterator(): \Traversable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->getMetricData($input)); @@ -104,7 +104,7 @@ public function getMessages(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->getMetricData($input)); @@ -148,7 +148,7 @@ public function getMetricDataResults(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->getMetricData($input)); @@ -179,9 +179,9 @@ protected function populateResult(Response $response): void $data = new \SimpleXMLElement($response->getContent()); $data = $data->GetMetricDataResult; - $this->metricDataResults = !$data->MetricDataResults ? [] : $this->populateResultMetricDataResults($data->MetricDataResults); - $this->nextToken = ($v = $data->NextToken) ? (string) $v : null; - $this->messages = !$data->Messages ? [] : $this->populateResultMetricDataResultMessages($data->Messages); + $this->metricDataResults = (0 === ($v = $data->MetricDataResults)->count()) ? [] : $this->populateResultMetricDataResults($v); + $this->nextToken = (null !== $v = $data->NextToken[0]) ? (string) $v : null; + $this->messages = (0 === ($v = $data->Messages)->count()) ? [] : $this->populateResultMetricDataResultMessages($v); } /** @@ -191,15 +191,32 @@ private function populateResultDatapointValues(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->member as $item) { - $a = ($v = $item) ? (float) (string) $v : null; - if (null !== $a) { - $items[] = $a; - } + $items[] = (float) (string) $item; } return $items; } + private function populateResultMessageData(\SimpleXMLElement $xml): MessageData + { + return new MessageData([ + 'Code' => (null !== $v = $xml->Code[0]) ? (string) $v : null, + 'Value' => (null !== $v = $xml->Value[0]) ? (string) $v : null, + ]); + } + + private function populateResultMetricDataResult(\SimpleXMLElement $xml): MetricDataResult + { + return new MetricDataResult([ + 'Id' => (null !== $v = $xml->Id[0]) ? (string) $v : null, + 'Label' => (null !== $v = $xml->Label[0]) ? (string) $v : null, + 'Timestamps' => (0 === ($v = $xml->Timestamps)->count()) ? null : $this->populateResultTimestamps($v), + 'Values' => (0 === ($v = $xml->Values)->count()) ? null : $this->populateResultDatapointValues($v), + 'StatusCode' => (null !== $v = $xml->StatusCode[0]) ? (string) $v : null, + 'Messages' => (0 === ($v = $xml->Messages)->count()) ? null : $this->populateResultMetricDataResultMessages($v), + ]); + } + /** * @return MessageData[] */ @@ -207,10 +224,7 @@ private function populateResultMetricDataResultMessages(\SimpleXMLElement $xml): { $items = []; foreach ($xml->member as $item) { - $items[] = new MessageData([ - 'Code' => ($v = $item->Code) ? (string) $v : null, - 'Value' => ($v = $item->Value) ? (string) $v : null, - ]); + $items[] = $this->populateResultMessageData($item); } return $items; @@ -223,14 +237,7 @@ private function populateResultMetricDataResults(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->member as $item) { - $items[] = new MetricDataResult([ - 'Id' => ($v = $item->Id) ? (string) $v : null, - 'Label' => ($v = $item->Label) ? (string) $v : null, - 'Timestamps' => !$item->Timestamps ? null : $this->populateResultTimestamps($item->Timestamps), - 'Values' => !$item->Values ? null : $this->populateResultDatapointValues($item->Values), - 'StatusCode' => ($v = $item->StatusCode) ? (string) $v : null, - 'Messages' => !$item->Messages ? null : $this->populateResultMetricDataResultMessages($item->Messages), - ]); + $items[] = $this->populateResultMetricDataResult($item); } return $items; @@ -243,10 +250,7 @@ private function populateResultTimestamps(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->member as $item) { - $a = ($v = $item) ? new \DateTimeImmutable((string) $v) : null; - if (null !== $a) { - $items[] = $a; - } + $items[] = new \DateTimeImmutable((string) $item); } return $items; diff --git a/src/Service/CloudWatch/src/Result/GetMetricStatisticsOutput.php b/src/Service/CloudWatch/src/Result/GetMetricStatisticsOutput.php index 9e4730603..dbc5340cd 100644 --- a/src/Service/CloudWatch/src/Result/GetMetricStatisticsOutput.php +++ b/src/Service/CloudWatch/src/Result/GetMetricStatisticsOutput.php @@ -44,8 +44,22 @@ protected function populateResult(Response $response): void $data = new \SimpleXMLElement($response->getContent()); $data = $data->GetMetricStatisticsResult; - $this->label = ($v = $data->Label) ? (string) $v : null; - $this->datapoints = !$data->Datapoints ? [] : $this->populateResultDatapoints($data->Datapoints); + $this->label = (null !== $v = $data->Label[0]) ? (string) $v : null; + $this->datapoints = (0 === ($v = $data->Datapoints)->count()) ? [] : $this->populateResultDatapoints($v); + } + + private function populateResultDatapoint(\SimpleXMLElement $xml): Datapoint + { + return new Datapoint([ + 'Timestamp' => (null !== $v = $xml->Timestamp[0]) ? new \DateTimeImmutable((string) $v) : null, + 'SampleCount' => (null !== $v = $xml->SampleCount[0]) ? (float) (string) $v : null, + 'Average' => (null !== $v = $xml->Average[0]) ? (float) (string) $v : null, + 'Sum' => (null !== $v = $xml->Sum[0]) ? (float) (string) $v : null, + 'Minimum' => (null !== $v = $xml->Minimum[0]) ? (float) (string) $v : null, + 'Maximum' => (null !== $v = $xml->Maximum[0]) ? (float) (string) $v : null, + 'Unit' => (null !== $v = $xml->Unit[0]) ? (string) $v : null, + 'ExtendedStatistics' => (0 === ($v = $xml->ExtendedStatistics)->count()) ? null : $this->populateResultDatapointValueMap($v), + ]); } /** @@ -69,16 +83,7 @@ private function populateResultDatapoints(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->member as $item) { - $items[] = new Datapoint([ - 'Timestamp' => ($v = $item->Timestamp) ? new \DateTimeImmutable((string) $v) : null, - 'SampleCount' => ($v = $item->SampleCount) ? (float) (string) $v : null, - 'Average' => ($v = $item->Average) ? (float) (string) $v : null, - 'Sum' => ($v = $item->Sum) ? (float) (string) $v : null, - 'Minimum' => ($v = $item->Minimum) ? (float) (string) $v : null, - 'Maximum' => ($v = $item->Maximum) ? (float) (string) $v : null, - 'Unit' => ($v = $item->Unit) ? (string) $v : null, - 'ExtendedStatistics' => !$item->ExtendedStatistics ? null : $this->populateResultDatapointValueMap($item->ExtendedStatistics), - ]); + $items[] = $this->populateResultDatapoint($item); } return $items; diff --git a/src/Service/CloudWatch/src/Result/ListMetricsOutput.php b/src/Service/CloudWatch/src/Result/ListMetricsOutput.php index 5df3699b1..3672a36af 100644 --- a/src/Service/CloudWatch/src/Result/ListMetricsOutput.php +++ b/src/Service/CloudWatch/src/Result/ListMetricsOutput.php @@ -57,7 +57,7 @@ public function getIterator(): \Traversable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->listMetrics($input)); @@ -102,7 +102,7 @@ public function getMetrics(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->listMetrics($input)); @@ -153,7 +153,7 @@ public function getOwningAccounts(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->listMetrics($input)); @@ -177,9 +177,17 @@ protected function populateResult(Response $response): void $data = new \SimpleXMLElement($response->getContent()); $data = $data->ListMetricsResult; - $this->metrics = !$data->Metrics ? [] : $this->populateResultMetrics($data->Metrics); - $this->nextToken = ($v = $data->NextToken) ? (string) $v : null; - $this->owningAccounts = !$data->OwningAccounts ? [] : $this->populateResultOwningAccounts($data->OwningAccounts); + $this->metrics = (0 === ($v = $data->Metrics)->count()) ? [] : $this->populateResultMetrics($v); + $this->nextToken = (null !== $v = $data->NextToken[0]) ? (string) $v : null; + $this->owningAccounts = (0 === ($v = $data->OwningAccounts)->count()) ? [] : $this->populateResultOwningAccounts($v); + } + + private function populateResultDimension(\SimpleXMLElement $xml): Dimension + { + return new Dimension([ + 'Name' => (string) $xml->Name, + 'Value' => (string) $xml->Value, + ]); } /** @@ -189,15 +197,21 @@ private function populateResultDimensions(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->member as $item) { - $items[] = new Dimension([ - 'Name' => (string) $item->Name, - 'Value' => (string) $item->Value, - ]); + $items[] = $this->populateResultDimension($item); } return $items; } + private function populateResultMetric(\SimpleXMLElement $xml): Metric + { + return new Metric([ + 'Namespace' => (null !== $v = $xml->Namespace[0]) ? (string) $v : null, + 'MetricName' => (null !== $v = $xml->MetricName[0]) ? (string) $v : null, + 'Dimensions' => (0 === ($v = $xml->Dimensions)->count()) ? null : $this->populateResultDimensions($v), + ]); + } + /** * @return Metric[] */ @@ -205,11 +219,7 @@ private function populateResultMetrics(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->member as $item) { - $items[] = new Metric([ - 'Namespace' => ($v = $item->Namespace) ? (string) $v : null, - 'MetricName' => ($v = $item->MetricName) ? (string) $v : null, - 'Dimensions' => !$item->Dimensions ? null : $this->populateResultDimensions($item->Dimensions), - ]); + $items[] = $this->populateResultMetric($item); } return $items; @@ -222,10 +232,7 @@ private function populateResultOwningAccounts(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->member as $item) { - $a = ($v = $item) ? (string) $v : null; - if (null !== $a) { - $items[] = $a; - } + $items[] = (string) $item; } return $items; diff --git a/src/Service/CloudWatchLogs/CHANGELOG.md b/src/Service/CloudWatchLogs/CHANGELOG.md index 407d8d92f..8dfc23851 100644 --- a/src/Service/CloudWatchLogs/CHANGELOG.md +++ b/src/Service/CloudWatchLogs/CHANGELOG.md @@ -2,6 +2,10 @@ ## NOT RELEASED +### Changed + +- use strict comparison `null !==` instead of `!` + ## 2.3.0 ### Added diff --git a/src/Service/CloudWatchLogs/src/Result/DescribeLogStreamsResponse.php b/src/Service/CloudWatchLogs/src/Result/DescribeLogStreamsResponse.php index f965bd2d7..499ad8f68 100644 --- a/src/Service/CloudWatchLogs/src/Result/DescribeLogStreamsResponse.php +++ b/src/Service/CloudWatchLogs/src/Result/DescribeLogStreamsResponse.php @@ -61,7 +61,7 @@ public function getLogStreams(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->describeLogStreams($input)); diff --git a/src/Service/CloudWatchLogs/src/Result/FilterLogEventsResponse.php b/src/Service/CloudWatchLogs/src/Result/FilterLogEventsResponse.php index 379b57c0e..c3fb6f5fa 100644 --- a/src/Service/CloudWatchLogs/src/Result/FilterLogEventsResponse.php +++ b/src/Service/CloudWatchLogs/src/Result/FilterLogEventsResponse.php @@ -63,7 +63,7 @@ public function getEvents(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->filterLogEvents($input)); @@ -100,7 +100,7 @@ public function getIterator(): \Traversable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->filterLogEvents($input)); @@ -152,7 +152,7 @@ public function getSearchedLogStreams(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->filterLogEvents($input)); diff --git a/src/Service/CodeCommit/CHANGELOG.md b/src/Service/CodeCommit/CHANGELOG.md index ca94e79ea..7695f1b7a 100644 --- a/src/Service/CodeCommit/CHANGELOG.md +++ b/src/Service/CodeCommit/CHANGELOG.md @@ -2,6 +2,10 @@ ## NOT RELEASED +### Changed + +- use strict comparison `null !==` instead of `!` + ## 1.2.0 ### Added diff --git a/src/Service/CodeCommit/src/Result/GetDifferencesOutput.php b/src/Service/CodeCommit/src/Result/GetDifferencesOutput.php index 1212205a9..a1612ea81 100644 --- a/src/Service/CodeCommit/src/Result/GetDifferencesOutput.php +++ b/src/Service/CodeCommit/src/Result/GetDifferencesOutput.php @@ -55,7 +55,7 @@ public function getDifferences(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->getDifferences($input)); diff --git a/src/Service/CodeCommit/src/Result/ListRepositoriesOutput.php b/src/Service/CodeCommit/src/Result/ListRepositoriesOutput.php index 7486d7760..92547d3a9 100644 --- a/src/Service/CodeCommit/src/Result/ListRepositoriesOutput.php +++ b/src/Service/CodeCommit/src/Result/ListRepositoriesOutput.php @@ -74,7 +74,7 @@ public function getRepositories(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->listRepositories($input)); diff --git a/src/Service/CognitoIdentityProvider/CHANGELOG.md b/src/Service/CognitoIdentityProvider/CHANGELOG.md index c67a42e40..5de17eaf5 100644 --- a/src/Service/CognitoIdentityProvider/CHANGELOG.md +++ b/src/Service/CognitoIdentityProvider/CHANGELOG.md @@ -2,6 +2,10 @@ ## NOT RELEASED +### Changed + +- use strict comparison `null !==` instead of `!` + ## 1.9.0 ### Added diff --git a/src/Service/CognitoIdentityProvider/src/Result/ListGroupsResponse.php b/src/Service/CognitoIdentityProvider/src/Result/ListGroupsResponse.php index 06efbfc73..97eff227d 100644 --- a/src/Service/CognitoIdentityProvider/src/Result/ListGroupsResponse.php +++ b/src/Service/CognitoIdentityProvider/src/Result/ListGroupsResponse.php @@ -54,7 +54,7 @@ public function getGroups(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->listGroups($input)); diff --git a/src/Service/CognitoIdentityProvider/src/Result/ListUsersResponse.php b/src/Service/CognitoIdentityProvider/src/Result/ListUsersResponse.php index 22b2dc195..2bcde837b 100644 --- a/src/Service/CognitoIdentityProvider/src/Result/ListUsersResponse.php +++ b/src/Service/CognitoIdentityProvider/src/Result/ListUsersResponse.php @@ -84,7 +84,7 @@ public function getUsers(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->paginationToken) { + if (null !== $page->paginationToken) { $input->setPaginationToken($page->paginationToken); $this->registerPrefetch($nextPage = $client->listUsers($input)); diff --git a/src/Service/DynamoDb/CHANGELOG.md b/src/Service/DynamoDb/CHANGELOG.md index c32773bba..f5497bb00 100644 --- a/src/Service/DynamoDb/CHANGELOG.md +++ b/src/Service/DynamoDb/CHANGELOG.md @@ -2,6 +2,10 @@ ## NOT RELEASED +### Changed + +- use strict comparison `null !==` instead of `!` + ## 3.2.2 ### Changed diff --git a/src/Service/DynamoDb/src/Result/BatchGetItemOutput.php b/src/Service/DynamoDb/src/Result/BatchGetItemOutput.php index 5ecac0730..11237a387 100644 --- a/src/Service/DynamoDb/src/Result/BatchGetItemOutput.php +++ b/src/Service/DynamoDb/src/Result/BatchGetItemOutput.php @@ -83,7 +83,7 @@ public function getConsumedCapacity(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->unprocessedKeys) { + if (null !== $page->unprocessedKeys) { $input->setRequestItems($page->unprocessedKeys); $this->registerPrefetch($nextPage = $client->batchGetItem($input)); diff --git a/src/Service/DynamoDb/src/Result/ListTablesOutput.php b/src/Service/DynamoDb/src/Result/ListTablesOutput.php index 674afb48d..2219d248f 100644 --- a/src/Service/DynamoDb/src/Result/ListTablesOutput.php +++ b/src/Service/DynamoDb/src/Result/ListTablesOutput.php @@ -79,7 +79,7 @@ public function getTableNames(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->lastEvaluatedTableName) { + if (null !== $page->lastEvaluatedTableName) { $input->setExclusiveStartTableName($page->lastEvaluatedTableName); $this->registerPrefetch($nextPage = $client->listTables($input)); diff --git a/src/Service/DynamoDb/src/Result/QueryOutput.php b/src/Service/DynamoDb/src/Result/QueryOutput.php index 7acf6d9cb..449e03d67 100644 --- a/src/Service/DynamoDb/src/Result/QueryOutput.php +++ b/src/Service/DynamoDb/src/Result/QueryOutput.php @@ -116,7 +116,7 @@ public function getItems(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->lastEvaluatedKey) { + if (null !== $page->lastEvaluatedKey) { $input->setExclusiveStartKey($page->lastEvaluatedKey); $this->registerPrefetch($nextPage = $client->query($input)); diff --git a/src/Service/DynamoDb/src/Result/ScanOutput.php b/src/Service/DynamoDb/src/Result/ScanOutput.php index 3436247ee..85d2ca3b4 100644 --- a/src/Service/DynamoDb/src/Result/ScanOutput.php +++ b/src/Service/DynamoDb/src/Result/ScanOutput.php @@ -116,7 +116,7 @@ public function getItems(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->lastEvaluatedKey) { + if (null !== $page->lastEvaluatedKey) { $input->setExclusiveStartKey($page->lastEvaluatedKey); $this->registerPrefetch($nextPage = $client->scan($input)); diff --git a/src/Service/ElastiCache/CHANGELOG.md b/src/Service/ElastiCache/CHANGELOG.md index f95ce54e9..9838d0fac 100644 --- a/src/Service/ElastiCache/CHANGELOG.md +++ b/src/Service/ElastiCache/CHANGELOG.md @@ -2,6 +2,10 @@ ## NOT RELEASED +### Changed + +- use strict comparison `null !==` instead of `!` + ## 1.2.3 ### Changed diff --git a/src/Service/ElastiCache/src/Result/CacheClusterMessage.php b/src/Service/ElastiCache/src/Result/CacheClusterMessage.php index a2fa7e56f..3500aa5e3 100644 --- a/src/Service/ElastiCache/src/Result/CacheClusterMessage.php +++ b/src/Service/ElastiCache/src/Result/CacheClusterMessage.php @@ -67,7 +67,7 @@ public function getCacheClusters(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->marker) { + if (null !== $page->marker) { $input->setMarker($page->marker); $this->registerPrefetch($nextPage = $client->describeCacheClusters($input)); @@ -108,8 +108,47 @@ protected function populateResult(Response $response): void $data = new \SimpleXMLElement($response->getContent()); $data = $data->DescribeCacheClustersResult; - $this->marker = ($v = $data->Marker) ? (string) $v : null; - $this->cacheClusters = !$data->CacheClusters ? [] : $this->populateResultCacheClusterList($data->CacheClusters); + $this->marker = (null !== $v = $data->Marker[0]) ? (string) $v : null; + $this->cacheClusters = (0 === ($v = $data->CacheClusters)->count()) ? [] : $this->populateResultCacheClusterList($v); + } + + private function populateResultCacheCluster(\SimpleXMLElement $xml): CacheCluster + { + return new CacheCluster([ + 'CacheClusterId' => (null !== $v = $xml->CacheClusterId[0]) ? (string) $v : null, + 'ConfigurationEndpoint' => 0 === $xml->ConfigurationEndpoint->count() ? null : $this->populateResultEndpoint($xml->ConfigurationEndpoint), + 'ClientDownloadLandingPage' => (null !== $v = $xml->ClientDownloadLandingPage[0]) ? (string) $v : null, + 'CacheNodeType' => (null !== $v = $xml->CacheNodeType[0]) ? (string) $v : null, + 'Engine' => (null !== $v = $xml->Engine[0]) ? (string) $v : null, + 'EngineVersion' => (null !== $v = $xml->EngineVersion[0]) ? (string) $v : null, + 'CacheClusterStatus' => (null !== $v = $xml->CacheClusterStatus[0]) ? (string) $v : null, + 'NumCacheNodes' => (null !== $v = $xml->NumCacheNodes[0]) ? (int) (string) $v : null, + 'PreferredAvailabilityZone' => (null !== $v = $xml->PreferredAvailabilityZone[0]) ? (string) $v : null, + 'PreferredOutpostArn' => (null !== $v = $xml->PreferredOutpostArn[0]) ? (string) $v : null, + 'CacheClusterCreateTime' => (null !== $v = $xml->CacheClusterCreateTime[0]) ? new \DateTimeImmutable((string) $v) : null, + 'PreferredMaintenanceWindow' => (null !== $v = $xml->PreferredMaintenanceWindow[0]) ? (string) $v : null, + 'PendingModifiedValues' => 0 === $xml->PendingModifiedValues->count() ? null : $this->populateResultPendingModifiedValues($xml->PendingModifiedValues), + 'NotificationConfiguration' => 0 === $xml->NotificationConfiguration->count() ? null : $this->populateResultNotificationConfiguration($xml->NotificationConfiguration), + 'CacheSecurityGroups' => (0 === ($v = $xml->CacheSecurityGroups)->count()) ? null : $this->populateResultCacheSecurityGroupMembershipList($v), + 'CacheParameterGroup' => 0 === $xml->CacheParameterGroup->count() ? null : $this->populateResultCacheParameterGroupStatus($xml->CacheParameterGroup), + 'CacheSubnetGroupName' => (null !== $v = $xml->CacheSubnetGroupName[0]) ? (string) $v : null, + 'CacheNodes' => (0 === ($v = $xml->CacheNodes)->count()) ? null : $this->populateResultCacheNodeList($v), + 'AutoMinorVersionUpgrade' => (null !== $v = $xml->AutoMinorVersionUpgrade[0]) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, + 'SecurityGroups' => (0 === ($v = $xml->SecurityGroups)->count()) ? null : $this->populateResultSecurityGroupMembershipList($v), + 'ReplicationGroupId' => (null !== $v = $xml->ReplicationGroupId[0]) ? (string) $v : null, + 'SnapshotRetentionLimit' => (null !== $v = $xml->SnapshotRetentionLimit[0]) ? (int) (string) $v : null, + 'SnapshotWindow' => (null !== $v = $xml->SnapshotWindow[0]) ? (string) $v : null, + 'AuthTokenEnabled' => (null !== $v = $xml->AuthTokenEnabled[0]) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, + 'AuthTokenLastModifiedDate' => (null !== $v = $xml->AuthTokenLastModifiedDate[0]) ? new \DateTimeImmutable((string) $v) : null, + 'TransitEncryptionEnabled' => (null !== $v = $xml->TransitEncryptionEnabled[0]) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, + 'AtRestEncryptionEnabled' => (null !== $v = $xml->AtRestEncryptionEnabled[0]) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, + 'ARN' => (null !== $v = $xml->ARN[0]) ? (string) $v : null, + 'ReplicationGroupLogDeliveryEnabled' => (null !== $v = $xml->ReplicationGroupLogDeliveryEnabled[0]) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, + 'LogDeliveryConfigurations' => (0 === ($v = $xml->LogDeliveryConfigurations)->count()) ? null : $this->populateResultLogDeliveryConfigurationList($v), + 'NetworkType' => (null !== $v = $xml->NetworkType[0]) ? (string) $v : null, + 'IpDiscovery' => (null !== $v = $xml->IpDiscovery[0]) ? (string) $v : null, + 'TransitEncryptionMode' => (null !== $v = $xml->TransitEncryptionMode[0]) ? (string) $v : null, + ]); } /** @@ -119,65 +158,26 @@ private function populateResultCacheClusterList(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->CacheCluster as $item) { - $items[] = new CacheCluster([ - 'CacheClusterId' => ($v = $item->CacheClusterId) ? (string) $v : null, - 'ConfigurationEndpoint' => !$item->ConfigurationEndpoint ? null : new Endpoint([ - 'Address' => ($v = $item->ConfigurationEndpoint->Address) ? (string) $v : null, - 'Port' => ($v = $item->ConfigurationEndpoint->Port) ? (int) (string) $v : null, - ]), - 'ClientDownloadLandingPage' => ($v = $item->ClientDownloadLandingPage) ? (string) $v : null, - 'CacheNodeType' => ($v = $item->CacheNodeType) ? (string) $v : null, - 'Engine' => ($v = $item->Engine) ? (string) $v : null, - 'EngineVersion' => ($v = $item->EngineVersion) ? (string) $v : null, - 'CacheClusterStatus' => ($v = $item->CacheClusterStatus) ? (string) $v : null, - 'NumCacheNodes' => ($v = $item->NumCacheNodes) ? (int) (string) $v : null, - 'PreferredAvailabilityZone' => ($v = $item->PreferredAvailabilityZone) ? (string) $v : null, - 'PreferredOutpostArn' => ($v = $item->PreferredOutpostArn) ? (string) $v : null, - 'CacheClusterCreateTime' => ($v = $item->CacheClusterCreateTime) ? new \DateTimeImmutable((string) $v) : null, - 'PreferredMaintenanceWindow' => ($v = $item->PreferredMaintenanceWindow) ? (string) $v : null, - 'PendingModifiedValues' => !$item->PendingModifiedValues ? null : new PendingModifiedValues([ - 'NumCacheNodes' => ($v = $item->PendingModifiedValues->NumCacheNodes) ? (int) (string) $v : null, - 'CacheNodeIdsToRemove' => !$item->PendingModifiedValues->CacheNodeIdsToRemove ? null : $this->populateResultCacheNodeIdsList($item->PendingModifiedValues->CacheNodeIdsToRemove), - 'EngineVersion' => ($v = $item->PendingModifiedValues->EngineVersion) ? (string) $v : null, - 'CacheNodeType' => ($v = $item->PendingModifiedValues->CacheNodeType) ? (string) $v : null, - 'AuthTokenStatus' => ($v = $item->PendingModifiedValues->AuthTokenStatus) ? (string) $v : null, - 'LogDeliveryConfigurations' => !$item->PendingModifiedValues->LogDeliveryConfigurations ? null : $this->populateResultPendingLogDeliveryConfigurationList($item->PendingModifiedValues->LogDeliveryConfigurations), - 'TransitEncryptionEnabled' => ($v = $item->PendingModifiedValues->TransitEncryptionEnabled) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, - 'TransitEncryptionMode' => ($v = $item->PendingModifiedValues->TransitEncryptionMode) ? (string) $v : null, - ]), - 'NotificationConfiguration' => !$item->NotificationConfiguration ? null : new NotificationConfiguration([ - 'TopicArn' => ($v = $item->NotificationConfiguration->TopicArn) ? (string) $v : null, - 'TopicStatus' => ($v = $item->NotificationConfiguration->TopicStatus) ? (string) $v : null, - ]), - 'CacheSecurityGroups' => !$item->CacheSecurityGroups ? null : $this->populateResultCacheSecurityGroupMembershipList($item->CacheSecurityGroups), - 'CacheParameterGroup' => !$item->CacheParameterGroup ? null : new CacheParameterGroupStatus([ - 'CacheParameterGroupName' => ($v = $item->CacheParameterGroup->CacheParameterGroupName) ? (string) $v : null, - 'ParameterApplyStatus' => ($v = $item->CacheParameterGroup->ParameterApplyStatus) ? (string) $v : null, - 'CacheNodeIdsToReboot' => !$item->CacheParameterGroup->CacheNodeIdsToReboot ? null : $this->populateResultCacheNodeIdsList($item->CacheParameterGroup->CacheNodeIdsToReboot), - ]), - 'CacheSubnetGroupName' => ($v = $item->CacheSubnetGroupName) ? (string) $v : null, - 'CacheNodes' => !$item->CacheNodes ? null : $this->populateResultCacheNodeList($item->CacheNodes), - 'AutoMinorVersionUpgrade' => ($v = $item->AutoMinorVersionUpgrade) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, - 'SecurityGroups' => !$item->SecurityGroups ? null : $this->populateResultSecurityGroupMembershipList($item->SecurityGroups), - 'ReplicationGroupId' => ($v = $item->ReplicationGroupId) ? (string) $v : null, - 'SnapshotRetentionLimit' => ($v = $item->SnapshotRetentionLimit) ? (int) (string) $v : null, - 'SnapshotWindow' => ($v = $item->SnapshotWindow) ? (string) $v : null, - 'AuthTokenEnabled' => ($v = $item->AuthTokenEnabled) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, - 'AuthTokenLastModifiedDate' => ($v = $item->AuthTokenLastModifiedDate) ? new \DateTimeImmutable((string) $v) : null, - 'TransitEncryptionEnabled' => ($v = $item->TransitEncryptionEnabled) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, - 'AtRestEncryptionEnabled' => ($v = $item->AtRestEncryptionEnabled) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, - 'ARN' => ($v = $item->ARN) ? (string) $v : null, - 'ReplicationGroupLogDeliveryEnabled' => ($v = $item->ReplicationGroupLogDeliveryEnabled) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, - 'LogDeliveryConfigurations' => !$item->LogDeliveryConfigurations ? null : $this->populateResultLogDeliveryConfigurationList($item->LogDeliveryConfigurations), - 'NetworkType' => ($v = $item->NetworkType) ? (string) $v : null, - 'IpDiscovery' => ($v = $item->IpDiscovery) ? (string) $v : null, - 'TransitEncryptionMode' => ($v = $item->TransitEncryptionMode) ? (string) $v : null, - ]); + $items[] = $this->populateResultCacheCluster($item); } return $items; } + private function populateResultCacheNode(\SimpleXMLElement $xml): CacheNode + { + return new CacheNode([ + 'CacheNodeId' => (null !== $v = $xml->CacheNodeId[0]) ? (string) $v : null, + 'CacheNodeStatus' => (null !== $v = $xml->CacheNodeStatus[0]) ? (string) $v : null, + 'CacheNodeCreateTime' => (null !== $v = $xml->CacheNodeCreateTime[0]) ? new \DateTimeImmutable((string) $v) : null, + 'Endpoint' => 0 === $xml->Endpoint->count() ? null : $this->populateResultEndpoint($xml->Endpoint), + 'ParameterGroupStatus' => (null !== $v = $xml->ParameterGroupStatus[0]) ? (string) $v : null, + 'SourceCacheNodeId' => (null !== $v = $xml->SourceCacheNodeId[0]) ? (string) $v : null, + 'CustomerAvailabilityZone' => (null !== $v = $xml->CustomerAvailabilityZone[0]) ? (string) $v : null, + 'CustomerOutpostArn' => (null !== $v = $xml->CustomerOutpostArn[0]) ? (string) $v : null, + ]); + } + /** * @return string[] */ @@ -185,10 +185,7 @@ private function populateResultCacheNodeIdsList(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->CacheNodeId as $item) { - $a = ($v = $item) ? (string) $v : null; - if (null !== $a) { - $items[] = $a; - } + $items[] = (string) $item; } return $items; @@ -201,24 +198,29 @@ private function populateResultCacheNodeList(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->CacheNode as $item) { - $items[] = new CacheNode([ - 'CacheNodeId' => ($v = $item->CacheNodeId) ? (string) $v : null, - 'CacheNodeStatus' => ($v = $item->CacheNodeStatus) ? (string) $v : null, - 'CacheNodeCreateTime' => ($v = $item->CacheNodeCreateTime) ? new \DateTimeImmutable((string) $v) : null, - 'Endpoint' => !$item->Endpoint ? null : new Endpoint([ - 'Address' => ($v = $item->Endpoint->Address) ? (string) $v : null, - 'Port' => ($v = $item->Endpoint->Port) ? (int) (string) $v : null, - ]), - 'ParameterGroupStatus' => ($v = $item->ParameterGroupStatus) ? (string) $v : null, - 'SourceCacheNodeId' => ($v = $item->SourceCacheNodeId) ? (string) $v : null, - 'CustomerAvailabilityZone' => ($v = $item->CustomerAvailabilityZone) ? (string) $v : null, - 'CustomerOutpostArn' => ($v = $item->CustomerOutpostArn) ? (string) $v : null, - ]); + $items[] = $this->populateResultCacheNode($item); } return $items; } + private function populateResultCacheParameterGroupStatus(\SimpleXMLElement $xml): CacheParameterGroupStatus + { + return new CacheParameterGroupStatus([ + 'CacheParameterGroupName' => (null !== $v = $xml->CacheParameterGroupName[0]) ? (string) $v : null, + 'ParameterApplyStatus' => (null !== $v = $xml->ParameterApplyStatus[0]) ? (string) $v : null, + 'CacheNodeIdsToReboot' => (0 === ($v = $xml->CacheNodeIdsToReboot)->count()) ? null : $this->populateResultCacheNodeIdsList($v), + ]); + } + + private function populateResultCacheSecurityGroupMembership(\SimpleXMLElement $xml): CacheSecurityGroupMembership + { + return new CacheSecurityGroupMembership([ + 'CacheSecurityGroupName' => (null !== $v = $xml->CacheSecurityGroupName[0]) ? (string) $v : null, + 'Status' => (null !== $v = $xml->Status[0]) ? (string) $v : null, + ]); + } + /** * @return CacheSecurityGroupMembership[] */ @@ -226,15 +228,54 @@ private function populateResultCacheSecurityGroupMembershipList(\SimpleXMLElemen { $items = []; foreach ($xml->CacheSecurityGroup as $item) { - $items[] = new CacheSecurityGroupMembership([ - 'CacheSecurityGroupName' => ($v = $item->CacheSecurityGroupName) ? (string) $v : null, - 'Status' => ($v = $item->Status) ? (string) $v : null, - ]); + $items[] = $this->populateResultCacheSecurityGroupMembership($item); } return $items; } + private function populateResultCloudWatchLogsDestinationDetails(\SimpleXMLElement $xml): CloudWatchLogsDestinationDetails + { + return new CloudWatchLogsDestinationDetails([ + 'LogGroup' => (null !== $v = $xml->LogGroup[0]) ? (string) $v : null, + ]); + } + + private function populateResultDestinationDetails(\SimpleXMLElement $xml): DestinationDetails + { + return new DestinationDetails([ + 'CloudWatchLogsDetails' => 0 === $xml->CloudWatchLogsDetails->count() ? null : $this->populateResultCloudWatchLogsDestinationDetails($xml->CloudWatchLogsDetails), + 'KinesisFirehoseDetails' => 0 === $xml->KinesisFirehoseDetails->count() ? null : $this->populateResultKinesisFirehoseDestinationDetails($xml->KinesisFirehoseDetails), + ]); + } + + private function populateResultEndpoint(\SimpleXMLElement $xml): Endpoint + { + return new Endpoint([ + 'Address' => (null !== $v = $xml->Address[0]) ? (string) $v : null, + 'Port' => (null !== $v = $xml->Port[0]) ? (int) (string) $v : null, + ]); + } + + private function populateResultKinesisFirehoseDestinationDetails(\SimpleXMLElement $xml): KinesisFirehoseDestinationDetails + { + return new KinesisFirehoseDestinationDetails([ + 'DeliveryStream' => (null !== $v = $xml->DeliveryStream[0]) ? (string) $v : null, + ]); + } + + private function populateResultLogDeliveryConfiguration(\SimpleXMLElement $xml): LogDeliveryConfiguration + { + return new LogDeliveryConfiguration([ + 'LogType' => (null !== $v = $xml->LogType[0]) ? (string) $v : null, + 'DestinationType' => (null !== $v = $xml->DestinationType[0]) ? (string) $v : null, + 'DestinationDetails' => 0 === $xml->DestinationDetails->count() ? null : $this->populateResultDestinationDetails($xml->DestinationDetails), + 'LogFormat' => (null !== $v = $xml->LogFormat[0]) ? (string) $v : null, + 'Status' => (null !== $v = $xml->Status[0]) ? (string) $v : null, + 'Message' => (null !== $v = $xml->Message[0]) ? (string) $v : null, + ]); + } + /** * @return LogDeliveryConfiguration[] */ @@ -242,26 +283,30 @@ private function populateResultLogDeliveryConfigurationList(\SimpleXMLElement $x { $items = []; foreach ($xml->LogDeliveryConfiguration as $item) { - $items[] = new LogDeliveryConfiguration([ - 'LogType' => ($v = $item->LogType) ? (string) $v : null, - 'DestinationType' => ($v = $item->DestinationType) ? (string) $v : null, - 'DestinationDetails' => !$item->DestinationDetails ? null : new DestinationDetails([ - 'CloudWatchLogsDetails' => !$item->DestinationDetails->CloudWatchLogsDetails ? null : new CloudWatchLogsDestinationDetails([ - 'LogGroup' => ($v = $item->DestinationDetails->CloudWatchLogsDetails->LogGroup) ? (string) $v : null, - ]), - 'KinesisFirehoseDetails' => !$item->DestinationDetails->KinesisFirehoseDetails ? null : new KinesisFirehoseDestinationDetails([ - 'DeliveryStream' => ($v = $item->DestinationDetails->KinesisFirehoseDetails->DeliveryStream) ? (string) $v : null, - ]), - ]), - 'LogFormat' => ($v = $item->LogFormat) ? (string) $v : null, - 'Status' => ($v = $item->Status) ? (string) $v : null, - 'Message' => ($v = $item->Message) ? (string) $v : null, - ]); + $items[] = $this->populateResultLogDeliveryConfiguration($item); } return $items; } + private function populateResultNotificationConfiguration(\SimpleXMLElement $xml): NotificationConfiguration + { + return new NotificationConfiguration([ + 'TopicArn' => (null !== $v = $xml->TopicArn[0]) ? (string) $v : null, + 'TopicStatus' => (null !== $v = $xml->TopicStatus[0]) ? (string) $v : null, + ]); + } + + private function populateResultPendingLogDeliveryConfiguration(\SimpleXMLElement $xml): PendingLogDeliveryConfiguration + { + return new PendingLogDeliveryConfiguration([ + 'LogType' => (null !== $v = $xml->LogType[0]) ? (string) $v : null, + 'DestinationType' => (null !== $v = $xml->DestinationType[0]) ? (string) $v : null, + 'DestinationDetails' => 0 === $xml->DestinationDetails->count() ? null : $this->populateResultDestinationDetails($xml->DestinationDetails), + 'LogFormat' => (null !== $v = $xml->LogFormat[0]) ? (string) $v : null, + ]); + } + /** * @return PendingLogDeliveryConfiguration[] */ @@ -269,24 +314,34 @@ private function populateResultPendingLogDeliveryConfigurationList(\SimpleXMLEle { $items = []; foreach ($xml->member as $item) { - $items[] = new PendingLogDeliveryConfiguration([ - 'LogType' => ($v = $item->LogType) ? (string) $v : null, - 'DestinationType' => ($v = $item->DestinationType) ? (string) $v : null, - 'DestinationDetails' => !$item->DestinationDetails ? null : new DestinationDetails([ - 'CloudWatchLogsDetails' => !$item->DestinationDetails->CloudWatchLogsDetails ? null : new CloudWatchLogsDestinationDetails([ - 'LogGroup' => ($v = $item->DestinationDetails->CloudWatchLogsDetails->LogGroup) ? (string) $v : null, - ]), - 'KinesisFirehoseDetails' => !$item->DestinationDetails->KinesisFirehoseDetails ? null : new KinesisFirehoseDestinationDetails([ - 'DeliveryStream' => ($v = $item->DestinationDetails->KinesisFirehoseDetails->DeliveryStream) ? (string) $v : null, - ]), - ]), - 'LogFormat' => ($v = $item->LogFormat) ? (string) $v : null, - ]); + $items[] = $this->populateResultPendingLogDeliveryConfiguration($item); } return $items; } + private function populateResultPendingModifiedValues(\SimpleXMLElement $xml): PendingModifiedValues + { + return new PendingModifiedValues([ + 'NumCacheNodes' => (null !== $v = $xml->NumCacheNodes[0]) ? (int) (string) $v : null, + 'CacheNodeIdsToRemove' => (0 === ($v = $xml->CacheNodeIdsToRemove)->count()) ? null : $this->populateResultCacheNodeIdsList($v), + 'EngineVersion' => (null !== $v = $xml->EngineVersion[0]) ? (string) $v : null, + 'CacheNodeType' => (null !== $v = $xml->CacheNodeType[0]) ? (string) $v : null, + 'AuthTokenStatus' => (null !== $v = $xml->AuthTokenStatus[0]) ? (string) $v : null, + 'LogDeliveryConfigurations' => (0 === ($v = $xml->LogDeliveryConfigurations)->count()) ? null : $this->populateResultPendingLogDeliveryConfigurationList($v), + 'TransitEncryptionEnabled' => (null !== $v = $xml->TransitEncryptionEnabled[0]) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, + 'TransitEncryptionMode' => (null !== $v = $xml->TransitEncryptionMode[0]) ? (string) $v : null, + ]); + } + + private function populateResultSecurityGroupMembership(\SimpleXMLElement $xml): SecurityGroupMembership + { + return new SecurityGroupMembership([ + 'SecurityGroupId' => (null !== $v = $xml->SecurityGroupId[0]) ? (string) $v : null, + 'Status' => (null !== $v = $xml->Status[0]) ? (string) $v : null, + ]); + } + /** * @return SecurityGroupMembership[] */ @@ -294,10 +349,7 @@ private function populateResultSecurityGroupMembershipList(\SimpleXMLElement $xm { $items = []; foreach ($xml->member as $item) { - $items[] = new SecurityGroupMembership([ - 'SecurityGroupId' => ($v = $item->SecurityGroupId) ? (string) $v : null, - 'Status' => ($v = $item->Status) ? (string) $v : null, - ]); + $items[] = $this->populateResultSecurityGroupMembership($item); } return $items; diff --git a/src/Service/Iam/CHANGELOG.md b/src/Service/Iam/CHANGELOG.md index de8c467a5..a5d1725a5 100644 --- a/src/Service/Iam/CHANGELOG.md +++ b/src/Service/Iam/CHANGELOG.md @@ -2,6 +2,10 @@ ## NOT RELEASED +### Changed + +- use strict comparison `null !==` instead of `!` + ## 1.5.3 ### Changed diff --git a/src/Service/Iam/src/Result/CreateAccessKeyResponse.php b/src/Service/Iam/src/Result/CreateAccessKeyResponse.php index 2fbe86686..3195bf07b 100644 --- a/src/Service/Iam/src/Result/CreateAccessKeyResponse.php +++ b/src/Service/Iam/src/Result/CreateAccessKeyResponse.php @@ -30,12 +30,17 @@ protected function populateResult(Response $response): void $data = new \SimpleXMLElement($response->getContent()); $data = $data->CreateAccessKeyResult; - $this->accessKey = new AccessKey([ - 'UserName' => (string) $data->AccessKey->UserName, - 'AccessKeyId' => (string) $data->AccessKey->AccessKeyId, - 'Status' => (string) $data->AccessKey->Status, - 'SecretAccessKey' => (string) $data->AccessKey->SecretAccessKey, - 'CreateDate' => ($v = $data->AccessKey->CreateDate) ? new \DateTimeImmutable((string) $v) : null, + $this->accessKey = $this->populateResultAccessKey($data->AccessKey); + } + + private function populateResultAccessKey(\SimpleXMLElement $xml): AccessKey + { + return new AccessKey([ + 'UserName' => (string) $xml->UserName, + 'AccessKeyId' => (string) $xml->AccessKeyId, + 'Status' => (string) $xml->Status, + 'SecretAccessKey' => (string) $xml->SecretAccessKey, + 'CreateDate' => (null !== $v = $xml->CreateDate[0]) ? new \DateTimeImmutable((string) $v) : null, ]); } } diff --git a/src/Service/Iam/src/Result/CreateServiceSpecificCredentialResponse.php b/src/Service/Iam/src/Result/CreateServiceSpecificCredentialResponse.php index 9663f6a5a..4390623ae 100644 --- a/src/Service/Iam/src/Result/CreateServiceSpecificCredentialResponse.php +++ b/src/Service/Iam/src/Result/CreateServiceSpecificCredentialResponse.php @@ -30,14 +30,19 @@ protected function populateResult(Response $response): void $data = new \SimpleXMLElement($response->getContent()); $data = $data->CreateServiceSpecificCredentialResult; - $this->serviceSpecificCredential = !$data->ServiceSpecificCredential ? null : new ServiceSpecificCredential([ - 'CreateDate' => new \DateTimeImmutable((string) $data->ServiceSpecificCredential->CreateDate), - 'ServiceName' => (string) $data->ServiceSpecificCredential->ServiceName, - 'ServiceUserName' => (string) $data->ServiceSpecificCredential->ServiceUserName, - 'ServicePassword' => (string) $data->ServiceSpecificCredential->ServicePassword, - 'ServiceSpecificCredentialId' => (string) $data->ServiceSpecificCredential->ServiceSpecificCredentialId, - 'UserName' => (string) $data->ServiceSpecificCredential->UserName, - 'Status' => (string) $data->ServiceSpecificCredential->Status, + $this->serviceSpecificCredential = 0 === $data->ServiceSpecificCredential->count() ? null : $this->populateResultServiceSpecificCredential($data->ServiceSpecificCredential); + } + + private function populateResultServiceSpecificCredential(\SimpleXMLElement $xml): ServiceSpecificCredential + { + return new ServiceSpecificCredential([ + 'CreateDate' => new \DateTimeImmutable((string) $xml->CreateDate), + 'ServiceName' => (string) $xml->ServiceName, + 'ServiceUserName' => (string) $xml->ServiceUserName, + 'ServicePassword' => (string) $xml->ServicePassword, + 'ServiceSpecificCredentialId' => (string) $xml->ServiceSpecificCredentialId, + 'UserName' => (string) $xml->UserName, + 'Status' => (string) $xml->Status, ]); } } diff --git a/src/Service/Iam/src/Result/CreateUserResponse.php b/src/Service/Iam/src/Result/CreateUserResponse.php index d2e69a1ed..828657494 100644 --- a/src/Service/Iam/src/Result/CreateUserResponse.php +++ b/src/Service/Iam/src/Result/CreateUserResponse.php @@ -32,18 +32,22 @@ protected function populateResult(Response $response): void $data = new \SimpleXMLElement($response->getContent()); $data = $data->CreateUserResult; - $this->user = !$data->User ? null : new User([ - 'Path' => (string) $data->User->Path, - 'UserName' => (string) $data->User->UserName, - 'UserId' => (string) $data->User->UserId, - 'Arn' => (string) $data->User->Arn, - 'CreateDate' => new \DateTimeImmutable((string) $data->User->CreateDate), - 'PasswordLastUsed' => ($v = $data->User->PasswordLastUsed) ? new \DateTimeImmutable((string) $v) : null, - 'PermissionsBoundary' => !$data->User->PermissionsBoundary ? null : new AttachedPermissionsBoundary([ - 'PermissionsBoundaryType' => ($v = $data->User->PermissionsBoundary->PermissionsBoundaryType) ? (string) $v : null, - 'PermissionsBoundaryArn' => ($v = $data->User->PermissionsBoundary->PermissionsBoundaryArn) ? (string) $v : null, - ]), - 'Tags' => !$data->User->Tags ? null : $this->populateResultTagListType($data->User->Tags), + $this->user = 0 === $data->User->count() ? null : $this->populateResultUser($data->User); + } + + private function populateResultAttachedPermissionsBoundary(\SimpleXMLElement $xml): AttachedPermissionsBoundary + { + return new AttachedPermissionsBoundary([ + 'PermissionsBoundaryType' => (null !== $v = $xml->PermissionsBoundaryType[0]) ? (string) $v : null, + 'PermissionsBoundaryArn' => (null !== $v = $xml->PermissionsBoundaryArn[0]) ? (string) $v : null, + ]); + } + + private function populateResultTag(\SimpleXMLElement $xml): Tag + { + return new Tag([ + 'Key' => (string) $xml->Key, + 'Value' => (string) $xml->Value, ]); } @@ -54,12 +58,23 @@ private function populateResultTagListType(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->member as $item) { - $items[] = new Tag([ - 'Key' => (string) $item->Key, - 'Value' => (string) $item->Value, - ]); + $items[] = $this->populateResultTag($item); } return $items; } + + private function populateResultUser(\SimpleXMLElement $xml): User + { + return new User([ + 'Path' => (string) $xml->Path, + 'UserName' => (string) $xml->UserName, + 'UserId' => (string) $xml->UserId, + 'Arn' => (string) $xml->Arn, + 'CreateDate' => new \DateTimeImmutable((string) $xml->CreateDate), + 'PasswordLastUsed' => (null !== $v = $xml->PasswordLastUsed[0]) ? new \DateTimeImmutable((string) $v) : null, + 'PermissionsBoundary' => 0 === $xml->PermissionsBoundary->count() ? null : $this->populateResultAttachedPermissionsBoundary($xml->PermissionsBoundary), + 'Tags' => (0 === ($v = $xml->Tags)->count()) ? null : $this->populateResultTagListType($v), + ]); + } } diff --git a/src/Service/Iam/src/Result/GetUserResponse.php b/src/Service/Iam/src/Result/GetUserResponse.php index dc1ace41a..60b0eb5f6 100644 --- a/src/Service/Iam/src/Result/GetUserResponse.php +++ b/src/Service/Iam/src/Result/GetUserResponse.php @@ -47,18 +47,22 @@ protected function populateResult(Response $response): void $data = new \SimpleXMLElement($response->getContent()); $data = $data->GetUserResult; - $this->user = new User([ - 'Path' => (string) $data->User->Path, - 'UserName' => (string) $data->User->UserName, - 'UserId' => (string) $data->User->UserId, - 'Arn' => (string) $data->User->Arn, - 'CreateDate' => new \DateTimeImmutable((string) $data->User->CreateDate), - 'PasswordLastUsed' => ($v = $data->User->PasswordLastUsed) ? new \DateTimeImmutable((string) $v) : null, - 'PermissionsBoundary' => !$data->User->PermissionsBoundary ? null : new AttachedPermissionsBoundary([ - 'PermissionsBoundaryType' => ($v = $data->User->PermissionsBoundary->PermissionsBoundaryType) ? (string) $v : null, - 'PermissionsBoundaryArn' => ($v = $data->User->PermissionsBoundary->PermissionsBoundaryArn) ? (string) $v : null, - ]), - 'Tags' => !$data->User->Tags ? null : $this->populateResultTagListType($data->User->Tags), + $this->user = $this->populateResultUser($data->User); + } + + private function populateResultAttachedPermissionsBoundary(\SimpleXMLElement $xml): AttachedPermissionsBoundary + { + return new AttachedPermissionsBoundary([ + 'PermissionsBoundaryType' => (null !== $v = $xml->PermissionsBoundaryType[0]) ? (string) $v : null, + 'PermissionsBoundaryArn' => (null !== $v = $xml->PermissionsBoundaryArn[0]) ? (string) $v : null, + ]); + } + + private function populateResultTag(\SimpleXMLElement $xml): Tag + { + return new Tag([ + 'Key' => (string) $xml->Key, + 'Value' => (string) $xml->Value, ]); } @@ -69,12 +73,23 @@ private function populateResultTagListType(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->member as $item) { - $items[] = new Tag([ - 'Key' => (string) $item->Key, - 'Value' => (string) $item->Value, - ]); + $items[] = $this->populateResultTag($item); } return $items; } + + private function populateResultUser(\SimpleXMLElement $xml): User + { + return new User([ + 'Path' => (string) $xml->Path, + 'UserName' => (string) $xml->UserName, + 'UserId' => (string) $xml->UserId, + 'Arn' => (string) $xml->Arn, + 'CreateDate' => new \DateTimeImmutable((string) $xml->CreateDate), + 'PasswordLastUsed' => (null !== $v = $xml->PasswordLastUsed[0]) ? new \DateTimeImmutable((string) $v) : null, + 'PermissionsBoundary' => 0 === $xml->PermissionsBoundary->count() ? null : $this->populateResultAttachedPermissionsBoundary($xml->PermissionsBoundary), + 'Tags' => (0 === ($v = $xml->Tags)->count()) ? null : $this->populateResultTagListType($v), + ]); + } } diff --git a/src/Service/Iam/src/Result/ListServiceSpecificCredentialsResponse.php b/src/Service/Iam/src/Result/ListServiceSpecificCredentialsResponse.php index d9e1f7e2f..311cc8c04 100644 --- a/src/Service/Iam/src/Result/ListServiceSpecificCredentialsResponse.php +++ b/src/Service/Iam/src/Result/ListServiceSpecificCredentialsResponse.php @@ -30,7 +30,19 @@ protected function populateResult(Response $response): void $data = new \SimpleXMLElement($response->getContent()); $data = $data->ListServiceSpecificCredentialsResult; - $this->serviceSpecificCredentials = !$data->ServiceSpecificCredentials ? [] : $this->populateResultServiceSpecificCredentialsListType($data->ServiceSpecificCredentials); + $this->serviceSpecificCredentials = (0 === ($v = $data->ServiceSpecificCredentials)->count()) ? [] : $this->populateResultServiceSpecificCredentialsListType($v); + } + + private function populateResultServiceSpecificCredentialMetadata(\SimpleXMLElement $xml): ServiceSpecificCredentialMetadata + { + return new ServiceSpecificCredentialMetadata([ + 'UserName' => (string) $xml->UserName, + 'Status' => (string) $xml->Status, + 'ServiceUserName' => (string) $xml->ServiceUserName, + 'CreateDate' => new \DateTimeImmutable((string) $xml->CreateDate), + 'ServiceSpecificCredentialId' => (string) $xml->ServiceSpecificCredentialId, + 'ServiceName' => (string) $xml->ServiceName, + ]); } /** @@ -40,14 +52,7 @@ private function populateResultServiceSpecificCredentialsListType(\SimpleXMLElem { $items = []; foreach ($xml->member as $item) { - $items[] = new ServiceSpecificCredentialMetadata([ - 'UserName' => (string) $item->UserName, - 'Status' => (string) $item->Status, - 'ServiceUserName' => (string) $item->ServiceUserName, - 'CreateDate' => new \DateTimeImmutable((string) $item->CreateDate), - 'ServiceSpecificCredentialId' => (string) $item->ServiceSpecificCredentialId, - 'ServiceName' => (string) $item->ServiceName, - ]); + $items[] = $this->populateResultServiceSpecificCredentialMetadata($item); } return $items; diff --git a/src/Service/Iam/src/Result/ListUsersResponse.php b/src/Service/Iam/src/Result/ListUsersResponse.php index bcbbf61b9..8d2c14ace 100644 --- a/src/Service/Iam/src/Result/ListUsersResponse.php +++ b/src/Service/Iam/src/Result/ListUsersResponse.php @@ -117,8 +117,24 @@ protected function populateResult(Response $response): void $data = $data->ListUsersResult; $this->users = $this->populateResultUserListType($data->Users); - $this->isTruncated = ($v = $data->IsTruncated) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null; - $this->marker = ($v = $data->Marker) ? (string) $v : null; + $this->isTruncated = (null !== $v = $data->IsTruncated[0]) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null; + $this->marker = (null !== $v = $data->Marker[0]) ? (string) $v : null; + } + + private function populateResultAttachedPermissionsBoundary(\SimpleXMLElement $xml): AttachedPermissionsBoundary + { + return new AttachedPermissionsBoundary([ + 'PermissionsBoundaryType' => (null !== $v = $xml->PermissionsBoundaryType[0]) ? (string) $v : null, + 'PermissionsBoundaryArn' => (null !== $v = $xml->PermissionsBoundaryArn[0]) ? (string) $v : null, + ]); + } + + private function populateResultTag(\SimpleXMLElement $xml): Tag + { + return new Tag([ + 'Key' => (string) $xml->Key, + 'Value' => (string) $xml->Value, + ]); } /** @@ -128,15 +144,26 @@ private function populateResultTagListType(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->member as $item) { - $items[] = new Tag([ - 'Key' => (string) $item->Key, - 'Value' => (string) $item->Value, - ]); + $items[] = $this->populateResultTag($item); } return $items; } + private function populateResultUser(\SimpleXMLElement $xml): User + { + return new User([ + 'Path' => (string) $xml->Path, + 'UserName' => (string) $xml->UserName, + 'UserId' => (string) $xml->UserId, + 'Arn' => (string) $xml->Arn, + 'CreateDate' => new \DateTimeImmutable((string) $xml->CreateDate), + 'PasswordLastUsed' => (null !== $v = $xml->PasswordLastUsed[0]) ? new \DateTimeImmutable((string) $v) : null, + 'PermissionsBoundary' => 0 === $xml->PermissionsBoundary->count() ? null : $this->populateResultAttachedPermissionsBoundary($xml->PermissionsBoundary), + 'Tags' => (0 === ($v = $xml->Tags)->count()) ? null : $this->populateResultTagListType($v), + ]); + } + /** * @return User[] */ @@ -144,19 +171,7 @@ private function populateResultUserListType(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->member as $item) { - $items[] = new User([ - 'Path' => (string) $item->Path, - 'UserName' => (string) $item->UserName, - 'UserId' => (string) $item->UserId, - 'Arn' => (string) $item->Arn, - 'CreateDate' => new \DateTimeImmutable((string) $item->CreateDate), - 'PasswordLastUsed' => ($v = $item->PasswordLastUsed) ? new \DateTimeImmutable((string) $v) : null, - 'PermissionsBoundary' => !$item->PermissionsBoundary ? null : new AttachedPermissionsBoundary([ - 'PermissionsBoundaryType' => ($v = $item->PermissionsBoundary->PermissionsBoundaryType) ? (string) $v : null, - 'PermissionsBoundaryArn' => ($v = $item->PermissionsBoundary->PermissionsBoundaryArn) ? (string) $v : null, - ]), - 'Tags' => !$item->Tags ? null : $this->populateResultTagListType($item->Tags), - ]); + $items[] = $this->populateResultUser($item); } return $items; diff --git a/src/Service/Iot/CHANGELOG.md b/src/Service/Iot/CHANGELOG.md index 3b97f9e06..a7b28070a 100644 --- a/src/Service/Iot/CHANGELOG.md +++ b/src/Service/Iot/CHANGELOG.md @@ -2,6 +2,10 @@ ## NOT RELEASED +### Changed + +- use strict comparison `null !==` instead of `!` + ## 2.0.4 ### Changed diff --git a/src/Service/Iot/src/Result/ListThingGroupsForThingResponse.php b/src/Service/Iot/src/Result/ListThingGroupsForThingResponse.php index 3b137fb9b..81d7109af 100644 --- a/src/Service/Iot/src/Result/ListThingGroupsForThingResponse.php +++ b/src/Service/Iot/src/Result/ListThingGroupsForThingResponse.php @@ -70,7 +70,7 @@ public function getThingGroups(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->listThingGroupsForThing($input)); diff --git a/src/Service/Iot/src/Result/ListThingGroupsResponse.php b/src/Service/Iot/src/Result/ListThingGroupsResponse.php index 95d7c0fa2..e7a34ecd7 100644 --- a/src/Service/Iot/src/Result/ListThingGroupsResponse.php +++ b/src/Service/Iot/src/Result/ListThingGroupsResponse.php @@ -70,7 +70,7 @@ public function getThingGroups(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->listThingGroups($input)); diff --git a/src/Service/Iot/src/Result/ListThingTypesResponse.php b/src/Service/Iot/src/Result/ListThingTypesResponse.php index c418a0bea..69e662795 100644 --- a/src/Service/Iot/src/Result/ListThingTypesResponse.php +++ b/src/Service/Iot/src/Result/ListThingTypesResponse.php @@ -74,7 +74,7 @@ public function getThingTypes(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->listThingTypes($input)); diff --git a/src/Service/Iot/src/Result/ListThingsInThingGroupResponse.php b/src/Service/Iot/src/Result/ListThingsInThingGroupResponse.php index 14bb3f940..315cd0fc3 100644 --- a/src/Service/Iot/src/Result/ListThingsInThingGroupResponse.php +++ b/src/Service/Iot/src/Result/ListThingsInThingGroupResponse.php @@ -69,7 +69,7 @@ public function getThings(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->listThingsInThingGroup($input)); diff --git a/src/Service/Iot/src/Result/ListThingsResponse.php b/src/Service/Iot/src/Result/ListThingsResponse.php index 254c6ccdc..0363f2385 100644 --- a/src/Service/Iot/src/Result/ListThingsResponse.php +++ b/src/Service/Iot/src/Result/ListThingsResponse.php @@ -72,7 +72,7 @@ public function getThings(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->listThings($input)); diff --git a/src/Service/Kinesis/CHANGELOG.md b/src/Service/Kinesis/CHANGELOG.md index af69c853c..1cb600498 100644 --- a/src/Service/Kinesis/CHANGELOG.md +++ b/src/Service/Kinesis/CHANGELOG.md @@ -2,6 +2,10 @@ ## NOT RELEASED +### Changed + +- use strict comparison `null !==` instead of `!` + ## 3.1.0 ### Added diff --git a/src/Service/Kinesis/src/Result/ListStreamConsumersOutput.php b/src/Service/Kinesis/src/Result/ListStreamConsumersOutput.php index cb31a182c..057348d4e 100644 --- a/src/Service/Kinesis/src/Result/ListStreamConsumersOutput.php +++ b/src/Service/Kinesis/src/Result/ListStreamConsumersOutput.php @@ -62,7 +62,7 @@ public function getConsumers(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->listStreamConsumers($input)); diff --git a/src/Service/Lambda/CHANGELOG.md b/src/Service/Lambda/CHANGELOG.md index 0df1e83a8..34d811ce3 100644 --- a/src/Service/Lambda/CHANGELOG.md +++ b/src/Service/Lambda/CHANGELOG.md @@ -4,6 +4,7 @@ ### Changed +- use strict comparison `null !==` instead of `!` - AWS enhancement: Documentation updates. ## 2.6.0 diff --git a/src/Service/Lambda/src/Result/ListFunctionsResponse.php b/src/Service/Lambda/src/Result/ListFunctionsResponse.php index e13edd1c2..b9d356704 100644 --- a/src/Service/Lambda/src/Result/ListFunctionsResponse.php +++ b/src/Service/Lambda/src/Result/ListFunctionsResponse.php @@ -71,7 +71,7 @@ public function getFunctions(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextMarker) { + if (null !== $page->nextMarker) { $input->setMarker($page->nextMarker); $this->registerPrefetch($nextPage = $client->listFunctions($input)); diff --git a/src/Service/Lambda/src/Result/ListLayerVersionsResponse.php b/src/Service/Lambda/src/Result/ListLayerVersionsResponse.php index 776b927c8..cc77d483d 100644 --- a/src/Service/Lambda/src/Result/ListLayerVersionsResponse.php +++ b/src/Service/Lambda/src/Result/ListLayerVersionsResponse.php @@ -65,7 +65,7 @@ public function getLayerVersions(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextMarker) { + if (null !== $page->nextMarker) { $input->setMarker($page->nextMarker); $this->registerPrefetch($nextPage = $client->listLayerVersions($input)); diff --git a/src/Service/Lambda/src/Result/ListVersionsByFunctionResponse.php b/src/Service/Lambda/src/Result/ListVersionsByFunctionResponse.php index 136da1efa..8fc119f6d 100644 --- a/src/Service/Lambda/src/Result/ListVersionsByFunctionResponse.php +++ b/src/Service/Lambda/src/Result/ListVersionsByFunctionResponse.php @@ -86,7 +86,7 @@ public function getVersions(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextMarker) { + if (null !== $page->nextMarker) { $input->setMarker($page->nextMarker); $this->registerPrefetch($nextPage = $client->listVersionsByFunction($input)); diff --git a/src/Service/MediaConvert/CHANGELOG.md b/src/Service/MediaConvert/CHANGELOG.md index f7cf123a7..fa038c6e6 100644 --- a/src/Service/MediaConvert/CHANGELOG.md +++ b/src/Service/MediaConvert/CHANGELOG.md @@ -2,6 +2,10 @@ ## NOT RELEASED +### Changed + +- use strict comparison `null !==` instead of `!` + ## 1.4.0 ### Added diff --git a/src/Service/MediaConvert/src/Result/DescribeEndpointsResponse.php b/src/Service/MediaConvert/src/Result/DescribeEndpointsResponse.php index a8c0a9266..dd7b0ad2c 100644 --- a/src/Service/MediaConvert/src/Result/DescribeEndpointsResponse.php +++ b/src/Service/MediaConvert/src/Result/DescribeEndpointsResponse.php @@ -55,7 +55,7 @@ public function getEndpoints(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->describeEndpoints($input)); diff --git a/src/Service/MediaConvert/src/Result/ListJobsResponse.php b/src/Service/MediaConvert/src/Result/ListJobsResponse.php index 9806a7c04..c6fada79c 100644 --- a/src/Service/MediaConvert/src/Result/ListJobsResponse.php +++ b/src/Service/MediaConvert/src/Result/ListJobsResponse.php @@ -240,7 +240,7 @@ public function getJobs(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->listJobs($input)); diff --git a/src/Service/Rekognition/CHANGELOG.md b/src/Service/Rekognition/CHANGELOG.md index 5f1d296ae..f43693c47 100644 --- a/src/Service/Rekognition/CHANGELOG.md +++ b/src/Service/Rekognition/CHANGELOG.md @@ -2,6 +2,10 @@ ## NOT RELEASED +### Changed + +- use strict comparison `null !==` instead of `!` + ## 1.3.0 ### Added diff --git a/src/Service/Rekognition/src/Result/ListCollectionsResponse.php b/src/Service/Rekognition/src/Result/ListCollectionsResponse.php index 2a8e21186..7fd673993 100644 --- a/src/Service/Rekognition/src/Result/ListCollectionsResponse.php +++ b/src/Service/Rekognition/src/Result/ListCollectionsResponse.php @@ -62,7 +62,7 @@ public function getCollectionIds(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->listCollections($input)); diff --git a/src/Service/Route53/CHANGELOG.md b/src/Service/Route53/CHANGELOG.md index d64378ce3..19fdc632c 100644 --- a/src/Service/Route53/CHANGELOG.md +++ b/src/Service/Route53/CHANGELOG.md @@ -6,6 +6,10 @@ - AWS api-change: This release adds support for TLSA, SSHFP, SVCB, and HTTPS record types. +### Changed + +- use strict comparison `null !==` instead of `!` + ## 2.4.0 ### Added diff --git a/src/Service/Route53/src/Exception/InvalidChangeBatchException.php b/src/Service/Route53/src/Exception/InvalidChangeBatchException.php index 9ed61070e..7a6da823d 100644 --- a/src/Service/Route53/src/Exception/InvalidChangeBatchException.php +++ b/src/Service/Route53/src/Exception/InvalidChangeBatchException.php @@ -30,7 +30,7 @@ protected function populateResult(ResponseInterface $response): void if (0 < $data->Error->count()) { $data = $data->Error; } - $this->messages = !$data->messages ? [] : $this->populateResultErrorMessages($data->messages); + $this->messages = (0 === ($v = $data->messages)->count()) ? [] : $this->populateResultErrorMessages($v); } /** @@ -40,10 +40,7 @@ private function populateResultErrorMessages(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->Message as $item) { - $a = ($v = $item) ? (string) $v : null; - if (null !== $a) { - $items[] = $a; - } + $items[] = (string) $item; } return $items; diff --git a/src/Service/Route53/src/Result/ChangeResourceRecordSetsResponse.php b/src/Service/Route53/src/Result/ChangeResourceRecordSetsResponse.php index 781b9aa93..5fc780ee2 100644 --- a/src/Service/Route53/src/Result/ChangeResourceRecordSetsResponse.php +++ b/src/Service/Route53/src/Result/ChangeResourceRecordSetsResponse.php @@ -33,11 +33,16 @@ public function getChangeInfo(): ChangeInfo protected function populateResult(Response $response): void { $data = new \SimpleXMLElement($response->getContent()); - $this->changeInfo = new ChangeInfo([ - 'Id' => (string) $data->ChangeInfo->Id, - 'Status' => (string) $data->ChangeInfo->Status, - 'SubmittedAt' => new \DateTimeImmutable((string) $data->ChangeInfo->SubmittedAt), - 'Comment' => ($v = $data->ChangeInfo->Comment) ? (string) $v : null, + $this->changeInfo = $this->populateResultChangeInfo($data->ChangeInfo); + } + + private function populateResultChangeInfo(\SimpleXMLElement $xml): ChangeInfo + { + return new ChangeInfo([ + 'Id' => (string) $xml->Id, + 'Status' => (string) $xml->Status, + 'SubmittedAt' => new \DateTimeImmutable((string) $xml->SubmittedAt), + 'Comment' => (null !== $v = $xml->Comment[0]) ? (string) $v : null, ]); } } diff --git a/src/Service/Route53/src/Result/CreateHostedZoneResponse.php b/src/Service/Route53/src/Result/CreateHostedZoneResponse.php index a3a28c726..d2a118e84 100644 --- a/src/Service/Route53/src/Result/CreateHostedZoneResponse.php +++ b/src/Service/Route53/src/Result/CreateHostedZoneResponse.php @@ -93,34 +93,28 @@ protected function populateResult(Response $response): void $this->location = $headers['location'][0] ?? null; $data = new \SimpleXMLElement($response->getContent()); - $this->hostedZone = new HostedZone([ - 'Id' => (string) $data->HostedZone->Id, - 'Name' => (string) $data->HostedZone->Name, - 'CallerReference' => (string) $data->HostedZone->CallerReference, - 'Config' => !$data->HostedZone->Config ? null : new HostedZoneConfig([ - 'Comment' => ($v = $data->HostedZone->Config->Comment) ? (string) $v : null, - 'PrivateZone' => ($v = $data->HostedZone->Config->PrivateZone) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, - ]), - 'ResourceRecordSetCount' => ($v = $data->HostedZone->ResourceRecordSetCount) ? (int) (string) $v : null, - 'LinkedService' => !$data->HostedZone->LinkedService ? null : new LinkedService([ - 'ServicePrincipal' => ($v = $data->HostedZone->LinkedService->ServicePrincipal) ? (string) $v : null, - 'Description' => ($v = $data->HostedZone->LinkedService->Description) ? (string) $v : null, - ]), - ]); - $this->changeInfo = new ChangeInfo([ - 'Id' => (string) $data->ChangeInfo->Id, - 'Status' => (string) $data->ChangeInfo->Status, - 'SubmittedAt' => new \DateTimeImmutable((string) $data->ChangeInfo->SubmittedAt), - 'Comment' => ($v = $data->ChangeInfo->Comment) ? (string) $v : null, - ]); - $this->delegationSet = new DelegationSet([ - 'Id' => ($v = $data->DelegationSet->Id) ? (string) $v : null, - 'CallerReference' => ($v = $data->DelegationSet->CallerReference) ? (string) $v : null, - 'NameServers' => $this->populateResultDelegationSetNameServers($data->DelegationSet->NameServers), + $this->hostedZone = $this->populateResultHostedZone($data->HostedZone); + $this->changeInfo = $this->populateResultChangeInfo($data->ChangeInfo); + $this->delegationSet = $this->populateResultDelegationSet($data->DelegationSet); + $this->vpc = 0 === $data->VPC->count() ? null : $this->populateResultVPC($data->VPC); + } + + private function populateResultChangeInfo(\SimpleXMLElement $xml): ChangeInfo + { + return new ChangeInfo([ + 'Id' => (string) $xml->Id, + 'Status' => (string) $xml->Status, + 'SubmittedAt' => new \DateTimeImmutable((string) $xml->SubmittedAt), + 'Comment' => (null !== $v = $xml->Comment[0]) ? (string) $v : null, ]); - $this->vpc = !$data->VPC ? null : new VPC([ - 'VPCRegion' => ($v = $data->VPC->VPCRegion) ? (string) $v : null, - 'VPCId' => ($v = $data->VPC->VPCId) ? (string) $v : null, + } + + private function populateResultDelegationSet(\SimpleXMLElement $xml): DelegationSet + { + return new DelegationSet([ + 'Id' => (null !== $v = $xml->Id[0]) ? (string) $v : null, + 'CallerReference' => (null !== $v = $xml->CallerReference[0]) ? (string) $v : null, + 'NameServers' => $this->populateResultDelegationSetNameServers($xml->NameServers), ]); } @@ -131,12 +125,45 @@ private function populateResultDelegationSetNameServers(\SimpleXMLElement $xml): { $items = []; foreach ($xml->NameServer as $item) { - $a = ($v = $item) ? (string) $v : null; - if (null !== $a) { - $items[] = $a; - } + $items[] = (string) $item; } return $items; } + + private function populateResultHostedZone(\SimpleXMLElement $xml): HostedZone + { + return new HostedZone([ + 'Id' => (string) $xml->Id, + 'Name' => (string) $xml->Name, + 'CallerReference' => (string) $xml->CallerReference, + 'Config' => 0 === $xml->Config->count() ? null : $this->populateResultHostedZoneConfig($xml->Config), + 'ResourceRecordSetCount' => (null !== $v = $xml->ResourceRecordSetCount[0]) ? (int) (string) $v : null, + 'LinkedService' => 0 === $xml->LinkedService->count() ? null : $this->populateResultLinkedService($xml->LinkedService), + ]); + } + + private function populateResultHostedZoneConfig(\SimpleXMLElement $xml): HostedZoneConfig + { + return new HostedZoneConfig([ + 'Comment' => (null !== $v = $xml->Comment[0]) ? (string) $v : null, + 'PrivateZone' => (null !== $v = $xml->PrivateZone[0]) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, + ]); + } + + private function populateResultLinkedService(\SimpleXMLElement $xml): LinkedService + { + return new LinkedService([ + 'ServicePrincipal' => (null !== $v = $xml->ServicePrincipal[0]) ? (string) $v : null, + 'Description' => (null !== $v = $xml->Description[0]) ? (string) $v : null, + ]); + } + + private function populateResultVPC(\SimpleXMLElement $xml): VPC + { + return new VPC([ + 'VPCRegion' => (null !== $v = $xml->VPCRegion[0]) ? (string) $v : null, + 'VPCId' => (null !== $v = $xml->VPCId[0]) ? (string) $v : null, + ]); + } } diff --git a/src/Service/Route53/src/Result/DeleteHostedZoneResponse.php b/src/Service/Route53/src/Result/DeleteHostedZoneResponse.php index 84843639b..e310642ac 100644 --- a/src/Service/Route53/src/Result/DeleteHostedZoneResponse.php +++ b/src/Service/Route53/src/Result/DeleteHostedZoneResponse.php @@ -28,11 +28,16 @@ public function getChangeInfo(): ChangeInfo protected function populateResult(Response $response): void { $data = new \SimpleXMLElement($response->getContent()); - $this->changeInfo = new ChangeInfo([ - 'Id' => (string) $data->ChangeInfo->Id, - 'Status' => (string) $data->ChangeInfo->Status, - 'SubmittedAt' => new \DateTimeImmutable((string) $data->ChangeInfo->SubmittedAt), - 'Comment' => ($v = $data->ChangeInfo->Comment) ? (string) $v : null, + $this->changeInfo = $this->populateResultChangeInfo($data->ChangeInfo); + } + + private function populateResultChangeInfo(\SimpleXMLElement $xml): ChangeInfo + { + return new ChangeInfo([ + 'Id' => (string) $xml->Id, + 'Status' => (string) $xml->Status, + 'SubmittedAt' => new \DateTimeImmutable((string) $xml->SubmittedAt), + 'Comment' => (null !== $v = $xml->Comment[0]) ? (string) $v : null, ]); } } diff --git a/src/Service/Route53/src/Result/ListHostedZonesByNameResponse.php b/src/Service/Route53/src/Result/ListHostedZonesByNameResponse.php index 479e04cb8..00804704a 100644 --- a/src/Service/Route53/src/Result/ListHostedZonesByNameResponse.php +++ b/src/Service/Route53/src/Result/ListHostedZonesByNameResponse.php @@ -130,14 +130,34 @@ protected function populateResult(Response $response): void { $data = new \SimpleXMLElement($response->getContent()); $this->hostedZones = $this->populateResultHostedZones($data->HostedZones); - $this->dnsName = ($v = $data->DNSName) ? (string) $v : null; - $this->hostedZoneId = ($v = $data->HostedZoneId) ? (string) $v : null; + $this->dnsName = (null !== $v = $data->DNSName[0]) ? (string) $v : null; + $this->hostedZoneId = (null !== $v = $data->HostedZoneId[0]) ? (string) $v : null; $this->isTruncated = filter_var((string) $data->IsTruncated, \FILTER_VALIDATE_BOOLEAN); - $this->nextDnsName = ($v = $data->NextDNSName) ? (string) $v : null; - $this->nextHostedZoneId = ($v = $data->NextHostedZoneId) ? (string) $v : null; + $this->nextDnsName = (null !== $v = $data->NextDNSName[0]) ? (string) $v : null; + $this->nextHostedZoneId = (null !== $v = $data->NextHostedZoneId[0]) ? (string) $v : null; $this->maxItems = (string) $data->MaxItems; } + private function populateResultHostedZone(\SimpleXMLElement $xml): HostedZone + { + return new HostedZone([ + 'Id' => (string) $xml->Id, + 'Name' => (string) $xml->Name, + 'CallerReference' => (string) $xml->CallerReference, + 'Config' => 0 === $xml->Config->count() ? null : $this->populateResultHostedZoneConfig($xml->Config), + 'ResourceRecordSetCount' => (null !== $v = $xml->ResourceRecordSetCount[0]) ? (int) (string) $v : null, + 'LinkedService' => 0 === $xml->LinkedService->count() ? null : $this->populateResultLinkedService($xml->LinkedService), + ]); + } + + private function populateResultHostedZoneConfig(\SimpleXMLElement $xml): HostedZoneConfig + { + return new HostedZoneConfig([ + 'Comment' => (null !== $v = $xml->Comment[0]) ? (string) $v : null, + 'PrivateZone' => (null !== $v = $xml->PrivateZone[0]) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, + ]); + } + /** * @return HostedZone[] */ @@ -145,22 +165,17 @@ private function populateResultHostedZones(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->HostedZone as $item) { - $items[] = new HostedZone([ - 'Id' => (string) $item->Id, - 'Name' => (string) $item->Name, - 'CallerReference' => (string) $item->CallerReference, - 'Config' => !$item->Config ? null : new HostedZoneConfig([ - 'Comment' => ($v = $item->Config->Comment) ? (string) $v : null, - 'PrivateZone' => ($v = $item->Config->PrivateZone) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, - ]), - 'ResourceRecordSetCount' => ($v = $item->ResourceRecordSetCount) ? (int) (string) $v : null, - 'LinkedService' => !$item->LinkedService ? null : new LinkedService([ - 'ServicePrincipal' => ($v = $item->LinkedService->ServicePrincipal) ? (string) $v : null, - 'Description' => ($v = $item->LinkedService->Description) ? (string) $v : null, - ]), - ]); + $items[] = $this->populateResultHostedZone($item); } return $items; } + + private function populateResultLinkedService(\SimpleXMLElement $xml): LinkedService + { + return new LinkedService([ + 'ServicePrincipal' => (null !== $v = $xml->ServicePrincipal[0]) ? (string) $v : null, + 'Description' => (null !== $v = $xml->Description[0]) ? (string) $v : null, + ]); + } } diff --git a/src/Service/Route53/src/Result/ListHostedZonesResponse.php b/src/Service/Route53/src/Result/ListHostedZonesResponse.php index a76d9642c..3bd4e56b7 100644 --- a/src/Service/Route53/src/Result/ListHostedZonesResponse.php +++ b/src/Service/Route53/src/Result/ListHostedZonesResponse.php @@ -147,10 +147,30 @@ protected function populateResult(Response $response): void $this->hostedZones = $this->populateResultHostedZones($data->HostedZones); $this->marker = (string) $data->Marker; $this->isTruncated = filter_var((string) $data->IsTruncated, \FILTER_VALIDATE_BOOLEAN); - $this->nextMarker = ($v = $data->NextMarker) ? (string) $v : null; + $this->nextMarker = (null !== $v = $data->NextMarker[0]) ? (string) $v : null; $this->maxItems = (string) $data->MaxItems; } + private function populateResultHostedZone(\SimpleXMLElement $xml): HostedZone + { + return new HostedZone([ + 'Id' => (string) $xml->Id, + 'Name' => (string) $xml->Name, + 'CallerReference' => (string) $xml->CallerReference, + 'Config' => 0 === $xml->Config->count() ? null : $this->populateResultHostedZoneConfig($xml->Config), + 'ResourceRecordSetCount' => (null !== $v = $xml->ResourceRecordSetCount[0]) ? (int) (string) $v : null, + 'LinkedService' => 0 === $xml->LinkedService->count() ? null : $this->populateResultLinkedService($xml->LinkedService), + ]); + } + + private function populateResultHostedZoneConfig(\SimpleXMLElement $xml): HostedZoneConfig + { + return new HostedZoneConfig([ + 'Comment' => (null !== $v = $xml->Comment[0]) ? (string) $v : null, + 'PrivateZone' => (null !== $v = $xml->PrivateZone[0]) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, + ]); + } + /** * @return HostedZone[] */ @@ -158,22 +178,17 @@ private function populateResultHostedZones(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->HostedZone as $item) { - $items[] = new HostedZone([ - 'Id' => (string) $item->Id, - 'Name' => (string) $item->Name, - 'CallerReference' => (string) $item->CallerReference, - 'Config' => !$item->Config ? null : new HostedZoneConfig([ - 'Comment' => ($v = $item->Config->Comment) ? (string) $v : null, - 'PrivateZone' => ($v = $item->Config->PrivateZone) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, - ]), - 'ResourceRecordSetCount' => ($v = $item->ResourceRecordSetCount) ? (int) (string) $v : null, - 'LinkedService' => !$item->LinkedService ? null : new LinkedService([ - 'ServicePrincipal' => ($v = $item->LinkedService->ServicePrincipal) ? (string) $v : null, - 'Description' => ($v = $item->LinkedService->Description) ? (string) $v : null, - ]), - ]); + $items[] = $this->populateResultHostedZone($item); } return $items; } + + private function populateResultLinkedService(\SimpleXMLElement $xml): LinkedService + { + return new LinkedService([ + 'ServicePrincipal' => (null !== $v = $xml->ServicePrincipal[0]) ? (string) $v : null, + 'Description' => (null !== $v = $xml->Description[0]) ? (string) $v : null, + ]); + } } diff --git a/src/Service/Route53/src/Result/ListResourceRecordSetsResponse.php b/src/Service/Route53/src/Result/ListResourceRecordSetsResponse.php index a65130ac8..23987ddb4 100644 --- a/src/Service/Route53/src/Result/ListResourceRecordSetsResponse.php +++ b/src/Service/Route53/src/Result/ListResourceRecordSetsResponse.php @@ -176,12 +176,84 @@ protected function populateResult(Response $response): void $data = new \SimpleXMLElement($response->getContent()); $this->resourceRecordSets = $this->populateResultResourceRecordSets($data->ResourceRecordSets); $this->isTruncated = filter_var((string) $data->IsTruncated, \FILTER_VALIDATE_BOOLEAN); - $this->nextRecordName = ($v = $data->NextRecordName) ? (string) $v : null; - $this->nextRecordType = ($v = $data->NextRecordType) ? (string) $v : null; - $this->nextRecordIdentifier = ($v = $data->NextRecordIdentifier) ? (string) $v : null; + $this->nextRecordName = (null !== $v = $data->NextRecordName[0]) ? (string) $v : null; + $this->nextRecordType = (null !== $v = $data->NextRecordType[0]) ? (string) $v : null; + $this->nextRecordIdentifier = (null !== $v = $data->NextRecordIdentifier[0]) ? (string) $v : null; $this->maxItems = (string) $data->MaxItems; } + private function populateResultAliasTarget(\SimpleXMLElement $xml): AliasTarget + { + return new AliasTarget([ + 'HostedZoneId' => (string) $xml->HostedZoneId, + 'DNSName' => (string) $xml->DNSName, + 'EvaluateTargetHealth' => filter_var((string) $xml->EvaluateTargetHealth, \FILTER_VALIDATE_BOOLEAN), + ]); + } + + private function populateResultCidrRoutingConfig(\SimpleXMLElement $xml): CidrRoutingConfig + { + return new CidrRoutingConfig([ + 'CollectionId' => (string) $xml->CollectionId, + 'LocationName' => (string) $xml->LocationName, + ]); + } + + private function populateResultCoordinates(\SimpleXMLElement $xml): Coordinates + { + return new Coordinates([ + 'Latitude' => (string) $xml->Latitude, + 'Longitude' => (string) $xml->Longitude, + ]); + } + + private function populateResultGeoLocation(\SimpleXMLElement $xml): GeoLocation + { + return new GeoLocation([ + 'ContinentCode' => (null !== $v = $xml->ContinentCode[0]) ? (string) $v : null, + 'CountryCode' => (null !== $v = $xml->CountryCode[0]) ? (string) $v : null, + 'SubdivisionCode' => (null !== $v = $xml->SubdivisionCode[0]) ? (string) $v : null, + ]); + } + + private function populateResultGeoProximityLocation(\SimpleXMLElement $xml): GeoProximityLocation + { + return new GeoProximityLocation([ + 'AWSRegion' => (null !== $v = $xml->AWSRegion[0]) ? (string) $v : null, + 'LocalZoneGroup' => (null !== $v = $xml->LocalZoneGroup[0]) ? (string) $v : null, + 'Coordinates' => 0 === $xml->Coordinates->count() ? null : $this->populateResultCoordinates($xml->Coordinates), + 'Bias' => (null !== $v = $xml->Bias[0]) ? (int) (string) $v : null, + ]); + } + + private function populateResultResourceRecord(\SimpleXMLElement $xml): ResourceRecord + { + return new ResourceRecord([ + 'Value' => (string) $xml->Value, + ]); + } + + private function populateResultResourceRecordSet(\SimpleXMLElement $xml): ResourceRecordSet + { + return new ResourceRecordSet([ + 'Name' => (string) $xml->Name, + 'Type' => (string) $xml->Type, + 'SetIdentifier' => (null !== $v = $xml->SetIdentifier[0]) ? (string) $v : null, + 'Weight' => (null !== $v = $xml->Weight[0]) ? (int) (string) $v : null, + 'Region' => (null !== $v = $xml->Region[0]) ? (string) $v : null, + 'GeoLocation' => 0 === $xml->GeoLocation->count() ? null : $this->populateResultGeoLocation($xml->GeoLocation), + 'Failover' => (null !== $v = $xml->Failover[0]) ? (string) $v : null, + 'MultiValueAnswer' => (null !== $v = $xml->MultiValueAnswer[0]) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, + 'TTL' => (null !== $v = $xml->TTL[0]) ? (int) (string) $v : null, + 'ResourceRecords' => (0 === ($v = $xml->ResourceRecords)->count()) ? null : $this->populateResultResourceRecords($v), + 'AliasTarget' => 0 === $xml->AliasTarget->count() ? null : $this->populateResultAliasTarget($xml->AliasTarget), + 'HealthCheckId' => (null !== $v = $xml->HealthCheckId[0]) ? (string) $v : null, + 'TrafficPolicyInstanceId' => (null !== $v = $xml->TrafficPolicyInstanceId[0]) ? (string) $v : null, + 'CidrRoutingConfig' => 0 === $xml->CidrRoutingConfig->count() ? null : $this->populateResultCidrRoutingConfig($xml->CidrRoutingConfig), + 'GeoProximityLocation' => 0 === $xml->GeoProximityLocation->count() ? null : $this->populateResultGeoProximityLocation($xml->GeoProximityLocation), + ]); + } + /** * @return ResourceRecordSet[] */ @@ -189,42 +261,7 @@ private function populateResultResourceRecordSets(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->ResourceRecordSet as $item) { - $items[] = new ResourceRecordSet([ - 'Name' => (string) $item->Name, - 'Type' => (string) $item->Type, - 'SetIdentifier' => ($v = $item->SetIdentifier) ? (string) $v : null, - 'Weight' => ($v = $item->Weight) ? (int) (string) $v : null, - 'Region' => ($v = $item->Region) ? (string) $v : null, - 'GeoLocation' => !$item->GeoLocation ? null : new GeoLocation([ - 'ContinentCode' => ($v = $item->GeoLocation->ContinentCode) ? (string) $v : null, - 'CountryCode' => ($v = $item->GeoLocation->CountryCode) ? (string) $v : null, - 'SubdivisionCode' => ($v = $item->GeoLocation->SubdivisionCode) ? (string) $v : null, - ]), - 'Failover' => ($v = $item->Failover) ? (string) $v : null, - 'MultiValueAnswer' => ($v = $item->MultiValueAnswer) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, - 'TTL' => ($v = $item->TTL) ? (int) (string) $v : null, - 'ResourceRecords' => !$item->ResourceRecords ? null : $this->populateResultResourceRecords($item->ResourceRecords), - 'AliasTarget' => !$item->AliasTarget ? null : new AliasTarget([ - 'HostedZoneId' => (string) $item->AliasTarget->HostedZoneId, - 'DNSName' => (string) $item->AliasTarget->DNSName, - 'EvaluateTargetHealth' => filter_var((string) $item->AliasTarget->EvaluateTargetHealth, \FILTER_VALIDATE_BOOLEAN), - ]), - 'HealthCheckId' => ($v = $item->HealthCheckId) ? (string) $v : null, - 'TrafficPolicyInstanceId' => ($v = $item->TrafficPolicyInstanceId) ? (string) $v : null, - 'CidrRoutingConfig' => !$item->CidrRoutingConfig ? null : new CidrRoutingConfig([ - 'CollectionId' => (string) $item->CidrRoutingConfig->CollectionId, - 'LocationName' => (string) $item->CidrRoutingConfig->LocationName, - ]), - 'GeoProximityLocation' => !$item->GeoProximityLocation ? null : new GeoProximityLocation([ - 'AWSRegion' => ($v = $item->GeoProximityLocation->AWSRegion) ? (string) $v : null, - 'LocalZoneGroup' => ($v = $item->GeoProximityLocation->LocalZoneGroup) ? (string) $v : null, - 'Coordinates' => !$item->GeoProximityLocation->Coordinates ? null : new Coordinates([ - 'Latitude' => (string) $item->GeoProximityLocation->Coordinates->Latitude, - 'Longitude' => (string) $item->GeoProximityLocation->Coordinates->Longitude, - ]), - 'Bias' => ($v = $item->GeoProximityLocation->Bias) ? (int) (string) $v : null, - ]), - ]); + $items[] = $this->populateResultResourceRecordSet($item); } return $items; @@ -237,9 +274,7 @@ private function populateResultResourceRecords(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->ResourceRecord as $item) { - $items[] = new ResourceRecord([ - 'Value' => (string) $item->Value, - ]); + $items[] = $this->populateResultResourceRecord($item); } return $items; diff --git a/src/Service/S3/CHANGELOG.md b/src/Service/S3/CHANGELOG.md index 6d3731958..dc431de12 100644 --- a/src/Service/S3/CHANGELOG.md +++ b/src/Service/S3/CHANGELOG.md @@ -6,6 +6,10 @@ - AWS api-change: Add support for the new optional bucket-region and prefix query parameters in the ListBuckets API. For ListBuckets requests that express pagination, Amazon S3 will now return both the bucket names and associated AWS regions in the response. +### Changed + +- use strict comparison `null !==` instead of `!` + ## 2.4.0 ### Added diff --git a/src/Service/S3/src/Exception/InvalidObjectStateException.php b/src/Service/S3/src/Exception/InvalidObjectStateException.php index 662befbe9..d63ed31d3 100644 --- a/src/Service/S3/src/Exception/InvalidObjectStateException.php +++ b/src/Service/S3/src/Exception/InvalidObjectStateException.php @@ -53,7 +53,7 @@ protected function populateResult(ResponseInterface $response): void if (0 < $data->Error->count()) { $data = $data->Error; } - $this->storageClass = ($v = $data->StorageClass) ? (string) $v : null; - $this->accessTier = ($v = $data->AccessTier) ? (string) $v : null; + $this->storageClass = (null !== $v = $data->StorageClass[0]) ? (string) $v : null; + $this->accessTier = (null !== $v = $data->AccessTier[0]) ? (string) $v : null; } } diff --git a/src/Service/S3/src/Result/CompleteMultipartUploadOutput.php b/src/Service/S3/src/Result/CompleteMultipartUploadOutput.php index 38e748b90..23775e9c7 100644 --- a/src/Service/S3/src/Result/CompleteMultipartUploadOutput.php +++ b/src/Service/S3/src/Result/CompleteMultipartUploadOutput.php @@ -260,13 +260,13 @@ protected function populateResult(Response $response): void $this->requestCharged = $headers['x-amz-request-charged'][0] ?? null; $data = new \SimpleXMLElement($response->getContent()); - $this->location = ($v = $data->Location) ? (string) $v : null; - $this->bucket = ($v = $data->Bucket) ? (string) $v : null; - $this->key = ($v = $data->Key) ? (string) $v : null; - $this->etag = ($v = $data->ETag) ? (string) $v : null; - $this->checksumCrc32 = ($v = $data->ChecksumCRC32) ? (string) $v : null; - $this->checksumCrc32C = ($v = $data->ChecksumCRC32C) ? (string) $v : null; - $this->checksumSha1 = ($v = $data->ChecksumSHA1) ? (string) $v : null; - $this->checksumSha256 = ($v = $data->ChecksumSHA256) ? (string) $v : null; + $this->location = (null !== $v = $data->Location[0]) ? (string) $v : null; + $this->bucket = (null !== $v = $data->Bucket[0]) ? (string) $v : null; + $this->key = (null !== $v = $data->Key[0]) ? (string) $v : null; + $this->etag = (null !== $v = $data->ETag[0]) ? (string) $v : null; + $this->checksumCrc32 = (null !== $v = $data->ChecksumCRC32[0]) ? (string) $v : null; + $this->checksumCrc32C = (null !== $v = $data->ChecksumCRC32C[0]) ? (string) $v : null; + $this->checksumSha1 = (null !== $v = $data->ChecksumSHA1[0]) ? (string) $v : null; + $this->checksumSha256 = (null !== $v = $data->ChecksumSHA256[0]) ? (string) $v : null; } } diff --git a/src/Service/S3/src/Result/CopyObjectOutput.php b/src/Service/S3/src/Result/CopyObjectOutput.php index d8ddc4ecf..86ac08239 100644 --- a/src/Service/S3/src/Result/CopyObjectOutput.php +++ b/src/Service/S3/src/Result/CopyObjectOutput.php @@ -199,13 +199,18 @@ protected function populateResult(Response $response): void $this->requestCharged = $headers['x-amz-request-charged'][0] ?? null; $data = new \SimpleXMLElement($response->getContent()); - $this->copyObjectResult = new CopyObjectResult([ - 'ETag' => ($v = $data->ETag) ? (string) $v : null, - 'LastModified' => ($v = $data->LastModified) ? new \DateTimeImmutable((string) $v) : null, - 'ChecksumCRC32' => ($v = $data->ChecksumCRC32) ? (string) $v : null, - 'ChecksumCRC32C' => ($v = $data->ChecksumCRC32C) ? (string) $v : null, - 'ChecksumSHA1' => ($v = $data->ChecksumSHA1) ? (string) $v : null, - 'ChecksumSHA256' => ($v = $data->ChecksumSHA256) ? (string) $v : null, + $this->copyObjectResult = $this->populateResultCopyObjectResult($data); + } + + private function populateResultCopyObjectResult(\SimpleXMLElement $xml): CopyObjectResult + { + return new CopyObjectResult([ + 'ETag' => (null !== $v = $xml->ETag[0]) ? (string) $v : null, + 'LastModified' => (null !== $v = $xml->LastModified[0]) ? new \DateTimeImmutable((string) $v) : null, + 'ChecksumCRC32' => (null !== $v = $xml->ChecksumCRC32[0]) ? (string) $v : null, + 'ChecksumCRC32C' => (null !== $v = $xml->ChecksumCRC32C[0]) ? (string) $v : null, + 'ChecksumSHA1' => (null !== $v = $xml->ChecksumSHA1[0]) ? (string) $v : null, + 'ChecksumSHA256' => (null !== $v = $xml->ChecksumSHA256[0]) ? (string) $v : null, ]); } } diff --git a/src/Service/S3/src/Result/CreateMultipartUploadOutput.php b/src/Service/S3/src/Result/CreateMultipartUploadOutput.php index c4aaa7d6e..1e4a4db5c 100644 --- a/src/Service/S3/src/Result/CreateMultipartUploadOutput.php +++ b/src/Service/S3/src/Result/CreateMultipartUploadOutput.php @@ -239,8 +239,8 @@ protected function populateResult(Response $response): void $this->checksumAlgorithm = $headers['x-amz-checksum-algorithm'][0] ?? null; $data = new \SimpleXMLElement($response->getContent()); - $this->bucket = ($v = $data->Bucket) ? (string) $v : null; - $this->key = ($v = $data->Key) ? (string) $v : null; - $this->uploadId = ($v = $data->UploadId) ? (string) $v : null; + $this->bucket = (null !== $v = $data->Bucket[0]) ? (string) $v : null; + $this->key = (null !== $v = $data->Key[0]) ? (string) $v : null; + $this->uploadId = (null !== $v = $data->UploadId[0]) ? (string) $v : null; } } diff --git a/src/Service/S3/src/Result/DeleteObjectsOutput.php b/src/Service/S3/src/Result/DeleteObjectsOutput.php index a5988d4da..1e4cddc3c 100644 --- a/src/Service/S3/src/Result/DeleteObjectsOutput.php +++ b/src/Service/S3/src/Result/DeleteObjectsOutput.php @@ -67,8 +67,18 @@ protected function populateResult(Response $response): void $this->requestCharged = $headers['x-amz-request-charged'][0] ?? null; $data = new \SimpleXMLElement($response->getContent()); - $this->deleted = !$data->Deleted ? [] : $this->populateResultDeletedObjects($data->Deleted); - $this->errors = !$data->Error ? [] : $this->populateResultErrors($data->Error); + $this->deleted = (0 === ($v = $data->Deleted)->count()) ? [] : $this->populateResultDeletedObjects($v); + $this->errors = (0 === ($v = $data->Error)->count()) ? [] : $this->populateResultErrors($v); + } + + private function populateResultDeletedObject(\SimpleXMLElement $xml): DeletedObject + { + return new DeletedObject([ + 'Key' => (null !== $v = $xml->Key[0]) ? (string) $v : null, + 'VersionId' => (null !== $v = $xml->VersionId[0]) ? (string) $v : null, + 'DeleteMarker' => (null !== $v = $xml->DeleteMarker[0]) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, + 'DeleteMarkerVersionId' => (null !== $v = $xml->DeleteMarkerVersionId[0]) ? (string) $v : null, + ]); } /** @@ -78,17 +88,22 @@ private function populateResultDeletedObjects(\SimpleXMLElement $xml): array { $items = []; foreach ($xml as $item) { - $items[] = new DeletedObject([ - 'Key' => ($v = $item->Key) ? (string) $v : null, - 'VersionId' => ($v = $item->VersionId) ? (string) $v : null, - 'DeleteMarker' => ($v = $item->DeleteMarker) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, - 'DeleteMarkerVersionId' => ($v = $item->DeleteMarkerVersionId) ? (string) $v : null, - ]); + $items[] = $this->populateResultDeletedObject($item); } return $items; } + private function populateResultError(\SimpleXMLElement $xml): Error + { + return new Error([ + 'Key' => (null !== $v = $xml->Key[0]) ? (string) $v : null, + 'VersionId' => (null !== $v = $xml->VersionId[0]) ? (string) $v : null, + 'Code' => (null !== $v = $xml->Code[0]) ? (string) $v : null, + 'Message' => (null !== $v = $xml->Message[0]) ? (string) $v : null, + ]); + } + /** * @return Error[] */ @@ -96,12 +111,7 @@ private function populateResultErrors(\SimpleXMLElement $xml): array { $items = []; foreach ($xml as $item) { - $items[] = new Error([ - 'Key' => ($v = $item->Key) ? (string) $v : null, - 'VersionId' => ($v = $item->VersionId) ? (string) $v : null, - 'Code' => ($v = $item->Code) ? (string) $v : null, - 'Message' => ($v = $item->Message) ? (string) $v : null, - ]); + $items[] = $this->populateResultError($item); } return $items; diff --git a/src/Service/S3/src/Result/GetBucketCorsOutput.php b/src/Service/S3/src/Result/GetBucketCorsOutput.php index 0c0f02ab6..5397ca67e 100644 --- a/src/Service/S3/src/Result/GetBucketCorsOutput.php +++ b/src/Service/S3/src/Result/GetBucketCorsOutput.php @@ -29,7 +29,7 @@ public function getCorsRules(): array protected function populateResult(Response $response): void { $data = new \SimpleXMLElement($response->getContent()); - $this->corsRules = !$data->CORSRule ? [] : $this->populateResultCORSRules($data->CORSRule); + $this->corsRules = (0 === ($v = $data->CORSRule)->count()) ? [] : $this->populateResultCORSRules($v); } /** @@ -39,10 +39,7 @@ private function populateResultAllowedHeaders(\SimpleXMLElement $xml): array { $items = []; foreach ($xml as $item) { - $a = ($v = $item) ? (string) $v : null; - if (null !== $a) { - $items[] = $a; - } + $items[] = (string) $item; } return $items; @@ -55,10 +52,7 @@ private function populateResultAllowedMethods(\SimpleXMLElement $xml): array { $items = []; foreach ($xml as $item) { - $a = ($v = $item) ? (string) $v : null; - if (null !== $a) { - $items[] = $a; - } + $items[] = (string) $item; } return $items; @@ -71,15 +65,24 @@ private function populateResultAllowedOrigins(\SimpleXMLElement $xml): array { $items = []; foreach ($xml as $item) { - $a = ($v = $item) ? (string) $v : null; - if (null !== $a) { - $items[] = $a; - } + $items[] = (string) $item; } return $items; } + private function populateResultCORSRule(\SimpleXMLElement $xml): CORSRule + { + return new CORSRule([ + 'ID' => (null !== $v = $xml->ID[0]) ? (string) $v : null, + 'AllowedHeaders' => (0 === ($v = $xml->AllowedHeader)->count()) ? null : $this->populateResultAllowedHeaders($v), + 'AllowedMethods' => $this->populateResultAllowedMethods($xml->AllowedMethod), + 'AllowedOrigins' => $this->populateResultAllowedOrigins($xml->AllowedOrigin), + 'ExposeHeaders' => (0 === ($v = $xml->ExposeHeader)->count()) ? null : $this->populateResultExposeHeaders($v), + 'MaxAgeSeconds' => (null !== $v = $xml->MaxAgeSeconds[0]) ? (int) (string) $v : null, + ]); + } + /** * @return CORSRule[] */ @@ -87,14 +90,7 @@ private function populateResultCORSRules(\SimpleXMLElement $xml): array { $items = []; foreach ($xml as $item) { - $items[] = new CORSRule([ - 'ID' => ($v = $item->ID) ? (string) $v : null, - 'AllowedHeaders' => !$item->AllowedHeader ? null : $this->populateResultAllowedHeaders($item->AllowedHeader), - 'AllowedMethods' => $this->populateResultAllowedMethods($item->AllowedMethod), - 'AllowedOrigins' => $this->populateResultAllowedOrigins($item->AllowedOrigin), - 'ExposeHeaders' => !$item->ExposeHeader ? null : $this->populateResultExposeHeaders($item->ExposeHeader), - 'MaxAgeSeconds' => ($v = $item->MaxAgeSeconds) ? (int) (string) $v : null, - ]); + $items[] = $this->populateResultCORSRule($item); } return $items; @@ -107,10 +103,7 @@ private function populateResultExposeHeaders(\SimpleXMLElement $xml): array { $items = []; foreach ($xml as $item) { - $a = ($v = $item) ? (string) $v : null; - if (null !== $a) { - $items[] = $a; - } + $items[] = (string) $item; } return $items; diff --git a/src/Service/S3/src/Result/GetBucketEncryptionOutput.php b/src/Service/S3/src/Result/GetBucketEncryptionOutput.php index ab48d8a70..8265266f0 100644 --- a/src/Service/S3/src/Result/GetBucketEncryptionOutput.php +++ b/src/Service/S3/src/Result/GetBucketEncryptionOutput.php @@ -25,8 +25,29 @@ public function getServerSideEncryptionConfiguration(): ?ServerSideEncryptionCon protected function populateResult(Response $response): void { $data = new \SimpleXMLElement($response->getContent()); - $this->serverSideEncryptionConfiguration = new ServerSideEncryptionConfiguration([ - 'Rules' => $this->populateResultServerSideEncryptionRules($data->Rule), + $this->serverSideEncryptionConfiguration = $this->populateResultServerSideEncryptionConfiguration($data); + } + + private function populateResultServerSideEncryptionByDefault(\SimpleXMLElement $xml): ServerSideEncryptionByDefault + { + return new ServerSideEncryptionByDefault([ + 'SSEAlgorithm' => (string) $xml->SSEAlgorithm, + 'KMSMasterKeyID' => (null !== $v = $xml->KMSMasterKeyID[0]) ? (string) $v : null, + ]); + } + + private function populateResultServerSideEncryptionConfiguration(\SimpleXMLElement $xml): ServerSideEncryptionConfiguration + { + return new ServerSideEncryptionConfiguration([ + 'Rules' => $this->populateResultServerSideEncryptionRules($xml->Rule), + ]); + } + + private function populateResultServerSideEncryptionRule(\SimpleXMLElement $xml): ServerSideEncryptionRule + { + return new ServerSideEncryptionRule([ + 'ApplyServerSideEncryptionByDefault' => 0 === $xml->ApplyServerSideEncryptionByDefault->count() ? null : $this->populateResultServerSideEncryptionByDefault($xml->ApplyServerSideEncryptionByDefault), + 'BucketKeyEnabled' => (null !== $v = $xml->BucketKeyEnabled[0]) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, ]); } @@ -37,13 +58,7 @@ private function populateResultServerSideEncryptionRules(\SimpleXMLElement $xml) { $items = []; foreach ($xml as $item) { - $items[] = new ServerSideEncryptionRule([ - 'ApplyServerSideEncryptionByDefault' => !$item->ApplyServerSideEncryptionByDefault ? null : new ServerSideEncryptionByDefault([ - 'SSEAlgorithm' => (string) $item->ApplyServerSideEncryptionByDefault->SSEAlgorithm, - 'KMSMasterKeyID' => ($v = $item->ApplyServerSideEncryptionByDefault->KMSMasterKeyID) ? (string) $v : null, - ]), - 'BucketKeyEnabled' => ($v = $item->BucketKeyEnabled) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, - ]); + $items[] = $this->populateResultServerSideEncryptionRule($item); } return $items; diff --git a/src/Service/S3/src/Result/GetObjectAclOutput.php b/src/Service/S3/src/Result/GetObjectAclOutput.php index 2d58c6e4a..170529eb3 100644 --- a/src/Service/S3/src/Result/GetObjectAclOutput.php +++ b/src/Service/S3/src/Result/GetObjectAclOutput.php @@ -64,11 +64,27 @@ protected function populateResult(Response $response): void $this->requestCharged = $headers['x-amz-request-charged'][0] ?? null; $data = new \SimpleXMLElement($response->getContent()); - $this->owner = !$data->Owner ? null : new Owner([ - 'DisplayName' => ($v = $data->Owner->DisplayName) ? (string) $v : null, - 'ID' => ($v = $data->Owner->ID) ? (string) $v : null, + $this->owner = 0 === $data->Owner->count() ? null : $this->populateResultOwner($data->Owner); + $this->grants = (0 === ($v = $data->AccessControlList)->count()) ? [] : $this->populateResultGrants($v); + } + + private function populateResultGrant(\SimpleXMLElement $xml): Grant + { + return new Grant([ + 'Grantee' => 0 === $xml->Grantee->count() ? null : $this->populateResultGrantee($xml->Grantee), + 'Permission' => (null !== $v = $xml->Permission[0]) ? (string) $v : null, + ]); + } + + private function populateResultGrantee(\SimpleXMLElement $xml): Grantee + { + return new Grantee([ + 'DisplayName' => (null !== $v = $xml->DisplayName[0]) ? (string) $v : null, + 'EmailAddress' => (null !== $v = $xml->EmailAddress[0]) ? (string) $v : null, + 'ID' => (null !== $v = $xml->ID[0]) ? (string) $v : null, + 'Type' => (string) ($xml->attributes('xsi', true)['type'][0] ?? null), + 'URI' => (null !== $v = $xml->URI[0]) ? (string) $v : null, ]); - $this->grants = !$data->AccessControlList ? [] : $this->populateResultGrants($data->AccessControlList); } /** @@ -78,18 +94,17 @@ private function populateResultGrants(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->Grant as $item) { - $items[] = new Grant([ - 'Grantee' => !$item->Grantee ? null : new Grantee([ - 'DisplayName' => ($v = $item->Grantee->DisplayName) ? (string) $v : null, - 'EmailAddress' => ($v = $item->Grantee->EmailAddress) ? (string) $v : null, - 'ID' => ($v = $item->Grantee->ID) ? (string) $v : null, - 'Type' => (string) ($item->Grantee->attributes('xsi', true)['type'][0] ?? null), - 'URI' => ($v = $item->Grantee->URI) ? (string) $v : null, - ]), - 'Permission' => ($v = $item->Permission) ? (string) $v : null, - ]); + $items[] = $this->populateResultGrant($item); } return $items; } + + private function populateResultOwner(\SimpleXMLElement $xml): Owner + { + return new Owner([ + 'DisplayName' => (null !== $v = $xml->DisplayName[0]) ? (string) $v : null, + 'ID' => (null !== $v = $xml->ID[0]) ? (string) $v : null, + ]); + } } diff --git a/src/Service/S3/src/Result/GetObjectTaggingOutput.php b/src/Service/S3/src/Result/GetObjectTaggingOutput.php index d868b8aaf..a70f81279 100644 --- a/src/Service/S3/src/Result/GetObjectTaggingOutput.php +++ b/src/Service/S3/src/Result/GetObjectTaggingOutput.php @@ -49,6 +49,14 @@ protected function populateResult(Response $response): void $this->tagSet = $this->populateResultTagSet($data->TagSet); } + private function populateResultTag(\SimpleXMLElement $xml): Tag + { + return new Tag([ + 'Key' => (string) $xml->Key, + 'Value' => (string) $xml->Value, + ]); + } + /** * @return Tag[] */ @@ -56,10 +64,7 @@ private function populateResultTagSet(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->Tag as $item) { - $items[] = new Tag([ - 'Key' => (string) $item->Key, - 'Value' => (string) $item->Value, - ]); + $items[] = $this->populateResultTag($item); } return $items; diff --git a/src/Service/S3/src/Result/ListBucketsOutput.php b/src/Service/S3/src/Result/ListBucketsOutput.php index 4bf0465b3..0598ef08b 100644 --- a/src/Service/S3/src/Result/ListBucketsOutput.php +++ b/src/Service/S3/src/Result/ListBucketsOutput.php @@ -72,7 +72,7 @@ public function getBuckets(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->continuationToken) { + if (null !== $page->continuationToken) { $input->setContinuationToken($page->continuationToken); $this->registerPrefetch($nextPage = $client->listBuckets($input)); @@ -125,13 +125,19 @@ public function getPrefix(): ?string protected function populateResult(Response $response): void { $data = new \SimpleXMLElement($response->getContent()); - $this->buckets = !$data->Buckets ? [] : $this->populateResultBuckets($data->Buckets); - $this->owner = !$data->Owner ? null : new Owner([ - 'DisplayName' => ($v = $data->Owner->DisplayName) ? (string) $v : null, - 'ID' => ($v = $data->Owner->ID) ? (string) $v : null, + $this->buckets = (0 === ($v = $data->Buckets)->count()) ? [] : $this->populateResultBuckets($v); + $this->owner = 0 === $data->Owner->count() ? null : $this->populateResultOwner($data->Owner); + $this->continuationToken = (null !== $v = $data->ContinuationToken[0]) ? (string) $v : null; + $this->prefix = (null !== $v = $data->Prefix[0]) ? (string) $v : null; + } + + private function populateResultBucket(\SimpleXMLElement $xml): Bucket + { + return new Bucket([ + 'Name' => (null !== $v = $xml->Name[0]) ? (string) $v : null, + 'CreationDate' => (null !== $v = $xml->CreationDate[0]) ? new \DateTimeImmutable((string) $v) : null, + 'BucketRegion' => (null !== $v = $xml->BucketRegion[0]) ? (string) $v : null, ]); - $this->continuationToken = ($v = $data->ContinuationToken) ? (string) $v : null; - $this->prefix = ($v = $data->Prefix) ? (string) $v : null; } /** @@ -141,13 +147,17 @@ private function populateResultBuckets(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->Bucket as $item) { - $items[] = new Bucket([ - 'Name' => ($v = $item->Name) ? (string) $v : null, - 'CreationDate' => ($v = $item->CreationDate) ? new \DateTimeImmutable((string) $v) : null, - 'BucketRegion' => ($v = $item->BucketRegion) ? (string) $v : null, - ]); + $items[] = $this->populateResultBucket($item); } return $items; } + + private function populateResultOwner(\SimpleXMLElement $xml): Owner + { + return new Owner([ + 'DisplayName' => (null !== $v = $xml->DisplayName[0]) ? (string) $v : null, + 'ID' => (null !== $v = $xml->ID[0]) ? (string) $v : null, + ]); + } } diff --git a/src/Service/S3/src/Result/ListMultipartUploadsOutput.php b/src/Service/S3/src/Result/ListMultipartUploadsOutput.php index 896e8c232..52ec4413b 100644 --- a/src/Service/S3/src/Result/ListMultipartUploadsOutput.php +++ b/src/Service/S3/src/Result/ListMultipartUploadsOutput.php @@ -357,18 +357,25 @@ protected function populateResult(Response $response): void $this->requestCharged = $headers['x-amz-request-charged'][0] ?? null; $data = new \SimpleXMLElement($response->getContent()); - $this->bucket = ($v = $data->Bucket) ? (string) $v : null; - $this->keyMarker = ($v = $data->KeyMarker) ? (string) $v : null; - $this->uploadIdMarker = ($v = $data->UploadIdMarker) ? (string) $v : null; - $this->nextKeyMarker = ($v = $data->NextKeyMarker) ? (string) $v : null; - $this->prefix = ($v = $data->Prefix) ? (string) $v : null; - $this->delimiter = ($v = $data->Delimiter) ? (string) $v : null; - $this->nextUploadIdMarker = ($v = $data->NextUploadIdMarker) ? (string) $v : null; - $this->maxUploads = ($v = $data->MaxUploads) ? (int) (string) $v : null; - $this->isTruncated = ($v = $data->IsTruncated) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null; - $this->uploads = !$data->Upload ? [] : $this->populateResultMultipartUploadList($data->Upload); - $this->commonPrefixes = !$data->CommonPrefixes ? [] : $this->populateResultCommonPrefixList($data->CommonPrefixes); - $this->encodingType = ($v = $data->EncodingType) ? (string) $v : null; + $this->bucket = (null !== $v = $data->Bucket[0]) ? (string) $v : null; + $this->keyMarker = (null !== $v = $data->KeyMarker[0]) ? (string) $v : null; + $this->uploadIdMarker = (null !== $v = $data->UploadIdMarker[0]) ? (string) $v : null; + $this->nextKeyMarker = (null !== $v = $data->NextKeyMarker[0]) ? (string) $v : null; + $this->prefix = (null !== $v = $data->Prefix[0]) ? (string) $v : null; + $this->delimiter = (null !== $v = $data->Delimiter[0]) ? (string) $v : null; + $this->nextUploadIdMarker = (null !== $v = $data->NextUploadIdMarker[0]) ? (string) $v : null; + $this->maxUploads = (null !== $v = $data->MaxUploads[0]) ? (int) (string) $v : null; + $this->isTruncated = (null !== $v = $data->IsTruncated[0]) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null; + $this->uploads = (0 === ($v = $data->Upload)->count()) ? [] : $this->populateResultMultipartUploadList($v); + $this->commonPrefixes = (0 === ($v = $data->CommonPrefixes)->count()) ? [] : $this->populateResultCommonPrefixList($v); + $this->encodingType = (null !== $v = $data->EncodingType[0]) ? (string) $v : null; + } + + private function populateResultCommonPrefix(\SimpleXMLElement $xml): CommonPrefix + { + return new CommonPrefix([ + 'Prefix' => (null !== $v = $xml->Prefix[0]) ? (string) $v : null, + ]); } /** @@ -378,14 +385,33 @@ private function populateResultCommonPrefixList(\SimpleXMLElement $xml): array { $items = []; foreach ($xml as $item) { - $items[] = new CommonPrefix([ - 'Prefix' => ($v = $item->Prefix) ? (string) $v : null, - ]); + $items[] = $this->populateResultCommonPrefix($item); } return $items; } + private function populateResultInitiator(\SimpleXMLElement $xml): Initiator + { + return new Initiator([ + 'ID' => (null !== $v = $xml->ID[0]) ? (string) $v : null, + 'DisplayName' => (null !== $v = $xml->DisplayName[0]) ? (string) $v : null, + ]); + } + + private function populateResultMultipartUpload(\SimpleXMLElement $xml): MultipartUpload + { + return new MultipartUpload([ + 'UploadId' => (null !== $v = $xml->UploadId[0]) ? (string) $v : null, + 'Key' => (null !== $v = $xml->Key[0]) ? (string) $v : null, + 'Initiated' => (null !== $v = $xml->Initiated[0]) ? new \DateTimeImmutable((string) $v) : null, + 'StorageClass' => (null !== $v = $xml->StorageClass[0]) ? (string) $v : null, + 'Owner' => 0 === $xml->Owner->count() ? null : $this->populateResultOwner($xml->Owner), + 'Initiator' => 0 === $xml->Initiator->count() ? null : $this->populateResultInitiator($xml->Initiator), + 'ChecksumAlgorithm' => (null !== $v = $xml->ChecksumAlgorithm[0]) ? (string) $v : null, + ]); + } + /** * @return MultipartUpload[] */ @@ -393,23 +419,17 @@ private function populateResultMultipartUploadList(\SimpleXMLElement $xml): arra { $items = []; foreach ($xml as $item) { - $items[] = new MultipartUpload([ - 'UploadId' => ($v = $item->UploadId) ? (string) $v : null, - 'Key' => ($v = $item->Key) ? (string) $v : null, - 'Initiated' => ($v = $item->Initiated) ? new \DateTimeImmutable((string) $v) : null, - 'StorageClass' => ($v = $item->StorageClass) ? (string) $v : null, - 'Owner' => !$item->Owner ? null : new Owner([ - 'DisplayName' => ($v = $item->Owner->DisplayName) ? (string) $v : null, - 'ID' => ($v = $item->Owner->ID) ? (string) $v : null, - ]), - 'Initiator' => !$item->Initiator ? null : new Initiator([ - 'ID' => ($v = $item->Initiator->ID) ? (string) $v : null, - 'DisplayName' => ($v = $item->Initiator->DisplayName) ? (string) $v : null, - ]), - 'ChecksumAlgorithm' => ($v = $item->ChecksumAlgorithm) ? (string) $v : null, - ]); + $items[] = $this->populateResultMultipartUpload($item); } return $items; } + + private function populateResultOwner(\SimpleXMLElement $xml): Owner + { + return new Owner([ + 'DisplayName' => (null !== $v = $xml->DisplayName[0]) ? (string) $v : null, + 'ID' => (null !== $v = $xml->ID[0]) ? (string) $v : null, + ]); + } } diff --git a/src/Service/S3/src/Result/ListObjectVersionsOutput.php b/src/Service/S3/src/Result/ListObjectVersionsOutput.php index 765095f00..17f01b447 100644 --- a/src/Service/S3/src/Result/ListObjectVersionsOutput.php +++ b/src/Service/S3/src/Result/ListObjectVersionsOutput.php @@ -399,19 +399,19 @@ protected function populateResult(Response $response): void $this->requestCharged = $headers['x-amz-request-charged'][0] ?? null; $data = new \SimpleXMLElement($response->getContent()); - $this->isTruncated = ($v = $data->IsTruncated) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null; - $this->keyMarker = ($v = $data->KeyMarker) ? (string) $v : null; - $this->versionIdMarker = ($v = $data->VersionIdMarker) ? (string) $v : null; - $this->nextKeyMarker = ($v = $data->NextKeyMarker) ? (string) $v : null; - $this->nextVersionIdMarker = ($v = $data->NextVersionIdMarker) ? (string) $v : null; - $this->versions = !$data->Version ? [] : $this->populateResultObjectVersionList($data->Version); - $this->deleteMarkers = !$data->DeleteMarker ? [] : $this->populateResultDeleteMarkers($data->DeleteMarker); - $this->name = ($v = $data->Name) ? (string) $v : null; - $this->prefix = ($v = $data->Prefix) ? (string) $v : null; - $this->delimiter = ($v = $data->Delimiter) ? (string) $v : null; - $this->maxKeys = ($v = $data->MaxKeys) ? (int) (string) $v : null; - $this->commonPrefixes = !$data->CommonPrefixes ? [] : $this->populateResultCommonPrefixList($data->CommonPrefixes); - $this->encodingType = ($v = $data->EncodingType) ? (string) $v : null; + $this->isTruncated = (null !== $v = $data->IsTruncated[0]) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null; + $this->keyMarker = (null !== $v = $data->KeyMarker[0]) ? (string) $v : null; + $this->versionIdMarker = (null !== $v = $data->VersionIdMarker[0]) ? (string) $v : null; + $this->nextKeyMarker = (null !== $v = $data->NextKeyMarker[0]) ? (string) $v : null; + $this->nextVersionIdMarker = (null !== $v = $data->NextVersionIdMarker[0]) ? (string) $v : null; + $this->versions = (0 === ($v = $data->Version)->count()) ? [] : $this->populateResultObjectVersionList($v); + $this->deleteMarkers = (0 === ($v = $data->DeleteMarker)->count()) ? [] : $this->populateResultDeleteMarkers($v); + $this->name = (null !== $v = $data->Name[0]) ? (string) $v : null; + $this->prefix = (null !== $v = $data->Prefix[0]) ? (string) $v : null; + $this->delimiter = (null !== $v = $data->Delimiter[0]) ? (string) $v : null; + $this->maxKeys = (null !== $v = $data->MaxKeys[0]) ? (int) (string) $v : null; + $this->commonPrefixes = (0 === ($v = $data->CommonPrefixes)->count()) ? [] : $this->populateResultCommonPrefixList($v); + $this->encodingType = (null !== $v = $data->EncodingType[0]) ? (string) $v : null; } /** @@ -421,15 +421,19 @@ private function populateResultChecksumAlgorithmList(\SimpleXMLElement $xml): ar { $items = []; foreach ($xml as $item) { - $a = ($v = $item) ? (string) $v : null; - if (null !== $a) { - $items[] = $a; - } + $items[] = (string) $item; } return $items; } + private function populateResultCommonPrefix(\SimpleXMLElement $xml): CommonPrefix + { + return new CommonPrefix([ + 'Prefix' => (null !== $v = $xml->Prefix[0]) ? (string) $v : null, + ]); + } + /** * @return CommonPrefix[] */ @@ -437,14 +441,23 @@ private function populateResultCommonPrefixList(\SimpleXMLElement $xml): array { $items = []; foreach ($xml as $item) { - $items[] = new CommonPrefix([ - 'Prefix' => ($v = $item->Prefix) ? (string) $v : null, - ]); + $items[] = $this->populateResultCommonPrefix($item); } return $items; } + private function populateResultDeleteMarkerEntry(\SimpleXMLElement $xml): DeleteMarkerEntry + { + return new DeleteMarkerEntry([ + 'Owner' => 0 === $xml->Owner->count() ? null : $this->populateResultOwner($xml->Owner), + 'Key' => (null !== $v = $xml->Key[0]) ? (string) $v : null, + 'VersionId' => (null !== $v = $xml->VersionId[0]) ? (string) $v : null, + 'IsLatest' => (null !== $v = $xml->IsLatest[0]) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, + 'LastModified' => (null !== $v = $xml->LastModified[0]) ? new \DateTimeImmutable((string) $v) : null, + ]); + } + /** * @return DeleteMarkerEntry[] */ @@ -452,21 +465,28 @@ private function populateResultDeleteMarkers(\SimpleXMLElement $xml): array { $items = []; foreach ($xml as $item) { - $items[] = new DeleteMarkerEntry([ - 'Owner' => !$item->Owner ? null : new Owner([ - 'DisplayName' => ($v = $item->Owner->DisplayName) ? (string) $v : null, - 'ID' => ($v = $item->Owner->ID) ? (string) $v : null, - ]), - 'Key' => ($v = $item->Key) ? (string) $v : null, - 'VersionId' => ($v = $item->VersionId) ? (string) $v : null, - 'IsLatest' => ($v = $item->IsLatest) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, - 'LastModified' => ($v = $item->LastModified) ? new \DateTimeImmutable((string) $v) : null, - ]); + $items[] = $this->populateResultDeleteMarkerEntry($item); } return $items; } + private function populateResultObjectVersion(\SimpleXMLElement $xml): ObjectVersion + { + return new ObjectVersion([ + 'ETag' => (null !== $v = $xml->ETag[0]) ? (string) $v : null, + 'ChecksumAlgorithm' => (0 === ($v = $xml->ChecksumAlgorithm)->count()) ? null : $this->populateResultChecksumAlgorithmList($v), + 'Size' => (null !== $v = $xml->Size[0]) ? (int) (string) $v : null, + 'StorageClass' => (null !== $v = $xml->StorageClass[0]) ? (string) $v : null, + 'Key' => (null !== $v = $xml->Key[0]) ? (string) $v : null, + 'VersionId' => (null !== $v = $xml->VersionId[0]) ? (string) $v : null, + 'IsLatest' => (null !== $v = $xml->IsLatest[0]) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, + 'LastModified' => (null !== $v = $xml->LastModified[0]) ? new \DateTimeImmutable((string) $v) : null, + 'Owner' => 0 === $xml->Owner->count() ? null : $this->populateResultOwner($xml->Owner), + 'RestoreStatus' => 0 === $xml->RestoreStatus->count() ? null : $this->populateResultRestoreStatus($xml->RestoreStatus), + ]); + } + /** * @return ObjectVersion[] */ @@ -474,26 +494,25 @@ private function populateResultObjectVersionList(\SimpleXMLElement $xml): array { $items = []; foreach ($xml as $item) { - $items[] = new ObjectVersion([ - 'ETag' => ($v = $item->ETag) ? (string) $v : null, - 'ChecksumAlgorithm' => !$item->ChecksumAlgorithm ? null : $this->populateResultChecksumAlgorithmList($item->ChecksumAlgorithm), - 'Size' => ($v = $item->Size) ? (int) (string) $v : null, - 'StorageClass' => ($v = $item->StorageClass) ? (string) $v : null, - 'Key' => ($v = $item->Key) ? (string) $v : null, - 'VersionId' => ($v = $item->VersionId) ? (string) $v : null, - 'IsLatest' => ($v = $item->IsLatest) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, - 'LastModified' => ($v = $item->LastModified) ? new \DateTimeImmutable((string) $v) : null, - 'Owner' => !$item->Owner ? null : new Owner([ - 'DisplayName' => ($v = $item->Owner->DisplayName) ? (string) $v : null, - 'ID' => ($v = $item->Owner->ID) ? (string) $v : null, - ]), - 'RestoreStatus' => !$item->RestoreStatus ? null : new RestoreStatus([ - 'IsRestoreInProgress' => ($v = $item->RestoreStatus->IsRestoreInProgress) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, - 'RestoreExpiryDate' => ($v = $item->RestoreStatus->RestoreExpiryDate) ? new \DateTimeImmutable((string) $v) : null, - ]), - ]); + $items[] = $this->populateResultObjectVersion($item); } return $items; } + + private function populateResultOwner(\SimpleXMLElement $xml): Owner + { + return new Owner([ + 'DisplayName' => (null !== $v = $xml->DisplayName[0]) ? (string) $v : null, + 'ID' => (null !== $v = $xml->ID[0]) ? (string) $v : null, + ]); + } + + private function populateResultRestoreStatus(\SimpleXMLElement $xml): RestoreStatus + { + return new RestoreStatus([ + 'IsRestoreInProgress' => (null !== $v = $xml->IsRestoreInProgress[0]) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, + 'RestoreExpiryDate' => (null !== $v = $xml->RestoreExpiryDate[0]) ? new \DateTimeImmutable((string) $v) : null, + ]); + } } diff --git a/src/Service/S3/src/Result/ListObjectsV2Output.php b/src/Service/S3/src/Result/ListObjectsV2Output.php index af9ab7241..0e470bb9e 100644 --- a/src/Service/S3/src/Result/ListObjectsV2Output.php +++ b/src/Service/S3/src/Result/ListObjectsV2Output.php @@ -175,7 +175,7 @@ public function getCommonPrefixes(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextContinuationToken) { + if (null !== $page->nextContinuationToken) { $input->setContinuationToken($page->nextContinuationToken); $this->registerPrefetch($nextPage = $client->listObjectsV2($input)); @@ -219,7 +219,7 @@ public function getContents(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextContinuationToken) { + if (null !== $page->nextContinuationToken) { $input->setContinuationToken($page->nextContinuationToken); $this->registerPrefetch($nextPage = $client->listObjectsV2($input)); @@ -287,7 +287,7 @@ public function getIterator(): \Traversable $page = $this; while (true) { $page->initialize(); - if ($page->nextContinuationToken) { + if (null !== $page->nextContinuationToken) { $input->setContinuationToken($page->nextContinuationToken); $this->registerPrefetch($nextPage = $client->listObjectsV2($input)); @@ -366,18 +366,18 @@ protected function populateResult(Response $response): void $this->requestCharged = $headers['x-amz-request-charged'][0] ?? null; $data = new \SimpleXMLElement($response->getContent()); - $this->isTruncated = ($v = $data->IsTruncated) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null; - $this->contents = !$data->Contents ? [] : $this->populateResultObjectList($data->Contents); - $this->name = ($v = $data->Name) ? (string) $v : null; - $this->prefix = ($v = $data->Prefix) ? (string) $v : null; - $this->delimiter = ($v = $data->Delimiter) ? (string) $v : null; - $this->maxKeys = ($v = $data->MaxKeys) ? (int) (string) $v : null; - $this->commonPrefixes = !$data->CommonPrefixes ? [] : $this->populateResultCommonPrefixList($data->CommonPrefixes); - $this->encodingType = ($v = $data->EncodingType) ? (string) $v : null; - $this->keyCount = ($v = $data->KeyCount) ? (int) (string) $v : null; - $this->continuationToken = ($v = $data->ContinuationToken) ? (string) $v : null; - $this->nextContinuationToken = ($v = $data->NextContinuationToken) ? (string) $v : null; - $this->startAfter = ($v = $data->StartAfter) ? (string) $v : null; + $this->isTruncated = (null !== $v = $data->IsTruncated[0]) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null; + $this->contents = (0 === ($v = $data->Contents)->count()) ? [] : $this->populateResultObjectList($v); + $this->name = (null !== $v = $data->Name[0]) ? (string) $v : null; + $this->prefix = (null !== $v = $data->Prefix[0]) ? (string) $v : null; + $this->delimiter = (null !== $v = $data->Delimiter[0]) ? (string) $v : null; + $this->maxKeys = (null !== $v = $data->MaxKeys[0]) ? (int) (string) $v : null; + $this->commonPrefixes = (0 === ($v = $data->CommonPrefixes)->count()) ? [] : $this->populateResultCommonPrefixList($v); + $this->encodingType = (null !== $v = $data->EncodingType[0]) ? (string) $v : null; + $this->keyCount = (null !== $v = $data->KeyCount[0]) ? (int) (string) $v : null; + $this->continuationToken = (null !== $v = $data->ContinuationToken[0]) ? (string) $v : null; + $this->nextContinuationToken = (null !== $v = $data->NextContinuationToken[0]) ? (string) $v : null; + $this->startAfter = (null !== $v = $data->StartAfter[0]) ? (string) $v : null; } /** @@ -387,15 +387,19 @@ private function populateResultChecksumAlgorithmList(\SimpleXMLElement $xml): ar { $items = []; foreach ($xml as $item) { - $a = ($v = $item) ? (string) $v : null; - if (null !== $a) { - $items[] = $a; - } + $items[] = (string) $item; } return $items; } + private function populateResultCommonPrefix(\SimpleXMLElement $xml): CommonPrefix + { + return new CommonPrefix([ + 'Prefix' => (null !== $v = $xml->Prefix[0]) ? (string) $v : null, + ]); + } + /** * @return CommonPrefix[] */ @@ -403,14 +407,26 @@ private function populateResultCommonPrefixList(\SimpleXMLElement $xml): array { $items = []; foreach ($xml as $item) { - $items[] = new CommonPrefix([ - 'Prefix' => ($v = $item->Prefix) ? (string) $v : null, - ]); + $items[] = $this->populateResultCommonPrefix($item); } return $items; } + private function populateResultObject(\SimpleXMLElement $xml): AwsObject + { + return new AwsObject([ + 'Key' => (null !== $v = $xml->Key[0]) ? (string) $v : null, + 'LastModified' => (null !== $v = $xml->LastModified[0]) ? new \DateTimeImmutable((string) $v) : null, + 'ETag' => (null !== $v = $xml->ETag[0]) ? (string) $v : null, + 'ChecksumAlgorithm' => (0 === ($v = $xml->ChecksumAlgorithm)->count()) ? null : $this->populateResultChecksumAlgorithmList($v), + 'Size' => (null !== $v = $xml->Size[0]) ? (int) (string) $v : null, + 'StorageClass' => (null !== $v = $xml->StorageClass[0]) ? (string) $v : null, + 'Owner' => 0 === $xml->Owner->count() ? null : $this->populateResultOwner($xml->Owner), + 'RestoreStatus' => 0 === $xml->RestoreStatus->count() ? null : $this->populateResultRestoreStatus($xml->RestoreStatus), + ]); + } + /** * @return AwsObject[] */ @@ -418,24 +434,25 @@ private function populateResultObjectList(\SimpleXMLElement $xml): array { $items = []; foreach ($xml as $item) { - $items[] = new AwsObject([ - 'Key' => ($v = $item->Key) ? (string) $v : null, - 'LastModified' => ($v = $item->LastModified) ? new \DateTimeImmutable((string) $v) : null, - 'ETag' => ($v = $item->ETag) ? (string) $v : null, - 'ChecksumAlgorithm' => !$item->ChecksumAlgorithm ? null : $this->populateResultChecksumAlgorithmList($item->ChecksumAlgorithm), - 'Size' => ($v = $item->Size) ? (int) (string) $v : null, - 'StorageClass' => ($v = $item->StorageClass) ? (string) $v : null, - 'Owner' => !$item->Owner ? null : new Owner([ - 'DisplayName' => ($v = $item->Owner->DisplayName) ? (string) $v : null, - 'ID' => ($v = $item->Owner->ID) ? (string) $v : null, - ]), - 'RestoreStatus' => !$item->RestoreStatus ? null : new RestoreStatus([ - 'IsRestoreInProgress' => ($v = $item->RestoreStatus->IsRestoreInProgress) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, - 'RestoreExpiryDate' => ($v = $item->RestoreStatus->RestoreExpiryDate) ? new \DateTimeImmutable((string) $v) : null, - ]), - ]); + $items[] = $this->populateResultObject($item); } return $items; } + + private function populateResultOwner(\SimpleXMLElement $xml): Owner + { + return new Owner([ + 'DisplayName' => (null !== $v = $xml->DisplayName[0]) ? (string) $v : null, + 'ID' => (null !== $v = $xml->ID[0]) ? (string) $v : null, + ]); + } + + private function populateResultRestoreStatus(\SimpleXMLElement $xml): RestoreStatus + { + return new RestoreStatus([ + 'IsRestoreInProgress' => (null !== $v = $xml->IsRestoreInProgress[0]) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null, + 'RestoreExpiryDate' => (null !== $v = $xml->RestoreExpiryDate[0]) ? new \DateTimeImmutable((string) $v) : null, + ]); + } } diff --git a/src/Service/S3/src/Result/ListPartsOutput.php b/src/Service/S3/src/Result/ListPartsOutput.php index e01af9ffc..2f6241869 100644 --- a/src/Service/S3/src/Result/ListPartsOutput.php +++ b/src/Service/S3/src/Result/ListPartsOutput.php @@ -316,24 +316,48 @@ protected function populateResult(Response $response): void $this->requestCharged = $headers['x-amz-request-charged'][0] ?? null; $data = new \SimpleXMLElement($response->getContent()); - $this->bucket = ($v = $data->Bucket) ? (string) $v : null; - $this->key = ($v = $data->Key) ? (string) $v : null; - $this->uploadId = ($v = $data->UploadId) ? (string) $v : null; - $this->partNumberMarker = ($v = $data->PartNumberMarker) ? (int) (string) $v : null; - $this->nextPartNumberMarker = ($v = $data->NextPartNumberMarker) ? (int) (string) $v : null; - $this->maxParts = ($v = $data->MaxParts) ? (int) (string) $v : null; - $this->isTruncated = ($v = $data->IsTruncated) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null; - $this->parts = !$data->Part ? [] : $this->populateResultParts($data->Part); - $this->initiator = !$data->Initiator ? null : new Initiator([ - 'ID' => ($v = $data->Initiator->ID) ? (string) $v : null, - 'DisplayName' => ($v = $data->Initiator->DisplayName) ? (string) $v : null, + $this->bucket = (null !== $v = $data->Bucket[0]) ? (string) $v : null; + $this->key = (null !== $v = $data->Key[0]) ? (string) $v : null; + $this->uploadId = (null !== $v = $data->UploadId[0]) ? (string) $v : null; + $this->partNumberMarker = (null !== $v = $data->PartNumberMarker[0]) ? (int) (string) $v : null; + $this->nextPartNumberMarker = (null !== $v = $data->NextPartNumberMarker[0]) ? (int) (string) $v : null; + $this->maxParts = (null !== $v = $data->MaxParts[0]) ? (int) (string) $v : null; + $this->isTruncated = (null !== $v = $data->IsTruncated[0]) ? filter_var((string) $v, \FILTER_VALIDATE_BOOLEAN) : null; + $this->parts = (0 === ($v = $data->Part)->count()) ? [] : $this->populateResultParts($v); + $this->initiator = 0 === $data->Initiator->count() ? null : $this->populateResultInitiator($data->Initiator); + $this->owner = 0 === $data->Owner->count() ? null : $this->populateResultOwner($data->Owner); + $this->storageClass = (null !== $v = $data->StorageClass[0]) ? (string) $v : null; + $this->checksumAlgorithm = (null !== $v = $data->ChecksumAlgorithm[0]) ? (string) $v : null; + } + + private function populateResultInitiator(\SimpleXMLElement $xml): Initiator + { + return new Initiator([ + 'ID' => (null !== $v = $xml->ID[0]) ? (string) $v : null, + 'DisplayName' => (null !== $v = $xml->DisplayName[0]) ? (string) $v : null, + ]); + } + + private function populateResultOwner(\SimpleXMLElement $xml): Owner + { + return new Owner([ + 'DisplayName' => (null !== $v = $xml->DisplayName[0]) ? (string) $v : null, + 'ID' => (null !== $v = $xml->ID[0]) ? (string) $v : null, ]); - $this->owner = !$data->Owner ? null : new Owner([ - 'DisplayName' => ($v = $data->Owner->DisplayName) ? (string) $v : null, - 'ID' => ($v = $data->Owner->ID) ? (string) $v : null, + } + + private function populateResultPart(\SimpleXMLElement $xml): Part + { + return new Part([ + 'PartNumber' => (null !== $v = $xml->PartNumber[0]) ? (int) (string) $v : null, + 'LastModified' => (null !== $v = $xml->LastModified[0]) ? new \DateTimeImmutable((string) $v) : null, + 'ETag' => (null !== $v = $xml->ETag[0]) ? (string) $v : null, + 'Size' => (null !== $v = $xml->Size[0]) ? (int) (string) $v : null, + 'ChecksumCRC32' => (null !== $v = $xml->ChecksumCRC32[0]) ? (string) $v : null, + 'ChecksumCRC32C' => (null !== $v = $xml->ChecksumCRC32C[0]) ? (string) $v : null, + 'ChecksumSHA1' => (null !== $v = $xml->ChecksumSHA1[0]) ? (string) $v : null, + 'ChecksumSHA256' => (null !== $v = $xml->ChecksumSHA256[0]) ? (string) $v : null, ]); - $this->storageClass = ($v = $data->StorageClass) ? (string) $v : null; - $this->checksumAlgorithm = ($v = $data->ChecksumAlgorithm) ? (string) $v : null; } /** @@ -343,16 +367,7 @@ private function populateResultParts(\SimpleXMLElement $xml): array { $items = []; foreach ($xml as $item) { - $items[] = new Part([ - 'PartNumber' => ($v = $item->PartNumber) ? (int) (string) $v : null, - 'LastModified' => ($v = $item->LastModified) ? new \DateTimeImmutable((string) $v) : null, - 'ETag' => ($v = $item->ETag) ? (string) $v : null, - 'Size' => ($v = $item->Size) ? (int) (string) $v : null, - 'ChecksumCRC32' => ($v = $item->ChecksumCRC32) ? (string) $v : null, - 'ChecksumCRC32C' => ($v = $item->ChecksumCRC32C) ? (string) $v : null, - 'ChecksumSHA1' => ($v = $item->ChecksumSHA1) ? (string) $v : null, - 'ChecksumSHA256' => ($v = $item->ChecksumSHA256) ? (string) $v : null, - ]); + $items[] = $this->populateResultPart($item); } return $items; diff --git a/src/Service/S3/src/Result/UploadPartCopyOutput.php b/src/Service/S3/src/Result/UploadPartCopyOutput.php index 355c94568..eebb8f82d 100644 --- a/src/Service/S3/src/Result/UploadPartCopyOutput.php +++ b/src/Service/S3/src/Result/UploadPartCopyOutput.php @@ -148,13 +148,18 @@ protected function populateResult(Response $response): void $this->requestCharged = $headers['x-amz-request-charged'][0] ?? null; $data = new \SimpleXMLElement($response->getContent()); - $this->copyPartResult = new CopyPartResult([ - 'ETag' => ($v = $data->ETag) ? (string) $v : null, - 'LastModified' => ($v = $data->LastModified) ? new \DateTimeImmutable((string) $v) : null, - 'ChecksumCRC32' => ($v = $data->ChecksumCRC32) ? (string) $v : null, - 'ChecksumCRC32C' => ($v = $data->ChecksumCRC32C) ? (string) $v : null, - 'ChecksumSHA1' => ($v = $data->ChecksumSHA1) ? (string) $v : null, - 'ChecksumSHA256' => ($v = $data->ChecksumSHA256) ? (string) $v : null, + $this->copyPartResult = $this->populateResultCopyPartResult($data); + } + + private function populateResultCopyPartResult(\SimpleXMLElement $xml): CopyPartResult + { + return new CopyPartResult([ + 'ETag' => (null !== $v = $xml->ETag[0]) ? (string) $v : null, + 'LastModified' => (null !== $v = $xml->LastModified[0]) ? new \DateTimeImmutable((string) $v) : null, + 'ChecksumCRC32' => (null !== $v = $xml->ChecksumCRC32[0]) ? (string) $v : null, + 'ChecksumCRC32C' => (null !== $v = $xml->ChecksumCRC32C[0]) ? (string) $v : null, + 'ChecksumSHA1' => (null !== $v = $xml->ChecksumSHA1[0]) ? (string) $v : null, + 'ChecksumSHA256' => (null !== $v = $xml->ChecksumSHA256[0]) ? (string) $v : null, ]); } } diff --git a/src/Service/Scheduler/CHANGELOG.md b/src/Service/Scheduler/CHANGELOG.md index cb4048789..c345f4c46 100644 --- a/src/Service/Scheduler/CHANGELOG.md +++ b/src/Service/Scheduler/CHANGELOG.md @@ -2,6 +2,10 @@ ## NOT RELEASED +### Changed + +- use strict comparison `null !==` instead of `!` + ## 1.1.3 ### Changed diff --git a/src/Service/Scheduler/src/Result/ListScheduleGroupsOutput.php b/src/Service/Scheduler/src/Result/ListScheduleGroupsOutput.php index 289e186a8..29e8b0aad 100644 --- a/src/Service/Scheduler/src/Result/ListScheduleGroupsOutput.php +++ b/src/Service/Scheduler/src/Result/ListScheduleGroupsOutput.php @@ -70,7 +70,7 @@ public function getScheduleGroups(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->listScheduleGroups($input)); diff --git a/src/Service/Scheduler/src/Result/ListSchedulesOutput.php b/src/Service/Scheduler/src/Result/ListSchedulesOutput.php index 0c9489d4f..a3b53fa68 100644 --- a/src/Service/Scheduler/src/Result/ListSchedulesOutput.php +++ b/src/Service/Scheduler/src/Result/ListSchedulesOutput.php @@ -71,7 +71,7 @@ public function getSchedules(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->listSchedules($input)); diff --git a/src/Service/SecretsManager/CHANGELOG.md b/src/Service/SecretsManager/CHANGELOG.md index a2b51e6e2..32cb91f72 100644 --- a/src/Service/SecretsManager/CHANGELOG.md +++ b/src/Service/SecretsManager/CHANGELOG.md @@ -2,6 +2,10 @@ ## NOT RELEASED +### Changed + +- use strict comparison `null !==` instead of `!` + ## 2.4.0 ### Added diff --git a/src/Service/SecretsManager/src/Result/ListSecretsResponse.php b/src/Service/SecretsManager/src/Result/ListSecretsResponse.php index 17cedf0c1..bd58b58bc 100644 --- a/src/Service/SecretsManager/src/Result/ListSecretsResponse.php +++ b/src/Service/SecretsManager/src/Result/ListSecretsResponse.php @@ -74,7 +74,7 @@ public function getSecretList(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->listSecrets($input)); diff --git a/src/Service/Sns/CHANGELOG.md b/src/Service/Sns/CHANGELOG.md index 568ae8fd8..eac05e402 100644 --- a/src/Service/Sns/CHANGELOG.md +++ b/src/Service/Sns/CHANGELOG.md @@ -2,6 +2,10 @@ ## NOT RELEASED +### Changed + +- use strict comparison `null !==` instead of `!` + ## 1.7.4 ### Changed diff --git a/src/Service/Sns/src/Result/CreateEndpointResponse.php b/src/Service/Sns/src/Result/CreateEndpointResponse.php index 2aac668a4..410db0690 100644 --- a/src/Service/Sns/src/Result/CreateEndpointResponse.php +++ b/src/Service/Sns/src/Result/CreateEndpointResponse.php @@ -29,6 +29,6 @@ protected function populateResult(Response $response): void $data = new \SimpleXMLElement($response->getContent()); $data = $data->CreatePlatformEndpointResult; - $this->endpointArn = ($v = $data->EndpointArn) ? (string) $v : null; + $this->endpointArn = (null !== $v = $data->EndpointArn[0]) ? (string) $v : null; } } diff --git a/src/Service/Sns/src/Result/CreateTopicResponse.php b/src/Service/Sns/src/Result/CreateTopicResponse.php index cfe7fe0e1..add192657 100644 --- a/src/Service/Sns/src/Result/CreateTopicResponse.php +++ b/src/Service/Sns/src/Result/CreateTopicResponse.php @@ -29,6 +29,6 @@ protected function populateResult(Response $response): void $data = new \SimpleXMLElement($response->getContent()); $data = $data->CreateTopicResult; - $this->topicArn = ($v = $data->TopicArn) ? (string) $v : null; + $this->topicArn = (null !== $v = $data->TopicArn[0]) ? (string) $v : null; } } diff --git a/src/Service/Sns/src/Result/ListSubscriptionsByTopicResponse.php b/src/Service/Sns/src/Result/ListSubscriptionsByTopicResponse.php index f20482143..1178a8e2a 100644 --- a/src/Service/Sns/src/Result/ListSubscriptionsByTopicResponse.php +++ b/src/Service/Sns/src/Result/ListSubscriptionsByTopicResponse.php @@ -73,7 +73,7 @@ public function getSubscriptions(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->listSubscriptionsByTopic($input)); @@ -97,8 +97,19 @@ protected function populateResult(Response $response): void $data = new \SimpleXMLElement($response->getContent()); $data = $data->ListSubscriptionsByTopicResult; - $this->subscriptions = !$data->Subscriptions ? [] : $this->populateResultSubscriptionsList($data->Subscriptions); - $this->nextToken = ($v = $data->NextToken) ? (string) $v : null; + $this->subscriptions = (0 === ($v = $data->Subscriptions)->count()) ? [] : $this->populateResultSubscriptionsList($v); + $this->nextToken = (null !== $v = $data->NextToken[0]) ? (string) $v : null; + } + + private function populateResultSubscription(\SimpleXMLElement $xml): Subscription + { + return new Subscription([ + 'SubscriptionArn' => (null !== $v = $xml->SubscriptionArn[0]) ? (string) $v : null, + 'Owner' => (null !== $v = $xml->Owner[0]) ? (string) $v : null, + 'Protocol' => (null !== $v = $xml->Protocol[0]) ? (string) $v : null, + 'Endpoint' => (null !== $v = $xml->Endpoint[0]) ? (string) $v : null, + 'TopicArn' => (null !== $v = $xml->TopicArn[0]) ? (string) $v : null, + ]); } /** @@ -108,13 +119,7 @@ private function populateResultSubscriptionsList(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->member as $item) { - $items[] = new Subscription([ - 'SubscriptionArn' => ($v = $item->SubscriptionArn) ? (string) $v : null, - 'Owner' => ($v = $item->Owner) ? (string) $v : null, - 'Protocol' => ($v = $item->Protocol) ? (string) $v : null, - 'Endpoint' => ($v = $item->Endpoint) ? (string) $v : null, - 'TopicArn' => ($v = $item->TopicArn) ? (string) $v : null, - ]); + $items[] = $this->populateResultSubscription($item); } return $items; diff --git a/src/Service/Sns/src/Result/ListTopicsResponse.php b/src/Service/Sns/src/Result/ListTopicsResponse.php index e808a30a4..1108023ae 100644 --- a/src/Service/Sns/src/Result/ListTopicsResponse.php +++ b/src/Service/Sns/src/Result/ListTopicsResponse.php @@ -73,7 +73,7 @@ public function getTopics(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->listTopics($input)); @@ -97,8 +97,15 @@ protected function populateResult(Response $response): void $data = new \SimpleXMLElement($response->getContent()); $data = $data->ListTopicsResult; - $this->topics = !$data->Topics ? [] : $this->populateResultTopicsList($data->Topics); - $this->nextToken = ($v = $data->NextToken) ? (string) $v : null; + $this->topics = (0 === ($v = $data->Topics)->count()) ? [] : $this->populateResultTopicsList($v); + $this->nextToken = (null !== $v = $data->NextToken[0]) ? (string) $v : null; + } + + private function populateResultTopic(\SimpleXMLElement $xml): Topic + { + return new Topic([ + 'TopicArn' => (null !== $v = $xml->TopicArn[0]) ? (string) $v : null, + ]); } /** @@ -108,9 +115,7 @@ private function populateResultTopicsList(\SimpleXMLElement $xml): array { $items = []; foreach ($xml->member as $item) { - $items[] = new Topic([ - 'TopicArn' => ($v = $item->TopicArn) ? (string) $v : null, - ]); + $items[] = $this->populateResultTopic($item); } return $items; diff --git a/src/Service/Sns/src/Result/PublishBatchResponse.php b/src/Service/Sns/src/Result/PublishBatchResponse.php index 115681965..fb4fcb43f 100644 --- a/src/Service/Sns/src/Result/PublishBatchResponse.php +++ b/src/Service/Sns/src/Result/PublishBatchResponse.php @@ -48,8 +48,18 @@ protected function populateResult(Response $response): void $data = new \SimpleXMLElement($response->getContent()); $data = $data->PublishBatchResult; - $this->successful = !$data->Successful ? [] : $this->populateResultPublishBatchResultEntryList($data->Successful); - $this->failed = !$data->Failed ? [] : $this->populateResultBatchResultErrorEntryList($data->Failed); + $this->successful = (0 === ($v = $data->Successful)->count()) ? [] : $this->populateResultPublishBatchResultEntryList($v); + $this->failed = (0 === ($v = $data->Failed)->count()) ? [] : $this->populateResultBatchResultErrorEntryList($v); + } + + private function populateResultBatchResultErrorEntry(\SimpleXMLElement $xml): BatchResultErrorEntry + { + return new BatchResultErrorEntry([ + 'Id' => (string) $xml->Id, + 'Code' => (string) $xml->Code, + 'Message' => (null !== $v = $xml->Message[0]) ? (string) $v : null, + 'SenderFault' => filter_var((string) $xml->SenderFault, \FILTER_VALIDATE_BOOLEAN), + ]); } /** @@ -59,17 +69,21 @@ private function populateResultBatchResultErrorEntryList(\SimpleXMLElement $xml) { $items = []; foreach ($xml->member as $item) { - $items[] = new BatchResultErrorEntry([ - 'Id' => (string) $item->Id, - 'Code' => (string) $item->Code, - 'Message' => ($v = $item->Message) ? (string) $v : null, - 'SenderFault' => filter_var((string) $item->SenderFault, \FILTER_VALIDATE_BOOLEAN), - ]); + $items[] = $this->populateResultBatchResultErrorEntry($item); } return $items; } + private function populateResultPublishBatchResultEntry(\SimpleXMLElement $xml): PublishBatchResultEntry + { + return new PublishBatchResultEntry([ + 'Id' => (null !== $v = $xml->Id[0]) ? (string) $v : null, + 'MessageId' => (null !== $v = $xml->MessageId[0]) ? (string) $v : null, + 'SequenceNumber' => (null !== $v = $xml->SequenceNumber[0]) ? (string) $v : null, + ]); + } + /** * @return PublishBatchResultEntry[] */ @@ -77,11 +91,7 @@ private function populateResultPublishBatchResultEntryList(\SimpleXMLElement $xm { $items = []; foreach ($xml->member as $item) { - $items[] = new PublishBatchResultEntry([ - 'Id' => ($v = $item->Id) ? (string) $v : null, - 'MessageId' => ($v = $item->MessageId) ? (string) $v : null, - 'SequenceNumber' => ($v = $item->SequenceNumber) ? (string) $v : null, - ]); + $items[] = $this->populateResultPublishBatchResultEntry($item); } return $items; diff --git a/src/Service/Sns/src/Result/PublishResponse.php b/src/Service/Sns/src/Result/PublishResponse.php index 5f8049f14..b94e2fd87 100644 --- a/src/Service/Sns/src/Result/PublishResponse.php +++ b/src/Service/Sns/src/Result/PublishResponse.php @@ -48,7 +48,7 @@ protected function populateResult(Response $response): void $data = new \SimpleXMLElement($response->getContent()); $data = $data->PublishResult; - $this->messageId = ($v = $data->MessageId) ? (string) $v : null; - $this->sequenceNumber = ($v = $data->SequenceNumber) ? (string) $v : null; + $this->messageId = (null !== $v = $data->MessageId[0]) ? (string) $v : null; + $this->sequenceNumber = (null !== $v = $data->SequenceNumber[0]) ? (string) $v : null; } } diff --git a/src/Service/Sns/src/Result/SubscribeResponse.php b/src/Service/Sns/src/Result/SubscribeResponse.php index d56ae7f2b..3e7a0f7c3 100644 --- a/src/Service/Sns/src/Result/SubscribeResponse.php +++ b/src/Service/Sns/src/Result/SubscribeResponse.php @@ -31,6 +31,6 @@ protected function populateResult(Response $response): void $data = new \SimpleXMLElement($response->getContent()); $data = $data->SubscribeResult; - $this->subscriptionArn = ($v = $data->SubscriptionArn) ? (string) $v : null; + $this->subscriptionArn = (null !== $v = $data->SubscriptionArn[0]) ? (string) $v : null; } } diff --git a/src/Service/Sqs/CHANGELOG.md b/src/Service/Sqs/CHANGELOG.md index 638d92105..f134a1965 100644 --- a/src/Service/Sqs/CHANGELOG.md +++ b/src/Service/Sqs/CHANGELOG.md @@ -2,6 +2,10 @@ ## NOT RELEASED +### Changed + +- use strict comparison `null !==` instead of `!` + ## 2.2.0 ### Added diff --git a/src/Service/Sqs/src/Result/ListQueuesResult.php b/src/Service/Sqs/src/Result/ListQueuesResult.php index 7ad3b5f61..6cdedde9a 100644 --- a/src/Service/Sqs/src/Result/ListQueuesResult.php +++ b/src/Service/Sqs/src/Result/ListQueuesResult.php @@ -72,7 +72,7 @@ public function getQueueUrls(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->listQueues($input)); diff --git a/src/Service/Ssm/CHANGELOG.md b/src/Service/Ssm/CHANGELOG.md index a3a1affe7..14086476a 100644 --- a/src/Service/Ssm/CHANGELOG.md +++ b/src/Service/Ssm/CHANGELOG.md @@ -2,6 +2,10 @@ ## NOT RELEASED +### Changed + +- use strict comparison `null !==` instead of `!` + ## 2.1.4 ### Changed diff --git a/src/Service/Ssm/src/Result/GetParametersByPathResult.php b/src/Service/Ssm/src/Result/GetParametersByPathResult.php index e99e75677..f327b016a 100644 --- a/src/Service/Ssm/src/Result/GetParametersByPathResult.php +++ b/src/Service/Ssm/src/Result/GetParametersByPathResult.php @@ -70,7 +70,7 @@ public function getParameters(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->getParametersByPath($input)); diff --git a/src/Service/TimestreamQuery/CHANGELOG.md b/src/Service/TimestreamQuery/CHANGELOG.md index 63c2cfcb4..8f4a61213 100644 --- a/src/Service/TimestreamQuery/CHANGELOG.md +++ b/src/Service/TimestreamQuery/CHANGELOG.md @@ -6,6 +6,10 @@ - AWS api-change: This release adds support for Query Insights, a feature that provides details of query execution, enabling users to identify areas for improvement to optimize their queries, resulting in improved query performance and lower query costs. +### Changed + +- use strict comparison `null !==` instead of `!` + ## 2.0.4 ### Changed diff --git a/src/Service/TimestreamQuery/src/Result/QueryResponse.php b/src/Service/TimestreamQuery/src/Result/QueryResponse.php index 2dbfcc3cf..3ce0384b9 100644 --- a/src/Service/TimestreamQuery/src/Result/QueryResponse.php +++ b/src/Service/TimestreamQuery/src/Result/QueryResponse.php @@ -139,7 +139,7 @@ public function getRows(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if ($page->nextToken) { + if (null !== $page->nextToken) { $input->setNextToken($page->nextToken); $this->registerPrefetch($nextPage = $client->query($input));