Comments

beram created an issue. See original summary.

  • beram committed 8f6214c on 8.x-1.x
    Issue #2859795 by beram: Use short array syntax coding standards for...
beram’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

pankajchaudhari’s picture

Drupal is full of arrays, even in Drupal 8. But when you look at an array in Drupal 8, you may be left wondering why they look different to how they looked in Drupal 7. The reason is that the Drupal code standards now recommend using short array syntax.

Short array syntax was added to PHP in PHP 5.4 and replaces array() with [].

This is how it used to look with the long array syntax:
$array = array(
"foo" => "bar",
"bar" => "foo",
);

This is how it looks now with the newer shortened syntax:
$array = [
"foo" => "bar",
"bar" => "foo",
];

To see examples of this, check out this week's tutorial:
Read the introduction to PHP short array syntax