Uploaded image for project: 'Moodle Community Sites'
  1. Moodle Community Sites
  2. MDLSITE-5873

Clarify coding style for trailing comma in multi-line array declaration

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Component/s: Coding style
    • Labels:
      None

      Description

      I'd like to propose that we recommend or require the use of a trailing comma on multi-line array declarations.

      For example:

      $foo = [
        'a',
        'b',
        'c',
      ];
      

      Rationale:

      1. Adding additional keys to the array later leads to fewer lines of diff (1 addition, vs. 1 removal + 2 addition)
      2. Git blame and git history are clearer.

        Attachments

          Activity

            People

            • Votes:
              3 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: