guuzen / psalm-enum-plugin
Reports attempts to create enum with a wrong case
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:psalm-plugin
Requires
- php: >=8.1
- vimeo/psalm: ^6
Requires (Dev)
- psalm/plugin-phpunit: ^0.19.0
- roave/security-advisories: dev-latest
This package is not auto-updated.
Last update: 2025-06-22 09:31:41 UTC
README
Psalm doesn't detect situations when we try to create backed enums using from
method with a wrong literal
For example:
enum StringEnum: string { case ONE = 'one'; /** * @param 'two' $value */ public static function createSelf(string $value): void { /** * Psalm won't complain */ self::from($value); } }
Might be useful if you generate OAS enums as phpdoc union literals and want to know about type problems before running your code
Installation
composer require --dev guuzen/psalm-enum-plugin
It needs to be enabled by either using psalm-plugin tool:
vendor/bin/psalm-plugin enable guuzen/psalm-enum-plugin
or by manually adding to your psalm.xml
<plugins> <pluginClass class="Guuzen\PsalmEnumPlugin\Plugin"/> </plugins>