Standardize getter docblocks

Created on 15 April 2015, over 9 years ago
Updated 16 July 2024, 5 months ago

Core currently uses two different wording styles of getter docblocks, "Gets the..." and "Returns the..."

Examples:

  /**
   * Gets the context value.
   *
   * @return mixed
   *   The currently set context value, or NULL if it is not set.
   */
  public function getContextValue();
  /**
   * Returns the asset libraries attached to the current response.
   *
   * @return string[]
   */
  public function getLibraries();

This is a small but annoying inconsistency, impacting DX because it's not obvious what the "right way" is purely from looking at code.
The outside PHP world prefers "Gets...", newer core code does as well. I've spoken to Alex Pott at the dev days and he has agreed that we should standardize on "Gets..."

So, plan of action:
1) We create a bunch of issues with patches. Smaller patches == less chance of conflicts.
2) We update the drupal.org page on docblocks, and document the preferred style.

I will reroll any core patch broken by these changes. Just list them in this issue or one of the child ones.

📌 Task
Status

Closed: duplicate

Component

Coding Standards

Created by

🇷🇸Serbia bojanz

Live updates comments and jobs are added and updated live.
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.

  • 🇳🇿New Zealand quietone

    This is really about a coding standard for the summary line of a getter. Moving to Coding Standard project.

  • Status changed to Closed: duplicate 5 months ago
  • 🇳🇿New Zealand quietone

    There is an older issue about standardizing the getters and setters. Therefor I am closing this so there is one place to discuss a solution.

Production build 0.71.5 2024