Skip to content

Commit 3f0ca5e

Browse files
committed
Allow one letter upper case words
1 parent 70592da commit 3f0ca5e

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

coder_sniffer/Drupal/Sniffs/NamingConventions/ValidClassNameSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function process(File $phpcsFile, $stackPtr)
7373
}
7474

7575
// Ensure the name does not contain acronyms.
76-
if (preg_match('|[A-Z]{2}|', $name) === 1) {
76+
if (preg_match('|[A-Z]{3}|', $name) === 1) {
7777
$error = '%s name must use UpperCamel naming and not contain multiple upper case letters in a row';
7878
$phpcsFile->addError($error, $stackPtr, 'NoUpperAcronyms', $errorData);
7979
}

tests/Drupal/NamingConventions/ValidClassNameUnitTest.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
<?php
22

33
class CorrectClassName {}
4+
class CorrectClassWithAReallyLongName {}
45
class IncorrectJSONClassName {}
56
class INCORRECT_CLASS_NAME {}
67
class INCORRECTCLASSNAME {}
78
class incorrectLowercaseClassName {}
89

910
interface CorrectInterfaceName {}
11+
interface CorrectInterfaceWithAReallyLongName {}
1012
interface IncorrectJSONInterfaceName {}
1113
interface INCORRECT_INTERFACE_NAME {}
1214
interface INCORRECTINTERFACENAME {}
1315
interface incorrectLowercaseInterfaceName {}
1416

1517
trait CorrectTraitName {}
18+
trait CorrectTraitWithAReallyLongName {}
1619
trait IncorrectJSONTraitName {}
1720
trait INCORRECT_TRAIT_NAME {}
1821
trait INCORRECTTRAITNAME {}
1922
trait incorrectLowercaseTraitName {}
2023

2124
enum CorrectEnumName {}
25+
enum CorrectEnumWithAReallyLongName {}
2226
enum IncorrectJSONEnumName {}
2327
enum INCORRECT_ENUM_NAME {}
2428
enum INCORRECTENUMNAME {}

tests/Drupal/NamingConventions/ValidClassNameUnitTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@ class ValidClassNameUnitTest extends CoderSniffUnitTest
2121
protected function getErrorList(string $testFile): array
2222
{
2323
return [
24-
4 => 1,
25-
5 => 2,
26-
6 => 1,
24+
5 => 1,
25+
6 => 2,
2726
7 => 1,
28-
10 => 1,
29-
11 => 2,
27+
8 => 1,
3028
12 => 1,
31-
13 => 1,
32-
16 => 1,
33-
17 => 2,
34-
18 => 1,
29+
13 => 2,
30+
14 => 1,
31+
15 => 1,
3532
19 => 1,
33+
20 => 2,
34+
21 => 1,
3635
22 => 1,
37-
23 => 2,
38-
24 => 1,
39-
25 => 1,
36+
26 => 1,
37+
27 => 2,
38+
28 => 1,
39+
29 => 1,
4040
];
4141

4242
}//end getErrorList()

tests/Drupal/NamingConventions/ValidEnumCaseUnitTest.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ enum Test: int {
99
case THREE = 3;
1010
// Upper case parts are not allowed.
1111
case FourJSONCase = 4;
12-
case FiveCorrect = 5;
12+
case FiveAndAHorseCorrect = 5;
1313
}

0 commit comments

Comments
 (0)