slevomat / coding-standard

Slevomat Coding Standard for PHP_CodeSniffer provides many useful sniffs
MIT License
1.39k stars 171 forks source link

Enum case casing sniff #1649

Open dereuromark opened 9 months ago

dereuromark commented 9 months ago

I saw the following sniffs around enums

    <rule ref="SlevomatCodingStandard.Classes.BackedEnumTypeSpacing"/>
    <rule ref="SlevomatCodingStandard.Classes.EnumCaseSpacing"/>

But I think it would also be a good idea to have the recommended casing for enum cases to be added Refs https://www.php.net/manual/en/language.enumerations.backed.php

See also

enum Suit: string
{
    case Hearts = 'H';
    case SOME_SPADES = 'S';
}

should be fixed to

enum Suit: string
{
    case Hearts = 'H';
    case SomeSpades = 'S';
}

with a warning as this would probably be not safe to change.

We could also just issue an error instead of fixable error for existing underscored ones.