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
Wait for #3126127: Fix LanguageNegotiationMethodInterface::getLangcode() result docblock to be resolved- Decide whether the preferred return type will be
string|falseorstring|null - 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
Comment #2
stefanos.petrakisSetting to Postponed till #3126127: Fix LanguageNegotiationMethodInterface::getLangcode() result docblock is resolved.
Comment #3
xjmUnpostponing now that the first issue is in.
Comment #4
stefanos.petrakisUpdated the description according to my understanding of how things could play out in a sequential way
Comment #5
stefanos.petrakis