17
17
*
18
18
* @psalm-template T
19
19
* @psalm-immutable
20
+ * @psalm-consistent-constructor
20
21
*/
21
22
abstract class Enum implements \JsonSerializable
22
23
{
@@ -55,7 +56,6 @@ abstract class Enum implements \JsonSerializable
55
56
/**
56
57
* Creates a new value of some type
57
58
*
58
- * @psalm-pure
59
59
* @param mixed $value
60
60
*
61
61
* @psalm-param static<T>|T $value
@@ -78,7 +78,7 @@ public function __construct($value)
78
78
}
79
79
80
80
/**
81
- * @psalm-pure
81
+ * @psalm-mutation-free
82
82
* @return mixed
83
83
* @psalm-return T
84
84
*/
@@ -90,19 +90,19 @@ public function getValue()
90
90
/**
91
91
* Returns the enum key (i.e. the constant name).
92
92
*
93
- * @psalm-pure
93
+ * @psalm-mutation-free
94
94
*/
95
95
public function getKey (): string
96
96
{
97
97
return $ this ->key ;
98
98
}
99
99
100
100
/**
101
- * @psalm-pure
101
+ * @psalm-mutation-free
102
102
* @psalm-suppress InvalidCast
103
103
* @return string
104
104
*/
105
- public function __toString ()
105
+ public function __toString (): string
106
106
{
107
107
return (string )$ this ->value ;
108
108
}
@@ -113,8 +113,8 @@ public function __toString()
113
113
*
114
114
* This method is final, for more information read https://github.com/myclabs/php-enum/issues/4
115
115
*
116
- * @psalm-pure
117
- * @psalm-param mixed $variable
116
+ * @psalm-mutation-free
117
+ * @psalm-param static<T> $variable
118
118
* @return bool
119
119
*/
120
120
final public function equals ($ variable = null ): bool
@@ -127,7 +127,7 @@ final public function equals($variable = null): bool
127
127
/**
128
128
* Returns the names (keys) of all constants in the Enum class
129
129
*
130
- * @psalm-pure
130
+ * @psalm-mutation-free
131
131
* @psalm-return list<string>
132
132
* @return array
133
133
*/
@@ -139,7 +139,7 @@ public static function keys()
139
139
/**
140
140
* Returns instances of the Enum class of all Enum constants
141
141
*
142
- * @psalm-pure
142
+ * @psalm-mutation-free
143
143
* @psalm-return array<string, static>
144
144
* @return static[] Constant name in key, Enum instance in value
145
145
*/
@@ -158,10 +158,11 @@ public static function values()
158
158
/**
159
159
* Returns all possible values as an array
160
160
*
161
- * @psalm-pure
161
+ * @psalm-mutation-free
162
162
* @psalm-suppress ImpureStaticProperty
163
+ * @psalm-suppress ImpureMethodCall
163
164
*
164
- * @psalm-return array<string, mixed >
165
+ * @psalm-return array<string, T >
165
166
* @return array Constant name in key, constant value in value
166
167
*/
167
168
public static function toArray ()
@@ -181,7 +182,7 @@ public static function toArray()
181
182
*
182
183
* @param $value
183
184
* @psalm-param mixed $value
184
- * @psalm-pure
185
+ * @psalm-mutation-free
185
186
* @return bool
186
187
*/
187
188
public static function isValid ($ value )
@@ -194,7 +195,7 @@ public static function isValid($value)
194
195
*
195
196
* @param $key
196
197
* @psalm-param string $key
197
- * @psalm-pure
198
+ * @psalm-mutation-free
198
199
* @return bool
199
200
*/
200
201
public static function isValidKey ($ key )
@@ -210,7 +211,7 @@ public static function isValidKey($key)
210
211
* @param mixed $value
211
212
*
212
213
* @psalm-param mixed $value
213
- * @psalm-pure
214
+ * @psalm-mutation-free
214
215
* @return string|false
215
216
*/
216
217
public static function search ($ value )
@@ -247,7 +248,7 @@ public static function __callStatic($name, $arguments)
247
248
*
248
249
* @return mixed
249
250
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
250
- * @psalm-pure
251
+ * @psalm-mutation-free
251
252
*/
252
253
public function jsonSerialize ()
253
254
{
0 commit comments