From 049f9524282422b49fef87b3babe31c9b3ba53bd Mon Sep 17 00:00:00 2001 From: Klaus Purer Date: Sat, 4 Jan 2025 12:18:23 +0100 Subject: [PATCH] feat(ValidEnumCase): Add UpperCamel name sniff for enum cases --- .../NamingConventions/ValidEnumCaseSniff.php | 35 ++++++++++++++ .../ValidEnumCaseUnitTest.inc | 8 ++++ .../ValidEnumCaseUnitTest.php | 48 +++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 coder_sniffer/Drupal/Sniffs/NamingConventions/ValidEnumCaseSniff.php create mode 100644 tests/Drupal/NamingConventions/ValidEnumCaseUnitTest.inc create mode 100644 tests/Drupal/NamingConventions/ValidEnumCaseUnitTest.php diff --git a/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidEnumCaseSniff.php b/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidEnumCaseSniff.php new file mode 100644 index 00000000..7eca94a7 --- /dev/null +++ b/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidEnumCaseSniff.php @@ -0,0 +1,35 @@ + + */ + public function register() + { + return [T_ENUM_CASE]; + + }//end register() + + +}//end class diff --git a/tests/Drupal/NamingConventions/ValidEnumCaseUnitTest.inc b/tests/Drupal/NamingConventions/ValidEnumCaseUnitTest.inc new file mode 100644 index 00000000..d1819d99 --- /dev/null +++ b/tests/Drupal/NamingConventions/ValidEnumCaseUnitTest.inc @@ -0,0 +1,8 @@ + + */ + protected function getErrorList(string $testFile): array + { + return [ + 5 => 1, + 7 => 1, + ]; + + }//end getErrorList() + + + /** + * Returns the lines where warnings should occur. + * + * The key of the array should represent the line number and the value + * should represent the number of warnings that should occur on that line. + * + * @param string $testFile The name of the file being tested. + * + * @return array + */ + protected function getWarningList(string $testFile): array + { + return []; + + }//end getWarningList() + + +}//end class