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

Coding style clarification on short array syntax

    XMLWordPrintable

Details

    • Bug
    • Status: Open
    • Low
    • Resolution: Unresolved
    • Coding style
    • None

    Description

      People (including me) are really starting to use the short array syntax. I don't really want to start this discussion, but unfortunately, we are also seeing examples of inconsistent code like:

      $foo = ['item'];
      // not many lines..
      $bar = array('foo', 'bar', 'baz');
      $baz = array(['foo' => 'bar'], ['baz']);
      

      I see that drupal have faced this issue and discussed it extensively too:
      https://www.drupal.org/node/2135291

      They have a section in their coding style which I think we should adopt something similar:

      The use of PHP 5.4+ short array syntax for Drupal 8.x is being discussed and is used in some patches already. When used, try to apply it consistently to at least a whole method or function.

      Looks like phpcs has a fixer for it, so thats an extremely invasive option to go wholesale into it.

      Attachments

        Issue Links

          Activity

            People

              poltawski Dan Poltawski
              poltawski Dan Poltawski
              Marina Glancy, Eloy Lafuente (stronk7)
              Votes:
              3 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated: