diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index c76732289016ec6341ce914d90a4e6a4e6102411..b9c47e84b8bebd87a95cfca3a94bd3ae555504c1 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 346792da67d9f425d4cb3011ce795aa9bea8168b..9ed2af14babe758c23520a2bbadc26565bc0cf69 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: coverage: none - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Initialize tests run: make initialize diff --git a/CHANGELOG.md b/CHANGELOG.md index 568ae8fd845e38edf74dc545187b9b8822f80ccb..01507511fa88571717fff4654889a409676f0cc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ ## NOT RELEASED +## 1.7.5 + +### Changed + +- use strict comparison `null !==` instead of `!` +- AWS enhancement: Documentation updates. + ## 1.7.4 ### Changed diff --git a/src/Input/CreateTopicInput.php b/src/Input/CreateTopicInput.php index e507f88626e8de5fa3d1d4218708716d50d3d04f..bcd7268079e1a94f3d681775e8736a654b550731 100644 --- a/src/Input/CreateTopicInput.php +++ b/src/Input/CreateTopicInput.php @@ -54,11 +54,8 @@ final class CreateTopicInput extends Input * * The following attributes apply only to FIFO topics [^4]: * - * - `ArchivePolicy` – Adds or updates an inline policy document to archive messages stored in the specified Amazon - * SNS topic. - * - `BeginningArchiveTime` – The earliest starting point at which a message in the topic’s archive can be replayed - * from. This point in time is based on the configured message retention period set by the topic’s message archiving - * policy. + * - `ArchivePolicy` – The policy that sets the retention period for messages stored in the message archive of an + * Amazon SNS FIFO topic. * - `ContentBasedDeduplication` – Enables content-based deduplication for FIFO topics. * * - By default, `ContentBasedDeduplication` is set to `false`. If you create a FIFO topic and this attribute is diff --git a/src/Result/CreateEndpointResponse.php b/src/Result/CreateEndpointResponse.php index 2aac668a416e60fe33154678aab0e400e092d5d5..410db0690c5835a99203161fcbdf882d1050dcb7 100644 --- a/src/Result/CreateEndpointResponse.php +++ b/src/Result/CreateEndpointResponse.php @@ -29,6 +29,6 @@ class CreateEndpointResponse extends Result $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/Result/CreateTopicResponse.php b/src/Result/CreateTopicResponse.php index cfe7fe0e1f14c386511d5deaf2c036516ecbfe17..add192657f5871865566c3388f8f1166bcaa2230 100644 --- a/src/Result/CreateTopicResponse.php +++ b/src/Result/CreateTopicResponse.php @@ -29,6 +29,6 @@ class CreateTopicResponse extends Result $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/Result/ListSubscriptionsByTopicResponse.php b/src/Result/ListSubscriptionsByTopicResponse.php index f204821432d4ebbe82f49336342a88c58de44256..1178a8e2a79cdeb4e6fb95573144b490d4af6834 100644 --- a/src/Result/ListSubscriptionsByTopicResponse.php +++ b/src/Result/ListSubscriptionsByTopicResponse.php @@ -73,7 +73,7 @@ class ListSubscriptionsByTopicResponse extends Result implements \IteratorAggreg $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 @@ class ListSubscriptionsByTopicResponse extends Result implements \IteratorAggreg $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 @@ class ListSubscriptionsByTopicResponse extends Result implements \IteratorAggreg { $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/Result/ListTopicsResponse.php b/src/Result/ListTopicsResponse.php index e808a30a4dc2088b06aaba6cc61a183a54f60bb7..1108023ae4dff267fffe6d21917f9b7fcdcd4550 100644 --- a/src/Result/ListTopicsResponse.php +++ b/src/Result/ListTopicsResponse.php @@ -73,7 +73,7 @@ class ListTopicsResponse extends Result implements \IteratorAggregate $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 @@ class ListTopicsResponse extends Result implements \IteratorAggregate $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 @@ class ListTopicsResponse extends Result implements \IteratorAggregate { $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/Result/PublishBatchResponse.php b/src/Result/PublishBatchResponse.php index 11568196574b5cda00253ba2a203ff4a4b0e2f8e..fb4fcb43faf689d2ebcaf2fa16c9077042bf61b9 100644 --- a/src/Result/PublishBatchResponse.php +++ b/src/Result/PublishBatchResponse.php @@ -48,8 +48,18 @@ class PublishBatchResponse extends Result $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 @@ class PublishBatchResponse extends Result { $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 @@ class PublishBatchResponse extends Result { $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/Result/PublishResponse.php b/src/Result/PublishResponse.php index 5f8049f1476b85261671444e7a71e1a67a130655..b94e2fd87c600a54a60a099c9d8d9ed41188102a 100644 --- a/src/Result/PublishResponse.php +++ b/src/Result/PublishResponse.php @@ -48,7 +48,7 @@ class PublishResponse extends Result $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/Result/SubscribeResponse.php b/src/Result/SubscribeResponse.php index d56ae7f2b3c71a6a8cb863e4e80ff4709b15d997..3e7a0f7c3e71a3317cff78feb2d7272b8b5f6ac8 100644 --- a/src/Result/SubscribeResponse.php +++ b/src/Result/SubscribeResponse.php @@ -31,6 +31,6 @@ class SubscribeResponse extends Result $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; } }