@@ -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,7 +85,7 @@ public function getKey()
81
85
}
82
86
83
87
/**
84
- * @psalm-suppress InvalidCast
88
+ * @psalm-pure
85
89
* @return string
86
90
*/
87
91
public function __toString ()
@@ -95,6 +99,7 @@ public function __toString()
95
99
*
96
100
* This method is final, for more information read https://github.com/myclabs/php-enum/issues/4
97
101
*
102
+ * @psalm-pure
98
103
* @psalm-param mixed $variable
99
104
* @return bool
100
105
*/
@@ -108,7 +113,7 @@ final public function equals($variable = null): bool
108
113
/**
109
114
* Returns the names (keys) of all constants in the Enum class
110
115
*
111
- * @psalm-external-mutation-free
116
+ * @psalm-pure
112
117
* @psalm-return list<string>
113
118
* @return array
114
119
*/
@@ -120,7 +125,7 @@ public static function keys()
120
125
/**
121
126
* Returns instances of the Enum class of all Enum constants
122
127
*
123
- * @psalm-external-mutation-free
128
+ * @psalm-pure
124
129
* @psalm-return array<string, static>
125
130
* @return static[] Constant name in key, Enum instance in value
126
131
*/
@@ -139,7 +144,9 @@ public static function values()
139
144
/**
140
145
* Returns all possible values as an array
141
146
*
142
- * @psalm-external-mutation-free
147
+ * @psalm-pure
148
+ * @psalm-suppress ImpureStaticProperty
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