@@ -31,6 +31,8 @@ abstract class Enum implements \JsonSerializable
31
31
/**
32
32
* Store existing constants in a static cache per object.
33
33
*
34
+ * @psalm-pure
35
+ *
34
36
* @var array
35
37
* @psalm-var array<class-string, array<string, mixed>>
36
38
*/
@@ -39,6 +41,7 @@ abstract class Enum implements \JsonSerializable
39
41
/**
40
42
* Creates a new value of some type
41
43
*
44
+ * @psalm-pure
42
45
* @param mixed $value
43
46
*
44
47
* @psalm-param static<T>|T $value
@@ -61,6 +64,7 @@ public function __construct($value)
61
64
}
62
65
63
66
/**
67
+ * @psalm-pure
64
68
* @return mixed
65
69
* @psalm-return T
66
70
*/
@@ -72,7 +76,7 @@ public function getValue()
72
76
/**
73
77
* Returns the enum key (i.e. the constant name).
74
78
*
75
- * @psalm-external-mutation-free
79
+ * @psalm-pure
76
80
* @return mixed
77
81
*/
78
82
public function getKey ()
@@ -81,6 +85,7 @@ public function getKey()
81
85
}
82
86
83
87
/**
88
+ * @psalm-pure
84
89
* @psalm-suppress InvalidCast
85
90
* @return string
86
91
*/
@@ -95,6 +100,7 @@ public function __toString()
95
100
*
96
101
* This method is final, for more information read https://github.com/myclabs/php-enum/issues/4
97
102
*
103
+ * @psalm-pure
98
104
* @psalm-param mixed $variable
99
105
* @return bool
100
106
*/
@@ -108,7 +114,7 @@ final public function equals($variable = null): bool
108
114
/**
109
115
* Returns the names (keys) of all constants in the Enum class
110
116
*
111
- * @psalm-external-mutation-free
117
+ * @psalm-pure
112
118
* @psalm-return list<string>
113
119
* @return array
114
120
*/
@@ -120,7 +126,7 @@ public static function keys()
120
126
/**
121
127
* Returns instances of the Enum class of all Enum constants
122
128
*
123
- * @psalm-external-mutation-free
129
+ * @psalm-pure
124
130
* @psalm-return array<string, static>
125
131
* @return static[] Constant name in key, Enum instance in value
126
132
*/
@@ -139,7 +145,8 @@ public static function values()
139
145
/**
140
146
* Returns all possible values as an array
141
147
*
142
- * @psalm-external-mutation-free
148
+ * @psalm-pure
149
+ *
143
150
* @psalm-return array<string, mixed>
144
151
* @return array Constant name in key, constant value in value
145
152
*/
@@ -160,7 +167,7 @@ public static function toArray()
160
167
*
161
168
* @param $value
162
169
* @psalm-param mixed $value
163
- * @psalm-external-mutation-free
170
+ * @psalm-pure
164
171
* @return bool
165
172
*/
166
173
public static function isValid ($ value )
@@ -173,7 +180,7 @@ public static function isValid($value)
173
180
*
174
181
* @param $key
175
182
* @psalm-param string $key
176
- * @psalm-external-mutation-free
183
+ * @psalm-pure
177
184
* @return bool
178
185
*/
179
186
public static function isValidKey ($ key )
@@ -189,7 +196,7 @@ public static function isValidKey($key)
189
196
* @param $value
190
197
*
191
198
* @psalm-param mixed $value
192
- * @psalm-external-mutation-free
199
+ * @psalm-pure
193
200
* @return mixed
194
201
*/
195
202
public static function search ($ value )
@@ -204,7 +211,7 @@ public static function search($value)
204
211
* @param array $arguments
205
212
*
206
213
* @return static
207
- * @psalm-external-mutation-free
214
+ * @psalm-pure
208
215
* @throws \BadMethodCallException
209
216
*/
210
217
public static function __callStatic ($ name , $ arguments )
@@ -223,6 +230,7 @@ public static function __callStatic($name, $arguments)
223
230
*
224
231
* @return mixed
225
232
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
233
+ * @psalm-pure
226
234
*/
227
235
public function jsonSerialize ()
228
236
{
0 commit comments