Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
"require-dev": {
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "1.*",
"vimeo/psalm": "^4.6.2"
"vimeo/psalm": "^5.2"
}
}
3 changes: 2 additions & 1 deletion src/Enum.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public static function values()

/** @psalm-var T $value */
foreach (static::toArray() as $key => $value) {
/** @psalm-suppress UnsafeGenericInstantiation */
$values[$key] = new static($value);
}

Expand Down Expand Up @@ -297,6 +298,7 @@ public static function __callStatic($name, $arguments)
$message = "No static method or enum constant '$name' in class " . static::class;
throw new \BadMethodCallException($message);
}
/** @psalm-suppress UnsafeGenericInstantiation */
return self::$instances[$class][$name] = new static($array[$name]);
}
return clone self::$instances[$class][$name];
Expand All @@ -308,7 +310,6 @@ public static function __callStatic($name, $arguments)
*
* @return mixed
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
* @psalm-pure
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this removal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of this error:

ERROR: ImpureMethodCall - src/Enum.php:313:7 - Cannot call an impure constructor from a pure context (see https://psalm.dev/203)
    #[\ReturnTypeWillChange]

We should either remove @psalm-pure or #[\ReturnTypeWillChange]

Since Enum's JSON serialization can be anything, We may keep the second one.

*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
Expand Down