Skip to content

Commit af073a6

Browse files
committed
suppress some psalm errors that are actually bugs in current psalm implementation or are related to deserialization workaround
1 parent 46cf3d8 commit af073a6

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
"require-dev": {
2929
"phpunit/phpunit": "^9.5",
3030
"squizlabs/php_codesniffer": "1.*",
31-
"vimeo/psalm": "^4.5.1"
31+
"vimeo/psalm": "^4.6.2"
3232
}
3333
}

src/Enum.php

+12
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,24 @@ public function __construct($value)
6969
$value = $value->getValue();
7070
}
7171

72+
/** @psalm-suppress ImplicitToStringCast assertValidValueReturningKey returns always a string but psalm has currently an issue here */
7273
$this->key = static::assertValidValueReturningKey($value);
7374

7475
/** @psalm-var T */
7576
$this->value = $value;
7677
}
7778

79+
/**
80+
* This method exists only for the compatibility reason when deserializing a previously serialized version that didn't had the key property
81+
*/
7882
public function __wakeup()
7983
{
84+
/** @psalm-suppress DocblockTypeContradiction key can be null when deserializing a serialized enum without the key property */
8085
if ($this->key === null) {
86+
/**
87+
* @psalm-suppress InaccessibleProperty key is not readonly as marked by psalm
88+
* @psalm-suppress PossiblyFalsePropertyAssignmentValue key might be false deserializing a case that was removed
89+
*/
8190
$this->key = static::search($this->value);
8291
}
8392
}
@@ -215,6 +224,7 @@ public static function isValid($value)
215224
*
216225
* @psalm-pure
217226
* @psalm-assert T $value
227+
* @param mixed $value
218228
*/
219229
public static function assertValidValue($value): void
220230
{
@@ -226,6 +236,8 @@ public static function assertValidValue($value): void
226236
*
227237
* @psalm-pure
228238
* @psalm-assert T $value
239+
* @param mixed $value
240+
* @return string
229241
*/
230242
private static function assertValidValueReturningKey($value): string
231243
{

0 commit comments

Comments
 (0)