Skip to content

Commit 7ea70d0

Browse files
committed
fix(ValidClassName): Allow upper case with number
1 parent 04a4563 commit 7ea70d0

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

coder_sniffer/Drupal/Sniffs/NamingConventions/ValidClassNameSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function process(File $phpcsFile, $stackPtr)
7676
// @todo We could make this more strict to check if there are more than
7777
// 2 upper case characters in a row, but not decided yet.
7878
// See https://www.drupal.org/project/coder/issues/3497433
79-
if (strtoupper($name) === $name) {
79+
if (preg_match('|^[A-Z]{3}[A-Z_]*$|', $name) === 1) {
8080
$error = '%s name must use UpperCamel naming and not contain multiple upper case letters in a row';
8181
$phpcsFile->addError($error, $stackPtr, 'NoUpperAcronyms', $errorData);
8282
}

tests/Drupal/NamingConventions/ValidEnumCaseUnitTest.inc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,17 @@ enum Test: int {
1111
case FourJSONCase = 4;
1212
case FiveAndAHorseCorrect = 5;
1313
}
14+
15+
// Those are all ok.
16+
enum FiscalQuarter {
17+
case Q1;
18+
case Q2;
19+
case Q3;
20+
case Q4;
21+
}
22+
23+
enum Plan {
24+
case A;
25+
case B;
26+
case C;
27+
}

0 commit comments

Comments
 (0)