Normalize ::getLangcode()'s result across all implementations of LanguageNegotiationMethodInterface

Created on 28 December 2022, about 2 years ago
Updated 30 January 2023, about 2 years ago

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. Decide whether the preferred return type will be string|false or string|null
  2. Update the interface definition and documentation to return the preferred return type; update the implementations of LanguageNegotiationMethodInterface::getLangcode() to reflect consistently the updated definition
πŸ“Œ Task
Status

Active

Version

10.1 ✨

Component
Language moduleΒ  β†’

Last updated 6 days ago

  • Maintained by
  • πŸ‡©πŸ‡ͺGermany @sun
Created by

πŸ‡¨πŸ‡­Switzerland stefanos.petrakis@gmail.com Biel, Switzerland

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.

Production build 0.71.5 2024