Over in #2226533: Changes to the Language class due to the LanguageInterface (followup)

we have made the mistake of creating a monster patch that needs a daily reroll -

it is upto 300 comments and the patch size is an unreviewable 260Kb

Other issues have been spawned to cut down the beast... but from here

https://www.drupal.org/node/2226533#comment-9162179

I want to break out all the annotation improvements into a more digestible form,

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

martin107’s picture

Assigned: martin107 » Unassigned
Issue summary: View changes
Status: Active » Needs review
FileSize
4.23 KB

All looks ok to me....famous last words.

jhodgdon’s picture

Status: Needs review » Needs work

This looks suspicious to me:

   /**
    * List of langcodes.
    *
-   * @var array
+   * @var \Drupal\Core\Language\LanguageInterface[]
    */
   protected $langcodes = array();

Is this perhaps string[] ?

And until we change our coding standards

+  /**
+   * @var \Drupal\Core\Language\LanguageInterface[]
+   */
   protected $languages;

this isn't a proper doc block... needs one-line description.

The rest looks good to me...

martin107’s picture

Status: Needs work » Needs review
FileSize
5.13 KB
2.23 KB

I have fixed both issues ...

Regarding, the correct annotation for $langcode,

The situation is horribly confused,... and so thank you for making me double check.

If you look in the setup function, at the assignment of $langcode items ...

$this->$langcodes[$i] = $language

.. which is a line builds up an array of \Drupal\Core\Language\Language objects

which implies the that

* @var \Drupal\Core\Language\LanguageInterface[]

is the correct annotation .... BUT the real objection is WHY is a store of language objects called 'langcodes'?

the answer is that $langcode array is only ever used to pull out what is in effect the langcode property from within the selected language. ( the id )

So my fix is simplify and to store only what we want, not store a container holding what we want.

jhodgdon’s picture

Component: documentation » language.module

Well technically these are both class member variables and should have doc blocks, not one line @var statements (which are supposed to be only for local variables):

+  /** @var \Drupal\Core\Language\LanguageInterface[] */
   protected $languages;
   protected $languageManager;

Other than that, this looks fine. It's not just documentation any more though.

martin107’s picture

Title: Language module annotation improvements. » Language module annotation improvements [ plus minor followup ]
FileSize
5.43 KB
873 bytes

@jhodgdon .. thanks again.

The next d8MI meeting is not for a week... I will try and get other eyes on this before then.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

This all looks good to me now. Thanks!

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x. Thanks!

  • webchick committed d4b7bc7 on 8.0.x
    Issue #2341927 by martin107: Language module annotation improvements [...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.