[policy, no patch] Decide how to handle parameter renaming now that PHP 8 allows it to be used as an API

Created on 20 January 2023, over 2 years ago

Problem/Motivation

In πŸ“Œ Fix or ignore words that start with "v", excluding real non-English words Fixed , we have the following spelling error fix that was committed:

+++ b/core/modules/taxonomy/src/TermStorageInterface.php
@@ -116,16 +116,16 @@ public function resetWeights($vid);
-   * @param array $vocabs
-   *   (optional) A vocabularies array to restrict the term search. Defaults to
-   *   empty array.
+   * @param array $vids
+   *   (optional) an array of vocabulary IDs to restrict the term search.
+   *   Defaults to empty array.
    * @param string $langcode
    *   (optional) A language code to restrict the term search. Defaults to NULL.
    *
    * @return array
    *   An array of nids and the term entities they were tagged with.
    */
-  public function getNodeTerms(array $nids, array $vocabs = [], $langcode = NULL);
+  public function getNodeTerms(array $nids, array $vids = [], $langcode = NULL);

Using the abbreviation "vocabs" was already against our naming and documentation standards; cspell just surfaced the issue. However, there are definitely other reasons to rename parameters -- e.g., to convert them from camelCase to snake_case as part of bulk cleanups for constructor property promotion.

However, per @dpi on the linked issue:

Since PHP 8.0 parameter naming are a part of the API contract, as named arguments may be used by callers.

// Will break
\Drupal::entityTypeManager()->getStorage('taxonomy_term')->getNodeTerms(nids: [], vocabs: []);
As much as its unlikely to happen in this case, as it is the first non optional, it is still possible and will break usages. I've certainly made use of parameter names when its redundant, in the name of legibility.

How can we make sure parameters are not affected by these spelling issues?

Proposed resolution

Decide how to handle parameter renaming for PHP 8+.

If necessary, revert the change from TermStorageInterface before 11.1.0.

Remaining tasks

TBD

User interface changes

N/A

API changes

TBD

Data model changes

TBD

Release notes snippet

TBD

πŸ“Œ Task
Status

Active

Version

10.1 ✨

Component
OtherΒ  β†’

Last updated about 11 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States xjm

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.

  • Status changed to Needs review 27 days ago
  • πŸ‡³πŸ‡ΏNew Zealand quietone

    The related issue concluded by agreeing that "Named arguments should not be considered part of the public API." Since that is the case it may not be necessary to make a policy decision here. Instead, any renaming would be evaluation according to the existing guidelines, which state, "A reasonable effort will be made to keep the API stable and provide a backwards compatible (BC) layer. Wherever possible, old APIs will be deprecated for removal in the next major version instead of being removed immediately."

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Not sure best to review but what @quietone says makes sense.

  • πŸ‡³πŸ‡ΏNew Zealand quietone

    For completeness, the decision from the related is documented at https://www.drupal.org/about/core/policies/core-change-policies/bc-polic... β†’

Production build 0.71.5 2024