Skip to content

Commit 1bc37a5

Browse files
committed
Mark entire API as immutable and pure
1 parent 78396d7 commit 1bc37a5

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

‎src/DialogId.php

+28
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
/**
88
* Represents the type of a bot API dialog ID.
99
*
10+
* @psalm-immutable
11+
*
1012
* @api
1113
*/
1214
enum DialogId
@@ -39,6 +41,8 @@ enum DialogId
3941
/**
4042
* Get the type of a dialog using just its bot API dialog ID.
4143
*
44+
* @psalm-pure
45+
*
4246
* @param integer $id Bot API ID.
4347
*/
4448
public static function getType(int $id): self
@@ -61,6 +65,8 @@ public static function getType(int $id): self
6165

6266
/**
6367
* Checks whether the provided bot API ID is a supergroup or channel ID.
68+
*
69+
* @psalm-pure
6470
*/
6571
public static function isSupergroupOrChannel(int $id): bool
6672
{
@@ -69,20 +75,26 @@ public static function isSupergroupOrChannel(int $id): bool
6975

7076
/**
7177
* Checks whether the provided bot API ID is a chat ID.
78+
*
79+
* @psalm-pure
7280
*/
7381
public static function isChat(int $id): bool
7482
{
7583
return self::getType($id) === self::CHAT;
7684
}
7785
/**
7886
* Checks whether the provided bot API ID is a user ID.
87+
*
88+
* @psalm-pure
7989
*/
8090
public static function isUser(int $id): bool
8191
{
8292
return self::getType($id) === self::USER;
8393
}
8494
/**
8595
* Checks whether the provided bot API ID is a secret chat ID.
96+
*
97+
* @psalm-pure
8698
*/
8799
public static function isSecretChat(int $id): bool
88100
{
@@ -92,6 +104,8 @@ public static function isSecretChat(int $id): bool
92104
/**
93105
* Convert MTProto secret chat ID to bot API secret chat ID.
94106
*
107+
* @psalm-pure
108+
*
95109
* @param int $id MTProto secret chat ID
96110
*
97111
* @return int Bot API secret chat ID
@@ -108,6 +122,8 @@ public static function fromSecretChatId(int $id): int
108122
/**
109123
* Convert bot API secret chat ID to MTProto secret chat ID.
110124
*
125+
* @psalm-pure
126+
*
111127
* @param int $id Bot API secret chat ID
112128
*
113129
* @return int MTProto secret chat ID
@@ -124,6 +140,8 @@ public static function toSecretChatId(int $id): int
124140
/**
125141
* Convert MTProto channel ID to bot API channel ID.
126142
*
143+
* @psalm-pure
144+
*
127145
* @param int $id MTProto channel ID
128146
*/
129147
public static function fromSupergroupOrChannelId(int $id): int
@@ -138,6 +156,8 @@ public static function fromSupergroupOrChannelId(int $id): int
138156
/**
139157
* Convert bot API channel ID to MTProto channel ID.
140158
*
159+
* @psalm-pure
160+
*
141161
* @param int $id Bot API channel ID
142162
*/
143163
public static function toSupergroupOrChannelId(int $id): int
@@ -152,6 +172,8 @@ public static function toSupergroupOrChannelId(int $id): int
152172
/**
153173
* Convert MTProto chat ID to bot API chat ID.
154174
*
175+
* @psalm-pure
176+
*
155177
* @param int $id MTProto chat ID
156178
*/
157179
public static function fromChatId(int $id): int
@@ -166,6 +188,8 @@ public static function fromChatId(int $id): int
166188
/**
167189
* Convert bot API chat ID to MTProto chat ID.
168190
*
191+
* @psalm-pure
192+
*
169193
* @param int $id Bot API chat ID
170194
*/
171195
public static function toChatId(int $id): int
@@ -180,6 +204,8 @@ public static function toChatId(int $id): int
180204
/**
181205
* Convert MTProto user ID to bot API user ID.
182206
*
207+
* @psalm-pure
208+
*
183209
* @param int $id MTProto user ID
184210
*/
185211
public static function fromUserId(int $id): int
@@ -193,6 +219,8 @@ public static function fromUserId(int $id): int
193219
/**
194220
* Convert bot API user ID to MTProto user ID.
195221
*
222+
* @psalm-pure
223+
*
196224
* @param int $id Bot API user ID
197225
*/
198226
public static function toUserId(int $id): int

0 commit comments

Comments
 (0)