From fec34a68fa804b084c2f02d31bfd531f3ce6cceb Mon Sep 17 00:00:00 2001 From: Jimmy Pettersson Date: Wed, 4 Dec 2024 21:05:01 +0100 Subject: [PATCH] fix: CI --- .php-cs-fixer.dist.php | 1 + lib/GetStream/StreamChat/Channel.php | 40 ++++++++++----------- lib/GetStream/StreamChat/Client.php | 52 ++++++++++++++-------------- 3 files changed, 47 insertions(+), 46 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 3aa9c92..a544029 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -9,6 +9,7 @@ return $config->setRules([ '@PSR2' => true, 'array_syntax' => ['syntax' => 'short'], + 'nullable_type_declaration_for_default_null_value' => true, ]) ->setFinder($finder) ; diff --git a/lib/GetStream/StreamChat/Channel.php b/lib/GetStream/StreamChat/Channel.php index 07741bf..f25a5f2 100644 --- a/lib/GetStream/StreamChat/Channel.php +++ b/lib/GetStream/StreamChat/Channel.php @@ -30,7 +30,7 @@ class Channel private $client; /** @internal */ - public function __construct(Client $client, string $channelTypeName, string $channelId = null, array $data = null) + public function __construct(Client $client, string $channelTypeName, ?string $channelId = null, ?array $data = null) { if ($data === null) { $data = []; @@ -72,7 +72,7 @@ private static function addUser(array $payload, string $userId) * @link https://getstream.io/chat/docs/php/send_message/?language=php * @throws StreamException */ - public function sendMessage(array $message, string $userId, string $parentId = null, array $options = null): StreamResponse + public function sendMessage(array $message, string $userId, ?string $parentId = null, ?array $options = null): StreamResponse { if ($options === null) { $options = []; @@ -139,7 +139,7 @@ public function deleteReaction(string $messageId, string $reactionType, string $ * @link https://getstream.io/chat/docs/php/creating_channels/?language=php * @throws StreamException */ - public function create(string $userId, array $members = null): StreamResponse + public function create(string $userId, ?array $members = null): StreamResponse { $this->customData['created_by'] = ["id" => $userId]; $response = $this->query([ @@ -185,7 +185,7 @@ public function query(array $options): StreamResponse * @link https://getstream.io/chat/docs/php/query_members/?language=php * @throws StreamException */ - public function queryMembers(array $filterConditions = null, array $sort = null, array $options = null): StreamResponse + public function queryMembers(?array $filterConditions = null, ?array $sort = null, ?array $options = null): StreamResponse { if ($options === null) { $options = []; @@ -216,7 +216,7 @@ public function queryMembers(array $filterConditions = null, array $sort = null, * @link https://getstream.io/chat/docs/php/channel_update/?language=php * @throws StreamException */ - public function update(array $channelData = null, array $updateMessage = null, array $options = null): StreamResponse + public function update(?array $channelData = null, ?array $updateMessage = null, ?array $options = null): StreamResponse { $payload = [ "data" => $channelData, @@ -234,7 +234,7 @@ public function update(array $channelData = null, array $updateMessage = null, a * @link https://getstream.io/chat/docs/php/channel_update/?language=php * @throws StreamException */ - public function updatePartial(array $set = null, array $unset = null): StreamResponse + public function updatePartial(?array $set = null, ?array $unset = null): StreamResponse { if ($set === null && $unset === null) { throw new StreamException("set or unset is required"); @@ -260,7 +260,7 @@ public function delete(): StreamResponse * @link https://getstream.io/chat/docs/php/truncate_channel/?language=php * @throws StreamException */ - public function truncate(array $options = null): StreamResponse + public function truncate(?array $options = null): StreamResponse { if ($options === null) { $options = (object)[]; @@ -276,7 +276,7 @@ public function truncate(array $options = null): StreamResponse * @param array|null $options * @return StreamResponse */ - public function assignRoles(array $roles, array $message = null, array $options = null): StreamResponse + public function assignRoles(array $roles, ?array $message = null, ?array $options = null): StreamResponse { $opts = [ "assign_roles" => $roles @@ -293,7 +293,7 @@ public function assignRoles(array $roles, array $message = null, array $options * @link https://getstream.io/chat/docs/php/channel_members/?language=php * @throws StreamException */ - public function addMembers(array $userIds, array $options = null): StreamResponse + public function addMembers(array $userIds, ?array $options = null): StreamResponse { $payload = [ "add_members" => $userIds @@ -345,7 +345,7 @@ public function demoteModerators(array $userIds): StreamResponse * @link https://getstream.io/chat/docs/php/send_message/?language=php * @throws StreamException */ - public function markRead(string $userId, array $data = null): StreamResponse + public function markRead(string $userId, ?array $data = null): StreamResponse { if ($data === null) { $data = []; @@ -376,7 +376,7 @@ public function getReactions(string $messageId, array $options = []): StreamResp * @link https://getstream.io/chat/docs/php/moderation/?language=php * @throws StreamException */ - public function banUser(string $targetId, array $options = null): StreamResponse + public function banUser(string $targetId, ?array $options = null): StreamResponse { if ($options === null) { $options = []; @@ -390,7 +390,7 @@ public function banUser(string $targetId, array $options = null): StreamResponse * @link https://getstream.io/chat/docs/php/moderation/?language=php * @throws StreamException */ - public function unbanUser(string $targetId, array $options = null): StreamResponse + public function unbanUser(string $targetId, ?array $options = null): StreamResponse { if ($options === null) { $options = []; @@ -404,7 +404,7 @@ public function unbanUser(string $targetId, array $options = null): StreamRespon * @link https://getstream.io/chat/docs/php/channel_invites/?language=php * @throws StreamException */ - public function inviteMembers(array $userIds, array $message = null): StreamResponse + public function inviteMembers(array $userIds, ?array $message = null): StreamResponse { $payload = [ "invites" => $userIds, @@ -418,7 +418,7 @@ public function inviteMembers(array $userIds, array $message = null): StreamResp * @link https://getstream.io/chat/docs/php/channel_invites/?language=php * @throws StreamException */ - public function acceptInvite(string $userId, array $options = null): StreamResponse + public function acceptInvite(string $userId, ?array $options = null): StreamResponse { if ($options === null) { $options = []; @@ -434,7 +434,7 @@ public function acceptInvite(string $userId, array $options = null): StreamRespo * @link https://getstream.io/chat/docs/php/channel_invites/?language=php * @throws StreamException */ - public function rejectInvite(string $userId, array $options = null): StreamResponse + public function rejectInvite(string $userId, ?array $options = null): StreamResponse { if ($options === null) { $options = []; @@ -452,7 +452,7 @@ public function rejectInvite(string $userId, array $options = null): StreamRespo * @link https://getstream.io/chat/docs/php/file_uploads/?language=php * @throws StreamException */ - public function sendFile(string $url, string $name, array $user, string $contentType = null): StreamResponse + public function sendFile(string $url, string $name, array $user, ?string $contentType = null): StreamResponse { return $this->client->sendFile($this->getUrl() . '/file', $url, $name, $user, $contentType); } @@ -465,7 +465,7 @@ public function sendFile(string $url, string $name, array $user, string $content * @link https://getstream.io/chat/docs/php/file_uploads/?language=php * @throws StreamException */ - public function sendImage(string $url, string $name, array $user, string $contentType = null): StreamResponse + public function sendImage(string $url, string $name, array $user, ?string $contentType = null): StreamResponse { return $this->client->sendFile($this->getUrl() . '/image', $url, $name, $user, $contentType); } @@ -520,7 +520,7 @@ public function show(string $userId): StreamResponse * @link https://getstream.io/chat/docs/php/muting_channels/?language=php * @throws StreamException */ - public function mute(string $userId, int $expirationInMilliSeconds = null): StreamResponse + public function mute(string $userId, ?int $expirationInMilliSeconds = null): StreamResponse { $postData = [ "user_id" => $userId, @@ -585,7 +585,7 @@ public function unpin(string $userId): StreamResponse /** Archives the channel for the user. * @throws StreamException */ - public function pin(string $userId): StreamResponse + public function archive(string $userId): StreamResponse { if (empty($userId)) { throw new StreamException("user ID must be not empty"); @@ -603,7 +603,7 @@ public function pin(string $userId): StreamResponse /** Unarchives the channel for the user. * @throws StreamException */ - public function pin(string $userId): StreamResponse + public function unarchive(string $userId): StreamResponse { if (empty($userId)) { throw new StreamException("user ID must be not empty"); diff --git a/lib/GetStream/StreamChat/Client.php b/lib/GetStream/StreamChat/Client.php index c5444cb..53716c0 100644 --- a/lib/GetStream/StreamChat/Client.php +++ b/lib/GetStream/StreamChat/Client.php @@ -59,7 +59,7 @@ class Client /** * @deprecated Both `$apiVersion` and `$location` variables are deprecated and will be removed in a future version. */ - public function __construct(string $apiKey, string $apiSecret, string $apiVersion = null, string $location = null, float $timeout = null) + public function __construct(string $apiKey, string $apiSecret, ?string $apiVersion = null, ?string $location = null, ?float $timeout = null) { if ($apiVersion !== null || $location !== null) { $warn = "\$apiVersion and \$location parameters are deprecated and will be removed in a future version. "; @@ -211,7 +211,7 @@ private function makeHttpRequest(string $uri, string $method, $data = [], array * @link https://getstream.io/chat/docs/php/tokens_and_authentication/?language=php * @throws StreamException */ - public function createToken(string $userId, int $expiration = null, int $issuedAt = null): string + public function createToken(string $userId, ?int $expiration = null, ?int $issuedAt = null): string { $payload = ['user_id' => $userId]; @@ -399,7 +399,7 @@ public function deleteUser(string $userId, array $options = []): StreamResponse * @link https://getstream.io/chat/docs/php/update_users/?language=php * @throws StreamException */ - public function deleteUsers(array $userIds, array $options = null): StreamResponse + public function deleteUsers(array $userIds, ?array $options = null): StreamResponse { if ($options === null) { $options = []; @@ -423,7 +423,7 @@ public function restoreUsers(array $userIds): StreamResponse * @link https://getstream.io/chat/docs/php/channel_delete/?language=php * @throws StreamException */ - public function deleteChannels(array $cids, array $options = null): StreamResponse + public function deleteChannels(array $cids, ?array $options = null): StreamResponse { if ($options === null) { $options = []; @@ -447,7 +447,7 @@ public function setGuestUser(array $guestRequest): StreamResponse * @link https://getstream.io/chat/docs/php/update_users/?language=php * @throws StreamException */ - public function deactivateUser(string $userId, array $options = null): StreamResponse + public function deactivateUser(string $userId, ?array $options = null): StreamResponse { if ($options === null) { $options = (object)[]; @@ -461,7 +461,7 @@ public function deactivateUser(string $userId, array $options = null): StreamRes * @link https://getstream.io/chat/docs/php/update_users/?language=php * @throws StreamException returns task ID that you can use to check the status of the operation (see getTask method) */ - public function deactivateUsers(array $userIds, array $options = null): StreamResponse + public function deactivateUsers(array $userIds, ?array $options = null): StreamResponse { if ($options === null) { $options = []; @@ -475,7 +475,7 @@ public function deactivateUsers(array $userIds, array $options = null): StreamRe * @link https://getstream.io/chat/docs/php/update_users/?language=php * @throws StreamException */ - public function reactivateUser(string $userId, array $options = null): StreamResponse + public function reactivateUser(string $userId, ?array $options = null): StreamResponse { if ($options === null) { $options = (object)[]; @@ -488,7 +488,7 @@ public function reactivateUser(string $userId, array $options = null): StreamRes * @link https://getstream.io/chat/docs/php/update_users/?language=php * @throws StreamException returns task ID that you can use to check the status of the operation (see getTask method) */ - public function reactivateUsers(array $userIds, array $options = null): StreamResponse + public function reactivateUsers(array $userIds, ?array $options = null): StreamResponse { if ($options === null) { $options = []; @@ -514,7 +514,7 @@ public function exportUser(string $userId, array $options = []): StreamResponse * @link https://getstream.io/chat/docs/php/moderation/?language=php * @throws StreamException */ - public function banUser(string $targetId, array $options = null): StreamResponse + public function banUser(string $targetId, ?array $options = null): StreamResponse { if ($options === null) { $options = []; @@ -530,7 +530,7 @@ public function banUser(string $targetId, array $options = null): StreamResponse * @link https://getstream.io/chat/docs/php/moderation/?language=php * @throws StreamException */ - public function unbanUser(string $targetId, array $options = null): StreamResponse + public function unbanUser(string $targetId, ?array $options = null): StreamResponse { if ($options === null) { $options = []; @@ -547,7 +547,7 @@ public function unbanUser(string $targetId, array $options = null): StreamRespon * @link https://getstream.io/chat/docs/php/moderation/?language=php * @throws StreamException */ - public function shadowBan(string $targetId, array $options = null): StreamResponse + public function shadowBan(string $targetId, ?array $options = null): StreamResponse { if ($options === null) { $options = []; @@ -564,7 +564,7 @@ public function shadowBan(string $targetId, array $options = null): StreamRespon * @link https://getstream.io/chat/docs/php/moderation/?language=php * @throws StreamException */ - public function removeShadowBan(string $targetId, array $options = null): StreamResponse + public function removeShadowBan(string $targetId, ?array $options = null): StreamResponse { if ($options === null) { $options = []; @@ -617,7 +617,7 @@ public function queryMessageFlags(array $filterConditions, array $options = []): * @link https://getstream.io/chat/docs/php/moderation/?language=php * @throws StreamException */ - public function flagMessage(string $targetId, array $options = null): StreamResponse + public function flagMessage(string $targetId, ?array $options = null): StreamResponse { if ($options === null) { $options = []; @@ -633,7 +633,7 @@ public function flagMessage(string $targetId, array $options = null): StreamResp * @link https://getstream.io/chat/docs/php/moderation/?language=php * @throws StreamException */ - public function unFlagMessage(string $targetId, array $options = null): StreamResponse + public function unFlagMessage(string $targetId, ?array $options = null): StreamResponse { if ($options === null) { $options = []; @@ -646,7 +646,7 @@ public function unFlagMessage(string $targetId, array $options = null): StreamRe * @link https://getstream.io/chat/docs/php/moderation/?language=php * @throws StreamException */ - public function flagUser(string $targetId, array $options = null): StreamResponse + public function flagUser(string $targetId, ?array $options = null): StreamResponse { if ($options === null) { $options = []; @@ -659,7 +659,7 @@ public function flagUser(string $targetId, array $options = null): StreamRespons * @link https://getstream.io/chat/docs/php/moderation/?language=php * @throws StreamException */ - public function unFlagUser(string $targetId, array $options = null): StreamResponse + public function unFlagUser(string $targetId, ?array $options = null): StreamResponse { if ($options === null) { $options = []; @@ -738,7 +738,7 @@ public function markAllRead(string $userId): StreamResponse * @link https://getstream.io/chat/docs/php/pinned_messages/?language=php * @throws StreamException */ - public function pinMessage(string $messageId, string $userId, int $expiration = null): StreamResponse + public function pinMessage(string $messageId, string $userId, ?int $expiration = null): StreamResponse { $updates = [ "set" => [ @@ -773,7 +773,7 @@ public function unPinMessage(string $messageId, string $userId): StreamResponse * @link https://getstream.io/chat/docs/php/send_message/?language=php#partial-update * @throws StreamException */ - public function partialUpdateMessage(string $messageId, array $updates, string $userId = null, array $options = null): StreamResponse + public function partialUpdateMessage(string $messageId, array $updates, ?string $userId = null, ?array $options = null): StreamResponse { if ($options === null) { $options = []; @@ -824,7 +824,7 @@ public function deleteMessage(string $messageId, array $options = []): StreamRes * @link https://getstream.io/chat/docs/php/query_users/?language=php * @throws StreamException */ - public function queryUsers(array $filterConditions, array $sort = null, array $options = null): StreamResponse + public function queryUsers(array $filterConditions, ?array $sort = null, ?array $options = null): StreamResponse { if ($options === null) { $options = []; @@ -848,7 +848,7 @@ public function queryUsers(array $filterConditions, array $sort = null, array $o * @link https://getstream.io/chat/docs/php/query_channels/?language=php * @throws StreamException */ - public function queryChannels(array $filterConditions, array $sort = null, array $options = null): StreamResponse + public function queryChannels(array $filterConditions, ?array $sort = null, ?array $options = null): StreamResponse { if (!$filterConditions) { throw new StreamException("filterConditions can't be empty"); @@ -927,7 +927,7 @@ public function deleteChannelType(string $channelTypeName): StreamResponse /** Return a client to interract with the channel. * @throws StreamException */ - public function Channel(string $channelTypeName, ?string $channelId, array $data = null): Channel + public function Channel(string $channelTypeName, string $channelId, ?array $data = null): Channel { return new Channel($this, $channelTypeName, $channelId, $data); } @@ -936,7 +936,7 @@ public function Channel(string $channelTypeName, ?string $channelId, array $data * @deprecated method: use `$client->Channel` instead * @throws StreamException */ - public function getChannel(string $channelTypeName, string $channelId, array $data = null): Channel + public function getChannel(string $channelTypeName, string $channelId, ?array $data = null): Channel { return $this->Channel($channelTypeName, $channelId, $data); } @@ -1035,7 +1035,7 @@ public function deleteCommand(string $name): StreamResponse * @link https://getstream.io/chat/docs/php/push_devices/?language=php * @throws StreamException */ - public function addDevice(string $deviceId, string $pushProvider, string $userId, string $pushProviderName = null): StreamResponse + public function addDevice(string $deviceId, string $pushProvider, string $userId, ?string $pushProviderName = null): StreamResponse { $data = [ "id" => $deviceId, @@ -1125,7 +1125,7 @@ public function revokeUsersToken(array $userIDs, $before): StreamResponse * @link https://getstream.io/chat/docs/php/rate_limits/?language=php * @throws StreamException */ - public function getRateLimits(bool $serverSide = false, bool $android = false, bool $ios = false, bool $web = false, array $endpoints = null): StreamResponse + public function getRateLimits(bool $serverSide = false, bool $android = false, bool $ios = false, bool $web = false, ?array $endpoints = null): StreamResponse { $data = []; if ($serverSide) { @@ -1162,7 +1162,7 @@ public function verifyWebhook(string $requestBody, string $XSignature): bool * @link https://getstream.io/chat/docs/php/search/?language=php * @throws StreamException */ - public function search(array $filterConditions, $query, array $options = null): StreamResponse + public function search(array $filterConditions, $query, ?array $options = null): StreamResponse { if ($options === null) { $options = []; @@ -1198,7 +1198,7 @@ public function search(array $filterConditions, $query, array $options = null): * @link https://getstream.io/chat/docs/php/file_uploads/?language=php * @throws StreamException */ - public function sendFile(string $uri, string $url, string $name, array $user, string $contentType = null): StreamResponse + public function sendFile(string $uri, string $url, string $name, array $user, ?string $contentType = null): StreamResponse { if ($contentType === null) { $contentType = 'application/octet-stream';