Decide on coding standard for configuration keys of ConfigEntities

Created on 5 November 2012, about 12 years ago
Updated 14 August 2024, 4 months ago

Problem/Motivation

The member variables of ConfigEntity's map 1-to-1 to the configuration keys in the corresponding config YAML files. Coding standards dictate lowerCamelCase for member variables in OOP code and underscore_separated for config keys. We need to decide what we want here. Most ConfigEntity's are not bitten by this, because they only contain one-word keys, in which case lowerCamelCase and underscore_separated fall together. :-)

We already have an inconsistency in core with the View entity (View::base_table) and the Breakpoint and BreakpointGroup entities.

Proposed resolution

-

Remaining tasks

Decide on one of the following:

  1. Make class members of configuration entities that map to configuration keys underscore_separated.
    Con: This violates the coding standards for object-oriented code.
  2. Make configuration keys that map to class members of configuration entities lowerCamelCase.
    Con: This violates the coding standard for configuration keys.
  3. Change our coding standard to require lowerCamelCase for all configuration keys.
    Con: It feels unnatural to use lowerCamelCase for non-object-oriented code. (This in a way applies to 2. as well.)
  4. Introduce an abstraction layer that maps underscore_separated configuration keys to lowerCamelCase class members.
    Con: More code, additional abstraction.

User interface changes

-

API changes

-

📌 Task
Status

Postponed: needs info

Version

11.0

Component
Documentation 

Last updated about 9 hours ago

No maintainer
Created by

🇩🇪Germany tstoeckler Essen, Germany

Live updates comments and jobs are added and updated live.
  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Is this really a problem? 🤔 Tempted to close this 😇

  • Status changed to Postponed: needs info 4 months ago
  • 🇳🇿New Zealand quietone

    We now have this in the related coding standard is

    Methods and class properties should use lowerCamel naming. In Drupal 8, properties of configuration entities are exempt of these conventions. Those properties are allowed to use underscores.

    And the sniff Drupal.NamingConventions.ValidVariableName.LowerCamelName is enabled. The exceptions are ignore like this

      // phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName
      protected $migration_tags = [];
    

    I am inclined to agree with @Wim Leers, that this can be closed. Anyone disagree?

Production build 0.71.5 2024