diff --git a/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidClassNameSniff.php b/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidClassNameSniff.php index a7df880c666c49429d2ebd7d994f037975afc6e3..0ff3a569e74673271f9892eee4586f0a8645127c 100644 --- a/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidClassNameSniff.php +++ b/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidClassNameSniff.php @@ -74,9 +74,9 @@ class ValidClassNameSniff implements Sniff // Ensure the name is not all uppercase. // @todo We could make this more strict to check if there are more than - // 2 upper case characters in a row, but not decided yet. + // 2 upper case characters in a row anywhere, but not decided yet. // See https://www.drupal.org/project/coder/issues/3497433 - if (strtoupper($name) === $name) { + if (preg_match('|^[A-Z]{3}[^a-z]*$|', $name) === 1) { $error = '%s name must use UpperCamel naming and not contain multiple upper case letters in a row'; $phpcsFile->addError($error, $stackPtr, 'NoUpperAcronyms', $errorData); } diff --git a/tests/Drupal/NamingConventions/ValidEnumCaseUnitTest.inc b/tests/Drupal/NamingConventions/ValidEnumCaseUnitTest.inc index b6b428076dad14e09c1cffafeae473b4a73a55e3..d037f5ba033c7f06f76929c6047812bdc2d5205f 100644 --- a/tests/Drupal/NamingConventions/ValidEnumCaseUnitTest.inc +++ b/tests/Drupal/NamingConventions/ValidEnumCaseUnitTest.inc @@ -10,4 +10,19 @@ enum Test: int { // Upper case parts are allowed for now. case FourJSONCase = 4; case FiveAndAHorseCorrect = 5; + case UIExample = 6; +} + +// Those are all ok. +enum FiscalQuarter { + case Q1; + case Q2; + case Q3; + case Q4; +} + +enum Plan { + case A; + case B; + case C; }