Enforce UpperCamel naming for enum and trait

Created on 6 January 2025, 2 months ago

Problem/Motivation

Enums and Traits should use UpperCamel naming, this is currently not checked in Coder

The checking is done by the Drupal.NamingConventions.ValidClassName sniff.

Steps to reproduce

Write bad enum or trait names.

Proposed resolution

  • Expand checking of ValidClassNameSniff to traits and enums.

Test examples:


class CorrectClassName {}
class CorrectClassWithAReallyLongName {}
class INCORRECT_CLASS_NAME {}
class INCORRECTCLASSNAME {}
class incorrectLowercaseClassName {}

interface CorrectInterfaceName {}
interface CorrectInterfaceWithAReallyLongName {}
interface INCORRECT_INTERFACE_NAME {}
interface INCORRECTINTERFACENAME {}
interface incorrectLowercaseInterfaceName {}

trait CorrectTraitName {}
trait CorrectTraitWithAReallyLongName {}
trait INCORRECT_TRAIT_NAME {}
trait INCORRECTTRAITNAME {}
trait incorrectLowercaseTraitName {}

enum CorrectEnumName {}
enum CorrectEnumWithAReallyLongName {}
enum INCORRECT_ENUM_NAME {}
enum INCORRECTENUMNAME {}
enum incorrectLowercaseEnumName {}

Remaining tasks

pull request

API changes

None

📌 Task
Status

Active

Version

8.3

Component

Coder Sniffer

Created by

🇦🇹Austria klausi 🇦🇹 Vienna

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024