Skip to content

Commit af4b562

Browse files
authored
Merge pull request #142 from drealecs/fix_psalm_reported_issues
suppress some psalm reported errors
2 parents 46cf3d8 + c55aa7f commit af4b562

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-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

+13
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,25 @@ 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
81+
* that didn't had the key property
82+
*/
7883
public function __wakeup()
7984
{
85+
/** @psalm-suppress DocblockTypeContradiction key can be null when deserializing an enum without the key */
8086
if ($this->key === null) {
87+
/**
88+
* @psalm-suppress InaccessibleProperty key is not readonly as marked by psalm
89+
* @psalm-suppress PossiblyFalsePropertyAssignmentValue deserializing a case that was removed
90+
*/
8191
$this->key = static::search($this->value);
8292
}
8393
}
@@ -215,6 +225,7 @@ public static function isValid($value)
215225
*
216226
* @psalm-pure
217227
* @psalm-assert T $value
228+
* @param mixed $value
218229
*/
219230
public static function assertValidValue($value): void
220231
{
@@ -226,6 +237,8 @@ public static function assertValidValue($value): void
226237
*
227238
* @psalm-pure
228239
* @psalm-assert T $value
240+
* @param mixed $value
241+
* @return string
229242
*/
230243
private static function assertValidValueReturningKey($value): string
231244
{

0 commit comments

Comments
 (0)