Drupal.Commenting.VariableComment.VarOrder - @var before @code

Created on 16 September 2017, about 7 years ago
Updated 3 August 2024, 3 months ago

Drupal.Commenting.VariableComment.VarOrder was introduced in #2781933: Detect trailing semicolon in variable declarations and I'm missing its background. Is @var required to be first even before any @code tags?

  /**
   * Array of fields to update to an expression in case of a duplicate record.
   *
   * This variable is a nested array in the following format:
   * @code
   * <some field> => array(
   *  'condition' => <condition to execute, as a string>,
   *  'arguments' => <array of arguments for condition, or NULL for none>,
   * );
   * @endcode
   *
   * @var array
   */

The Drupal coding standards page api-documentation-and-comment-standards#order does not mention @code in the order of sections. Should it be considered a section?

Also we have:

    * @link http://github.com/zendframework/zf2 for the canonical source repository
    * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
    * @license http://framework.zend.com/license/new-bsd New BSD License
    *
    * A map of characters to be replaced through strtr.
    *
   * @var array

which fails the tests. @copyright and @license are not part of coding standards. @link is mentioned in our CS, but should not be considered a section from my pov.

🐛 Bug report
Status

Closed: won't fix

Version

3.0

Component

Coder Sniffer

Created by

🇷🇴Romania mfernea

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.

  • 🇳🇿New Zealand quietone

    I worked on the core issue 📌 Fix 'Drupal.Commenting.VariableComment.VarOrder' coding standard Postponed today and reporting back here.

    The Drupal coding standards page api-documentation-and-comment-standards#order does not mention @code in the order of sections. Should it be considered a section?

    Can make an in issue in the Coding Standards project so that can be discussed.

    Core does not have any '@copyright' or '@license' in doc blocks. So, that point seems to be outdated.

    And '@link .. @endlink' is reported as an error. But I think this is correct for the Variable comment block where the explanation is after @var.

    Also, there were no instances in Drupal core where an '@link .. @endlink' was moved as a result of enabling the sniff.

    So, for me I would go with won't fix on this.

  • Status changed to Closed: won't fix 3 months ago
  • 🇦🇹Austria klausi 🇦🇹 Vienna

    I agree - and I don't think we will need @var comments in the future as now you must always specify the type of your class property as type hint (at least for new code). Eventually we can remove the @var coding standard and enforce property type hints with a sniff from Slevomat.

Production build 0.71.5 2024