Problem/Motivation

This is a follow-up from #3126127-21: Fix LanguageNegotiationMethodInterface::getLangcode() result docblock; the documentation for the LanguageNegotiationMethodInterface::getLangcode() is in disagreement with the current implementations. The documentation is currently:

  /**
   * Performs language negotiation.
   *
   * @param \Symfony\Component\HttpFoundation\Request $request
   *   (optional) The current request. Defaults to NULL if it has not been
   *   initialized yet.
   *
   * @return string
   *   A valid language code or FALSE if the negotiation was unsuccessful.
   */
  public function getLangcode(Request $request = NULL);

The return value is restricted to string and the comment expands this definition to include FALSE. However, the various plugin classes that implement this interface (usually via extends LanguageNegotiationMethodBase), do not exclusively return strings or FALSE values, they at times return NULL values.

Proposed resolution

As suggested in #3126127-21: Fix LanguageNegotiationMethodInterface::getLangcode() result docblock, the documentation should in a first step be updated to be consistent with implementations (in that issue) and then in a second step the implementations should be revised and the result of calling getLangcode() (in this issue) be normalized.

Remaining tasks

  1. Wait for #3126127: Fix LanguageNegotiationMethodInterface::getLangcode() result docblock to be resolved
  2. Decide whether the preferred return type will be string|false or string|null
  3. Update the interface definition and documentation to return the preferred return type; update the implementations of LanguageNegotiationMethodInterface::getLangcode() to reflect consistently the updated definition

Comments

stefanos.petrakis created an issue. See original summary.

stefanos.petrakis’s picture

Status: Active » Postponed
xjm’s picture

Unpostponing now that the first issue is in.

stefanos.petrakis’s picture

Issue summary: View changes

Updated the description according to my understanding of how things could play out in a sequential way

stefanos.petrakis’s picture

Issue summary: View changes

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.