Skip to content

Commit c436460

Browse files
committed
remove the @psalm-pure tags and replace them with @psalm-mutation-free where appropriate and also run with the latest psalm version
1 parent 3daca5a commit c436460

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
"require-dev": {
2929
"phpunit/phpunit": "^7",
3030
"squizlabs/php_codesniffer": "1.*",
31-
"vimeo/psalm": "^3.8"
31+
"vimeo/psalm": "^4.5"
3232
}
3333
}

src/Enum.php

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*
1818
* @psalm-template T
1919
* @psalm-immutable
20+
* @psalm-consistent-constructor
2021
*/
2122
abstract class Enum implements \JsonSerializable
2223
{
@@ -55,7 +56,6 @@ abstract class Enum implements \JsonSerializable
5556
/**
5657
* Creates a new value of some type
5758
*
58-
* @psalm-pure
5959
* @param mixed $value
6060
*
6161
* @psalm-param static<T>|T $value
@@ -78,7 +78,7 @@ public function __construct($value)
7878
}
7979

8080
/**
81-
* @psalm-pure
81+
* @psalm-mutation-free
8282
* @return mixed
8383
* @psalm-return T
8484
*/
@@ -90,19 +90,19 @@ public function getValue()
9090
/**
9191
* Returns the enum key (i.e. the constant name).
9292
*
93-
* @psalm-pure
93+
* @psalm-mutation-free
9494
*/
9595
public function getKey(): string
9696
{
9797
return $this->key;
9898
}
9999

100100
/**
101-
* @psalm-pure
101+
* @psalm-mutation-free
102102
* @psalm-suppress InvalidCast
103103
* @return string
104104
*/
105-
public function __toString()
105+
public function __toString(): string
106106
{
107107
return (string)$this->value;
108108
}
@@ -113,8 +113,8 @@ public function __toString()
113113
*
114114
* This method is final, for more information read https://github.com/myclabs/php-enum/issues/4
115115
*
116-
* @psalm-pure
117-
* @psalm-param mixed $variable
116+
* @psalm-mutation-free
117+
* @psalm-param static<T> $variable
118118
* @return bool
119119
*/
120120
final public function equals($variable = null): bool
@@ -127,7 +127,7 @@ final public function equals($variable = null): bool
127127
/**
128128
* Returns the names (keys) of all constants in the Enum class
129129
*
130-
* @psalm-pure
130+
* @psalm-mutation-free
131131
* @psalm-return list<string>
132132
* @return array
133133
*/
@@ -139,7 +139,7 @@ public static function keys()
139139
/**
140140
* Returns instances of the Enum class of all Enum constants
141141
*
142-
* @psalm-pure
142+
* @psalm-mutation-free
143143
* @psalm-return array<string, static>
144144
* @return static[] Constant name in key, Enum instance in value
145145
*/
@@ -158,10 +158,11 @@ public static function values()
158158
/**
159159
* Returns all possible values as an array
160160
*
161-
* @psalm-pure
161+
* @psalm-mutation-free
162162
* @psalm-suppress ImpureStaticProperty
163+
* @psalm-suppress ImpureMethodCall
163164
*
164-
* @psalm-return array<string, mixed>
165+
* @psalm-return array<string, T>
165166
* @return array Constant name in key, constant value in value
166167
*/
167168
public static function toArray()
@@ -181,7 +182,7 @@ public static function toArray()
181182
*
182183
* @param $value
183184
* @psalm-param mixed $value
184-
* @psalm-pure
185+
* @psalm-mutation-free
185186
* @return bool
186187
*/
187188
public static function isValid($value)
@@ -194,7 +195,7 @@ public static function isValid($value)
194195
*
195196
* @param $key
196197
* @psalm-param string $key
197-
* @psalm-pure
198+
* @psalm-mutation-free
198199
* @return bool
199200
*/
200201
public static function isValidKey($key)
@@ -210,7 +211,7 @@ public static function isValidKey($key)
210211
* @param mixed $value
211212
*
212213
* @psalm-param mixed $value
213-
* @psalm-pure
214+
* @psalm-mutation-free
214215
* @return string|false
215216
*/
216217
public static function search($value)
@@ -247,7 +248,7 @@ public static function __callStatic($name, $arguments)
247248
*
248249
* @return mixed
249250
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
250-
* @psalm-pure
251+
* @psalm-mutation-free
251252
*/
252253
public function jsonSerialize()
253254
{

0 commit comments

Comments
 (0)