diff --git a/.pubnub.yml b/.pubnub.yml index e201686f..1b86674d 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,8 +1,13 @@ name: php -version: 7.0.0 +version: 7.0.1 schema: 1 scm: github.com/pubnub/php changelog: + - date: 2024-07-10 + version: 7.0.1 + changes: + - type: improvement + text: "Added strict typing for some customer facing elements." - date: 2024-06-27 version: 7.0.0 changes: @@ -429,8 +434,8 @@ sdks: - x86-64 - distribution-type: library distribution-repository: GitHub release - package-name: php-7.0.0.zip - location: https://github.com/pubnub/php/releases/tag/7.0.0 + package-name: php-7.0.1.zip + location: https://github.com/pubnub/php/releases/tag/7.0.1 requires: - name: rmccue/requests min-version: 1.0.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index 93a51118..5ed35e59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 7.0.1 +July 10 2024 + +#### Modified +- Added strict typing for some customer facing elements. + ## 7.0.0 June 27 2024 diff --git a/README.md b/README.md index ce2efa1b..f22d4053 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ You will need the publish and subscribe keys to authenticate your app. Get your { "require": { - "pubnub/pubnub": "7.0.0" + "pubnub/pubnub": "7.0.1" } } ``` diff --git a/composer.json b/composer.json index 846fd0e0..c7d54c97 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "keywords": ["api", "real-time", "realtime", "real time", "ajax", "push"], "homepage": "http://www.pubnub.com/", "license": "proprietary", - "version": "7.0.0", + "version": "7.0.1", "authors": [ { "name": "PubNub", diff --git a/src/PubNub/Endpoints/Access/Audit.php b/src/PubNub/Endpoints/Access/Audit.php index 40ad01e3..e135dc8c 100644 --- a/src/PubNub/Endpoints/Access/Audit.php +++ b/src/PubNub/Endpoints/Access/Audit.php @@ -9,10 +9,9 @@ use PubNub\Models\Consumer\AccessManager\PNAccessManagerAuditResult; use PubNub\PubNubUtil; - class Audit extends Endpoint { - const PATH = "/v1/auth/audit/sub-key/%s"; + protected const PATH = "/v1/auth/audit/sub-key/%s"; /** @var string[] */ protected $authKeys = []; @@ -88,7 +87,7 @@ protected function httpMethod() /** * @return PNAccessManagerAuditResult */ - public function sync() + public function sync(): PNAccessManagerAuditResult { return parent::sync(); } @@ -97,7 +96,7 @@ public function sync() * @param array $result Decoded json * @return PNAccessManagerAuditResult */ - protected function createResponse($result) + protected function createResponse($result): PNAccessManagerAuditResult { return PNAccessManagerAuditResult::fromJson($result['payload']); } diff --git a/src/PubNub/Endpoints/Access/Grant.php b/src/PubNub/Endpoints/Access/Grant.php index d8d90ff4..57ad8382 100644 --- a/src/PubNub/Endpoints/Access/Grant.php +++ b/src/PubNub/Endpoints/Access/Grant.php @@ -4,15 +4,14 @@ use PubNub\Endpoints\Endpoint; use PubNub\Exceptions\PubNubValidationException; -use PubNub\Models\Consumer\AccessManager\PNAccessManagerGrantResult; use PubNub\PubNubUtil; use PubNub\Enums\PNHttpMethod; use PubNub\Enums\PNOperationType; - +use PubNub\Models\Consumer\AccessManager\PNAccessManagerAbstractResult; class Grant extends Endpoint { - const PATH = "/v2/auth/grant/sub-key/%s"; + protected const PATH = "/v2/auth/grant/sub-key/%s"; /** @var string[] */ protected $authKeys = []; @@ -195,7 +194,10 @@ public function validateParams() $this->validateSubscribeKey(); $this->validateSecretKey(); - if ($this->write === null && $this->read === null && $this->manage === null && $this->get === null && $this->update === null && $this->join === null) { + if ( + $this->write === null && $this->read === null && $this->manage === null && $this->get === null + && $this->update === null && $this->join === null + ) { throw new PubNubValidationException("At least one flag should be specified"); } } @@ -277,20 +279,20 @@ public function buildPath() } /** - * @return PNAccessManagerGrantResult + * @return PNAccessManagerAbstractResult */ - public function sync() + public function sync(): PNAccessManagerAbstractResult { return parent::sync(); } /** * @param array $result - * @return PNAccessManagerGrantResult + * @return PNAccessManagerAbstractResult */ - public function createResponse($result) + public function createResponse($result): PNAccessManagerAbstractResult { - return PNAccessManagerGrantResult::fromJson($result['payload']); + return PNAccessManagerAbstractResult::fromJson($result['payload']); } /** @@ -365,4 +367,3 @@ public function getName() return "Grant"; } } - diff --git a/src/PubNub/Endpoints/Access/GrantToken.php b/src/PubNub/Endpoints/Access/GrantToken.php index d12751e7..f10b18c7 100644 --- a/src/PubNub/Endpoints/Access/GrantToken.php +++ b/src/PubNub/Endpoints/Access/GrantToken.php @@ -14,7 +14,7 @@ class GrantToken extends Endpoint { - private const PATH = '/v3/pam/%s/grant'; + protected const PATH = '/v3/pam/%s/grant'; /** @var int */ protected $ttl; @@ -239,16 +239,16 @@ public function buildPath() /** * @return PNAccessManagerGrantResult */ - public function sync() + public function sync(): PNAccessManagerGrantResult { return parent::sync(); } /** * @param string $token - * @return PNAccessManagerGrantResult + * @return : PNAccessManagerGrantResult */ - public function createResponse($response) + public function createResponse($response): PNAccessManagerGrantResult { return $response['data']['token']; } diff --git a/src/PubNub/Endpoints/Access/RevokeToken.php b/src/PubNub/Endpoints/Access/RevokeToken.php index 9b48d7f5..61c5bec4 100644 --- a/src/PubNub/Endpoints/Access/RevokeToken.php +++ b/src/PubNub/Endpoints/Access/RevokeToken.php @@ -11,7 +11,7 @@ class RevokeToken extends Endpoint { - const PATH = "/v3/pam/%s/grant/%s"; + protected const PATH = "/v3/pam/%s/grant/%s"; protected $token; @@ -74,7 +74,7 @@ public function buildPath() /** * @return PNRequestResult */ - public function sync() + public function sync(): PNRequestResult { return parent::sync(); } @@ -83,7 +83,7 @@ public function sync() * @param string $token * @return PNRequestResult */ - public function createResponse($response) + public function createResponse($response): PNRequestResult { return new PNRequestResult( $response['status'], diff --git a/src/PubNub/Endpoints/ChannelGroups/AddChannelToChannelGroup.php b/src/PubNub/Endpoints/ChannelGroups/AddChannelToChannelGroup.php index dcc6c3d7..92a6296e 100644 --- a/src/PubNub/Endpoints/ChannelGroups/AddChannelToChannelGroup.php +++ b/src/PubNub/Endpoints/ChannelGroups/AddChannelToChannelGroup.php @@ -9,10 +9,9 @@ use PubNub\Models\Consumer\ChannelGroup\PNChannelGroupsAddChannelResult; use PubNub\PubNubUtil; - class AddChannelToChannelGroup extends Endpoint { - const PATH = "/v1/channel-registration/sub-key/%s/channel-group/%s"; + protected const PATH = "/v1/channel-registration/sub-key/%s/channel-group/%s"; /** @var string[] */ protected $channels = []; @@ -78,11 +77,16 @@ protected function buildPath() ); } + public function sync(): PNChannelGroupsAddChannelResult + { + return parent::sync(); + } + /** * @param array $result Decoded json * @return PNChannelGroupsAddChannelResult */ - protected function createResponse($result) + protected function createResponse($result): PNChannelGroupsAddChannelResult { return new PNChannelGroupsAddChannelResult(); } @@ -104,7 +108,7 @@ protected function customParams() */ protected function isAuthRequired() { - return True; + return true; } /** diff --git a/src/PubNub/Endpoints/ChannelGroups/ListChannelsInChannelGroup.php b/src/PubNub/Endpoints/ChannelGroups/ListChannelsInChannelGroup.php index fd729fc2..cd38e067 100644 --- a/src/PubNub/Endpoints/ChannelGroups/ListChannelsInChannelGroup.php +++ b/src/PubNub/Endpoints/ChannelGroups/ListChannelsInChannelGroup.php @@ -8,10 +8,9 @@ use PubNub\Exceptions\PubNubValidationException; use PubNub\Models\Consumer\ChannelGroup\PNChannelGroupsListChannelsResult; - class ListChannelsInChannelGroup extends Endpoint { - const PATH = "/v1/channel-registration/sub-key/%s/channel-group/%s"; + protected const PATH = "/v1/channel-registration/sub-key/%s/channel-group/%s"; /** @var string */ protected $channelGroup; @@ -72,7 +71,7 @@ protected function buildPath() /** * @return PNChannelGroupsListChannelsResult */ - public function sync() + public function sync(): PNChannelGroupsListChannelsResult { return parent::sync(); } @@ -81,7 +80,7 @@ public function sync() * @param array $result Decoded json * @return PNChannelGroupsListChannelsResult */ - protected function createResponse($result) + protected function createResponse($result): PNChannelGroupsListChannelsResult { return PNChannelGroupsListChannelsResult::fromPayload(static::fetchPayload($result)); } @@ -91,7 +90,7 @@ protected function createResponse($result) */ protected function isAuthRequired() { - return True; + return true; } /** @@ -133,4 +132,4 @@ protected function getName() { return "ListChannelsInChannelGroup"; } -} \ No newline at end of file +} diff --git a/src/PubNub/Endpoints/ChannelGroups/RemoveChannelFromChannelGroup.php b/src/PubNub/Endpoints/ChannelGroups/RemoveChannelFromChannelGroup.php index a0722bd7..3908429e 100644 --- a/src/PubNub/Endpoints/ChannelGroups/RemoveChannelFromChannelGroup.php +++ b/src/PubNub/Endpoints/ChannelGroups/RemoveChannelFromChannelGroup.php @@ -9,10 +9,9 @@ use PubNub\Models\Consumer\ChannelGroup\PNChannelGroupsRemoveChannelResult; use PubNub\PubNubUtil; - class RemoveChannelFromChannelGroup extends Endpoint { - const PATH = "/v1/channel-registration/sub-key/%s/channel-group/%s"; + protected const PATH = "/v1/channel-registration/sub-key/%s/channel-group/%s"; /** @var string */ protected $channelGroup; @@ -93,7 +92,7 @@ protected function customParams() /** * @return PNChannelGroupsRemoveChannelResult */ - public function sync() + public function sync(): PNChannelGroupsRemoveChannelResult { return parent::sync(); } @@ -102,7 +101,7 @@ public function sync() * @param array $result Decoded json * @return PNChannelGroupsRemoveChannelResult */ - protected function createResponse($result) + protected function createResponse($result): PNChannelGroupsRemoveChannelResult { return new PNChannelGroupsRemoveChannelResult(); } @@ -112,7 +111,7 @@ protected function createResponse($result) */ protected function isAuthRequired() { - return True; + return true; } /** @@ -154,4 +153,4 @@ protected function getName() { return "RemoveChannelFromChannelGroup"; } -} \ No newline at end of file +} diff --git a/src/PubNub/Endpoints/ChannelGroups/RemoveChannelGroup.php b/src/PubNub/Endpoints/ChannelGroups/RemoveChannelGroup.php index 6140e4e5..3e0e6299 100644 --- a/src/PubNub/Endpoints/ChannelGroups/RemoveChannelGroup.php +++ b/src/PubNub/Endpoints/ChannelGroups/RemoveChannelGroup.php @@ -8,10 +8,9 @@ use PubNub\Exceptions\PubNubValidationException; use PubNub\Models\Consumer\ChannelGroup\PNChannelGroupsRemoveGroupResult; - class RemoveChannelGroup extends Endpoint { - const PATH = "/v1/channel-registration/sub-key/%s/channel-group/%s/remove"; + protected const PATH = "/v1/channel-registration/sub-key/%s/channel-group/%s/remove"; /** @var string */ private $channelGroup; @@ -72,7 +71,7 @@ protected function buildPath() /** * @return PNChannelGroupsRemoveGroupResult */ - public function sync() + public function sync(): PNChannelGroupsRemoveGroupResult { return parent::sync(); } @@ -81,7 +80,7 @@ public function sync() * @param array $result Decoded json * @return PNChannelGroupsRemoveGroupResult */ - protected function createResponse($result) + protected function createResponse($result): PNChannelGroupsRemoveGroupResult { return new PNChannelGroupsRemoveGroupResult(); } @@ -91,7 +90,7 @@ protected function createResponse($result) */ protected function isAuthRequired() { - return True; + return true; } /** @@ -133,4 +132,4 @@ protected function getName() { return "RemoveChannelGroup"; } -} \ No newline at end of file +} diff --git a/src/PubNub/Endpoints/FileSharing/DeleteFile.php b/src/PubNub/Endpoints/FileSharing/DeleteFile.php index be9897fa..2f20bef3 100644 --- a/src/PubNub/Endpoints/FileSharing/DeleteFile.php +++ b/src/PubNub/Endpoints/FileSharing/DeleteFile.php @@ -11,7 +11,12 @@ class DeleteFile extends FileSharingEndpoint { protected const ENDPOINT_URL = "/v1/files/%s/channels/%s/files/%s/%s"; - protected function createResponse($result) + public function sync(): PNDeleteFileResult + { + return parent::sync(); + } + + protected function createResponse($result): PNDeleteFileResult { return new PNDeleteFileResult($result); } diff --git a/src/PubNub/Endpoints/FileSharing/DownloadFile.php b/src/PubNub/Endpoints/FileSharing/DownloadFile.php index 9325376e..6d2ac029 100644 --- a/src/PubNub/Endpoints/FileSharing/DownloadFile.php +++ b/src/PubNub/Endpoints/FileSharing/DownloadFile.php @@ -39,7 +39,12 @@ protected function isAuthRequired() return false; } - protected function createResponse($result) + public function sync(): PNDownloadFileResult + { + return parent::sync(); + } + + protected function createResponse($result): PNDownloadFileResult { if ($this->pubnub->isCryptoEnabled()) { return new PNDownloadFileResult($this->pubnub->getCrypto()->decrypt((string)$result)); diff --git a/src/PubNub/Endpoints/FileSharing/FetchFileUploadS3Data.php b/src/PubNub/Endpoints/FileSharing/FetchFileUploadS3Data.php index 1055bd1a..b21ba37e 100644 --- a/src/PubNub/Endpoints/FileSharing/FetchFileUploadS3Data.php +++ b/src/PubNub/Endpoints/FileSharing/FetchFileUploadS3Data.php @@ -82,7 +82,12 @@ public function httpMethod() return PNHttpMethod::POST; } - public function createResponse($result) + public function sync(): PNFetchFileUploadS3DataResult + { + return parent::sync(); + } + + public function createResponse($result): PNFetchFileUploadS3DataResult { return new PNFetchFileUploadS3DataResult($result); } diff --git a/src/PubNub/Endpoints/FileSharing/GetFileDownloadUrl.php b/src/PubNub/Endpoints/FileSharing/GetFileDownloadUrl.php index 0ff670f1..5593776b 100644 --- a/src/PubNub/Endpoints/FileSharing/GetFileDownloadUrl.php +++ b/src/PubNub/Endpoints/FileSharing/GetFileDownloadUrl.php @@ -42,7 +42,7 @@ protected function isAuthRequired() return false; } - protected function createResponse($result) + protected function createResponse($result): PNGetFileDownloadURLResult { return new PNGetFileDownloadURLResult($result); } diff --git a/src/PubNub/Endpoints/FileSharing/ListFiles.php b/src/PubNub/Endpoints/FileSharing/ListFiles.php index 753fd0e8..876fe216 100644 --- a/src/PubNub/Endpoints/FileSharing/ListFiles.php +++ b/src/PubNub/Endpoints/FileSharing/ListFiles.php @@ -74,6 +74,11 @@ protected function isAuthRequired(): bool return true; } + public function sync(): PNGetFilesResult + { + return parent::sync(); + } + protected function createResponse($result): PNGetFilesResult { return new PNGetFilesResult($result); diff --git a/src/PubNub/Endpoints/FileSharing/PublishFileMessage.php b/src/PubNub/Endpoints/FileSharing/PublishFileMessage.php index c9129809..63b06d4c 100644 --- a/src/PubNub/Endpoints/FileSharing/PublishFileMessage.php +++ b/src/PubNub/Endpoints/FileSharing/PublishFileMessage.php @@ -55,7 +55,7 @@ protected function buildPath() public function encryptMessage($message) { - $crypto = $this->pubnub->getCryptoSafe(); + $crypto = $this->pubnub->getCrypto(); $messageString = PubNubUtil::writeValueAsString($message); if ($crypto) { return $crypto->encrypt($messageString); @@ -101,11 +101,16 @@ public function getName(): string return "Sending file upload notification"; } - public function createResponse($result) + public function createResponse($result): PNPublishFileMessageResult { return new PNPublishFileMessageResult($result); } + public function sync(): PNPublishFileMessageResult + { + return parent::sync(); + } + protected function isAuthRequired() { return true; diff --git a/src/PubNub/Endpoints/FileSharing/SendFile.php b/src/PubNub/Endpoints/FileSharing/SendFile.php index 02ee6b43..80698972 100644 --- a/src/PubNub/Endpoints/FileSharing/SendFile.php +++ b/src/PubNub/Endpoints/FileSharing/SendFile.php @@ -7,6 +7,7 @@ use PubNub\Enums\PNHttpMethod; use PubNub\Enums\PNOperationType; use PubNub\Exceptions\PubNubValidationException; +use PubNub\Models\Consumer\FileSharing\PNPublishFileMessageResult; use PubNub\PubNubUtil; use WpOrg\Requests\Requests; @@ -188,7 +189,7 @@ protected function buildPath() protected function encryptPayload() { - $crypto = $this->pubnub->getCryptoSafe(); + $crypto = $this->pubnub->getCrypto(); if ($this->fileHandle) { $fileContent = stream_get_contents($this->fileHandle); } else { @@ -245,7 +246,7 @@ protected function uploadFile() return $response; } - public function sync() + public function sync(): PNPublishFileMessageResult { $this->fileUploadEnvelope = (new FetchFileUploadS3Data($this->pubnub)) ->channel($this->channel) diff --git a/src/PubNub/Endpoints/History.php b/src/PubNub/Endpoints/History.php index 24b0ed2e..ff0fb528 100644 --- a/src/PubNub/Endpoints/History.php +++ b/src/PubNub/Endpoints/History.php @@ -8,29 +8,28 @@ use PubNub\Models\Consumer\History\PNHistoryResult; use PubNub\PubNubUtil; - class History extends Endpoint { - const PATH = "/v2/history/sub-key/%s/channel/%s"; - const MAX_COUNT = 100; + protected const PATH = "/v2/history/sub-key/%s/channel/%s"; + protected const MAX_COUNT = 100; /** @var string */ - protected $channel; + protected string $channel; /** @var int */ - protected $start; + protected ?int $start; /** @var int */ - protected $end; + protected ?int $end; /** @var bool */ - protected $reverse; + protected ?bool $reverse; /** @var int */ - protected $count; + protected ?int $count; /** @var bool */ - protected $includeTimetoken; + protected ?bool $includeTimetoken; /** * @param string $channel @@ -105,7 +104,7 @@ public function validateParams() { $this->validateSubscribeKey(); - if ($this->channel === null || strlen($this->channel) === 0) { + if (!isset($this->channel) || strlen($this->channel) === 0) { throw new PubNubValidationException("Channel missing"); } } @@ -117,25 +116,25 @@ protected function customParams() { $params = []; - if ($this->start !== null) { + if (isset($this->start)) { $params['start'] = (string) $this->start; } - if ($this->end !== null) { + if (isset($this->end)) { $params['end'] = (string) $this->end; } - if ($this->count !== null && $this->count > 0 && $this->count <= static::MAX_COUNT) { + if (isset($this->count) && $this->count > 0 && $this->count <= static::MAX_COUNT) { $params['count'] = (string) $this->count; } else { $params['count'] = '100'; } - if ($this->reverse !== null) { + if (isset($this->reverse)) { $this->reverse ? $params['reverse'] = "true" : $params['reverse'] = "false"; } - if ($this->includeTimetoken !== null) { + if (isset($this->includeTimetoken)) { $this->includeTimetoken ? $params['include_token'] = "true" : $params['include_token'] = "false"; } @@ -156,7 +155,8 @@ protected function buildData() protected function buildPath() { return sprintf( - static::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), + static::PATH, + $this->pubnub->getConfiguration()->getSubscribeKey(), PubNubUtil::urlEncode($this->channel) ); } @@ -164,7 +164,7 @@ protected function buildPath() /** * @return PNHistoryResult */ - public function sync() + public function sync(): PNHistoryResult { return parent::sync(); } @@ -173,20 +173,21 @@ public function sync() * @param array $result Decoded json * @return PNHistoryResult */ - protected function createResponse($result) + protected function createResponse($result): PNHistoryResult { + $includeTimetoken = isset($this->includeTimetoken) ? $this->includeTimetoken : null; try { return PNHistoryResult::fromJson( $result, $this->pubnub->getConfiguration()->getCryptoSafe(), - $this->includeTimetoken, + $includeTimetoken, $this->pubnub->getConfiguration()->getCipherKey() ); } catch (PubNubValidationException $e) { return PNHistoryResult::fromJson( $result, null, - $this->includeTimetoken, + $includeTimetoken, null ); } @@ -239,4 +240,4 @@ public function getName() { return "History"; } -} \ No newline at end of file +} diff --git a/src/PubNub/Endpoints/HistoryDelete.php b/src/PubNub/Endpoints/HistoryDelete.php index 66b9970c..8a82c245 100644 --- a/src/PubNub/Endpoints/HistoryDelete.php +++ b/src/PubNub/Endpoints/HistoryDelete.php @@ -10,7 +10,7 @@ class HistoryDelete extends Endpoint { - const PATH = "/v3/history/sub-key/%s/channel/%s"; + protected const PATH = "/v3/history/sub-key/%s/channel/%s"; /** @var string */ protected $channel; @@ -70,7 +70,7 @@ protected function validateParams() * @param array $result Decoded json * @return mixed */ - protected function createResponse($result) + protected function createResponse($result): PNHistoryDeleteResult { return new PNHistoryDeleteResult(); } @@ -105,7 +105,8 @@ protected function buildData() protected function buildPath() { return sprintf( - static::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), + static::PATH, + $this->pubnub->getConfiguration()->getSubscribeKey(), PubNubUtil::urlEncode($this->channel) ); } @@ -164,8 +165,8 @@ protected function getName() * @return PNHistoryDeleteResult * @throws \PubNub\Exceptions\PubNubException */ - public function sync() + public function sync(): PNHistoryDeleteResult { return parent::sync(); } -} \ No newline at end of file +} diff --git a/src/PubNub/Endpoints/MessageCount.php b/src/PubNub/Endpoints/MessageCount.php index f6b7ca08..ab0c4717 100644 --- a/src/PubNub/Endpoints/MessageCount.php +++ b/src/PubNub/Endpoints/MessageCount.php @@ -11,7 +11,7 @@ class MessageCount extends Endpoint { - const PATH = "/v3/history/sub-key/%s/message-counts/%s"; + protected const PATH = "/v3/history/sub-key/%s/message-counts/%s"; /** @var array */ protected $channels = []; @@ -59,7 +59,6 @@ protected function validateParams() if (count($this->channelsTimetoken) > 1 && count($this->channels) !== count($this->channelsTimetoken)) { throw new PubNubValidationException("The number of channels and the number of timetokens do not match"); } - } /** @@ -67,7 +66,7 @@ protected function validateParams() * @return PNMessageCountResult * @throws PubNubServerException */ - protected function createResponse($result) + protected function createResponse($result): PNMessageCountResult { if (!isset($result['channels'])) { $exception = (new PubNubServerException()) @@ -109,7 +108,8 @@ protected function buildData() protected function buildPath() { return sprintf( - static::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), + static::PATH, + $this->pubnub->getConfiguration()->getSubscribeKey(), PubNubUtil::joinChannels($this->channels) ); } @@ -166,8 +166,8 @@ protected function getName() * @return PNMessageCountResult * @throws \PubNub\Exceptions\PubNubException */ - public function sync() + public function sync(): PNMessageCountResult { return parent::sync(); } -} \ No newline at end of file +} diff --git a/src/PubNub/Endpoints/MessagePersistance/FetchMessages.php b/src/PubNub/Endpoints/MessagePersistance/FetchMessages.php index 098a457d..3a8f1441 100644 --- a/src/PubNub/Endpoints/MessagePersistance/FetchMessages.php +++ b/src/PubNub/Endpoints/MessagePersistance/FetchMessages.php @@ -153,7 +153,7 @@ public function sync(): PNFetchMessagesResult * @param array $json Decoded json * @return PNPublishResult */ - protected function createResponse($json) + protected function createResponse($json): PNFetchMessagesResult { return PNFetchMessagesResult::fromJson( $json, diff --git a/src/PubNub/Endpoints/Objects/Channel/GetAllChannelMetadata.php b/src/PubNub/Endpoints/Objects/Channel/GetAllChannelMetadata.php index 79be6e87..71a581b2 100644 --- a/src/PubNub/Endpoints/Objects/Channel/GetAllChannelMetadata.php +++ b/src/PubNub/Endpoints/Objects/Channel/GetAllChannelMetadata.php @@ -10,7 +10,7 @@ class GetAllChannelMetadata extends ObjectsCollectionEndpoint { - const PATH = "/v2/objects/%s/channels"; + protected const PATH = "/v2/objects/%s/channels"; /** @var string */ protected $channel; @@ -72,11 +72,16 @@ protected function buildPath() * @param array $result Decoded json * @return PNGetAllChannelMetadataResult */ - protected function createResponse($result) + protected function createResponse($result): PNGetAllChannelMetadataResult { return PNGetAllChannelMetadataResult::fromPayload($result); } + public function sync(): PNGetAllChannelMetadataResult + { + return parent::sync(); + } + /** * @return array */ @@ -84,50 +89,42 @@ protected function customParams() { $params = $this->defaultParams(); - if (array_key_exists("customFields", $this->include)) - { + if (array_key_exists("customFields", $this->include)) { $params['include'] = 'custom'; } - if (array_key_exists("totalCount", $this->include)) - { + if (array_key_exists("totalCount", $this->include)) { $params['count'] = "true"; } - if (array_key_exists("next", $this->page)) - { + if (array_key_exists("next", $this->page)) { $params['start'] = $this->page["next"]; } - if (array_key_exists("prev", $this->page)) - { + if (array_key_exists("prev", $this->page)) { $params['end'] = $this->page["prev"]; } - if (!empty($this->filter)) - { + if (!empty($this->filter)) { $params['filter'] = $this->filter; } - if (!empty($this->limit)) - { + if (!empty($this->limit)) { $params['limit'] = $this->limit; } - if (!empty($this->sort)) - { - $sortEntries = []; + if (!empty($this->sort)) { + $sortEntries = []; - foreach ($this->sort as $key => $value) - { - if ($value === 'asc' || $value === 'desc') { - array_push($sortEntries, "$key:$value"); - } else { - array_push($sortEntries, $key); + foreach ($this->sort as $key => $value) { + if ($value === 'asc' || $value === 'desc') { + array_push($sortEntries, "$key:$value"); + } else { + array_push($sortEntries, $key); + } } - } - $params['sort'] = $sortEntries; + $params['sort'] = $sortEntries; } return $params; @@ -138,7 +135,7 @@ protected function customParams() */ protected function isAuthRequired() { - return True; + return true; } /** diff --git a/src/PubNub/Endpoints/Objects/Channel/GetChannelMetadata.php b/src/PubNub/Endpoints/Objects/Channel/GetChannelMetadata.php index ad955c5a..ec3570f0 100644 --- a/src/PubNub/Endpoints/Objects/Channel/GetChannelMetadata.php +++ b/src/PubNub/Endpoints/Objects/Channel/GetChannelMetadata.php @@ -8,10 +8,9 @@ use PubNub\Exceptions\PubNubValidationException; use PubNub\Models\Consumer\Objects\Channel\PNGetChannelMetadataResult; - class GetChannelMetadata extends Endpoint { - const PATH = "/v2/objects/%s/channels/%s"; + protected const PATH = "/v2/objects/%s/channels/%s"; /** @var string */ protected $channel; @@ -64,11 +63,16 @@ protected function buildPath() * @param array $result Decoded json * @return PNGetChannelMetadataResult */ - protected function createResponse($result) + protected function createResponse($result): PNGetChannelMetadataResult { return PNGetChannelMetadataResult::fromPayload($result); } + public function sync(): PNGetChannelMetadataResult + { + return parent::sync(); + } + /** * @return array */ @@ -86,7 +90,7 @@ protected function customParams() */ protected function isAuthRequired() { - return True; + return true; } /** diff --git a/src/PubNub/Endpoints/Objects/Channel/RemoveChannelMetadata.php b/src/PubNub/Endpoints/Objects/Channel/RemoveChannelMetadata.php index e7be49cd..21e2267e 100644 --- a/src/PubNub/Endpoints/Objects/Channel/RemoveChannelMetadata.php +++ b/src/PubNub/Endpoints/Objects/Channel/RemoveChannelMetadata.php @@ -7,10 +7,9 @@ use PubNub\Enums\PNOperationType; use PubNub\Exceptions\PubNubValidationException; - class RemoveChannelMetadata extends Endpoint { - const PATH = "/v2/objects/%s/channels/%s"; + protected const PATH = "/v2/objects/%s/channels/%s"; /** @var string */ protected $channel; @@ -63,11 +62,16 @@ protected function buildPath() * @param array $result Decoded json * @return bool */ - protected function createResponse($result) + protected function createResponse($result): bool { return array_key_exists("data", $result); } + public function sync(): bool + { + return parent::sync(); + } + /** * @return array */ @@ -83,7 +87,7 @@ protected function customParams() */ protected function isAuthRequired() { - return True; + return true; } /** diff --git a/src/PubNub/Endpoints/Objects/Channel/SetChannelMetadata.php b/src/PubNub/Endpoints/Objects/Channel/SetChannelMetadata.php index 2ed51a9d..c275ce55 100644 --- a/src/PubNub/Endpoints/Objects/Channel/SetChannelMetadata.php +++ b/src/PubNub/Endpoints/Objects/Channel/SetChannelMetadata.php @@ -9,10 +9,9 @@ use PubNub\Models\Consumer\Objects\Channel\PNSetChannelMetadataResult; use PubNub\PubNubUtil; - class SetChannelMetadata extends Endpoint { - const PATH = "/v2/objects/%s/channels/%s"; + protected const PATH = "/v2/objects/%s/channels/%s"; /** @var string */ protected $channel; @@ -83,11 +82,16 @@ protected function buildPath() * @param array $result Decoded json * @return PNSetChannelMetadataResult */ - protected function createResponse($result) + protected function createResponse($result): PNSetChannelMetadataResult { return PNSetChannelMetadataResult::fromPayload($result); } + public function sync(): PNSetChannelMetadataResult + { + return parent::sync(); + } + /** * @return array */ @@ -105,7 +109,7 @@ protected function customParams() */ protected function isAuthRequired() { - return True; + return true; } /** diff --git a/src/PubNub/Endpoints/Objects/Member/GetMembers.php b/src/PubNub/Endpoints/Objects/Member/GetMembers.php index 0ef39e0e..923ef1f9 100644 --- a/src/PubNub/Endpoints/Objects/Member/GetMembers.php +++ b/src/PubNub/Endpoints/Objects/Member/GetMembers.php @@ -8,10 +8,9 @@ use PubNub\Exceptions\PubNubValidationException; use PubNub\Models\Consumer\Objects\Member\PNMembersResult; - class GetMembers extends ObjectsCollectionEndpoint { - const PATH = "/v2/objects/%s/channels/%s/uuids"; + protected const PATH = "/v2/objects/%s/channels/%s/uuids"; /** @var string */ protected $channel; @@ -78,11 +77,16 @@ protected function buildPath() * @param array $result Decoded json * @return PNMembersResult */ - protected function createResponse($result) + protected function createResponse($result): PNMembersResult { return PNMembersResult::fromPayload($result); } + public function sync(): PNMembersResult + { + return parent::sync(); + } + /** * @return array */ @@ -93,18 +97,15 @@ protected function customParams() if (count($this->include) > 0) { $includes = []; - if (array_key_exists("customFields", $this->include)) - { + if (array_key_exists("customFields", $this->include)) { array_push($includes, 'custom'); } - if (array_key_exists("customUUIDFields", $this->include)) - { + if (array_key_exists("customUUIDFields", $this->include)) { array_push($includes, 'uuid.custom'); } - if (array_key_exists("UUIDFields", $this->include)) - { + if (array_key_exists("UUIDFields", $this->include)) { array_push($includes, 'uuid'); } @@ -115,45 +116,38 @@ protected function customParams() } } - if (array_key_exists("totalCount", $this->include)) - { + if (array_key_exists("totalCount", $this->include)) { $params['count'] = "true"; } - if (array_key_exists("next", $this->page)) - { + if (array_key_exists("next", $this->page)) { $params['start'] = $this->page["next"]; } - if (array_key_exists("prev", $this->page)) - { + if (array_key_exists("prev", $this->page)) { $params['end'] = $this->page["prev"]; } - if (!empty($this->filter)) - { + if (!empty($this->filter)) { $params['filter'] = $this->filter; } - if (!empty($this->limit)) - { + if (!empty($this->limit)) { $params['limit'] = $this->limit; } - if (!empty($this->sort)) - { - $sortEntries = []; + if (!empty($this->sort)) { + $sortEntries = []; - foreach ($this->sort as $key => $value) - { - if ($value === 'asc' || $value === 'desc') { - array_push($sortEntries, "$key:$value"); - } else { - array_push($sortEntries, $key); + foreach ($this->sort as $key => $value) { + if ($value === 'asc' || $value === 'desc') { + array_push($sortEntries, "$key:$value"); + } else { + array_push($sortEntries, $key); + } } - } - $params['sort'] = $sortEntries; + $params['sort'] = $sortEntries; } return $params; @@ -164,7 +158,7 @@ protected function customParams() */ protected function isAuthRequired() { - return True; + return true; } /** diff --git a/src/PubNub/Endpoints/Objects/Member/RemoveMembers.php b/src/PubNub/Endpoints/Objects/Member/RemoveMembers.php index b216847d..8fd83cfc 100644 --- a/src/PubNub/Endpoints/Objects/Member/RemoveMembers.php +++ b/src/PubNub/Endpoints/Objects/Member/RemoveMembers.php @@ -9,10 +9,9 @@ use PubNub\Models\Consumer\Objects\Member\PNMembersResult; use PubNub\PubNubUtil; - class RemoveMembers extends ObjectsCollectionEndpoint { - const PATH = "/v2/objects/%s/channels/%s/uuids"; + protected const PATH = "/v2/objects/%s/channels/%s/uuids"; /** @var string */ protected $channel; @@ -80,8 +79,7 @@ protected function buildData() { $entries = []; - foreach($this->uuids as $value) - { + foreach ($this->uuids as $value) { $entry = [ "uuid" => [ "id" => $value, @@ -112,11 +110,16 @@ protected function buildPath() * @param array $result Decoded json * @return PNMembersResult */ - protected function createResponse($result) + protected function createResponse($result): PNMembersResult { return PNMembersResult::fromPayload($result); } + public function sync(): PNMembersResult + { + return parent::sync(); + } + /** * @return array */ @@ -127,18 +130,15 @@ protected function customParams() if (count($this->include) > 0) { $includes = []; - if (array_key_exists("customFields", $this->include)) - { + if (array_key_exists("customFields", $this->include)) { array_push($includes, 'custom'); } - if (array_key_exists("customUUIDFields", $this->include)) - { + if (array_key_exists("customUUIDFields", $this->include)) { array_push($includes, 'uuid.custom'); } - if (array_key_exists("UUIDFields", $this->include)) - { + if (array_key_exists("UUIDFields", $this->include)) { array_push($includes, 'uuid'); } @@ -149,45 +149,38 @@ protected function customParams() } } - if (array_key_exists("totalCount", $this->include)) - { + if (array_key_exists("totalCount", $this->include)) { $params['count'] = "true"; } - if (array_key_exists("next", $this->page)) - { + if (array_key_exists("next", $this->page)) { $params['start'] = $this->page["next"]; } - if (array_key_exists("prev", $this->page)) - { + if (array_key_exists("prev", $this->page)) { $params['end'] = $this->page["prev"]; } - if (!empty($this->filter)) - { + if (!empty($this->filter)) { $params['filter'] = $this->filter; } - if (!empty($this->limit)) - { + if (!empty($this->limit)) { $params['limit'] = $this->limit; } - if (!empty($this->sort)) - { - $sortEntries = []; + if (!empty($this->sort)) { + $sortEntries = []; - foreach ($this->sort as $key => $value) - { - if ($value === 'asc' || $value === 'desc') { - array_push($sortEntries, "$key:$value"); - } else { - array_push($sortEntries, $key); + foreach ($this->sort as $key => $value) { + if ($value === 'asc' || $value === 'desc') { + array_push($sortEntries, "$key:$value"); + } else { + array_push($sortEntries, $key); + } } - } - $params['sort'] = $sortEntries; + $params['sort'] = $sortEntries; } return $params; @@ -198,7 +191,7 @@ protected function customParams() */ protected function isAuthRequired() { - return True; + return true; } /** diff --git a/src/PubNub/Endpoints/Objects/Member/SetMembers.php b/src/PubNub/Endpoints/Objects/Member/SetMembers.php index 8446d800..26253e2a 100644 --- a/src/PubNub/Endpoints/Objects/Member/SetMembers.php +++ b/src/PubNub/Endpoints/Objects/Member/SetMembers.php @@ -9,10 +9,9 @@ use PubNub\Models\Consumer\Objects\Member\PNMembersResult; use PubNub\PubNubUtil; - class SetMembers extends ObjectsCollectionEndpoint { - const PATH = "/v2/objects/%s/channels/%s/uuids"; + protected const PATH = "/v2/objects/%s/channels/%s/uuids"; /** @var string */ protected $channel; @@ -94,16 +93,14 @@ protected function buildData() { $entries = []; - foreach($this->uuids as $value) - { + foreach ($this->uuids as $value) { $entry = [ "uuid" => [ "id" => $value, ] ]; - if (!empty($this->custom)) - { + if (!empty($this->custom)) { $entry["custom"] = $this->custom; } @@ -127,11 +124,16 @@ protected function buildPath() ); } + public function sync(): PNMembersResult + { + return parent::sync(); + } + /** * @param array $result Decoded json * @return PNMembersResult */ - protected function createResponse($result) + protected function createResponse($result): PNMembersResult { return PNMembersResult::fromPayload($result); } @@ -146,18 +148,15 @@ protected function customParams() if (count($this->include) > 0) { $includes = []; - if (array_key_exists("customFields", $this->include)) - { + if (array_key_exists("customFields", $this->include)) { array_push($includes, 'custom'); } - if (array_key_exists("customUUIDFields", $this->include)) - { + if (array_key_exists("customUUIDFields", $this->include)) { array_push($includes, 'uuid.custom'); } - if (array_key_exists("UUIDFields", $this->include)) - { + if (array_key_exists("UUIDFields", $this->include)) { array_push($includes, 'uuid'); } @@ -168,45 +167,37 @@ protected function customParams() } } - if (array_key_exists("totalCount", $this->include)) - { + if (array_key_exists("totalCount", $this->include)) { $params['count'] = "true"; } - if (array_key_exists("next", $this->page)) - { + if (array_key_exists("next", $this->page)) { $params['start'] = $this->page["next"]; } - if (array_key_exists("prev", $this->page)) - { + if (array_key_exists("prev", $this->page)) { $params['end'] = $this->page["prev"]; } - if (!empty($this->filter)) - { + if (!empty($this->filter)) { $params['filter'] = $this->filter; } - if (!empty($this->limit)) - { + if (!empty($this->limit)) { $params['limit'] = $this->limit; } - if (!empty($this->sort)) - { - $sortEntries = []; + if (!empty($this->sort)) { + $sortEntries = []; - foreach ($this->sort as $key => $value) - { - if ($value === 'asc' || $value === 'desc') { - array_push($sortEntries, "$key:$value"); - } else { - array_push($sortEntries, $key); + foreach ($this->sort as $key => $value) { + if ($value === 'asc' || $value === 'desc') { + array_push($sortEntries, "$key:$value"); + } else { + array_push($sortEntries, $key); + } } - } - - $params['sort'] = $sortEntries; + $params['sort'] = $sortEntries; } return $params; @@ -217,7 +208,7 @@ protected function customParams() */ protected function isAuthRequired() { - return True; + return true; } /** diff --git a/src/PubNub/Endpoints/Objects/Membership/GetMemberships.php b/src/PubNub/Endpoints/Objects/Membership/GetMemberships.php index c0e5af8d..9aad0809 100644 --- a/src/PubNub/Endpoints/Objects/Membership/GetMemberships.php +++ b/src/PubNub/Endpoints/Objects/Membership/GetMemberships.php @@ -8,10 +8,9 @@ use PubNub\Exceptions\PubNubValidationException; use PubNub\Models\Consumer\Objects\Membership\PNMembershipsResult; - class GetMemberships extends ObjectsCollectionEndpoint { - const PATH = "/v2/objects/%s/uuids/%s/channels"; + protected const PATH = "/v2/objects/%s/uuids/%s/channels"; /** @var string */ protected $uuid; @@ -74,11 +73,16 @@ protected function buildPath() ); } + public function sync(): PNMembershipsResult + { + return parent::sync(); + } + /** * @param array $result Decoded json * @return PNMembershipsResult */ - protected function createResponse($result) + protected function createResponse($result): PNMembershipsResult { return PNMembershipsResult::fromPayload($result); } @@ -93,18 +97,15 @@ protected function customParams() if (count($this->include) > 0) { $includes = []; - if (array_key_exists("customFields", $this->include)) - { + if (array_key_exists("customFields", $this->include)) { array_push($includes, 'custom'); } - if (array_key_exists("customChannelFields", $this->include)) - { + if (array_key_exists("customChannelFields", $this->include)) { array_push($includes, 'channel.custom'); } - if (array_key_exists("channelFields", $this->include)) - { + if (array_key_exists("channelFields", $this->include)) { array_push($includes, 'channel'); } @@ -115,45 +116,38 @@ protected function customParams() } } - if (array_key_exists("totalCount", $this->include)) - { + if (array_key_exists("totalCount", $this->include)) { $params['count'] = "true"; } - if (array_key_exists("next", $this->page)) - { + if (array_key_exists("next", $this->page)) { $params['start'] = $this->page["next"]; } - if (array_key_exists("prev", $this->page)) - { + if (array_key_exists("prev", $this->page)) { $params['end'] = $this->page["prev"]; } - if (!empty($this->filter)) - { + if (!empty($this->filter)) { $params['filter'] = $this->filter; } - if (!empty($this->limit)) - { + if (!empty($this->limit)) { $params['limit'] = $this->limit; } - if (!empty($this->sort)) - { - $sortEntries = []; + if (!empty($this->sort)) { + $sortEntries = []; - foreach ($this->sort as $key => $value) - { - if ($value === 'asc' || $value === 'desc') { - array_push($sortEntries, "$key:$value"); - } else { - array_push($sortEntries, $key); + foreach ($this->sort as $key => $value) { + if ($value === 'asc' || $value === 'desc') { + array_push($sortEntries, "$key:$value"); + } else { + array_push($sortEntries, $key); + } } - } - $params['sort'] = $sortEntries; + $params['sort'] = $sortEntries; } return $params; @@ -164,7 +158,7 @@ protected function customParams() */ protected function isAuthRequired() { - return True; + return true; } /** diff --git a/src/PubNub/Endpoints/Objects/Membership/RemoveMemberships.php b/src/PubNub/Endpoints/Objects/Membership/RemoveMemberships.php index 45950c89..254727c5 100644 --- a/src/PubNub/Endpoints/Objects/Membership/RemoveMemberships.php +++ b/src/PubNub/Endpoints/Objects/Membership/RemoveMemberships.php @@ -9,10 +9,9 @@ use PubNub\Models\Consumer\Objects\Membership\PNMembershipsResult; use PubNub\PubNubUtil; - class RemoveMemberships extends ObjectsCollectionEndpoint { - const PATH = "/v2/objects/%s/uuids/%s/channels"; + protected const PATH = "/v2/objects/%s/uuids/%s/channels"; /** @var string */ protected $uuid; @@ -80,8 +79,7 @@ protected function buildData() { $entries = []; - foreach($this->channels as $value) - { + foreach ($this->channels as $value) { $entry = [ "channel" => [ "id" => $value, @@ -108,11 +106,16 @@ protected function buildPath() ); } + public function sync(): PNMembershipsResult + { + return parent::sync(); + } + /** * @param array $result Decoded json * @return PNMembershipsResult */ - protected function createResponse($result) + protected function createResponse($result): PNMembershipsResult { return PNMembershipsResult::fromPayload($result); } @@ -127,18 +130,15 @@ protected function customParams() if (count($this->include) > 0) { $includes = []; - if (array_key_exists("customFields", $this->include)) - { + if (array_key_exists("customFields", $this->include)) { array_push($includes, 'custom'); } - if (array_key_exists("customChannelFields", $this->include)) - { + if (array_key_exists("customChannelFields", $this->include)) { array_push($includes, 'channel.custom'); } - if (array_key_exists("channelFields", $this->include)) - { + if (array_key_exists("channelFields", $this->include)) { array_push($includes, 'channel'); } @@ -149,45 +149,38 @@ protected function customParams() } } - if (array_key_exists("totalCount", $this->include)) - { + if (array_key_exists("totalCount", $this->include)) { $params['count'] = "true"; } - if (array_key_exists("next", $this->page)) - { + if (array_key_exists("next", $this->page)) { $params['start'] = $this->page["next"]; } - if (array_key_exists("prev", $this->page)) - { + if (array_key_exists("prev", $this->page)) { $params['end'] = $this->page["prev"]; } - if (!empty($this->filter)) - { + if (!empty($this->filter)) { $params['filter'] = $this->filter; } - if (!empty($this->limit)) - { + if (!empty($this->limit)) { $params['limit'] = $this->limit; } - if (!empty($this->sort)) - { - $sortEntries = []; + if (!empty($this->sort)) { + $sortEntries = []; - foreach ($this->sort as $key => $value) - { - if ($value === 'asc' || $value === 'desc') { - array_push($sortEntries, "$key:$value"); - } else { - array_push($sortEntries, $key); + foreach ($this->sort as $key => $value) { + if ($value === 'asc' || $value === 'desc') { + array_push($sortEntries, "$key:$value"); + } else { + array_push($sortEntries, $key); + } } - } - $params['sort'] = $sortEntries; + $params['sort'] = $sortEntries; } return $params; @@ -198,7 +191,7 @@ protected function customParams() */ protected function isAuthRequired() { - return True; + return true; } /** diff --git a/src/PubNub/Endpoints/Objects/Membership/SetMemberships.php b/src/PubNub/Endpoints/Objects/Membership/SetMemberships.php index 6fd0cfdc..99eb2215 100644 --- a/src/PubNub/Endpoints/Objects/Membership/SetMemberships.php +++ b/src/PubNub/Endpoints/Objects/Membership/SetMemberships.php @@ -9,10 +9,9 @@ use PubNub\Models\Consumer\Objects\Membership\PNMembershipsResult; use PubNub\PubNubUtil; - class SetMemberships extends ObjectsCollectionEndpoint { - const PATH = "/v2/objects/%s/uuids/%s/channels"; + protected const PATH = "/v2/objects/%s/uuids/%s/channels"; /** @var string */ protected $uuid; @@ -94,16 +93,14 @@ protected function buildData() { $entries = []; - foreach($this->channels as $value) - { + foreach ($this->channels as $value) { $entry = [ "channel" => [ "id" => $value, ] ]; - if (!empty($this->custom)) - { + if (!empty($this->custom)) { $entry["custom"] = $this->custom; } @@ -127,11 +124,16 @@ protected function buildPath() ); } + public function sync(): PNMembershipsResult + { + return parent::sync(); + } + /** * @param array $result Decoded json * @return PNMembershipsResult */ - protected function createResponse($result) + protected function createResponse($result): PNMembershipsResult { return PNMembershipsResult::fromPayload($result); } @@ -146,18 +148,15 @@ protected function customParams() if (count($this->include) > 0) { $includes = []; - if (array_key_exists("customFields", $this->include)) - { + if (array_key_exists("customFields", $this->include)) { array_push($includes, 'custom'); } - if (array_key_exists("customChannelFields", $this->include)) - { + if (array_key_exists("customChannelFields", $this->include)) { array_push($includes, 'channel.custom'); } - if (array_key_exists("channelFields", $this->include)) - { + if (array_key_exists("channelFields", $this->include)) { array_push($includes, 'channel'); } @@ -168,45 +167,38 @@ protected function customParams() } } - if (array_key_exists("totalCount", $this->include)) - { + if (array_key_exists("totalCount", $this->include)) { $params['count'] = "true"; } - if (array_key_exists("next", $this->page)) - { + if (array_key_exists("next", $this->page)) { $params['start'] = $this->page["next"]; } - if (array_key_exists("prev", $this->page)) - { + if (array_key_exists("prev", $this->page)) { $params['end'] = $this->page["prev"]; } - if (!empty($this->filter)) - { + if (!empty($this->filter)) { $params['filter'] = $this->filter; } - if (!empty($this->limit)) - { + if (!empty($this->limit)) { $params['limit'] = $this->limit; } - if (!empty($this->sort)) - { - $sortEntries = []; + if (!empty($this->sort)) { + $sortEntries = []; - foreach ($this->sort as $key => $value) - { - if ($value === 'asc' || $value === 'desc') { - array_push($sortEntries, "$key:$value"); - } else { - array_push($sortEntries, $key); + foreach ($this->sort as $key => $value) { + if ($value === 'asc' || $value === 'desc') { + array_push($sortEntries, "$key:$value"); + } else { + array_push($sortEntries, $key); + } } - } - $params['sort'] = $sortEntries; + $params['sort'] = $sortEntries; } return $params; @@ -217,7 +209,7 @@ protected function customParams() */ protected function isAuthRequired() { - return True; + return true; } /** diff --git a/src/PubNub/Endpoints/Objects/UUID/GetAllUUIDMetadata.php b/src/PubNub/Endpoints/Objects/UUID/GetAllUUIDMetadata.php index c09636c4..3723b4aa 100644 --- a/src/PubNub/Endpoints/Objects/UUID/GetAllUUIDMetadata.php +++ b/src/PubNub/Endpoints/Objects/UUID/GetAllUUIDMetadata.php @@ -8,10 +8,9 @@ use PubNub\Exceptions\PubNubValidationException; use PubNub\Models\Consumer\Objects\UUID\PNGetAllUUIDMetadataResult; - class GetAllUUIDMetadata extends ObjectsCollectionEndpoint { - const PATH = "/v2/objects/%s/uuids"; + protected const PATH = "/v2/objects/%s/uuids"; /** @var string */ protected $uuid; @@ -69,11 +68,16 @@ protected function buildPath() ); } + public function sync(): PNGetAllUUIDMetadataResult + { + return parent::sync(); + } + /** * @param array $result Decoded json * @return PNGetAllUUIDMetadataResult */ - protected function createResponse($result) + protected function createResponse($result): PNGetAllUUIDMetadataResult { return PNGetAllUUIDMetadataResult::fromPayload($result); } @@ -85,50 +89,42 @@ protected function customParams() { $params = $this->defaultParams(); - if (array_key_exists("customFields", $this->include)) - { + if (array_key_exists("customFields", $this->include)) { $params['include'] = 'custom'; } - if (array_key_exists("totalCount", $this->include)) - { + if (array_key_exists("totalCount", $this->include)) { $params['count'] = "true"; } - if (array_key_exists("next", $this->page)) - { + if (array_key_exists("next", $this->page)) { $params['start'] = $this->page["next"]; } - if (array_key_exists("prev", $this->page)) - { + if (array_key_exists("prev", $this->page)) { $params['end'] = $this->page["prev"]; } - if (!empty($this->filter)) - { + if (!empty($this->filter)) { $params['filter'] = $this->filter; } - if (!empty($this->limit)) - { + if (!empty($this->limit)) { $params['limit'] = $this->limit; } - if (!empty($this->sort)) - { - $sortEntries = []; + if (!empty($this->sort)) { + $sortEntries = []; - foreach ($this->sort as $key => $value) - { - if ($value === 'asc' || $value === 'desc') { - array_push($sortEntries, "$key:$value"); - } else { - array_push($sortEntries, $key); + foreach ($this->sort as $key => $value) { + if ($value === 'asc' || $value === 'desc') { + array_push($sortEntries, "$key:$value"); + } else { + array_push($sortEntries, $key); + } } - } - $params['sort'] = $sortEntries; + $params['sort'] = $sortEntries; } return $params; @@ -139,7 +135,7 @@ protected function customParams() */ protected function isAuthRequired() { - return True; + return true; } /** diff --git a/src/PubNub/Endpoints/Objects/UUID/GetUUIDMetadata.php b/src/PubNub/Endpoints/Objects/UUID/GetUUIDMetadata.php index 0c378bd3..ed19d628 100644 --- a/src/PubNub/Endpoints/Objects/UUID/GetUUIDMetadata.php +++ b/src/PubNub/Endpoints/Objects/UUID/GetUUIDMetadata.php @@ -8,10 +8,9 @@ use PubNub\Exceptions\PubNubValidationException; use PubNub\Models\Consumer\Objects\UUID\PNGetUUIDMetadataResult; - class GetUUIDMetadata extends Endpoint { - const PATH = "/v2/objects/%s/uuids/%s"; + protected const PATH = "/v2/objects/%s/uuids/%s"; /** @var string */ protected $uuid; @@ -60,11 +59,16 @@ protected function buildPath() ); } + public function sync(): PNGetUUIDMetadataResult + { + return parent::sync(); + } + /** * @param array $result Decoded json * @return PNGetUUIDMetadataResult */ - protected function createResponse($result) + protected function createResponse($result): PNGetUUIDMetadataResult { return PNGetUUIDMetadataResult::fromPayload($result); } @@ -86,7 +90,7 @@ protected function customParams() */ protected function isAuthRequired() { - return True; + return true; } /** diff --git a/src/PubNub/Endpoints/Objects/UUID/RemoveUUIDMetadata.php b/src/PubNub/Endpoints/Objects/UUID/RemoveUUIDMetadata.php index 54ba1bef..59f73f5b 100644 --- a/src/PubNub/Endpoints/Objects/UUID/RemoveUUIDMetadata.php +++ b/src/PubNub/Endpoints/Objects/UUID/RemoveUUIDMetadata.php @@ -7,10 +7,9 @@ use PubNub\Enums\PNOperationType; use PubNub\Exceptions\PubNubValidationException; - class RemoveUUIDMetadata extends Endpoint { - const PATH = "/v2/objects/%s/uuids/%s"; + protected const PATH = "/v2/objects/%s/uuids/%s"; /** @var string */ protected $uuid; @@ -59,11 +58,16 @@ protected function buildPath() ); } + public function sync(): bool + { + return parent::sync(); + } + /** * @param array $result Decoded json * @return bool */ - protected function createResponse($result) + protected function createResponse($result): bool { return array_key_exists("data", $result); } @@ -83,7 +87,7 @@ protected function customParams() */ protected function isAuthRequired() { - return True; + return true; } /** diff --git a/src/PubNub/Endpoints/Objects/UUID/SetUUIDMetadata.php b/src/PubNub/Endpoints/Objects/UUID/SetUUIDMetadata.php index 6e138a9f..986b90dc 100644 --- a/src/PubNub/Endpoints/Objects/UUID/SetUUIDMetadata.php +++ b/src/PubNub/Endpoints/Objects/UUID/SetUUIDMetadata.php @@ -9,10 +9,9 @@ use PubNub\Models\Consumer\Objects\UUID\PNSetUUIDMetadataResult; use PubNub\PubNubUtil; - class SetUUIDMetadata extends Endpoint { - const PATH = "/v2/objects/%s/uuids/%s"; + protected const PATH = "/v2/objects/%s/uuids/%s"; /** @var string */ protected $uuid; @@ -79,11 +78,16 @@ protected function buildPath() ); } + public function sync(): PNSetUUIDMetadataResult + { + return parent::sync(); + } + /** * @param array $result Decoded json * @return PNSetUUIDMetadataResult */ - protected function createResponse($result) + protected function createResponse($result): PNSetUUIDMetadataResult { return PNSetUUIDMetadataResult::fromPayload($result); } @@ -105,7 +109,7 @@ protected function customParams() */ protected function isAuthRequired() { - return True; + return true; } /** diff --git a/src/PubNub/Endpoints/Presence/GetState.php b/src/PubNub/Endpoints/Presence/GetState.php index 15d69251..6f546216 100644 --- a/src/PubNub/Endpoints/Presence/GetState.php +++ b/src/PubNub/Endpoints/Presence/GetState.php @@ -9,10 +9,9 @@ use PubNub\Models\Consumer\Presence\PNGetStateResult; use PubNub\PubNubUtil; - class GetState extends Endpoint { - const PATH = "/v2/presence/sub-key/%s/channel/%s/uuid/%s"; + protected const PATH = "/v2/presence/sub-key/%s/channel/%s/uuid/%s"; /** @var array */ protected $channels = []; @@ -90,7 +89,7 @@ public function buildPath() /** * @return PNGetStateResult */ - public function sync() + public function sync(): PNGetStateResult { return parent::sync(); } @@ -99,7 +98,7 @@ public function sync() * @param array $result Decoded json * @return PNGetStateResult */ - public function createResponse($result) + public function createResponse($result): PNGetStateResult { if (count($this->channels) === 1 && count($this->channelGroups) === 0) { $channels = [$this->channels[0] => $result['payload']]; @@ -173,4 +172,4 @@ public function getName() { return "Grant"; } -} \ No newline at end of file +} diff --git a/src/PubNub/Endpoints/Presence/HereNow.php b/src/PubNub/Endpoints/Presence/HereNow.php index d3d5f2fb..811470b2 100644 --- a/src/PubNub/Endpoints/Presence/HereNow.php +++ b/src/PubNub/Endpoints/Presence/HereNow.php @@ -9,11 +9,10 @@ use PubNub\Models\Consumer\Presence\PNHereNowResult; use PubNub\PubNubUtil; - class HereNow extends Endpoint { - const PATH = "/v2/presence/sub-key/%s/channel/%s"; - const GLOBAL_PATH = "/v2/presence/sub-key/%s"; + protected const PATH = "/v2/presence/sub-key/%s/channel/%s"; + protected const GLOBAL_PATH = "/v2/presence/sub-key/%s"; /** @var string[] */ protected $channels = []; @@ -117,7 +116,8 @@ public function buildPath() if (count($this->channels) === 0 && count($this->groups) === 0) { return sprintf(HereNow::GLOBAL_PATH, $this->pubnub->getConfiguration()->getSubscribeKey()); } else { - return sprintf(HereNow::PATH, + return sprintf( + HereNow::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), PubNubUtil::joinChannels($this->channels) ); @@ -127,7 +127,7 @@ public function buildPath() /** * @return PNHereNowResult */ - public function sync() + public function sync(): PNHereNowResult { return parent::sync(); } @@ -136,7 +136,7 @@ public function sync() * @param array $result Decoded json * @return PNHereNowResult */ - protected function createResponse($result) + protected function createResponse($result): PNHereNowResult { return PNHereNowResult::fromJson($result, $this->channels); } @@ -188,4 +188,4 @@ protected function getName() { return "HereNow"; } -} \ No newline at end of file +} diff --git a/src/PubNub/Endpoints/Presence/Leave.php b/src/PubNub/Endpoints/Presence/Leave.php index 963e5462..de4096cb 100644 --- a/src/PubNub/Endpoints/Presence/Leave.php +++ b/src/PubNub/Endpoints/Presence/Leave.php @@ -8,10 +8,9 @@ use PubNub\Exceptions\PubNubValidationException; use PubNub\PubNubUtil; - class Leave extends Endpoint { - const PATH = "/v2/presence/sub-key/%s/channel/%s/leave"; + protected const PATH = "/v2/presence/sub-key/%s/channel/%s/leave"; /** @var string[] */ protected $channels = []; @@ -83,18 +82,24 @@ protected function buildPath() return sprintf( Leave::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), - PubNubUtil::joinChannels($this->channels)); + PubNubUtil::joinChannels($this->channels) + ); } /** * @param array $result Decoded json * @return array */ - protected function createResponse($result) + protected function createResponse($result): array { return $result; } + public function sync(): array + { + return parent::sync(); + } + /** * @return bool */ @@ -142,5 +147,4 @@ public function getName() { return "Leave"; } - } diff --git a/src/PubNub/Endpoints/Presence/SetState.php b/src/PubNub/Endpoints/Presence/SetState.php index ede0e71a..83fbb206 100644 --- a/src/PubNub/Endpoints/Presence/SetState.php +++ b/src/PubNub/Endpoints/Presence/SetState.php @@ -9,10 +9,9 @@ use PubNub\Models\Consumer\Presence\PNSetStateResult; use PubNub\PubNubUtil; - class SetState extends Endpoint { - const PATH = "/v2/presence/sub-key/%s/channel/%s/uuid/%s/data"; + protected const PATH = "/v2/presence/sub-key/%s/channel/%s/uuid/%s/data"; /** @var array */ protected $state = []; @@ -121,7 +120,7 @@ public function buildParams() /** * @return PNSetStateResult */ - public function sync() + public function sync(): PNSetStateResult { return parent::sync(); } @@ -130,7 +129,7 @@ public function sync() * @param array $result Decoded json * @return PNSetStateResult|array */ - public function createResponse($result) + public function createResponse($result): PNSetStateResult { if (array_key_exists('status', $result) && $result['status'] === 200) { return new PNSetStateResult($result['payload']); @@ -203,4 +202,4 @@ protected function getName() { return "SetState"; } -} \ No newline at end of file +} diff --git a/src/PubNub/Endpoints/Presence/WhereNow.php b/src/PubNub/Endpoints/Presence/WhereNow.php index d1d2a51b..3d36dd39 100644 --- a/src/PubNub/Endpoints/Presence/WhereNow.php +++ b/src/PubNub/Endpoints/Presence/WhereNow.php @@ -10,10 +10,9 @@ use PubNub\PubNub; use PubNub\PubNubUtil; - class WhereNow extends Endpoint { - const PATH = "/v2/presence/sub-key/%s/uuid/%s"; + protected const PATH = "/v2/presence/sub-key/%s/uuid/%s"; /** @var string */ protected $uuid; @@ -72,7 +71,8 @@ protected function buildData() */ public function buildPath() { - return sprintf(WhereNow::PATH, + return sprintf( + WhereNow::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), PubNubUtil::urlEncode($this->uuid) ); @@ -81,7 +81,7 @@ public function buildPath() /** * @return PNWhereNowResult */ - public function sync() + public function sync(): PNWhereNowResult { return parent::sync(); } @@ -90,7 +90,7 @@ public function sync() * @param array $result Decoded json * @return PNWhereNowResult */ - protected function createResponse($result) + protected function createResponse($result): PNWhereNowResult { return PNWhereNowResult::fromPayload(static::fetchPayload($result)); } @@ -142,4 +142,4 @@ protected function getName() { return "WhereNow"; } -} \ No newline at end of file +} diff --git a/src/PubNub/Endpoints/PubSub/Fire.php b/src/PubNub/Endpoints/PubSub/Fire.php index 3d5e3685..f5ee10f2 100644 --- a/src/PubNub/Endpoints/PubSub/Fire.php +++ b/src/PubNub/Endpoints/PubSub/Fire.php @@ -155,7 +155,7 @@ protected function customParams() /** * @return PNPublishResult */ - public function sync() + public function sync(): PNPublishResult { return parent::sync(); } @@ -164,7 +164,7 @@ public function sync() * @param array $json Decoded json * @return PNPublishResult */ - protected function createResponse($json) + protected function createResponse($json): PNPublishResult { $timetoken = floatval($json[2]); diff --git a/src/PubNub/Endpoints/PubSub/Publish.php b/src/PubNub/Endpoints/PubSub/Publish.php index 202f4d89..c7121654 100755 --- a/src/PubNub/Endpoints/PubSub/Publish.php +++ b/src/PubNub/Endpoints/PubSub/Publish.php @@ -10,20 +10,19 @@ use PubNub\Models\Consumer\PNPublishResult; use PubNub\PubNubUtil; - -class Publish extends Endpoint +final class Publish extends Endpoint { - const GET_PATH = "/publish/%s/%s/0/%s/%s/%s"; - const POST_PATH = "/publish/%s/%s/0/%s/%s"; + private const GET_PATH = "/publish/%s/%s/0/%s/%s/%s"; + private const POST_PATH = "/publish/%s/%s/0/%s/%s"; /** @var mixed $message to publish */ - protected $message; + protected mixed $message; - /** @var string $channel to send message on*/ - protected $channel; + /** @var string $channel to send message to */ + protected string $channel; /** @var bool $shouldStore in history */ - protected $shouldStore; + protected ?bool $shouldStore; /** @var bool $usePost HTTP method instead of default GET */ protected $usePost; @@ -132,11 +131,11 @@ public function ttl($ttl) */ protected function validateParams() { - if ($this->message === null) { + if (!isset($this->message)) { throw new PubNubValidationException("Message Missing"); } - if (!is_string($this->channel) || strlen($this->channel) === 0) { + if (!isset($this->channel) || !is_string($this->channel) || strlen($this->channel) === 0) { throw new PubNubValidationException("Channel Missing"); } @@ -151,11 +150,11 @@ protected function customParams() { $params = []; - if ($this->meta !== null) { + if (isset($this->meta)) { $params['meta'] = PubNubUtil::writeValueAsString($this->meta); } - if ($this->shouldStore !== null) { + if (isset($this->shouldStore)) { if ($this->shouldStore) { $params['store'] = "1"; } else { @@ -163,7 +162,7 @@ protected function customParams() } } - if ($this->ttl !== null) { + if (isset($this->ttl)) { $params['ttl'] = (string) $this->ttl; } @@ -249,7 +248,7 @@ protected function buildPath() /** * @return PNPublishResult */ - public function sync() + public function sync(): PNPublishResult { return parent::sync(); } @@ -258,7 +257,7 @@ public function sync() * @param array $result Decoded json * @return PNPublishResult */ - protected function createResponse($result) + protected function createResponse($result): PNPublishResult { $timetoken = floatval($result[2]); diff --git a/src/PubNub/Endpoints/PubSub/Signal.php b/src/PubNub/Endpoints/PubSub/Signal.php index bc25e253..e179e586 100644 --- a/src/PubNub/Endpoints/PubSub/Signal.php +++ b/src/PubNub/Endpoints/PubSub/Signal.php @@ -12,7 +12,7 @@ class Signal extends Endpoint { - const SIGNAL_PATH = "/signal/%s/%s/0/%s/0/%s"; + protected const SIGNAL_PATH = "/signal/%s/%s/0/%s/0/%s"; /** @var mixed $message to send the signal */ protected $message; @@ -68,11 +68,11 @@ protected function buildPath() $stringifiedMessage = PubNubUtil::urlEncode(PubNubUtil::writeValueAsString($this->message)); return sprintf( - static::SIGNAL_PATH, - $this->pubnub->getConfiguration()->getPublishKey(), - $this->pubnub->getConfiguration()->getSubscribeKey(), - PubNubUtil::urlEncode($this->channel), - $stringifiedMessage + static::SIGNAL_PATH, + $this->pubnub->getConfiguration()->getPublishKey(), + $this->pubnub->getConfiguration()->getSubscribeKey(), + PubNubUtil::urlEncode($this->channel), + $stringifiedMessage ); } @@ -88,18 +88,18 @@ protected function customParams() } /** - * @return PNPublishResult + * @return PNSignalResult */ - public function sync() + public function sync(): PNSignalResult { return parent::sync(); } /** * @param array $result Decoded json - * @return PNPublishResult + * @return PNSignalResult */ - protected function createResponse($result) + protected function createResponse($result): PNSignalResult { $timetoken = floatval($result[2]); diff --git a/src/PubNub/Endpoints/PubSub/Subscribe.php b/src/PubNub/Endpoints/PubSub/Subscribe.php index 8c45176e..e4db64ca 100644 --- a/src/PubNub/Endpoints/PubSub/Subscribe.php +++ b/src/PubNub/Endpoints/PubSub/Subscribe.php @@ -173,7 +173,7 @@ public function sync() * @param array $result Decoded json * @return SubscribeEnvelope */ - protected function createResponse($result) + protected function createResponse($result): SubscribeEnvelope { return SubscribeEnvelope::fromJson($result); } diff --git a/src/PubNub/Endpoints/Push/AddChannelsToPush.php b/src/PubNub/Endpoints/Push/AddChannelsToPush.php index aeb0f47b..00625cba 100644 --- a/src/PubNub/Endpoints/Push/AddChannelsToPush.php +++ b/src/PubNub/Endpoints/Push/AddChannelsToPush.php @@ -89,8 +89,13 @@ protected function buildPath() * @param array $result Decoded json * @return PNPushAddChannelResult */ - protected function createResponse($result) + protected function createResponse($result): PNPushAddChannelResult { return new PNPushAddChannelResult(); } + + public function sync(): PNPushAddChannelResult + { + return parent::sync(); + } } diff --git a/src/PubNub/Endpoints/Push/ListPushProvisions.php b/src/PubNub/Endpoints/Push/ListPushProvisions.php index baccc9c2..e4b3ca49 100644 --- a/src/PubNub/Endpoints/Push/ListPushProvisions.php +++ b/src/PubNub/Endpoints/Push/ListPushProvisions.php @@ -63,7 +63,7 @@ protected function buildPath() * @param array $result Decoded json * @return mixed */ - protected function createResponse($result) + protected function createResponse($result): PNPushListProvisionsResult { if ($result !== null || is_array($result)) { return PNPushListProvisionsResult::fromJson($result); @@ -71,4 +71,9 @@ protected function createResponse($result) return new PNPushListProvisionsResult([]); } } + + public function sync(): PNPushListProvisionsResult + { + return parent::sync(); + } } diff --git a/src/PubNub/Endpoints/Push/RemoveChannelsFromPush.php b/src/PubNub/Endpoints/Push/RemoveChannelsFromPush.php index 30e93560..15116bb7 100644 --- a/src/PubNub/Endpoints/Push/RemoveChannelsFromPush.php +++ b/src/PubNub/Endpoints/Push/RemoveChannelsFromPush.php @@ -92,8 +92,13 @@ protected function buildPath() * @param array $result Decoded json * @return PNPushRemoveChannelResult */ - protected function createResponse($result) + protected function createResponse($result): PNPushRemoveChannelResult { return new PNPushRemoveChannelResult(); } + + public function sync(): PNPushRemoveChannelResult + { + return parent::sync(); + } } diff --git a/src/PubNub/Endpoints/Push/RemoveDeviceFromPush.php b/src/PubNub/Endpoints/Push/RemoveDeviceFromPush.php index 2dd2632a..11f0a5da 100644 --- a/src/PubNub/Endpoints/Push/RemoveDeviceFromPush.php +++ b/src/PubNub/Endpoints/Push/RemoveDeviceFromPush.php @@ -64,8 +64,13 @@ protected function buildPath() * @param array $result Decoded json * @return PNPushRemoveAllChannelsResult */ - protected function createResponse($result) + protected function createResponse($result): PNPushRemoveAllChannelsResult { return new PNPushRemoveAllChannelsResult(); } + + public function sync(): PNPushRemoveAllChannelsResult + { + return parent::sync(); + } } diff --git a/src/PubNub/Endpoints/Time.php b/src/PubNub/Endpoints/Time.php index f7d6b135..0e58db3b 100755 --- a/src/PubNub/Endpoints/Time.php +++ b/src/PubNub/Endpoints/Time.php @@ -48,7 +48,7 @@ public function sync(): PNTimeResult * @param array $result * @return PNTimeResult */ - protected function createResponse($result) + protected function createResponse($result): PNTimeResult { $timetoken = floatval($result[0]); @@ -104,4 +104,4 @@ public function getName() { return "Time"; } -} \ No newline at end of file +} diff --git a/src/PubNub/Managers/TokenManager.php b/src/PubNub/Managers/TokenManager.php index 318a545f..84167419 100644 --- a/src/PubNub/Managers/TokenManager.php +++ b/src/PubNub/Managers/TokenManager.php @@ -4,14 +4,14 @@ class TokenManager { - private $token = null; + private ?string $token = null; - public function setToken($token) + public function setToken(string $token) { $this->token = $token; } - public function getToken() + public function getToken(): ?string { return $this->token; } diff --git a/src/PubNub/PubNub.php b/src/PubNub/PubNub.php index dbdae698..2cb9839d 100644 --- a/src/PubNub/PubNub.php +++ b/src/PubNub/PubNub.php @@ -53,48 +53,42 @@ use Psr\Log\LoggerAwareInterface; use Psr\Log\NullLogger; use PubNub\Endpoints\FileSharing\{SendFile, DeleteFile, DownloadFile, GetFileDownloadUrl, ListFiles}; +use PubNub\Models\Consumer\AccessManager\PNAccessManagerTokenResult; class PubNub implements LoggerAwareInterface { - protected const SDK_VERSION = "7.0.0"; + protected const SDK_VERSION = "7.0.1"; protected const SDK_NAME = "PubNub-PHP"; public static $MAX_SEQUENCE = 65535; - /** @var PNConfiguration */ protected PNConfiguration $configuration; - /** @var BasePathManager */ - protected $basePathManager; + protected BasePathManager $basePathManager; - /** @var SubscriptionManager */ - protected $subscriptionManager; + protected SubscriptionManager $subscriptionManager; - /** @var TelemetryManager */ - protected $telemetryManager; + protected TelemetryManager $telemetryManager; - /** @var TokenManager */ - protected $tokenManager; + protected TokenManager $tokenManager; - /** @var LoggerInterface */ protected LoggerInterface $logger; - /** @var int $nextSequence */ - protected $nextSequence = 0; + protected int $nextSequence = 0; protected ?CryptoModule $cryptoModule = null; /** * PNConfiguration constructor. * - * @param $initialConfig PNConfiguration + * @param $config PNConfiguration */ - public function __construct($initialConfig) + public function __construct(PNConfiguration $config) { - $this->validateConfig($initialConfig); - $initialConfig->lock(); - $this->configuration = $initialConfig; - $this->basePathManager = new BasePathManager($initialConfig); + $this->validateConfig($config); + $config->lock(); + $this->configuration = $config; + $this->basePathManager = new BasePathManager($config); $this->subscriptionManager = new SubscriptionManager($this); $this->telemetryManager = new TelemetryManager(); $this->tokenManager = new TokenManager(); @@ -105,7 +99,7 @@ public function __construct($initialConfig) * Pre-configured PubNub client with demo-keys * @return static */ - public static function demo() + public static function demo(): static { return new PubNub(PNConfiguration::demoKeys()); } @@ -115,7 +109,7 @@ public static function demo() * * @throws PubNubConfigurationException */ - private function validateConfig(PNConfiguration $configuration) + private function validateConfig(PNConfiguration $configuration): void { if (empty($configuration->getUuid())) { throw new PubNubConfigurationException('UUID should not be empty'); @@ -125,7 +119,7 @@ private function validateConfig(PNConfiguration $configuration) /** * @param SubscribeCallback $listener */ - public function addListener($listener) + public function addListener(SubscribeCallback $listener): void { $this->subscriptionManager->addListener($listener); } @@ -133,7 +127,7 @@ public function addListener($listener) /** * @param SubscribeCallback $listener */ - public function removeListener($listener) + public function removeListener(SubscribeCallback $listener): void { $this->subscriptionManager->removeListener($listener); } @@ -141,7 +135,7 @@ public function removeListener($listener) /** * @return Publish */ - public function publish() + public function publish(): Publish { return new Publish($this); } @@ -149,7 +143,7 @@ public function publish() /** * @return Fire */ - public function fire() + public function fire(): Fire { return new Fire($this); } @@ -157,7 +151,7 @@ public function fire() /** * @return Signal */ - public function signal() + public function signal(): Signal { return new Signal($this); } @@ -165,7 +159,7 @@ public function signal() /** * @return SubscribeBuilder */ - public function subscribe() + public function subscribe(): SubscribeBuilder { return new SubscribeBuilder($this->subscriptionManager); } @@ -173,7 +167,7 @@ public function subscribe() /** * @return History */ - public function history() + public function history(): History { return new History($this); } @@ -181,7 +175,7 @@ public function history() /** * @return HereNow */ - public function hereNow() + public function hereNow(): HereNow { return new HereNow($this); } @@ -189,7 +183,7 @@ public function hereNow() /** * @return WhereNow */ - public function whereNow() + public function whereNow(): WhereNow { return new WhereNow($this); } @@ -197,15 +191,16 @@ public function whereNow() /** * @return Grant */ - public function grant() + public function grant(): Grant { return new Grant($this); } /** * @return PNAccessManagerTokenResult + * @throws PubNubTokenParseException */ - public function parseToken($token) + public function parseToken($token): PNAccessManagerTokenResult { return (new GrantToken($this))->parseToken($token); } @@ -213,7 +208,7 @@ public function parseToken($token) /** * @return GrantToken */ - public function grantToken() + public function grantToken(): GrantToken { return new GrantToken($this); } @@ -221,7 +216,7 @@ public function grantToken() /** * @return RevokeToken */ - public function revokeToken() + public function revokeToken(): RevokeToken { return new RevokeToken($this); } @@ -229,7 +224,7 @@ public function revokeToken() /** * @return Audit */ - public function audit() + public function audit(): Audit { return new Audit($this); } @@ -237,7 +232,7 @@ public function audit() /** * @return Revoke */ - public function revoke() + public function revoke(): Revoke { return new Revoke($this); } @@ -245,7 +240,7 @@ public function revoke() /** * @return AddChannelToChannelGroup */ - public function addChannelToChannelGroup() + public function addChannelToChannelGroup(): AddChannelToChannelGroup { return new AddChannelToChannelGroup($this); } @@ -253,7 +248,7 @@ public function addChannelToChannelGroup() /** * @return RemoveChannelFromChannelGroup */ - public function removeChannelFromChannelGroup() + public function removeChannelFromChannelGroup(): RemoveChannelFromChannelGroup { return new RemoveChannelFromChannelGroup($this); } @@ -261,7 +256,7 @@ public function removeChannelFromChannelGroup() /** * @return RemoveChannelGroup */ - public function removeChannelGroup() + public function removeChannelGroup(): RemoveChannelGroup { return new RemoveChannelGroup($this); } @@ -269,7 +264,7 @@ public function removeChannelGroup() /** * @return ListChannelsInChannelGroup */ - public function listChannelsInChannelGroup() + public function listChannelsInChannelGroup(): ListChannelsInChannelGroup { return new ListChannelsInChannelGroup($this); } @@ -285,7 +280,7 @@ public function time(): Time /** * @return AddChannelsToPush */ - public function addChannelsToPush() + public function addChannelsToPush(): AddChannelsToPush { return new AddChannelsToPush($this); } @@ -293,7 +288,7 @@ public function addChannelsToPush() /** * @return RemoveChannelsFromPush */ - public function removeChannelsFromPush() + public function removeChannelsFromPush(): RemoveChannelsFromPush { return new RemoveChannelsFromPush($this); } @@ -301,7 +296,7 @@ public function removeChannelsFromPush() /** * @return RemoveDeviceFromPush */ - public function removeAllPushChannelsForDevice() + public function removeAllPushChannelsForDevice(): RemoveDeviceFromPush { return new RemoveDeviceFromPush($this); } @@ -309,7 +304,7 @@ public function removeAllPushChannelsForDevice() /** * @return ListPushProvisions */ - public function listPushProvisions() + public function listPushProvisions(): ListPushProvisions { return new ListPushProvisions($this); } @@ -317,7 +312,7 @@ public function listPushProvisions() /** * @return SetChannelMetadata */ - public function setChannelMetadata() + public function setChannelMetadata(): SetChannelMetadata { return new SetChannelMetadata($this); } @@ -325,7 +320,7 @@ public function setChannelMetadata() /** * @return GetChannelMetadata */ - public function getChannelMetadata() + public function getChannelMetadata(): GetChannelMetadata { return new GetChannelMetadata($this); } @@ -333,7 +328,7 @@ public function getChannelMetadata() /** * @return GetAllChannelMetadata */ - public function getAllChannelMetadata() + public function getAllChannelMetadata(): GetAllChannelMetadata { return new GetAllChannelMetadata($this); } @@ -341,7 +336,7 @@ public function getAllChannelMetadata() /** * @return RemoveChannelMetadata */ - public function removeChannelMetadata() + public function removeChannelMetadata(): RemoveChannelMetadata { return new RemoveChannelMetadata($this); } @@ -349,7 +344,7 @@ public function removeChannelMetadata() /** * @return SetUUIDMetadata */ - public function setUUIDMetadata() + public function setUUIDMetadata(): SetUUIDMetadata { return new SetUUIDMetadata($this); } @@ -357,7 +352,7 @@ public function setUUIDMetadata() /** * @return GetUUIDMetadata */ - public function getUUIDMetadata() + public function getUUIDMetadata(): GetUUIDMetadata { return new GetUUIDMetadata($this); } @@ -365,7 +360,7 @@ public function getUUIDMetadata() /** * @return GetAllUUIDMetadata */ - public function getAllUUIDMetadata() + public function getAllUUIDMetadata(): GetAllUUIDMetadata { return new GetAllUUIDMetadata($this); } @@ -373,7 +368,7 @@ public function getAllUUIDMetadata() /** * @return RemoveUUIDMetadata */ - public function removeUUIDMetadata() + public function removeUUIDMetadata(): RemoveUUIDMetadata { return new RemoveUUIDMetadata($this); } @@ -381,7 +376,7 @@ public function removeUUIDMetadata() /** * @return GetMembers */ - public function getMembers() + public function getMembers(): GetMembers { return new GetMembers($this); } @@ -389,7 +384,7 @@ public function getMembers() /** * @return SetMembers */ - public function setMembers() + public function setMembers(): SetMembers { return new SetMembers($this); } @@ -397,7 +392,7 @@ public function setMembers() /** * @return RemoveMembers */ - public function removeMembers() + public function removeMembers(): RemoveMembers { return new RemoveMembers($this); } @@ -405,7 +400,7 @@ public function removeMembers() /** * @return GetMemberships */ - public function getMemberships() + public function getMemberships(): GetMemberships { return new GetMemberships($this); } @@ -413,7 +408,7 @@ public function getMemberships() /** * @return SetMemberships */ - public function setMemberships() + public function setMemberships(): SetMemberships { return new SetMemberships($this); } @@ -421,7 +416,7 @@ public function setMemberships() /** * @return RemoveMemberships */ - public function removeMemberships() + public function removeMemberships(): RemoveMemberships { return new RemoveMemberships($this); } @@ -429,7 +424,7 @@ public function removeMemberships() /** * @return int */ - public function timestamp() + public function timestamp(): int { return time(); } @@ -437,7 +432,7 @@ public function timestamp() /** * @return string */ - public static function getSdkVersion() + public static function getSdkVersion(): string { return static::SDK_VERSION; } @@ -445,7 +440,7 @@ public static function getSdkVersion() /** * @return string */ - public static function getSdkName() + public static function getSdkName(): string { return static::SDK_NAME; } @@ -453,7 +448,7 @@ public static function getSdkName() /** * @return string */ - public static function getSdkFullName() + public static function getSdkFullName(): string { $fullName = static::SDK_NAME . "/" . static::SDK_VERSION; @@ -465,7 +460,7 @@ public static function getSdkFullName() * * @return PNConfiguration */ - public function getConfiguration() + public function getConfiguration(): PNConfiguration { return $this->configuration; } @@ -473,15 +468,15 @@ public function getConfiguration() /** * @return string Base path */ - public function getBasePath($customHost = null) + public function getBasePath($customHost = null): string { return $this->basePathManager->getBasePath($customHost); } /** - * @return Logger + * @return LoggerInterface */ - public function getLogger() + public function getLogger(): LoggerInterface { return $this->logger; } @@ -497,7 +492,7 @@ public function setLogger(LoggerInterface $logger): void /** * @return GetState */ - public function getState() + public function getState(): GetState { return new GetState($this); } @@ -505,7 +500,7 @@ public function getState() /** * @return SetState */ - public function setState() + public function setState(): SetState { return new SetState($this); } @@ -513,7 +508,7 @@ public function setState() /** * @return HistoryDelete */ - public function deleteMessages() + public function deleteMessages(): HistoryDelete { return new HistoryDelete($this); } @@ -521,7 +516,7 @@ public function deleteMessages() /** * @return MessageCount */ - public function messageCounts() + public function messageCounts(): MessageCount { return new MessageCount($this); } @@ -529,7 +524,7 @@ public function messageCounts() /** * @return TelemetryManager */ - public function getTelemetryManager() + public function getTelemetryManager(): TelemetryManager { return $this->telemetryManager; } @@ -537,7 +532,7 @@ public function getTelemetryManager() /** * @return int unique sequence identifier */ - public function getSequenceId() + public function getSequenceId(): int { if (static::$MAX_SEQUENCE === $this->nextSequence) { $this->nextSequence = 1; @@ -551,7 +546,7 @@ public function getSequenceId() /** * @return string Token previously set by $this->setToken */ - public function getToken() + public function getToken(): ?string { return $this->tokenManager->getToken(); } @@ -559,21 +554,12 @@ public function getToken() /** * @param string $token Token obtained by GetToken */ - public function setToken($token) + public function setToken(string $token) { return $this->tokenManager->setToken($token); } - public function getCrypto(): CryptoModule | null - { - if ($this->cryptoModule) { - return $this->cryptoModule; - } else { - return $this->configuration->getCryptoSafe(); - } - } - - public function getCryptoSafe(): CryptoModule|null + public function getCrypto(): ?CryptoModule { if ($this->cryptoModule) { return $this->cryptoModule; @@ -597,27 +583,27 @@ public function fetchMessages(): FetchMessages return new FetchMessages($this); } - public function sendFile() + public function sendFile(): SendFile { return new SendFile($this); } - public function deleteFile() + public function deleteFile(): DeleteFile { return new DeleteFile($this); } - public function downloadFile() + public function downloadFile(): DownloadFile { return new DownloadFile($this); } - public function listFiles() + public function listFiles(): ListFiles { return new ListFiles($this); } - public function getFileDownloadUrl() + public function getFileDownloadUrl(): GetFileDownloadUrl { return new GetFileDownloadUrl($this); } diff --git a/tests/functional/AuditTest.php b/tests/functional/AuditTest.php index 34272954..631b0483 100644 --- a/tests/functional/AuditTest.php +++ b/tests/functional/AuditTest.php @@ -7,7 +7,6 @@ use PubNub\PubNub; use PubNub\PubNubUtil; - class AuditTest extends \PubNubTestCase { /** @var AuditExposed */ @@ -25,7 +24,10 @@ public function testAuditChannel() { $this->audit->channels('ch'); - $this->assertEquals(sprintf(Audit::PATH, $this->config_pam->getSubscribeKey()), $this->audit->buildPath()); + $this->assertEquals( + sprintf(AuditExposed::PATH, $this->config_pam->getSubscribeKey()), + $this->audit->buildPath() + ); $this->assertEquals([ 'pnsdk' => PubNubUtil::urlEncode(PubNub::getSdkFullName()), @@ -52,7 +54,10 @@ public function testAuditChannelGroup() { $this->audit->channelGroups(['gr1', 'gr2']); - $this->assertEquals(sprintf(Audit::PATH, $this->config_pam->getSubscribeKey()), $this->audit->buildPath()); + $this->assertEquals( + sprintf(AuditExposed::PATH, $this->config_pam->getSubscribeKey()), + $this->audit->buildPath() + ); $this->assertEquals([ 'pnsdk' => PubNubUtil::urlEncode(PubNub::getSdkFullName()), @@ -76,16 +81,19 @@ public function testAuditChannelGroup() } } +// phpcs:ignore PSR1.Classes.ClassDeclaration class PubNubStubbedAudit extends PubNub { - public function timestamp() + public function timestamp(): int { return 123; } } +// phpcs:ignore PSR1.Classes.ClassDeclaration class AuditExposed extends Audit { + public const PATH = parent::PATH; public function buildParams() { return parent::buildParams(); diff --git a/tests/functional/GetStateTest.php b/tests/functional/GetStateTest.php index e7be55a3..29395319 100644 --- a/tests/functional/GetStateTest.php +++ b/tests/functional/GetStateTest.php @@ -1,4 +1,5 @@ assertEquals( sprintf( - GetState::PATH, + ExposedGetState::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), "ch", $this->pubnub->getConfiguration()->getUuid() - ), $this->getState->buildPath()); + ), + $this->getState->buildPath() + ); $this->assertEquals([ 'pnsdk' => PubNubUtil::urlEncode(PubNub::getSdkFullName()), @@ -46,11 +48,13 @@ public function testGetStateSingleGroup() $this->assertEquals( sprintf( - GetState::PATH, + ExposedGetState::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), ",", $this->pubnub->getConfiguration()->getUuid() - ), $this->getState->buildPath()); + ), + $this->getState->buildPath() + ); $this->assertEquals([ 'pnsdk' => PubNubUtil::urlEncode(PubNub::getSdkFullName()), @@ -63,9 +67,10 @@ public function testGetStateSingleGroup() } } - +// phpcs:ignore PSR1.Classes.ClassDeclaration class ExposedGetState extends GetState { + public const PATH = parent::PATH; public function buildParams() { return parent::buildParams(); @@ -91,4 +96,4 @@ public function getChannelGroups() { return $this->channelGroups; } -} \ No newline at end of file +} diff --git a/tests/functional/GrantTest.php b/tests/functional/GrantTest.php index 472bb07d..af42c8cf 100644 --- a/tests/functional/GrantTest.php +++ b/tests/functional/GrantTest.php @@ -8,7 +8,6 @@ use PubNub\PubNub; use PubNub\PubNubUtil; - class GrantTest extends \PubNubTestCase { /** @var GrantExposed */ @@ -39,8 +38,8 @@ public function testReadAndWriteToChannel() $this->grant->channels('ch')->read(true)->write(true)->ttl(7); $this->assertEquals( - sprintf(Grant::PATH, $this->config_pam->getSubscribeKey()), - $this->grant->buildPath() + sprintf(GrantExposed::PATH, $this->config_pam->getSubscribeKey()), + $this->grant->buildPath() ); $this->assertEquals([ @@ -77,7 +76,7 @@ public function testReadAndWriteToChannelGroup() ->write(false); $this->assertEquals( - sprintf(Grant::PATH, $this->config_pam->getSubscribeKey()), + sprintf(GrantExposed::PATH, $this->config_pam->getSubscribeKey()), $this->grant->buildPath() ); @@ -107,17 +106,19 @@ public function testReadAndWriteToChannelGroup() } } +// phpcs:ignore PSR1.Classes.ClassDeclaration class PubNubStubbed extends PubNub { - public function timestamp() + public function timestamp(): int { return 123; } } - +// phpcs:ignore PSR1.Classes.ClassDeclaration class GrantExposed extends Grant { + public const PATH = parent::PATH; public function buildParams() { return parent::buildParams(); @@ -127,4 +128,4 @@ public function buildPath() { return parent::buildPath(); } -} \ No newline at end of file +} diff --git a/tests/functional/HereNowTest.php b/tests/functional/HereNowTest.php index a5d6fa8a..9d31b625 100644 --- a/tests/functional/HereNowTest.php +++ b/tests/functional/HereNowTest.php @@ -1,4 +1,5 @@ hereNow->channels("ch1"); - $this->assertEquals(sprintf(HereNow::PATH, - $this->pubnub->getConfiguration()->getSubscribeKey(), - "ch1"), $this->hereNow->buildPath()); + $this->assertEquals( + sprintf(ExposedHereNow::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), "ch1"), + $this->hereNow->buildPath() + ); $this->assertEquals([ 'pnsdk' => PubNubUtil::urlEncode(PubNub::getSdkFullName()), @@ -39,7 +40,7 @@ public function testHereNowGroups() $this->hereNow->channelGroups("gr1"); $this->assertEquals( - sprintf(HereNow::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), ","), + sprintf(ExposedHereNow::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), ","), $this->hereNow->buildPath() ); @@ -59,7 +60,7 @@ public function testHereNowWithOptions() ->includeUuids(false); $this->assertEquals( - sprintf(HereNow::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), "ch1"), + sprintf(ExposedHereNow::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), "ch1"), $this->hereNow->buildPath() ); @@ -73,8 +74,11 @@ public function testHereNowWithOptions() } } + +// phpcs:ignore PSR1.Classes.ClassDeclaration class ExposedHereNow extends HereNow { + public const PATH = parent::PATH; public function buildParams() { return parent::buildParams(); diff --git a/tests/functional/HistoryDeleteTest.php b/tests/functional/HistoryDeleteTest.php index 91dc69c9..f0ef6c71 100644 --- a/tests/functional/HistoryDeleteTest.php +++ b/tests/functional/HistoryDeleteTest.php @@ -1,4 +1,5 @@ channel('ch'); $this->assertEquals( - sprintf( - HistoryDelete::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), 'ch'), - $historyDelete->buildPath()); + sprintf(HistoryDeleteExposed::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), 'ch'), + $historyDelete->buildPath() + ); $this->assertEquals([ 'pnsdk' => PubNubUtil::urlEncode(PubNub::getSdkFullName()), @@ -41,7 +41,7 @@ public function testHistoryDeleteFull() ->end(200000); $this->assertEquals( - sprintf(HistoryDelete::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), 'ch'), + sprintf(HistoryDeleteExposed::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), 'ch'), $historyDelete->buildPath() ); @@ -54,8 +54,10 @@ public function testHistoryDeleteFull() } } +// phpcs:ignore PSR1.Classes.ClassDeclaration class HistoryDeleteExposed extends HistoryDelete { + public const PATH = parent::PATH; public function buildPath() { return parent::buildPath(); @@ -65,4 +67,4 @@ public function buildParams() { return parent::buildParams(); } -} \ No newline at end of file +} diff --git a/tests/functional/HistoryTest.php b/tests/functional/HistoryTest.php index 3f5a08c5..ddc094ed 100644 --- a/tests/functional/HistoryTest.php +++ b/tests/functional/HistoryTest.php @@ -1,4 +1,5 @@ history->channel('ch'); $this->assertEquals( - sprintf( - History::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), 'ch'), - $this->history->buildPath()); + sprintf(HistoryExposed::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), 'ch'), + $this->history->buildPath() + ); $this->assertEquals([ 'pnsdk' => PubNubUtil::urlEncode(PubNub::getSdkFullName()), @@ -47,7 +47,7 @@ public function testHistoryFull() ->includeTimetoken(true); $this->assertEquals( - sprintf(History::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), 'ch'), + sprintf(HistoryExposed::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), 'ch'), $this->history->buildPath() ); @@ -63,9 +63,12 @@ public function testHistoryFull() } } +// phpcs:ignore PSR1.Classes.ClassDeclaration class HistoryExposed extends History { - public function buildPath() + public const PATH = parent::PATH; + + public function buildPath() { return parent::buildPath(); } @@ -74,4 +77,4 @@ public function buildParams() { return parent::buildParams(); } -} \ No newline at end of file +} diff --git a/tests/functional/LeaveTest.php b/tests/functional/LeaveTest.php index 1ce1d279..188ff2ff 100644 --- a/tests/functional/LeaveTest.php +++ b/tests/functional/LeaveTest.php @@ -6,7 +6,6 @@ use PubNub\Endpoints\Presence\Leave; use PubNub\PubNubUtil; - class LeaveTest extends \PubNubTestCase { /** @var LeaveExposed */ @@ -42,7 +41,7 @@ public function testLeaveMultipleChannels() $this->leave->channels("ch1,ch2,ch3"); $this->assertEquals( - sprintf(Leave::PATH, $this->config->getSubscribeKey(), "ch1,ch2,ch3"), + sprintf(LeaveExposed::PATH, $this->config->getSubscribeKey(), "ch1,ch2,ch3"), $this->leave->buildPath() ); @@ -59,7 +58,7 @@ public function testLeaveMultipleChannelsUsingArray() $this->leave->channels(["ch1","ch2","ch3"]); $this->assertEquals( - sprintf(Leave::PATH, $this->config->getSubscribeKey(), "ch1,ch2,ch3"), + sprintf(LeaveExposed::PATH, $this->config->getSubscribeKey(), "ch1,ch2,ch3"), $this->leave->buildPath() ); @@ -76,7 +75,7 @@ public function testLeaveSingleGroup() $this->leave->channelGroups("gr"); $this->assertEquals( - sprintf(Leave::PATH, $this->config->getSubscribeKey(), ","), + sprintf(LeaveExposed::PATH, $this->config->getSubscribeKey(), ","), $this->leave->buildPath() ); @@ -94,7 +93,7 @@ public function testLeaveMultipleGroups() $this->leave->channelGroups("gr1,gr2,gr3"); $this->assertEquals( - sprintf(Leave::PATH, $this->config->getSubscribeKey(), ","), + sprintf(LeaveExposed::PATH, $this->config->getSubscribeKey(), ","), $this->leave->buildPath() ); @@ -112,7 +111,7 @@ public function testLeaveMultipleGroupsUsingArray() $this->leave->channelGroups(["gr1","gr2","gr3"]); $this->assertEquals( - sprintf(Leave::PATH, $this->config->getSubscribeKey(), ","), + sprintf(LeaveExposed::PATH, $this->config->getSubscribeKey(), ","), $this->leave->buildPath() ); @@ -130,7 +129,7 @@ public function testLeaveChannelsAndGroups() $this->leave->channels("ch1,ch2")->channelGroups(["gr1", "gr2"]); $this->assertEquals( - sprintf(Leave::PATH, $this->config->getSubscribeKey(), "ch1,ch2"), + sprintf(LeaveExposed::PATH, $this->config->getSubscribeKey(), "ch1,ch2"), $this->leave->buildPath() ); @@ -145,9 +144,10 @@ public function testLeaveChannelsAndGroups() } } - +// phpcs:ignore PSR1.Classes.ClassDeclaration class LeaveExposed extends Leave { + public const PATH = parent::PATH; public function buildPath() { return parent::buildPath(); @@ -173,4 +173,4 @@ public function getGroups() { return $this->groups; } -} \ No newline at end of file +} diff --git a/tests/functional/SetStateTest.php b/tests/functional/SetStateTest.php index 71fdfac5..9caf07b3 100644 --- a/tests/functional/SetStateTest.php +++ b/tests/functional/SetStateTest.php @@ -32,23 +32,28 @@ public function testSetStateSingleChannel() $this->assertEquals( sprintf( - SetState::PATH, + SetStateExposed::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), "ch", $this->pubnub->getConfiguration()->getUuid() - ), $this->setState->buildPath()); + ), + $this->setState->buildPath() + ); $params = $this->setState->buildParams(); $this->assertEquals( PubNubUtil::urlEncode(PubNub::getSdkFullName()), - $params['pnsdk']); + $params['pnsdk'] + ); $this->assertEquals( $this->pubnub->getConfiguration()->getUuid(), - $params['uuid']); + $params['uuid'] + ); $this->assertEquals( json_decode("%7B%22count%22%3A%205%2C%20%22name%22%3A%20%22Alex%22%7D"), - json_decode($params['state'])); + json_decode($params['state']) + ); $this->assertEquals(['ch'], $this->setState->getChannels()); } @@ -59,11 +64,13 @@ public function testSetStateSingleGroups() $this->assertEquals( sprintf( - SetState::PATH, + SetStateExposed::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), ",", $this->pubnub->getConfiguration()->getUuid() - ), $this->setState->buildPath()); + ), + $this->setState->buildPath() + ); $params = $this->setState->buildParams(); @@ -72,14 +79,17 @@ public function testSetStateSingleGroups() $this->assertEquals($params['channel-group'], 'gr'); $this->assertEquals( json_decode("%7B%22count%22%3A%205%2C%20%22name%22%3A%20%22Alex%22%7D"), - json_decode($params['state'])); + json_decode($params['state']) + ); $this->assertEquals(0, count($this->setState->getChannels())); $this->assertEquals(['gr'], $this->setState->getGroups()); } } +// phpcs:ignore PSR1.Classes.ClassDeclaration class SetStateExposed extends SetState { + public const PATH = parent::PATH; public function buildParams() { return parent::buildParams(); diff --git a/tests/functional/WhereNowTest.php b/tests/functional/WhereNowTest.php index 118a3489..5d1fad0a 100644 --- a/tests/functional/WhereNowTest.php +++ b/tests/functional/WhereNowTest.php @@ -1,4 +1,5 @@ whereNow->uuid("person_uuid"); $this->assertEquals( - sprintf(WhereNow::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), "person_uuid"), - $this->whereNow->buildPath()); + sprintf(ExposedWhereNow::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), "person_uuid"), + $this->whereNow->buildPath() + ); $this->assertEquals([ 'pnsdk' => PubNubUtil::urlEncode(PubNub::getSdkFullName()), @@ -37,8 +38,11 @@ public function testWhereNow() public function testWhereNowNoUuid() { $this->assertEquals( - sprintf(WhereNow::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), - $this->pubnub->getConfiguration()->getUuid()), + sprintf( + ExposedWhereNow::PATH, + $this->pubnub->getConfiguration()->getSubscribeKey(), + $this->pubnub->getConfiguration()->getUuid() + ), $this->whereNow->buildPath() ); @@ -49,8 +53,10 @@ public function testWhereNowNoUuid() } } +// phpcs:ignore PSR1.Classes.ClassDeclaration class ExposedWhereNow extends WhereNow { + public const PATH = parent::PATH; public function buildParams() { return parent::buildParams(); @@ -60,4 +66,4 @@ public function buildPath() { return parent::buildPath(); } -} \ No newline at end of file +} diff --git a/tests/functional/objects/channel/GetAllChannelMetadataTest.php b/tests/functional/objects/channel/GetAllChannelMetadataTest.php index 0965ec8d..9dbdaeec 100644 --- a/tests/functional/objects/channel/GetAllChannelMetadataTest.php +++ b/tests/functional/objects/channel/GetAllChannelMetadataTest.php @@ -3,6 +3,7 @@ namespace Tests\Functional\Objects\Channel; use PubNub\Endpoints\Objects\Channel\GetAllChannelMetadata; +use PubNub\Models\Consumer\Objects\Channel\PNGetAllChannelMetadataResult; use PubNub\PubNub; use PubNub\PubNubUtil; use PubNubTestCase; @@ -19,7 +20,7 @@ public function testGetAllChannelMetadata() ->includeFields([ "totalCount" => true, "customFields" => true ]); $this->assertEquals(sprintf( - GetAllChannelMetadata::PATH, + GetAllChannelMetadataExposed::PATH, $this->pubnub->getConfiguration()->getSubscribeKey() ), $getAllMetadata->buildPath()); @@ -70,8 +71,10 @@ public function testGetAllChannelMetadata() } } +// phpcs:ignore PSR1.Classes.ClassDeclaration class GetAllChannelMetadataExposed extends GetAllChannelMetadata { + public const PATH = parent::PATH; public function buildParams() { return parent::buildParams(); @@ -82,9 +85,8 @@ public function buildPath() return parent::buildPath(); } - public function createResponse($result) + public function createResponse($result): PNGetAllChannelMetadataResult { return parent::createResponse($result); } - } diff --git a/tests/functional/objects/channel/GetChannelMetadataTest.php b/tests/functional/objects/channel/GetChannelMetadataTest.php index 3e2ddac4..7a0a5fbc 100644 --- a/tests/functional/objects/channel/GetChannelMetadataTest.php +++ b/tests/functional/objects/channel/GetChannelMetadataTest.php @@ -3,6 +3,7 @@ namespace Tests\Functional\Objects\Channel; use PubNub\Endpoints\Objects\Channel\GetChannelMetadata; +use PubNub\Models\Consumer\Objects\Channel\PNGetChannelMetadataResult; use PubNub\PubNub; use PubNub\PubNubUtil; use PubNubTestCase; @@ -22,7 +23,7 @@ public function testGetMetadataFromChannel() ->channel("ch"); $this->assertEquals(sprintf( - GetChannelMetadata::PATH, + GetChannelMetadataExposed::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), "ch" ), $getMetadata->buildPath()); @@ -60,8 +61,11 @@ public function testGetMetadataFromChannel() } } +// phpcs:ignore PSR1.Classes.ClassDeclaration class GetChannelMetadataExposed extends GetChannelMetadata { + public const PATH = parent::PATH; + public function buildParams() { return parent::buildParams(); @@ -72,9 +76,8 @@ public function buildPath() return parent::buildPath(); } - public function createResponse($result) + public function createResponse($result): PNGetChannelMetadataResult { return parent::createResponse($result); } - } diff --git a/tests/functional/objects/channel/RemoveChannelMetadataTest.php b/tests/functional/objects/channel/RemoveChannelMetadataTest.php index cf3e7d3a..e70458a9 100644 --- a/tests/functional/objects/channel/RemoveChannelMetadataTest.php +++ b/tests/functional/objects/channel/RemoveChannelMetadataTest.php @@ -19,7 +19,7 @@ public function testGetaMetadataFromChannel() ->channel("ch"); $this->assertEquals(sprintf( - RemoveChannelMetadata::PATH, + RemoveChannelMetadataExposed::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), "ch" ), $removeMetadata->buildPath()); @@ -39,8 +39,11 @@ public function testGetaMetadataFromChannel() } } +//phpcs:ignore PSR1.Classes.ClassDeclaration class RemoveChannelMetadataExposed extends RemoveChannelMetadata { + public const PATH = parent::PATH; + public function buildParams() { return parent::buildParams(); @@ -51,9 +54,8 @@ public function buildPath() return parent::buildPath(); } - public function createResponse($result) + public function createResponse($result): bool { return parent::createResponse($result); } - } diff --git a/tests/functional/objects/channel/SetChannelMetadataTest.php b/tests/functional/objects/channel/SetChannelMetadataTest.php index 48ab1d67..1f9bf3b7 100644 --- a/tests/functional/objects/channel/SetChannelMetadataTest.php +++ b/tests/functional/objects/channel/SetChannelMetadataTest.php @@ -32,7 +32,7 @@ public function testAddCustomObjectMetadataToChannel() ->meta($metadata); $this->assertEquals(sprintf( - SetChannelMetadata::PATH, + SetChannelMetadataExposed::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), "ch" ), $setMetadata->buildPath()); @@ -78,7 +78,7 @@ public function testAddArrayMetadataToChannel() ->meta($metadata); $this->assertEquals(sprintf( - SetChannelMetadata::PATH, + SetChannelMetadataExposed::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), "ch" ), $setMetadata->buildPath()); @@ -113,7 +113,7 @@ public function testAddStdClassMetadataToChannel() $setMetadata = new SetChannelMetadataExposed($this->pubnub); $metadata = new stdClass(); - + $metadata->id = "ch"; $metadata->name = "ch_name"; $metadata->description = "ch_description"; @@ -127,7 +127,7 @@ public function testAddStdClassMetadataToChannel() ->meta($metadata); $this->assertEquals(sprintf( - SetChannelMetadata::PATH, + SetChannelMetadataExposed::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), "ch" ), $setMetadata->buildPath()); @@ -153,8 +153,10 @@ public function testAddStdClassMetadataToChannel() } } +// phpcs:ignore PSR1.Classes.ClassDeclaration class SetChannelMetadataExposed extends SetChannelMetadata { + public const PATH = parent::PATH; public function buildParams() { return parent::buildParams(); @@ -164,10 +166,9 @@ public function buildData() { return parent::buildData(); } - + public function buildPath() { return parent::buildPath(); } - } diff --git a/tests/functional/objects/member/GetMembersTest.php b/tests/functional/objects/member/GetMembersTest.php index f296d15a..e6e05e15 100644 --- a/tests/functional/objects/member/GetMembersTest.php +++ b/tests/functional/objects/member/GetMembersTest.php @@ -3,6 +3,7 @@ namespace Tests\Functional\Objects\Member; use PubNub\Endpoints\Objects\Member\GetMembers; +use PubNub\Models\Consumer\Objects\Member\PNMembersResult; use PubNub\PubNub; use PubNub\PubNubUtil; use PubNubTestCase; @@ -17,10 +18,15 @@ public function testGetMembers() $getMembers ->channel("ch") - ->includeFields([ "totalCount" => true, "customFields" => true, "customUUIDFields" => true, "UUIDFields" => true ]); + ->includeFields([ + "totalCount" => true, + "customFields" => true, + "customUUIDFields" => true, + "UUIDFields" => true + ]); $this->assertEquals(sprintf( - GetMembers::PATH, + GetMembersExposed::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), "ch" ), $getMembers->buildPath()); @@ -91,8 +97,11 @@ public function testGetMembers() } } +// phpcs:ignore PSR1.Classes.ClassDeclaration class GetMembersExposed extends GetMembers { + public const PATH = parent::PATH; + public function buildParams() { return parent::buildParams(); @@ -103,9 +112,8 @@ public function buildPath() return parent::buildPath(); } - public function createResponse($result) + public function createResponse($result): PNMembersResult { return parent::createResponse($result); } - } diff --git a/tests/functional/objects/member/RemoveMembersTest.php b/tests/functional/objects/member/RemoveMembersTest.php index 332aac7c..3f055b04 100644 --- a/tests/functional/objects/member/RemoveMembersTest.php +++ b/tests/functional/objects/member/RemoveMembersTest.php @@ -20,7 +20,7 @@ public function testRemoveMembersFromChannel() ->uuids(["uuid", "uuid1", "uuid2"]); $this->assertEquals(sprintf( - RemoveMembers::PATH, + RemoveMembersExposed::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), "ch" ), $removeMembers->buildPath()); @@ -33,7 +33,7 @@ public function testRemoveMembersFromChannel() $data = $removeMembers->buildData(); $decoded_data = json_decode($data); - + $this->assertNotEmpty($decoded_data->delete); $this->assertEquals(3, count($decoded_data->delete)); $this->assertNotEmpty($decoded_data->delete[0]->uuid); @@ -45,8 +45,10 @@ public function testRemoveMembersFromChannel() } } +// phpcs:ignore PSR1.Classes.ClassDeclaration class RemoveMembersExposed extends RemoveMembers { + public const PATH = parent::PATH; public function buildParams() { return parent::buildParams(); @@ -56,10 +58,9 @@ public function buildData() { return parent::buildData(); } - + public function buildPath() { return parent::buildPath(); } - } diff --git a/tests/functional/objects/member/SetMembersTest.php b/tests/functional/objects/member/SetMembersTest.php index 3ef7cb47..3ac48afe 100644 --- a/tests/functional/objects/member/SetMembersTest.php +++ b/tests/functional/objects/member/SetMembersTest.php @@ -21,7 +21,7 @@ public function testAddMembersToChannel() ->custom(["a" => "aa", "b" => "bb"]); $this->assertEquals(sprintf( - SetMembers::PATH, + SetMembersExposed::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), "ch" ), $setMembers->buildPath()); @@ -34,7 +34,7 @@ public function testAddMembersToChannel() $data = $setMembers->buildData(); $decoded_data = json_decode($data); - + $this->assertNotEmpty($decoded_data->set); $this->assertEquals(3, count($decoded_data->set)); @@ -61,8 +61,10 @@ public function testAddMembersToChannel() } } +// phpcs:ignore PSR1.Classes.ClassDeclaration class SetMembersExposed extends SetMembers { + public const PATH = parent::PATH; public function buildParams() { return parent::buildParams(); @@ -72,10 +74,9 @@ public function buildData() { return parent::buildData(); } - + public function buildPath() { return parent::buildPath(); } - } diff --git a/tests/functional/objects/membership/GetMembershipsTest.php b/tests/functional/objects/membership/GetMembershipsTest.php index 3d42a8b0..4492dcc1 100644 --- a/tests/functional/objects/membership/GetMembershipsTest.php +++ b/tests/functional/objects/membership/GetMembershipsTest.php @@ -3,6 +3,7 @@ namespace Tests\Functional\Objects\Membership; use PubNub\Endpoints\Objects\Membership\GetMemberships; +use PubNub\Models\Consumer\Objects\Membership\PNMembershipsResult; use PubNub\PubNub; use PubNub\PubNubUtil; use PubNubTestCase; @@ -17,10 +18,15 @@ public function testGetMemberships() $getMemberships ->uuid("uuid") - ->includeFields([ "totalCount" => true, "customFields" => true, "customChannelFields" => true, "channelFields" => true ]); + ->includeFields([ + "totalCount" => true, + "customFields" => true, + "customChannelFields" => true, + "channelFields" => true + ]); $this->assertEquals(sprintf( - GetMemberships::PATH, + GetMembershipsExposed::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), "uuid" ), $getMemberships->buildPath()); @@ -87,8 +93,11 @@ public function testGetMemberships() } } +// phpcs:ignore PSR1.Classes.ClassDeclaration class GetMembershipsExposed extends GetMemberships { + public const PATH = parent::PATH; + public function buildParams() { return parent::buildParams(); @@ -99,9 +108,8 @@ public function buildPath() return parent::buildPath(); } - public function createResponse($result) + public function createResponse($result): PNMembershipsResult { return parent::createResponse($result); } - } diff --git a/tests/functional/objects/membership/RemoveMembershipsTest.php b/tests/functional/objects/membership/RemoveMembershipsTest.php index 23765fb0..5ba5a48e 100644 --- a/tests/functional/objects/membership/RemoveMembershipsTest.php +++ b/tests/functional/objects/membership/RemoveMembershipsTest.php @@ -20,7 +20,7 @@ public function testRemoveMemberships() ->channels(["ch", "ch1", "ch2"]); $this->assertEquals(sprintf( - RemoveMemberships::PATH, + RemoveMembershipsExposed::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), "uuid" ), $removeMemberships->buildPath()); @@ -33,7 +33,7 @@ public function testRemoveMemberships() $data = $removeMemberships->buildData(); $decoded_data = json_decode($data); - + $this->assertNotEmpty($decoded_data->delete); $this->assertEquals(3, count($decoded_data->delete)); $this->assertNotEmpty($decoded_data->delete[0]->channel); @@ -45,8 +45,10 @@ public function testRemoveMemberships() } } +// phpcs:ignore PSR1.Classes.ClassDeclaration class RemoveMembershipsExposed extends RemoveMemberships { + public const PATH = parent::PATH; public function buildParams() { return parent::buildParams(); @@ -56,10 +58,9 @@ public function buildData() { return parent::buildData(); } - + public function buildPath() { return parent::buildPath(); } - } diff --git a/tests/functional/objects/membership/SetMembershipsTest.php b/tests/functional/objects/membership/SetMembershipsTest.php index b616412e..b0bf251d 100644 --- a/tests/functional/objects/membership/SetMembershipsTest.php +++ b/tests/functional/objects/membership/SetMembershipsTest.php @@ -21,7 +21,7 @@ public function testAddMemberships() ->custom(["a" => "aa", "b" => "bb"]); $this->assertEquals(sprintf( - SetMemberships::PATH, + SetMembershipsExposed::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), "uuid" ), $setMemberships->buildPath()); @@ -34,7 +34,7 @@ public function testAddMemberships() $data = $setMemberships->buildData(); $decoded_data = json_decode($data); - + $this->assertNotEmpty($decoded_data->set); $this->assertEquals(3, count($decoded_data->set)); @@ -61,8 +61,10 @@ public function testAddMemberships() } } +// phpcs:ignore PSR1.Classes.ClassDeclaration class SetMembershipsExposed extends SetMemberships { + public const PATH = parent::PATH; public function buildParams() { return parent::buildParams(); @@ -72,10 +74,9 @@ public function buildData() { return parent::buildData(); } - + public function buildPath() { return parent::buildPath(); } - } diff --git a/tests/functional/objects/uuid/GetAllUUIDMetadataTest.php b/tests/functional/objects/uuid/GetAllUUIDMetadataTest.php index a9571046..9a7c45e4 100644 --- a/tests/functional/objects/uuid/GetAllUUIDMetadataTest.php +++ b/tests/functional/objects/uuid/GetAllUUIDMetadataTest.php @@ -3,6 +3,7 @@ namespace Tests\Functional\Objects\UUID; use PubNub\Endpoints\Objects\UUID\GetAllUUIDMetadata; +use PubNub\Models\Consumer\Objects\UUID\PNGetAllUUIDMetadataResult; use PubNub\PubNub; use PubNub\PubNubUtil; use PubNubTestCase; @@ -16,10 +17,10 @@ public function testGetAllUUIDMetadata() $getAllMetadata = new GetAllUUIDMetadataExposed($this->pubnub); $getAllMetadata - ->includeFields([ "totalCount" => true, "customFields" => true ]); + ->includeFields(["totalCount" => true, "customFields" => true]); $this->assertEquals(sprintf( - GetAllUUIDMetadata::PATH, + GetAllUUIDMetadataExposed::PATH, $this->pubnub->getConfiguration()->getSubscribeKey() ), $getAllMetadata->buildPath()); @@ -74,8 +75,11 @@ public function testGetAllUUIDMetadata() } } +// phpcs:ignore PSR1.Classes.ClassDeclaration class GetAllUUIDMetadataExposed extends GetAllUUIDMetadata { + public const PATH = parent::PATH; + public function buildParams() { return parent::buildParams(); @@ -86,9 +90,8 @@ public function buildPath() return parent::buildPath(); } - public function createResponse($result) + public function createResponse($result): PNGetAllUUIDMetadataResult { return parent::createResponse($result); } - } diff --git a/tests/functional/objects/uuid/GetUUIDMetadataTest.php b/tests/functional/objects/uuid/GetUUIDMetadataTest.php index 6ae09fd1..4de2de19 100644 --- a/tests/functional/objects/uuid/GetUUIDMetadataTest.php +++ b/tests/functional/objects/uuid/GetUUIDMetadataTest.php @@ -3,6 +3,7 @@ namespace Tests\Functional\Objects\UUID; use PubNub\Endpoints\Objects\UUID\GetUUIDMetadata; +use PubNub\Models\Consumer\Objects\UUID\PNGetUUIDMetadataResult; use PubNub\PubNub; use PubNub\PubNubUtil; use PubNubTestCase; @@ -22,7 +23,7 @@ public function testGetMetadataFromUUID() ->uuid("uuid"); $this->assertEquals(sprintf( - GetUUIDMetadata::PATH, + GetUUIDMetadataExposed::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), "uuid" ), $getMetadata->buildPath()); @@ -64,8 +65,10 @@ public function testGetMetadataFromUUID() } } +// phpcs:ignore PSR1.Classes.ClassDeclaration class GetUUIDMetadataExposed extends GetUUIDMetadata { + public const PATH = parent::PATH; public function buildParams() { return parent::buildParams(); @@ -76,9 +79,8 @@ public function buildPath() return parent::buildPath(); } - public function createResponse($result) + public function createResponse($result): PNGetUUIDMetadataResult { return parent::createResponse($result); } - } diff --git a/tests/functional/objects/uuid/RemoveUUIDMetadataTest.php b/tests/functional/objects/uuid/RemoveUUIDMetadataTest.php index 37755e56..50aafe38 100644 --- a/tests/functional/objects/uuid/RemoveUUIDMetadataTest.php +++ b/tests/functional/objects/uuid/RemoveUUIDMetadataTest.php @@ -19,7 +19,7 @@ public function testGetaMetadataFromUUID() ->uuid("uuid"); $this->assertEquals(sprintf( - RemoveUUIDMetadata::PATH, + RemoveUUIDMetadataExposed::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), "uuid" ), $removeMetadata->buildPath()); @@ -39,8 +39,10 @@ public function testGetaMetadataFromUUID() } } +// phpcs:ignore PSR1.Classes.ClassDeclaration class RemoveUUIDMetadataExposed extends RemoveUUIDMetadata { + public const PATH = parent::PATH; public function buildParams() { return parent::buildParams(); @@ -51,9 +53,8 @@ public function buildPath() return parent::buildPath(); } - public function createResponse($result) + public function createResponse($result): bool { return parent::createResponse($result); } - } diff --git a/tests/functional/objects/uuid/SetUUIDMetadataTest.php b/tests/functional/objects/uuid/SetUUIDMetadataTest.php index 4bc5deb1..7f462546 100644 --- a/tests/functional/objects/uuid/SetUUIDMetadataTest.php +++ b/tests/functional/objects/uuid/SetUUIDMetadataTest.php @@ -34,7 +34,7 @@ public function testAddCustomObjectMetadataToUUID() ->meta($metadata); $this->assertEquals(sprintf( - SetUUIDMetadata::PATH, + SetUUIDMetadataExposed::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), "uuid" ), $setMetadata->buildPath()); @@ -84,7 +84,7 @@ public function testAddArrayMetadataToUUID() ->meta($metadata); $this->assertEquals(sprintf( - SetUUIDMetadata::PATH, + SetUUIDMetadataExposed::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), "uuid" ), $setMetadata->buildPath()); @@ -121,7 +121,7 @@ public function testAddStdClassMetadataToUUID() $setMetadata = new SetUUIDMetadataExposed($this->pubnub); $metadata = new stdClass(); - + $metadata->id = "uuid"; $metadata->name = "uuid_name"; $metadata->externalId = "uuid_external_id"; @@ -137,7 +137,7 @@ public function testAddStdClassMetadataToUUID() ->meta($metadata); $this->assertEquals(sprintf( - SetUUIDMetadata::PATH, + SetUUIDMetadataExposed::PATH, $this->pubnub->getConfiguration()->getSubscribeKey(), "uuid" ), $setMetadata->buildPath()); @@ -165,8 +165,10 @@ public function testAddStdClassMetadataToUUID() } } +// phpcs:ignore PSR1.Classes.ClassDeclaration class SetUUIDMetadataExposed extends SetUUIDMetadata { + public const PATH = parent::PATH; public function buildParams() { return parent::buildParams(); @@ -176,10 +178,9 @@ public function buildData() { return parent::buildData(); } - + public function buildPath() { return parent::buildPath(); } - } diff --git a/tests/integrational/HistoryTest.php b/tests/integrational/HistoryTest.php index 65cdec57..ac4b2172 100644 --- a/tests/integrational/HistoryTest.php +++ b/tests/integrational/HistoryTest.php @@ -76,6 +76,7 @@ public function testSuccess() */ public function testAuthSuccess() { + $this->expectNotToPerformAssertions(); $this->pubnub->getConfiguration()->setAuthKey("blah"); $history = new HistoryExposed($this->pubnub); diff --git a/tests/integrational/RemoveChannelGroupEndpointTest.php b/tests/integrational/RemoveChannelGroupEndpointTest.php index 2c122f2d..3ed8babc 100644 --- a/tests/integrational/RemoveChannelGroupEndpointTest.php +++ b/tests/integrational/RemoveChannelGroupEndpointTest.php @@ -8,7 +8,6 @@ use PubNubTestCase; use Tests\Helpers\StubTransport; - class RemoveChannelGroupEndpointTest extends PubNubTestCase { public function testSuccess() @@ -20,7 +19,7 @@ public function testSuccess() "pnsdk" => $this->encodedSdkName, "uuid" => "myUUID" ]) - ->setResponseBody("{\"status\": 200, \"message\": \"OK\", \"payload\": {} , \"service\": \"ChannelGroups\"}"); + ->setResponseBody("{\"status\": 200, \"message\": \"OK\", \"payload\": {},\"service\": \"ChannelGroups\"}"); $this->pubnub->getConfiguration()->setUuid("myUUID"); @@ -41,7 +40,7 @@ public function testGroupMissing() "pnsdk" => $this->encodedSdkName, "uuid" => "myUUID" ]) - ->setResponseBody("{\"status\": 200, \"message\": \"OK\", \"payload\": {} , \"service\": \"ChannelGroups\"}"); + ->setResponseBody("{\"status\": 200, \"message\": \"OK\", \"payload\": {},\"service\": \"ChannelGroups\"}"); $this->pubnub->getConfiguration()->setUuid("myUUID"); @@ -60,7 +59,7 @@ public function testEmptyGroup() "pnsdk" => $this->encodedSdkName, "uuid" => "myUUID" ]) - ->setResponseBody("{\"status\": 200, \"message\": \"OK\", \"payload\": {} , \"service\": \"ChannelGroups\"}"); + ->setResponseBody("{\"status\": 200, \"message\": \"OK\", \"payload\": {},\"service\": \"ChannelGroups\"}"); $this->pubnub->getConfiguration()->setUuid("myUUID"); @@ -69,6 +68,7 @@ public function testEmptyGroup() public function testIsAuthRequiredSuccess() { + $this->expectNotToPerformAssertions(); $removeChannelGroup = new RemoveChannelGroupExposed($this->pubnub); $removeChannelGroup->stubFor("/v1/channel-registration/sub-key/demo/channel-group/groupA/remove") @@ -77,7 +77,7 @@ public function testIsAuthRequiredSuccess() "uuid" => "myUUID", "auth" => "myKey" ]) - ->setResponseBody("{\"status\": 200, \"message\": \"OK\", \"payload\": {} , \"service\": \"ChannelGroups\"}"); + ->setResponseBody("{\"status\": 200, \"message\": \"OK\", \"payload\": {},\"service\": \"ChannelGroups\"}"); $this->pubnub->getConfiguration()->setUuid("myUUID")->setAuthKey("myKey"); @@ -92,7 +92,7 @@ public function superCallTest() } } - +// phpcs:ignore PSR1.Classes.ClassDeclaration class RemoveChannelGroupExposed extends RemoveChannelGroup { protected $transport; @@ -115,4 +115,4 @@ public function requestOptions() 'transport' => $this->transport ]; } -} \ No newline at end of file +} diff --git a/tests/unit/CryptoModule/PaddingTest.php b/tests/unit/CryptoModule/PaddingTest.php index 756cabd1..7f3c7401 100644 --- a/tests/unit/CryptoModule/PaddingTest.php +++ b/tests/unit/CryptoModule/PaddingTest.php @@ -26,7 +26,7 @@ protected function setUp(): void */ public function testPad(string $plain, string $padded): void { - $this->assertEquals($this->cryptor->pad($plain), $padded); + $this->assertEquals($this->cryptor->pad($plain, 16), $padded); } /** @@ -39,7 +39,7 @@ public function testPad(string $plain, string $padded): void */ public function testDepad(string $padded, string $expected): void { - $this->assertEquals($this->cryptor->depad($padded), $expected); + $this->assertEquals($this->cryptor->depad($padded, 16), $expected); } public function padProvider(): Generator diff --git a/tests/unit/CryptoTest.php b/tests/unit/CryptoTest.php index 76b411c1..5a3e1ee5 100644 --- a/tests/unit/CryptoTest.php +++ b/tests/unit/CryptoTest.php @@ -1,7 +1,8 @@ decrypt($toDecode, $logger); - $this->assertObjectHasAttribute("hi", $decrypted); + $this->assertObjectHasProperty("hi", $decrypted); $this->assertEquals("hello world", $decrypted->hi); } @@ -65,7 +66,7 @@ public function testOpenSSL_AES_RandomIV() * * @requires extension mcrypt */ - public function testMcrypt_AES() + public function testMcryptAES() { $logger = new \Monolog\Logger('CryptoTest'); $toDecode = "QfD1NCBJCmt1aPPGU2cshw==";