From 4cc6393f9730b7bcc1c40ac38d7dcf2f41772e6a Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 23 Feb 2022 11:34:43 +0100 Subject: [PATCH] Document code-style for enums and class constants --- contributing/code/standards.rst | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/contributing/code/standards.rst b/contributing/code/standards.rst index 92b4af2b5f3..bcf10eb3196 100644 --- a/contributing/code/standards.rst +++ b/contributing/code/standards.rst @@ -210,8 +210,12 @@ Naming Conventions * Use `snake_case`_ for configuration parameters and Twig template variables (e.g. ``framework.csrf_protection``, ``http_status_code``); -* Use namespaces for all PHP classes and `UpperCamelCase`_ for their names (e.g. - ``ConsoleLogger``); +* Use `SCREAMING_SNAKE_CASE`_ for constants (e.g. ``InputArgument::IS_ARRAY``); + +* Use `UpperCamelCase`_ for enumeration cases (e.g. ``InputArgumentMode::IsArray``); + +* Use namespaces for all PHP classes, interfaces, traits and enums and + `UpperCamelCase`_ for their names (e.g. ``ConsoleLogger``); * Prefix all abstract classes with ``Abstract`` except PHPUnit ``*TestCase``. Please note some early Symfony classes do not follow this convention and @@ -222,6 +226,9 @@ Naming Conventions * Suffix traits with ``Trait``; +* Don't use a dedicated suffix for classes or enumerations (e.g. like ``Class`` + or ``Enum``), except for the cases listed below. + * Suffix exceptions with ``Exception``; * Prefix PHP attributes with ``As`` where applicable (e.g. ``#[AsCommand]``