diff --git a/composer.json b/composer.json index 73caf14..924f924 100644 --- a/composer.json +++ b/composer.json @@ -28,6 +28,6 @@ "require-dev": { "phpunit/phpunit": "^9.5", "squizlabs/php_codesniffer": "1.*", - "vimeo/psalm": "^4.5.1" + "vimeo/psalm": "^4.6.2" } } diff --git a/src/Enum.php b/src/Enum.php index a16aa23..6967ab5 100644 --- a/src/Enum.php +++ b/src/Enum.php @@ -69,15 +69,25 @@ public function __construct($value) $value = $value->getValue(); } + /** @psalm-suppress ImplicitToStringCast assertValidValueReturningKey returns always a string but psalm has currently an issue here */ $this->key = static::assertValidValueReturningKey($value); /** @psalm-var T */ $this->value = $value; } + /** + * This method exists only for the compatibility reason when deserializing a previously serialized version + * that didn't had the key property + */ public function __wakeup() { + /** @psalm-suppress DocblockTypeContradiction key can be null when deserializing an enum without the key */ if ($this->key === null) { + /** + * @psalm-suppress InaccessibleProperty key is not readonly as marked by psalm + * @psalm-suppress PossiblyFalsePropertyAssignmentValue deserializing a case that was removed + */ $this->key = static::search($this->value); } } @@ -215,6 +225,7 @@ public static function isValid($value) * * @psalm-pure * @psalm-assert T $value + * @param mixed $value */ public static function assertValidValue($value): void { @@ -226,6 +237,8 @@ public static function assertValidValue($value): void * * @psalm-pure * @psalm-assert T $value + * @param mixed $value + * @return string */ private static function assertValidValueReturningKey($value): string {