@@ -31,6 +31,8 @@ abstract class Enum implements \JsonSerializable
3131 /**
3232 * Store existing constants in a static cache per object.
3333 *
34+ * @psalm-pure
35+ *
3436 * @var array
3537 * @psalm-var array<class-string, array<string, mixed>>
3638 */
@@ -39,6 +41,7 @@ abstract class Enum implements \JsonSerializable
3941 /**
4042 * Creates a new value of some type
4143 *
44+ * @psalm-pure
4245 * @param mixed $value
4346 *
4447 * @psalm-param static<T>|T $value
@@ -61,6 +64,7 @@ public function __construct($value)
6164 }
6265
6366 /**
67+ * @psalm-pure
6468 * @return mixed
6569 * @psalm-return T
6670 */
@@ -72,7 +76,7 @@ public function getValue()
7276 /**
7377 * Returns the enum key (i.e. the constant name).
7478 *
75- * @psalm-external-mutation-free
79+ * @psalm-pure
7680 * @return mixed
7781 */
7882 public function getKey ()
@@ -81,6 +85,7 @@ public function getKey()
8185 }
8286
8387 /**
88+ * @psalm-pure
8489 * @psalm-suppress InvalidCast
8590 * @return string
8691 */
@@ -95,6 +100,7 @@ public function __toString()
95100 *
96101 * This method is final, for more information read https://github.com/myclabs/php-enum/issues/4
97102 *
103+ * @psalm-pure
98104 * @psalm-param mixed $variable
99105 * @return bool
100106 */
@@ -108,7 +114,7 @@ final public function equals($variable = null): bool
108114 /**
109115 * Returns the names (keys) of all constants in the Enum class
110116 *
111- * @psalm-external-mutation-free
117+ * @psalm-pure
112118 * @psalm-return list<string>
113119 * @return array
114120 */
@@ -120,7 +126,7 @@ public static function keys()
120126 /**
121127 * Returns instances of the Enum class of all Enum constants
122128 *
123- * @psalm-external-mutation-free
129+ * @psalm-pure
124130 * @psalm-return array<string, static>
125131 * @return static[] Constant name in key, Enum instance in value
126132 */
@@ -139,7 +145,8 @@ public static function values()
139145 /**
140146 * Returns all possible values as an array
141147 *
142- * @psalm-external-mutation-free
148+ * @psalm-pure
149+ *
143150 * @psalm-return array<string, mixed>
144151 * @return array Constant name in key, constant value in value
145152 */
@@ -160,7 +167,7 @@ public static function toArray()
160167 *
161168 * @param $value
162169 * @psalm-param mixed $value
163- * @psalm-external-mutation-free
170+ * @psalm-pure
164171 * @return bool
165172 */
166173 public static function isValid ($ value )
@@ -173,7 +180,7 @@ public static function isValid($value)
173180 *
174181 * @param $key
175182 * @psalm-param string $key
176- * @psalm-external-mutation-free
183+ * @psalm-pure
177184 * @return bool
178185 */
179186 public static function isValidKey ($ key )
@@ -189,7 +196,7 @@ public static function isValidKey($key)
189196 * @param $value
190197 *
191198 * @psalm-param mixed $value
192- * @psalm-external-mutation-free
199+ * @psalm-pure
193200 * @return mixed
194201 */
195202 public static function search ($ value )
@@ -204,7 +211,7 @@ public static function search($value)
204211 * @param array $arguments
205212 *
206213 * @return static
207- * @psalm-external-mutation-free
214+ * @psalm-pure
208215 * @throws \BadMethodCallException
209216 */
210217 public static function __callStatic ($ name , $ arguments )
@@ -223,6 +230,7 @@ public static function __callStatic($name, $arguments)
223230 *
224231 * @return mixed
225232 * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
233+ * @psalm-pure
226234 */
227235 public function jsonSerialize ()
228236 {
0 commit comments