Skip to content

Commit

Permalink
remove the @psalm-pure tags and replace them with @psalm-mutation-fre…
Browse files Browse the repository at this point in the history
…e where appropriate and also run with the latest psalm version
  • Loading branch information
drealecs committed Feb 12, 2021
1 parent 3daca5a commit c436460
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
"require-dev": {
"phpunit/phpunit": "^7",
"squizlabs/php_codesniffer": "1.*",
"vimeo/psalm": "^3.8"
"vimeo/psalm": "^4.5"
}
}
31 changes: 16 additions & 15 deletions src/Enum.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*
* @psalm-template T
* @psalm-immutable
* @psalm-consistent-constructor
*/
abstract class Enum implements \JsonSerializable
{
Expand Down Expand Up @@ -55,7 +56,6 @@ abstract class Enum implements \JsonSerializable
/**
* Creates a new value of some type
*
* @psalm-pure
* @param mixed $value
*
* @psalm-param static<T>|T $value
Expand All @@ -78,7 +78,7 @@ public function __construct($value)
}

/**
* @psalm-pure
* @psalm-mutation-free
* @return mixed
* @psalm-return T
*/
Expand All @@ -90,19 +90,19 @@ public function getValue()
/**
* Returns the enum key (i.e. the constant name).
*
* @psalm-pure
* @psalm-mutation-free
*/
public function getKey(): string
{
return $this->key;
}

/**
* @psalm-pure
* @psalm-mutation-free
* @psalm-suppress InvalidCast
* @return string
*/
public function __toString()
public function __toString(): string
{
return (string)$this->value;
}
Expand All @@ -113,8 +113,8 @@ public function __toString()
*
* This method is final, for more information read https://github.com/myclabs/php-enum/issues/4
*
* @psalm-pure
* @psalm-param mixed $variable
* @psalm-mutation-free
* @psalm-param static<T> $variable
* @return bool
*/
final public function equals($variable = null): bool
Expand All @@ -127,7 +127,7 @@ final public function equals($variable = null): bool
/**
* Returns the names (keys) of all constants in the Enum class
*
* @psalm-pure
* @psalm-mutation-free
* @psalm-return list<string>
* @return array
*/
Expand All @@ -139,7 +139,7 @@ public static function keys()
/**
* Returns instances of the Enum class of all Enum constants
*
* @psalm-pure
* @psalm-mutation-free
* @psalm-return array<string, static>
* @return static[] Constant name in key, Enum instance in value
*/
Expand All @@ -158,10 +158,11 @@ public static function values()
/**
* Returns all possible values as an array
*
* @psalm-pure
* @psalm-mutation-free
* @psalm-suppress ImpureStaticProperty
* @psalm-suppress ImpureMethodCall
*
* @psalm-return array<string, mixed>
* @psalm-return array<string, T>
* @return array Constant name in key, constant value in value
*/
public static function toArray()
Expand All @@ -181,7 +182,7 @@ public static function toArray()
*
* @param $value
* @psalm-param mixed $value
* @psalm-pure
* @psalm-mutation-free
* @return bool
*/
public static function isValid($value)
Expand All @@ -194,7 +195,7 @@ public static function isValid($value)
*
* @param $key
* @psalm-param string $key
* @psalm-pure
* @psalm-mutation-free
* @return bool
*/
public static function isValidKey($key)
Expand All @@ -210,7 +211,7 @@ public static function isValidKey($key)
* @param mixed $value
*
* @psalm-param mixed $value
* @psalm-pure
* @psalm-mutation-free
* @return string|false
*/
public static function search($value)
Expand Down Expand Up @@ -247,7 +248,7 @@ public static function __callStatic($name, $arguments)
*
* @return mixed
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
* @psalm-pure
* @psalm-mutation-free
*/
public function jsonSerialize()
{
Expand Down

0 comments on commit c436460

Please sign in to comment.